3

在 SolverReset 之后

我想关闭 vba Solver 中的 Make Unconstrained Variables Non-Negative 选项。

在求解器中关闭使不受约束的变量为非负的命令是什么?

我试着录制一个宏来找出答案,但我得到的只是,

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
4

2 回答 2

9

你想要做的是添加:

SolverOptions Assumenonneg:=False

可以在MSDN上找到所有求解器选项的完整详细信息。

于 2014-07-09T08:47:14.240 回答
2

录制“SOLVER”宏时,打开 SOLVER 窗口中的选项选项卡,然后关闭。单击 SOLVE,然后单击“停止录制”这应该会给出“SLOVER 选项”,如下所示。您需要的选项是 AssumeNonNeg:= False(或 True)

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
于 2012-04-13T15:16:15.647 回答