How to check feasibility, i.e. whether a given point for x satisfies the constraints #3383
Replies: 1 comment
-
If you want to check if a pair (x',p') is a feasible (but not necessarily optimal) solution to the optimization problem min_x f(x,p) s.t. x_lb<= x<=x_ub, g_lb<=g(x,p)<=g_ub you can simpliy check if all the inequalities are satisfied (or sufficiently close to being satisfied, e.g. g_fun(x',p')-g_ub<tol). You can create the function g_fun by casadi.Function('g',{x,p},{g}) (Matlab syntax). Since I dont use opti I don't know if you can obtain x,p,g by opti.x, opti.p, opti.g or differently. If you want to check for optimality look at the KKT conditions for Casadis problem formulation in eq. (8) of the paper:
(Matlab syntax) where you can plug in lam_x and lam_g (tol should be smaller than 10^-24). |
Beta Was this translation helpful? Give feedback.
-
Hi CasADi-team,
Given a constrained optimization problem formulated using CasADi (Python), either NLP interface or Opti-Stack interface, how can one check the feasibility of certain values of the optimization variables? Is there a method like opti.is_feasible(x_to_check)?
Below is a minimal working example and my questions as comments at the appropriate positions.
Thanks in advance!
PS: And I hope you can excuse it if the question has already been answered elsewhere, but I couldn't find a suitable question so far.
Beta Was this translation helpful? Give feedback.
All reactions