I am invoking solver within a macro. The first time that I ran the macro solver worked fine and I got a legitimate answer. I reset the changed cells again and ran the macro a second time, and it seemed to violate one of my constraints. I opened solver right from excel and saw that it hadn't even added the constraint the second time, even though it is clearly there in the VBA script!
Here is the macro:
Sub Defense()
'
' Defense Macro
' Macro recorded 8/27/2006 by
'
'
SolverReset
SolverOk SetCell:="$S$3", MaxMinVal:=1, ValueOf:="0", ByChange:="$P$5:$P$38"
SolverAdd CellRef:="$D$5:$F$38", Relation:=5, FormulaText:="binary"
SolverAdd CellRef:="$D$3:$F$3", Relation:=2, FormulaText:="$D$2:$F$2"
SolverAdd CellRef:="$Q$5:$Q$38", Relation:=1, FormulaText:="1"
SolverOk SetCell:="$S$3", MaxMinVal:=1, ValueOf:="0", ByChange:="$P$5:$P$38"
SolverOptions MaxTime:=10000, Iterations:=30000, Precision:=0.000001, _
AssumeLinear:=True, StepThru:=False, Estimates:=1, Derivatives:=1, SearchOption _
:=1, IntTolerance:=0, Scaling:=False, Convergence:=0.01, AssumeNonNeg:=True
SolverOk SetCell:="$S$3", MaxMinVal:=1, ValueOf:="0", ByChange:="$P$5:$P$38"
SolverSolve
End Sub
The bolded line is the one that is missing when I open solver, and it is the same whether I make that the first, second or third constraint. Again, it works fine the first time, but thereafter it refuses to add this constraint.
Any ideas?
thanks
JB
Here is the macro:
Sub Defense()
'
' Defense Macro
' Macro recorded 8/27/2006 by
'
'
SolverReset
SolverOk SetCell:="$S$3", MaxMinVal:=1, ValueOf:="0", ByChange:="$P$5:$P$38"
SolverAdd CellRef:="$D$5:$F$38", Relation:=5, FormulaText:="binary"
SolverAdd CellRef:="$D$3:$F$3", Relation:=2, FormulaText:="$D$2:$F$2"
SolverAdd CellRef:="$Q$5:$Q$38", Relation:=1, FormulaText:="1"
SolverOk SetCell:="$S$3", MaxMinVal:=1, ValueOf:="0", ByChange:="$P$5:$P$38"
SolverOptions MaxTime:=10000, Iterations:=30000, Precision:=0.000001, _
AssumeLinear:=True, StepThru:=False, Estimates:=1, Derivatives:=1, SearchOption _
:=1, IntTolerance:=0, Scaling:=False, Convergence:=0.01, AssumeNonNeg:=True
SolverOk SetCell:="$S$3", MaxMinVal:=1, ValueOf:="0", ByChange:="$P$5:$P$38"
SolverSolve
End Sub
The bolded line is the one that is missing when I open solver, and it is the same whether I make that the first, second or third constraint. Again, it works fine the first time, but thereafter it refuses to add this constraint.
Any ideas?
thanks
JB