4

After SolverReset

I want to switch off the Make Unconstrained Variables Non-Negative option in the vba Solver.

What are the commands to switch off the Make Unconstrained Variables Non-Negative in Solver?

I tried recording a macro to find out but all I got was,

Sub Macro2()
'
' Macro2 Macro
'

'
    SolverOk SetCell:="$D$26", MaxMinVal:=2, ValueOf:=0, ByChange:="$B$9:$B$12", _
        Engine:=1, EngineDesc:="GRG Nonlinear"
    SolverOk SetCell:="$D$26", MaxMinVal:=2, ValueOf:=0, ByChange:="$B$9:$B$12", _
        Engine:=1, EngineDesc:="GRG Nonlinear"
    SolverSolve
End Sub
csta
  • 2,423
  • 5
  • 26
  • 34

2 Answers2

9

What you want to do is add:

SolverOptions Assumenonneg:=False

The full details of all solver options can be found on MSDN.

Daniel Daranas
  • 22,454
  • 9
  • 63
  • 116
Matt Joass
  • 91
  • 1
  • 1
2

When you record a 'SOLVER' macro, open the options tab in the SOLVER window and then close. Click SOLVE and then 'stop-recording' This should give the 'SLOVER options" as below. The option that you need is AssumeNonNeg:= False (or True) as required

SolverOptions MaxTime:=0, Iterations:=0, Precision:=0.000001, Convergence:= _
        0.0001, StepThru:=False, Scaling:=True, AssumeNonNeg:=False, Derivatives:=1
    SolverOptions PopulationSize:=100, RandomSeed:=0, MutationRate:=0.075, Multistart _
        :=False, RequireBounds:=True, MaxSubproblems:=0, MaxIntegerSols:=0, _
        IntTolerance:=1, SolveWithout:=False, MaxTimeNoImp:=30
Matthew Murdoch
  • 30,874
  • 30
  • 96
  • 127
eoinp
  • 21
  • 2