In the following code, RHS of NL-constraints should change. but the error happens. ERROR: UndefVarError: setRHS not defined. could you please learn me why this error happens?. thanks for your helps
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))
You are using outdated JuMP version examples. As of today you should use set_normalized_rhs
:
set_normalized_rhs(con_ref, some_rhs_value)
Note that this sets the normalized RHS that is after it has been pre-computed by JuMP. For example for @constraint(model, 2x - 5 <= 2)
the normalized value is 7
.
See also https://jump.dev/JuMP.jl/v0.21/constraints/#Constraint-modifications-1 for more details.