+ Reply to Thread
Results 1 to 11 of 11

How to continuously update cell values during iterations while running Solver from macro

  1. #1
    Registered User
    Join Date
    02-07-2014
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2010
    Posts
    6

    How to continuously update cell values during iterations while running Solver from macro

    Hi

    I'm writing a macro which uses the Excel Solver add-in, and I want to see the development of the variables in the excel sheet during the iterations (they are linked to graphs).

    I can make this work by running the solver manually and tick off the “Show iteration results”-option, but then I need to close the dialogue box for each iteration. Is there a way to update the results through a macro, and disable the dialogue box at the same time?

  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,758

    Re: How to continuously update cell values during iterations while running Solver from mac

    Perhaps something like this?

    To test rum macro "SolvLoop" but before you do so you need to set a reference to Solver in Visual Basic.

    "Developer" tab -> "Visual Basic" -> 2Tools" -> "References" and tick box marked "Solver"

    Alf
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    02-07-2014
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: How to continuously update cell values during iterations while running Solver from mac

    Thanks for the reply Alf, but I only have to solve one optimization problem. And I want to see how the decision variables develops throughout the optimization routine.

  4. #4
    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,758

    Re: How to continuously update cell values during iterations while running Solver from mac

    I want to see how the decision variables develops throughout the optimization routine
    Hmm interesting question. Perhaps one could set max time to a small value that should stop solver and showing the decision variable at that time, copy values reset Solver, paste back copied values and kickstart sover for another run. How to get rid of the pop up screen (Solver reach max time limit bla bla bla) I dont know really. I've in a similar situation tried to send "Alt s" as pressing "Alt + s" will "delete" the pop up screen. But it does not seem that this command works inside the solver macro

    Please Login or Register  to view this content.
    One could also play around a bit with max number of iterations this depends a bit on the complexety of the problem you wish solver to solve myself I've found it easier to adjust number of seconds.

    I also think you should contact the makers of Solver and ask for their advice. Their support department is quite helpfull at least with problems regarding the Excel 2010 Solver.

    http://www.solver.com/

    If they do give you a solution could you please post it in this thread as this is rather usefull knowledge.

    Alf

  5. #5
    Registered User
    Join Date
    02-07-2014
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: How to continuously update cell values during iterations while running Solver from mac

    Thanks again, I've also tried to change both iteration numbers and time limit, but neither seems to work. It's like the solver get stuck on the same solution for every iteration.

    I have, however found a solution on how to get rid of the pop up. When I launch the Solver i use:

    Please Login or Register  to view this content.
    where Results is a figure discribing the status of the solution. The important bit here is "ShowTrial" which is a userdefined function that tells what to do with the pop up, or so I believe. Any way, it works for this purpose.

    Please Login or Register  to view this content.

  6. #6
    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,758

    Re: How to continuously update cell values during iterations while running Solver from mac

    Hi

    I contacted the support departmen at Frontline Systems and this if what they told me:

    Basically, we define a function that gets called whenever the maxtime limit is reached, and the action taken depends on the return value of this function:


    Please Login or Register  to view this content.
    So, here, in the subroutine "myfb", I set maxtime = 9 and solve the problem by calling SolverSolve (I pass on UserFinish = true to not display solver solution dialog, and set ShowRef equal to the function "showTRial"); the function showTRial will get called when maxtime is reached, and since this just returns 0, it will stop the solution process without displaying the dialog.
    This is partly what you already found out. How to incorporate this in a loop? And how to capture to the partly finished "solution" and then let solver continue solving the problem? I do wonder could you upload the file that you are working with or if it contains sensitive information post a mock up file?

    Alf

  7. #7
    Registered User
    Join Date
    02-07-2014
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: How to continuously update cell values during iterations while running Solver from mac

    I've attached the optimization problem, and stripped out everything not relevant for the solution.

    See if you can make any sense of it. Its the x-variables that I need updated.
    Last edited by mariusov; 02-12-2014 at 03:12 AM.

  8. #8
    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,758

    Re: How to continuously update cell values during iterations while running Solver from mac

    I've attached the optimization problem
    ???? You sure you did that as I can't find it. Lost in cyber space probably.

    Alf

  9. #9
    Registered User
    Join Date
    02-07-2014
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: How to continuously update cell values during iterations while running Solver from mac

    Sorry, there was something wrong with the file I attached initially, so I had to remove it. Will be right back

  10. #10
    Registered User
    Join Date
    02-07-2014
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: How to continuously update cell values during iterations while running Solver from mac

    Here it is
    Attached Files Attached Files

  11. #11
    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,758

    Re: How to continuously update cell values during iterations while running Solver from mac

    Ok got it. Will have a go at it and see if I can do anything at all.

    Alf

+ 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. Macro Cell Error At Cell message when running Solver in VBA
    By Eharr3 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-15-2013, 03:36 PM
  2. Macro running continuously
    By billpurdom in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-07-2013, 12:29 PM
  3. Need macro to continuously update spreadsheet, as if hitting F9 every few seconds
    By powerops in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-09-2013, 04:44 AM
  4. Continuously running a recorded macro-Please Help
    By Nik.Kaps in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-10-2012, 07:27 AM
  5. How do you continuously update time and date in an Excel cell?
    By engine99 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-20-2005, 11:06 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