vba:似乎无法关闭求解器的“使不受约束的变量为非负”选项

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7746492/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 14:15:12  来源:igfitidea点击:

vba : Can't seem to turn off the "making unconstrained variables non-negative" option for Solver

vbasetting

提问by csta

After SolverReset

求解器重置后

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

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

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", MaxMinVal:=2, ValueOf:=0, ByChange:="$B:$B", _
        Engine:=1, EngineDesc:="GRG Nonlinear"
    SolverOk SetCell:="$D", MaxMinVal:=2, ValueOf:=0, ByChange:="$B:$B", _
        Engine:=1, EngineDesc:="GRG Nonlinear"
    SolverSolve
End Sub

回答by Matt Joass

What you want to do is add:

你想要做的是添加:

SolverOptions Assumenonneg:=False

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

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

回答by eoinp

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

录制“求解器”宏时,打开求解器窗口中的选项选项卡,然后关闭。单击 SOLVE,然后单击 'stop-recording' 这应该给出如下所示的 'SLOVER options'。您需要的选项是 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