## leastsq in optimization toolbox 1.0d of matlab 4.2c

### leastsq in optimization toolbox 1.0d of matlab 4.2c

Hi,

I would like to use the leastsq function in the optimization toolbox

(matlab 4.2c for optimization toolbox 1.0d version only) to perform
some calculations. I would like to introduce some equality constraints
in the (linear and non-linear) least square calculation. Is there any
function
similar than leastsq which can include some equality constraints in the
optimiation toolbox 1.0d for matlab 4.2c. Although constr can perform
calculation with constraints, it cannot be used in the least square
calculation.
Thanks.

Wang De Chao

### leastsq in optimization toolbox 1.0d of matlab 4.2c

> Hi,

>     I would like to use the leastsq function in the optimization toolbox

> (matlab 4.2c for optimization toolbox 1.0d version only) to perform
> some calculations. I would like to introduce some equality constraints
> in the (linear and non-linear) least square calculation. Is there any
> function
> similar than leastsq which can include some equality constraints in the
> optimiation toolbox 1.0d for matlab 4.2c. Although constr can perform
> calculation with constraints, it cannot be used in the least square
> calculation.

Well, yes it can. Use the same objective function that leastsq
would call, but at the end, return the sum of the squares of your
residuals to constr as its objective. Also compute and return the
inequality constraints.

A quick perusal of constr tells me that it does not explicitly
include equality constraints, but you can get around this either
by eliminating a number of the unknowns using a QR factorization
if the equality constraints are linear, or by using a set of double
inequality constraints, viz,

G <= 0
-G <= 0

John D'Errico

### leastsq in optimization toolbox 1.0d of matlab 4.2c

>A quick perusal of constr tells me that it does not explicitly
>include equality constraints, but you can get around this either
>by eliminating a number of the unknowns using a QR factorization
>if the equality constraints are linear, or by using a set of double
>inequality constraints, viz,

Although it is not documented in the function, constr *can* handle
equality constraints.  Simply put the equality constraints first in the
constraint vector in the objective function and set OPTIONS(13) to the
number of equality constraints.

opt = foptions;
opt(13) = <number of equality constraints>;
x = constr('objective',x0,opt);

--
Doug Schwarz
Eastman Kodak Company

Hi,

I would like to use the leastsq function in the optimization toolbox
to perform some calculations. I would like to introduce some equality
constraints in the least square calculation. Is there any function
similar than leastsq which can include some equality constraints.
Although constr can perform calculation with constraints, it cannot be
used in the least square calculation.  Thanks.

D. C. Wang