help-octave
[Top][All Lists]

## Newbie question - sqp solver equality constraints function

 From: alexegin Subject: Newbie question - sqp solver equality constraints function Date: Wed, 21 Jun 2017 09:40:57 -0700 (PDT)

```Hello all!
I am trying to use *sqp* solver to find optimal vector *X*. All of the
vector elements /must/ meet the following constraints:
# 1. All of the elements must be more than -1.0 and less than 1.0-1.0 < X(i)
< 1.0# 2.1 Sum of all elements those are _less than zero_ must be equal to
-1.0# 2.2 Sum of all the elements those are _more than zero_ must be equal
to 1.0dMinuses = 0.0;dPluses   = 0.0;for i = 1:rows( X )  if ( X( i ) < 0.0
)    dMinuses += X( i );  else    dPluses += X( i );  endif;endfor;bResult =
( ( dMinuses + 1.0 ) == 0.0 ) && ( ( dPluses - 1.0 ) == 0.0 );
The first constraint -1.0 < X(i) < 1.0 can be easily passed to *sqp* solver
by upper and lower bounds.But I do not know how to pass the second ones
*simultaneously*:
SUM( X( i ) ) - 1.0 = 0.0, X( i ) >= 0.0SUM( X( i ) ) + 1.0 = 0.0, X( i ) <
0.0
Thank you very much in advance.

--
View this message in context:
http://octave.1599824.n4.nabble.com/Newbie-question-sqp-solver-equality-constraints-function-tp4683834.html
Sent from the Octave - General mailing list archive at Nabble.com.

```