Data2Dynamics / d2d

a modeling environment tailored to parameter estimation in dynamical systems
https://github.com/Data2Dynamics/d2d
57 stars 29 forks source link

using nonlinear constrain in fmincon #156

Closed arnabbandyopadhyay closed 3 years ago

arnabbandyopadhyay commented 4 years ago

Hi,

I want to use nonlinear constrain for estimating parameters and i want to use fmincon. In arFit.m file I see I can pass constrain function: myconfun = @confun, but it is not straight forward to me how do I write this constrain function and how do I pass this into fitting. can you please guide me how to resolve this, or if there are other ways I can pass nonlinear constrains in to he fitting. I appreciate your help. Thanks Arnab

clemenskreutz commented 3 years ago

Hi. Nonlinear optimization with constraints is difficult. Often, optimization does not converge because the constraints cannot be justified. Penalized optimization is much more robust. You can increase the penality strength iteratively apply "increasing the penalization strength" & optimization. Penalties can be integrated via parameters (see ar.type) or via new observables (without data). If you nevertheless decide to perform constrained optimization, you have to also provide the correct derivatives of the constraints (w.r.t. parameters). Constraint violation and its derivative are output arguments of @ConFun. The implementation is like in standard fmincon examples (see "Nonlinear Constraints" chapter in the Matlab help)