ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need advice on Solver loop (https://www.excelbanter.com/excel-programming/399015-need-advice-solver-loop.html)

robs3131

Need advice on Solver loop
 
Hi,

I have a loop that executes Solver -- I have the following questions:

1 - It appears that once Solver is first set up to run, it stores the values
and constraints so that if they are not changed, it will keep those initial
values. Assuming this is correct and given that I am referencing cells on my
sheet that change in value with each instance of the loop, I'm thinking that
all I need to do is set up Solver once in my code for it's initial run and
then just have it execute each time it loops through. Does this sound right
to you? Below is my Solver code within the loop.

SolverOk SetCell:="$AF$1", MaxMinVal:=2, ValueOf:="0", _
ByChange:="payfclearbin"
SolverAdd CellRef:="payfclearbin", Relation:=5, FormulaText:="binary"
SolverAdd CellRef:="$AE$1", Relation:=2, FormulaText:=Range("AD1").Value
SolverSolve userfinish:=True

2 - Just in case I need to, if I wanted to delete all prior constraints
("Cellref"), is there a way to have all constraints deleted at once rather
than deleting each individual constraint one by one?


Thanks!

Robert

--
Robert

Dana DeLouis

Need advice on Solver loop
 
is there a way to have all constraints deleted at once rather
than deleting each individual constraint one by one?


Hi. Just my opinion is that it's hard to keep track on Constraints to
delete them 1 by 1.
I find it easier to just do a "Reset".

SolverReset
SolverOk SetCell:="AF1", MaxMinVal:=2, ByChange:="PayfClearBin"

Now, you are back to normal with no constraints.

(Note: you can drop the =0 since it's ignored)

--
HTH
Dana DeLouis


"robs3131" wrote in message
...
Hi,

I have a loop that executes Solver -- I have the following questions:

1 - It appears that once Solver is first set up to run, it stores the
values
and constraints so that if they are not changed, it will keep those
initial
values. Assuming this is correct and given that I am referencing cells on
my
sheet that change in value with each instance of the loop, I'm thinking
that
all I need to do is set up Solver once in my code for it's initial run and
then just have it execute each time it loops through. Does this sound
right
to you? Below is my Solver code within the loop.

SolverOk SetCell:="$AF$1", MaxMinVal:=2, ValueOf:="0", _
ByChange:="payfclearbin"
SolverAdd CellRef:="payfclearbin", Relation:=5, FormulaText:="binary"
SolverAdd CellRef:="$AE$1", Relation:=2, FormulaText:=Range("AD1").Value
SolverSolve userfinish:=True

2 - Just in case I need to, if I wanted to delete all prior constraints
("Cellref"), is there a way to have all constraints deleted at once rather
than deleting each individual constraint one by one?


Thanks!

Robert

--
Robert




All times are GMT +1. The time now is 10:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com