Thread Subject: fmincon ceq--can I use it as linear constraint?

Subject: fmincon ceq--can I use it as linear constraint?

From: Q Zhang

Date: 29 Oct, 2009 11:04:01

Message: 1 of 3

Here is my optimization problem:
a is 3*1 vector which is equal to cap which is also a 3*1 vector with real value.

[a,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = ...
    fmincon(@function,a0,aeqa,beqa,[],[],lba,uba,@mycon,...,
    optionsa,b,c,d,e);

function [c,ceq]=mycon(a)
ceq=a-cap;
c=[];

"Error:  Too many input arguments.

Error in ==> equil_3investors_know_onlytype_new at 93
[a] = ..."

I am wondering to use ceq to construct the linear constraint problem but it doesnt work. Could someone help me a bit about this?

Many thanks in advance,

QZ

Subject: fmincon ceq--can I use it as linear constraint?

From: Steven Lord

Date: 29 Oct, 2009 14:31:31

Message: 2 of 3


"Q Zhang" <silence_qunzi@hotmail.com> wrote in message
news:hcbsr1$icd$1@fred.mathworks.com...
> Here is my optimization problem:
> a is 3*1 vector which is equal to cap which is also a 3*1 vector with real
> value.
>
> [a,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = ...
> fmincon(@function,a0,aeqa,beqa,[],[],lba,uba,@mycon,...,
> optionsa,b,c,d,e);
>
> function [c,ceq]=mycon(a)
> ceq=a-cap;
> c=[];
>
> "Error:  Too many input arguments.
>
> Error in ==> equil_3investors_know_onlytype_new at 93
> [a] = ..."
>
> I am wondering to use ceq to construct the linear constraint problem but
> it doesnt work. Could someone help me a bit about this?

If you specify additional inputs to FMINCON in this way, intending for them
to be passed into your objective function, your nonlinear constraint
function MUST also accept those additional inputs, even if it doesn't need
or want to use them.

If you're using MATLAB 7.0 (R14) or later and instead use an anonymous
function to specify your objective function:

a = 1;
b = 2;
c = 3;
d = 4;
e = 5;
[a,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = ...
   fmincon(@(x) function(x, a, b, c, d,
e),a0,aeqa,beqa,[],[],lba,uba,@mycon,...,
   options);

then your constraint function doesn't have to accept any additional inputs.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Subject: fmincon ceq--can I use it as linear constraint?

From: Q Zhang

Date: 29 Oct, 2009 18:05:07

Message: 3 of 3

"Steven Lord" <slord@mathworks.com> wrote in message <hcc8uh$h4$1@fred.mathworks.com>...
>
> "Q Zhang" <silence_qunzi@hotmail.com> wrote in message
> news:hcbsr1$icd$1@fred.mathworks.com...
> > Here is my optimization problem:
> > a is 3*1 vector which is equal to cap which is also a 3*1 vector with real
> > value.
> >
> > [a,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = ...
> > fmincon(@function,a0,aeqa,beqa,[],[],lba,uba,@mycon,...,
> > optionsa,b,c,d,e);
> >
> > function [c,ceq]=mycon(a)
> > ceq=a-cap;
> > c=[];
> >
> > "Error:  Too many input arguments.
> >
> > Error in ==> equil_3investors_know_onlytype_new at 93
> > [a] = ..."
> >
> > I am wondering to use ceq to construct the linear constraint problem but
> > it doesnt work. Could someone help me a bit about this?
>
> If you specify additional inputs to FMINCON in this way, intending for them
> to be passed into your objective function, your nonlinear constraint
> function MUST also accept those additional inputs, even if it doesn't need
> or want to use them.
>
> If you're using MATLAB 7.0 (R14) or later and instead use an anonymous
> function to specify your objective function:
>
> a = 1;
> b = 2;
> c = 3;
> d = 4;
> e = 5;
> [a,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = ...
> fmincon(@(x) function(x, a, b, c, d,
> e),a0,aeqa,beqa,[],[],lba,uba,@mycon,...,
> options);
>
> then your constraint function doesn't have to accept any additional inputs.
>
> --
> Steve Lord
> slord@mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
>
Many thanks Steven !! It works now:)

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
fmincon Skirt Zhang 29 Oct, 2009 07:09:03
rssFeed for this Thread

Contact us at files@mathworks.com