help-octave
[Top][All Lists]

## Re: qp(): how do I get a simple inequality constraint?

 From: forkandwait Subject: Re: qp(): how do I get a simple inequality constraint? Date: Fri, 23 Sep 2011 17:15:49 +0000 (UTC) User-agent: Loom/3.14 (http://gmane.org/)

```Leo Butler <l.butler <at> cmich.edu> writes:

>
> forkandwait <forkandwait <at> gmail.com> writes:
> >
> > min (p'*G*p)/2 + f'*p
> >
> > subject to C*p <= b
>
> In my first post, I should have said to use A_lb, A_in and A_ub to
> enforce the inequallity on your slack variable, as you divined.
>

Like this? --

phat = qp(x0, G, f, [], [], [], [], [], C, b)

This is what I have, and I get a very different answer than the book.  See below
for my inputs (phat is the result, book_phat is what the book has, etc).

I will continue hacking and reading (can you recommend a book?).

(The difficulty in posing the question is that the algorithm munges a bunch of
stuff before calling qp, so determining whether the problem is in the set up or
my call to qp() is not so trivial, at least for an optimization ignoramus like
myself.)

The full qp reference is this:  qp(x0, H, q, A, b,lb, ub, A_lb, A_in, A_ub)

My inputs and outputs:

phat =
0.00000
1.00000
0.00000
1.00000
0.01673
1.00000

book_phat =
0.00000
1.00000
0.45000
0.54000
0.01000
0.97000

G =
1.4151e+002  0.0000e+000  0.0000e+000  0.0000e+000  3.0723e+003  0.0000e+000
0.0000e+000  1.4151e+002  6.6074e+002  0.0000e+000  0.0000e+000  0.0000e+000
0.0000e+000  6.6074e+002  3.0851e+003  0.0000e+000  0.0000e+000  0.0000e+000
0.0000e+000  0.0000e+000  0.0000e+000  3.0851e+003  0.0000e+000  1.4345e+004
3.0723e+003  0.0000e+000  0.0000e+000  0.0000e+000  6.6701e+004  0.0000e+000
0.0000e+000  0.0000e+000  0.0000e+000  1.4345e+004  0.0000e+000  6.6701e+004

f =
-5.1391e+001
-2.7590e+002
-1.2882e+003
-5.1457e+004
-1.1157e+003
-2.3926e+005

C =
-1   0   0   0   0   0
0  -1   0   0   0   0
0   0  -1   0   0   0
0   0   0  -1   0   0
0   0   0   0  -1   0
0   0   0   0   0  -1
1   1   0   0   0   0
0   0   1   1   0   0
0   0   0   0   0   1

b =
0
0
0
0
0
0
1
1
1

```