是否有可能更改julia中非线性约束的RHS?

是否有可能更改julia中非线性约束的RHS?,julia,julia-jump,Julia,Julia Jump,是否有可能更改非线性约束的RHS using JuMP, Ipopt, Juniper,Gurobi,CPUTime T=0; ZT=zeros(2,1); ZB=zeros(2,1); #-----Model parameters-------------------------------------------------------- sig=0.86; landa=50; E=T0=T1=.0833; T2=0.75; gam2=1; gam1=0; a1=5; a2=4.22; a3

是否有可能更改非线性约束的RHS

using JuMP, Ipopt, Juniper,Gurobi,CPUTime
T=0;
ZT=zeros(2,1);
ZB=zeros(2,1);
#-----Model parameters--------------------------------------------------------
sig=0.86;
landa=50;
E=T0=T1=.0833;
T2=0.75;
gam2=1; gam1=0;
a1=5; a2=4.22; a3=977.4; ap=977.4;
C1=949.2; c0=114.24;
f(x) = cdf(Normal(0, 1), x);
#---------------------------------------------------------------------------
ALT= Model(optimizer_with_attributes(Juniper.Optimizer, "nl_solver"=>optimizer_with_attributes(Ipopt.Optimizer, "print_level" => 0),

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

       );

# variables-----------------------------------------------------------------
JuMP.register(ALT, :f, 1, f; autodiff = true);
@variable(ALT, h >= 0.1);
@variable(ALT, L >= 0.00001);
@variable(ALT, n>=2, Int);

#---------------------------------------------------------------------------

@NLexpression(ALT,k7,1-f(L-sig*sqrt(n))+f(-L-sig*sqrt(n)));

#constraints--------------------------------------------------------

@NLconstraint(ALT, f(-L) <= 1/400);

#objective function---------------------------------------------------------
@NLexpression(ALT,f2,1/k7);
#------------------------------------------------------------------------
@NLconstraint(ALT,rf2,f2<=10000);

@NLconstraint(ALT,lf2,f2>=-10000);

@NLobjective(ALT,Min,f2);

optimize!(ALT);

minf2=getvalue(f2)

set_normalized_rhs(rf2,minf2); 

ZB[2]=getvalue(f2);
@NLobjective(ALT,Min,f1);
optimize!(ALT);
ZB[1]=getvalue(f1);
使用JuMP、Ipopt、Juniper、Gurobi、CPUTime
T=0;
ZT=零(2,1);
ZB=零(2,1);
#-----模型参数--------------------------------------------------------
sig=0.86;
兰达=50;
E=T0=T1=0.0833;
T2=0.75;
gam2=1;gam1=0;
a1=5;a2=4.22;a3=977.4;ap=977.4;
C1=949.2;c0=114.24;
f(x)=cdf(正常值(0,1),x);
#---------------------------------------------------------------------------
ALT=模型(优化器_带有_属性(Juniper.optimizer,“nl_解算器”=>优化器_带有_属性(Ipopt.optimizer,“打印级别”=>0),
“mip_解算器”=>具有_属性的优化器(Gurobi.optimizer,“logLevel”=>0),“注册的_函数”=>[Juniper.register(:f,1,f;autodiff=true)])
);
#变数-----------------------------------------------------------------
寄存器(ALT,:f,1,f;autodiff=true);
@变量(ALT,h>=0.1);
@变量(ALT,L>=0.00001);
@变量(ALT,n>=2,Int);
#---------------------------------------------------------------------------
@NL表达(ALT,k7,1-f(L-sig*sqrt(n))+f(-L-sig*sqrt(n));
#约束条件--------------------------------------------------------
@NLconstraint(ALT,f(-L)您可以使用a替换右侧,并在解算后更新其值

ERROR: MethodError: no method matching set_normalized_rhs(::ConstraintRef{Model,NonlinearConstraintIndex,ScalarShape}, ::Float64)
Closest candidates are:
  set_normalized_rhs(::ConstraintRef{Model,MathOptInterface.ConstraintIndex{F,S},Shape} where Shape<:AbstractShape, ::Any) where {T, S<:Union{MathOptInterface.EqualTo{T}, MathOptInterface.GreaterThan{T}, MathOptInterface.LessThan{T}}, F<:Union{MathOptInterface.ScalarAffineFunction{T}, MathOptInterface.ScalarQuadraticFunction{T}}} at C:\Users\admin\.julia\packages\JuMP\YXK4e\src\constraints.jl:478
Stacktrace:
 [1] top-level scope at none:1```.