Parameterized Rootfinder

89 views
Skip to first unread message

Arnab Joardar

unread,
Apr 4, 2023, 4:23:33 PM4/4/23
to CasADi
Hello,

I was wondering if there is a way to supply user values as parameters to a root finder object to find the roots.
The way I am constructing it now is as such:

        % Set up constraint that has to be met
        f_constraint = Function('f_constraint',{states_kj},...
                                {Local_state_map_fun(x_init(proj,:)',states_kj,delta_y)},...
                                {'states_kj'},{'f_constraint'});
        s=rootfinder('s', 'newton', f_constraint);

An older post also looked at this, but I couldn't understand what Joel meant: how does the rootfinder know which variable (x or u in that example) is the variable and which is a user supplied guess or parameter?

The line
s([10, 1, 0, 0], [10, 1])
has two entries, one for x and the other for u. Are all 6 initial conditions? How does it interpret that the values for u are parameters and the values for x are an initial guess?

Thanks a lot in advance,
Arnab

Arnab Joardar

unread,
Apr 4, 2023, 4:51:49 PM4/4/23
to CasADi
I also found the following commit talking about it's implementation, but the sample code provided is in python. Will the equivalent syntax in Matlab be as follows?

param = MX.sym('param',(2*num_dof_total+num_local_dof),1);
f_constraint_fun = Function('f_constraint_fun',{states_kj,param},...
                                                 {Local_state_map_fun( param(1:2*num_dof_total,1) , states_kj , param((2*num_dof_total+1):(2*num_dof_total+num_local_dof),1) )},...
                                                 {'states_kj','param'},{'f_constraint_fun'});
constrint_manifold=rootfinder('constrint_manifold', 'newton',  'x', states_kj, 'p', param, 'g', f_constraint_fun);

To use it, I am hoping this way will work:

x_temp_proj(1,:) = constrint_manifold(x_temp_for(1,:)' , [x_init(1,:)' ; delta_y])';

I will update here in case it works.
Reply all
Reply to author
Forward
0 new messages