help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sqp: What are the equality and inequality constraint functions?


From: John W. Eaton
Subject: Re: sqp: What are the equality and inequality constraint functions?
Date: Thu, 13 Jan 2011 04:09:12 -0500

On 13-Jan-2011, Sebastian Schubert wrote:

| Hi,
| 
| > > I have a non-linear, non-quadratic function to minimize with some
| > > constraints and sqp might be usable. However, I don't fully
| > > understand the manual. From the first part, especially,
| > > 
| > > ---------------
| > > Function File: [X, OBJ, INFO, ITER, NF, LAMBDA] = sqp (X, PHI, G,
| > > 
| > >          H, LB, UB, MAXITER, TOLERANCE)
| > >     
| > >     Solve the nonlinear program
| > >     
| > >               min phi (x)
| > >               
| > >                x
| > >     
| > >     subject to
| > >     
| > >               g(x)  = 0
| > >               h(x) >= 0
| > >               lb <= x <= ub
| > > 
| > > ---------------
| 
| > Short answer: the documentation is using vector shorthand; g and h
| > are vector-valued functions, lb and ub are vectors the size of x.
| 
| I think h is a matrix. Citing the manual again:
| 
| "If supplied, the gradient function must be of the form
|       g = gradient (x)
| in which X is a vector and G is a vector.
| If supplied, the hessian function must be of the form
|         h = hessian (x)
| in which X is a vector and H is a matrix."

This part of the description applies to the case of PHI being a 2 or
three element cell array of function handles.  It is separate from the
constraint functions G and H that appear later in the argument list.

| > So lb, ub should be vectors the same size as x, which will give you
| > lb(i)<=x(i)<=ub(i), so in your case let
| > 
| > lb = zeros(size(x)); ub = ones(size(x));
| 
| Yes, that is what I also would've done.
| 
| > I believe you can just make your g function an anonymous function:
| > 
| > g = @(x) sum(x) - 1;
| 
| Because of the reasons above, I guess this would be wrong.

I think it's correct.

| From all this, I would expect that there isn't any possibility to use 
| function constraints similar to qp, but then there is "If supplied, the 
| equality and inequality constraint functions must be of the form
|           r = f (x)
| in which X is a vector and R is a vector." What does this mean?

It means that the functions g(x) and h(x) used to specify general
nonlinear equality and inequality constraints should produce outputs
of the same size as their arguments, which will be values of the
decision variables stored in X.

The sqp function has a test that uses equality constraints.  Have you
looked at it?  Try

  type sqp

at the Octave prompt and scroll to the end.

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]