Interrupting a solver

31 views
Skip to first unread message

Arnab Joardar

unread,
Mar 27, 2023, 9:51:34 PM3/27/23
to CasADi
Hello,

I am trying to minimize a cost function f(x) while keeping an eye on some other function g(x). The intention is to interrupt the solver if h(x) < epsilon.

Maybe I wasn't searching correctly, but I couldn't find any conversation with the keyword 'interrupt'. 
The problem I am trying to solve is akin to a ball bouncing on the ground: as soon as the solver detects that contact has been made by the ball with the ground, the solver should be interrupted. I intend to then use the coefficient of restitution to reinitialize the ball's state and restart the simulation using those new initial states.

Any idea how I can accomplish this? I am trying to solve this on Matlab. From this example, is the variable `arg' all the decision variables `x' in the below snippet:
<<
% Create an NLP solver
prob = struct('f', J, 'x', vertcat(w{:}), 'g', vertcat(G{:}));
solver = nlpsol('solver', 'ipopt', prob,opts);

% Solve the NLP
sol = solver('x0', w0, 'lbx', lbw, 'ubx', ubw,...
            'lbg', lbg, 'ubg', ubg);
w_opt = full(sol.x);
>>.

Another question that I wanted to ask related to callback functions, is there a way to update the function in the callback after the solver has been interrupted? If I have a scheme which will select amongst m functions:h_1(x),...,h_m(x) after evaluating the results from the interrupted solver, can I pass this selected function to the callback function and then restart the problem?
Reply all
Reply to author
Forward
0 new messages