+ Reply to Thread
Results 1 to 5 of 5

Solver doesn't find global Max

  1. #1
    Registered User
    Join Date
    08-15-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    53

    Solver doesn't find global Max

    I am trying to find the maximum value in a cell using Excel Solver by adjusting the values in two other cells. However, the Solver finds, what I assume are local maxima, and not the global maximum value. The found max value depends on the starting values of the variables.

    I have attached a simple example showing the issue.

    Use Solver to Maximize cell P8 (Orange highlight) by changing variable cells C2 & B3 (Yellow highlights)
    NOTE: I really wanted to change cell B2 instead of C2, but the integer constraint didn't work for Cell B2 so I instead change C2 while setting B2=int(C2)

    Optimal values are C3=7 (or any value 7-7.99999), B2=7 and B3=91.65% which results in P8=18.34%
    However, the solver does not find the optimal values. For example, if I start with C2=10 and B3=100%; I get C2=41.95 and B2=41, B3=86.95% and P8=8.50%


    The attached file only has two rows. The real files have several hundred rows (but still only one cell to maximize).



    p.s. If it is not possible to use the Solver, in my case, is it possible to use a VB script to test all combinations?
    For example:
    B2 = 2-100 step 1
    B3= 10%-120% step 2
    and then put the output into a new spreadsheet showing
    B2 B3 P8
    2 10% 22%
    ..
    100 120% 15%

    I could then sort the output to find the max value for P8.......
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Solver doesn't find global Max

    I think Solver is having trouble with the integer constraint in B2. If I drop that constraint (=C2 instead of =INT(C2)), then my version of Solver seems to have little trouble getting really close from a variety of starting values. It's not perfect, but it gets really close.

    If it is not possible to use the Solver, in my case, is it possible to use a VB script to test all combinations?
    Does it have to be a VB script? You can do this using Excel's built in Data Table utility https://www.excel-easy.com/examples/data-tables.html [Enter =P8 in I24. Enter desired percentages in I25:I30. Enter Days in J24:P24. Select range and insert Data table using C2 for the row input cell and B3 for the column input cell (or vice-versa if I got them mixed up).] In fact, that was one of the first things I did to study your problem was to build a quick data table and chart it on a scatter chart so I could see what your objective function was doing at different input values. From this exercise, I could see that the maximum was always going to be at day 7, and would be near 90%.

    Here's how I might approach this problem. Solver should have no problem finding the percentage in B3, once the best choice for days in B2 in discovered (I'm assuming there will be variations of the problem that won't maximize at 7 days, though this specific example appears to fix on 7 days). I might set up a data table like I've described, because that tool will allow me to quickly see that 7 (or whatever) days is the optimum choice for number of days. Enter that value in B2.

    Then run Solver and tell solver to find the maximum of P8 by changing only B3. Solver should have no trouble finding that maximum.

    If you feel that you must have Solver find both days and percentage in one go, then I would drop the integer constraint on B2 and let Solver find the optimum at fractional days.

    Thoughts?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    08-15-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Solver doesn't find global Max

    @MrShorty,

    As you suggested, I tried to remove the integer constraint by setting B2=C2
    However, depending on my starting values, I may then get an error "Solver encountered an error value..."

    The "real" spreadsheet with many rows will indeed have a value for B2 that is different from 7 (it will be larger).
    The problem is then to confirm that I really have found the optimal values.
    I will look into the data table approach, which is a good idea regardless, later.

    I may also try some 3rd party add-ons. Are you familiar with OpenSolver (https://opensolver.org/) or What'sBest! (https://www.lindo.com/index.php/prod...optimization)?

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Solver doesn't find global Max

    I have dabbled a little with open solver, but have not been sold on it. Other users here (@Alf) seem to have a lot more experience with it. I have never heard of What'sBest.

  5. #5
    Registered User
    Join Date
    08-15-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Solver doesn't find global Max

    @MrShorty,
    I forgot to thank you for the Table suggestion. I have been using that now instead of the Solver and it is better in many ways !

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 7
    Last Post: 12-31-2016, 12:29 PM
  2. Solver doesn't find the best solution
    By waldymar in forum Excel General
    Replies: 1
    Last Post: 02-10-2016, 11:46 AM
  3. Solver doesn't find maxium revenue
    By Surminderbains in forum Excel General
    Replies: 13
    Last Post: 10-09-2015, 04:53 PM
  4. Solver doesn't find the right answer
    By yangbo07520 in forum Excel General
    Replies: 1
    Last Post: 10-09-2013, 02:24 PM
  5. solver doesn't find all solutions
    By Alexander_Golinsky in forum Excel General
    Replies: 4
    Last Post: 05-26-2012, 06:13 PM
  6. Solver: global or local max?
    By Ipinho100 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-30-2011, 08:11 AM
  7. [SOLVED] Solver checked but doesn't appear
    By [email protected] in forum Excel General
    Replies: 1
    Last Post: 02-06-2005, 05:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1