In MATLAB, you can use the fmincon
function to minimize non-linear inequalities. The general syntax of the fmincon
function is as follows:
main.m38 chars2 lines
where
fun
is a handle to the objective function.x0
is the initial guess of the solution.A
and b
are matrices that define the non-linear inequality constraints A*x <= b
.Aeq
and beq
are matrices that define the non-linear equality constraints Aeq*x = beq
.lb
and ub
are the lower and upper bounds of the optimization variables.Here's an example code that illustrates how to use fmincon
to minimize a non-linear inequality:
main.m385 chars17 lines
In this example, the objective function is the Rosenbrock function, which has a non-linear inequality constraint x2 - x1 <= 1
. The fmincon
function is called with the objective function, the initial guess of the solution, the non-linear inequality constraint, and the lower and upper bounds of the optimization variables. The output x
is the solution to the optimization problem, and fval
is the value of the objective function at x
.
gistlibby LogSnag