dose JuMP.setRHS 申请 julia 中的非线性模型?

dose JuMP.setRHS apply for non-linear modles in julia?

在下面的代码中,NL 约束的 RHS 应该改变。但错误发生了。 错误:UndefVarError:未定义 setRHS。你能告诉我为什么会发生这个错误吗?感谢您的帮助

using JuMP,CPLEX, Ipopt
#parameters--------------------------------------------------------
sig=0.86;
#---------------------------------------------------------------------------
ALT= Model(optimizer_with_attributes(Juniper.Optimizer, "nl_solver"=>optimizer_with_attributes(Ipopt.Optimizer, "print_level" => 0),

       "mip_solver"=>optimizer_with_attributes(CPLEx.Optimizer, "logLevel" => 0),"registered_functions" =>[Juniper.register( :f, 1, f; autodiff = true)])

       )

# variables-----------------------------------------------------------------
f(x) = cdf(Normal(0, 1), x);
JuMP.register(ALT, :f, 1, f; autodiff = true);
@variable(ALT, h >= 0.1);
@variable(ALT, L >= 0.0001);
@variable(ALT, n>=2, Int);
#-------------------------------------------------------------------
@NLexpression(ALT,k7,1-f(L-sig*sqrt(n))+f(-L-sig*sqrt(n)));

@NLexpression(ALT,f2,1/k7)
#constraints--------------------------------------------------------
@NLconstraint(ALT, f(-L) <= 1/400);

@NLconstraint(ALT,rf2,f2<=10000);

#-------------------------------------------------------------------
@NLobjective(ALT, Min, f2)

optimize!(ALT)
JuMP.setRHS(rf2,getvalueNLobjective(1/k7))

您使用的是过时的 JuMP 版本示例。从今天开始,您应该使用 set_normalized_rhs:

set_normalized_rhs(con_ref, some_rhs_value)

请注意,这会在 JuMP pre-computed 之后设置 标准化 RHS。例如 @constraint(model, 2x - 5 <= 2) 的归一化值为 7.

有关详细信息,另请参阅 https://jump.dev/JuMP.jl/v0.21/constraints/#Constraint-modifications-1