7/26/2023 0 Comments Fmincon![]() For reference, the Matlab code passes the following options to fmincon(): fmincon options: I've verified that the Python code is correct by calling the Python hessian/jacobian function from fmincon() and making sure that the same solution is reached. The Matlab code has analytic solutions for both the objective and constraint hessian and jacobian, which I've rewritten entirely in Python. There already exists a Matlab implementation of this script, so I'm essentially just trying to find a Python solver that has equivalent performance to Matlab's fmincon(). This is explained in more detail in this paper byĭiscuss an approach for step size selection.I'm currently trying to implement a Python script for solving a constrained nonlinear optimization problem with ~1000 variables and ~700 constraints (both linear and nonlinear). Some experimentation with different step sizes is often needed toįind a value that is appropriate for a particular function. Problem with a too-small step size is that roundoff error makes the calculation "differentiated." The problem with a too-large step size is obvious. Step size being either too large or too small for the function being numerically So the relevant question is not HOW are they calculated but why do the gradientsĬalculated by finite difference differ so significantly from those calculatedįrom an analytical expression? Usually this is caused by the finite difference fmincon is usingĮither forward (default) or central difference formulas with the step size selectedĪccording to the documentation for FiniteDifferenceStepSize. Specifically, the documentation for the FiniteDifferenceType andįiniteDifferenceStepSize options explain this in some detail. The fmincon documentation is fairly clear on HOW it calculates gradients. $(\mathbf p, \mathbf q)$ also enters linearly into the objective and constraints in that problem. $V(\mathbf p, \mathbf q)$ is actually the value function of some linear programming problem, and I've written a script that invokes linprog to calculate the value of my objective.
0 Comments
Leave a Reply. |