Using limitation to get two ranges of a state

26 views
Skip to first unread message

劉宇軒

unread,
Mar 28, 2023, 2:28:29 AM3/28/23
to CasADi
I have a problem with the casadi and ipopt.
When I try to limit the range of a state, I try to use the limitation. For example, the value range of a variable x is [0,1], I want to change the value range to [0,0.4] and [0.6,1] by limiting (x-0.5)^2>0.1^2, but the range from the solver is only available in [0,0.4];

Can I get the range I wanted?
and the Matlab code is:
import casadi.*
x=MX.sym('x',1);
x0=0;
lbx=[0];
ubx=[1];
g=[(x-0.5)^2];
lbg=[0.1^2]
ubg=1;
J=1e11*(x-0.9)^2;
nlp = struct('x', x, 'f', J, 'g', g);
options = struct;
options.ipopt.print_level = false;
options.print_time=false;
options.ipopt.max_iter = 15000;
solver = casadi.nlpsol('solver', 'ipopt', nlp,options);
sol = solver('x0', x0, 'lbx', lbx, 'ubx', ubx,'lbg', lbg, 'ubg', ubg);
u_opt = full(sol.x)
Reply all
Reply to author
Forward
0 new messages