Algebraic Constraint Jacobian

23 vues
Accéder directement au premier message non lu

Kristian Meyer

non lue,
2 juil. 2021, 07:21:5902/07/2021
à lmfit-py
Dear team,

I'm following the example called "Fit with Algebraic Constraint" - In the example the "expr" attribute of the Parameter object is used to impose algebraic constraints.  The leastsq minimizer is used requiring the Jacobian to be specified.

I have a question regarding how the Jacobian is specified. Essentially an algebraic constraint is specified in the objective function, but how does the optimizer know about this if the constraint Jacobian is not specified? What will happen if the optimizer tries to violate the constraint? 

In advance, thank you very much for considering my question,

Best regards
Kristian 

Matt Newville

non lue,
2 juil. 2021, 07:55:0002/07/2021
à lmfit-py
Hi Kristian,


On Fri, Jul 2, 2021 at 6:22 AM Kristian Meyer <krille...@gmail.com> wrote:
Dear team,

I'm following the example called "Fit with Algebraic Constraint" - In the example the "expr" attribute of the Parameter object is used to impose algebraic constraints.  The leastsq minimizer is used requiring the Jacobian to be specified.

I have a question regarding how the Jacobian is specified. Essentially an algebraic constraint is specified in the objective function, but how does the optimizer know about this if the constraint Jacobian is not specified? What will happen if the optimizer tries to violate the constraint? 

The constraint expressions are evaluated from the variables but are not themselves actually variables for the underlying minimizer.  The constraints cannot be violated -- they are defined.

Basically, we give the minimization routine a set of unconstrained, unbounded variables and our own internally defined objective function.   That allows any solver to be used - they think they are doing unconstrained optimization.   The internal objective function does the work of recasting those unconstrained variables from the minimizer to the user's Parameters, including transforming bounded (min/max) values, setting values for 'fixed' variables (which is no work at all), and evaluating the constraint expressions in terms of the other Parameter values.  Those newly updated Parameters are then passed to the user's objective function.  The result of the users' objective function are lightly checked and then passed back to the minimizer.

The Jacobian is needed for the actual variables.

--Matt

Kristian Meyer

non lue,
2 juil. 2021, 08:53:3802/07/2021
à lmfit-py

Dear Matt,

Thank you for this great answer, it makes my understanding of your code better. This is really a very elegant solution.

Best regards
Kristian 
Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message