+ Reply to Thread
Results 1 to 4 of 4

Looping with solver

  1. #1
    Registered User
    Join Date
    03-12-2016
    Location
    Virginia
    MS-Off Ver
    2013
    Posts
    3

    Looping with solver

    I have created an optimizer using solver which will output the optimal value, given several constraints, in a particular cell (which is AG1 in my case).
    However, I want to write a loop that will iteratively prompt solver to find the next best solution by updating the maximum value constraint to a lower value.

    Basically what I have now is:

    Please Login or Register  to view this content.
    where X is the number iterations and AH1 is the cell containing a decreased value that I want to set as the new maximum constraint, which I will decrease by .01 each time.

    However, the problem with this code is that the solver won't actually update any of the spreadsheet cells until after I stop execution, by which the AH1 cell will have decreased .01 times however many iterations it went through before being stopped and produce only that particular solution.

    Can someone give me a pointer as to how I can, through a single execution of code: 1) retrieve the solution with all cells in the spreadsheet updated per iteration 2) store/print the results of all iterations in a separate spreadsheet so that I can basically view all solutions?

  2. #2
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,786

    Re: Looping with solver

    As you have not given much information about your problem I'm not sure how to help you but perhaps

    Please Login or Register  to view this content.
    Ms Office 2013? This is not the Mac version by the way as there are problems running solver with a macro.

    Alf

  3. #3
    Registered User
    Join Date
    03-12-2016
    Location
    Virginia
    MS-Off Ver
    2013
    Posts
    3

    Re: Looping with solver

    So, I haven't been working on this for a while, but I've made some changes:

    Please Login or Register  to view this content.

    The rundown is, I have my solver constraints saved in blocks AE14:AH18 on Sheet1. Each time solver runs, it SHOULD change the values of AJ1:AJ150, and it does so perfectly fine if I run it manually.
    I then want to copy each iteration of solution to an individual column on Sheet2, as you can see. The [Range("AH1") = Range("AH1") - 0.01] part of the code modifies a constraint to prompt a new solution each iteration.
    The problem is, when I run it inside this loop, I don't think solver is actually changing the values of the AJ1:AJ150 until the last iteration.

    After I run the script, I get columns of invalid cell reference errors before the last column, which did successfully paste the solution. Basically, solver only works correctly on the last iteration of the loop.

    Are there any pointers as to how I can store multiple solutions of solver in the manner that I described / identify what may be the issue?

  4. #4
    Registered User
    Join Date
    03-12-2016
    Location
    Virginia
    MS-Off Ver
    2013
    Posts
    3

    Re: Looping with solver

    Anybody who might have an answer?

+ 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. VBA looping solver
    By ElliotBlack in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-30-2015, 10:12 AM
  2. VBA looping solver
    By ElliotBlack in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-29-2015, 07:05 PM
  3. VBA looping solver
    By ElliotBlack in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-29-2015, 07:04 PM
  4. Solver Looping
    By Weston12 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-10-2014, 07:31 PM
  5. looping of Solver in VBA
    By bored in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-14-2010, 11:28 AM
  6. Looping and Solver
    By junejaja in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-28-2008, 11:53 AM
  7. Looping a Solver
    By Peter1999 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-31-2007, 08:32 AM

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