`(xm,fm,theta,lam)=fmincon(optfunc,nge,neq, xin)`

`(xm,fm,theta,lam)=fmincon(optfunc,nge,neq, xin,showit,itmax,tol)`

Inputs | |

`optfunc` |
The function to be minimized and the constraints. See below. |

`nge` |
The number of inequality constraints. |

`neq` |
The number of equality constraints. |

`xin` |
Initial estimate of the point at which the optimum occurs. |

`showit` |
Optional. If true, the progress of iterations is printed. Default value is false. |

`itmax` |
Optional. Maximum number of allowed iterations. Defaults to `200` . |

`tol` |
Optional. Required accuracy of the solution. Defaults to `1.e-8` . |

Outputs | |

`fm` |
The estimated minimum value. |

`xm` |
The estimated location of the minimum. |

`theta` |
The estimated vector of Lagrange multipliers for inequality constraints. |

`lam` |
The estimated vector of Lagrange multipliers for equality constraints. |

`fmincon`

The function

`optfunc`

should be of the form
` (f,DF)=optfunc(x)`

which returns, for the given input

`x`

, the function value, the constraints,
and their gradients.
The output

`f`

should be a vector, with `f[1]`

being the function to be minimized, `f[2:nh+1]`

the set of inequality constraints, and `f[nh+2:ng+nh+1]`

the set of equality constraints.
The output

`DF`

should be a `(1+nh+ng)Xn`

matrix, where `n`

is the size of
the input `xin`

. Each row of `DF`

is the gradient of the corresponding
function returned in `f`

.
>>/*> From> http://www.math.mtu.edu/~msgocken/ma5630spring2003/lectures/nlp/nlp.pdf>> Minmize (x1-1)^2+2(x2+2)^2+3(x3+3)^2> subject to> x3-x1^2 >=0> and x3-x1-x2 =1.>>*/>>function (f,df)=func(x)> f=[ (x[1]-1)^2+2(x[2]+2)^2+3(x[3]+3)^2> x[3]-x[1]^2> x[3]-x[1]-x[2]-1]> df=[2(x[1]-1) 4(x[2]+2) 6(x[3]+3)> -2x[1] 0 1> -1 -1 1]>end>>(f,x,l,s)=fmincon(@func,1,1,rand(3,1))>>// Estimated solution>>x,NL0.1229 -1.1078 0.0151>>// Estimated Lagrangian multiplier>>l,NL21.6619>>s,NL-3.5710>>// Functions and constraints at the estimated optimum>>func(x),NL29.6339 0 0