Thread Subject: Help! Anyone knows about fmincon?

Subject: Help! Anyone knows about fmincon?

From: Xiaolu Wang

Date: 27 Aug, 2008 23:37:01

Message: 1 of 3

I've been working on optimizing some utility function under
constraint by fmincon(). But the result doesn't make any
sense and there's something saying :

Optimization terminated: no feasible solution found.
Magnitude of search direction less than 2*options.TolX but
constraints are not satisfied.

Does anyone know why this happens and how to get rid of it?

the utility function I'm working on is:
(x' * rtn - (1/2) * x' * sigma * x)
where rtn is a vector of expected return of assets and
sigma is the covariance matrix of assets. In order to
optimize it, I use fmincon() on (x' * rtn - (1/2) * x' *
sigma * x)^(-1), which is the same thing.


the constraints are:
ones(N,1)'*x = 0;
-ones(N,1)<x<ones(N,1);
sum(abs(x)) = 2.

many thanks

Subject: Help! Anyone knows about fmincon?

From: Paul Kerr-Delworth

Date: 28 Aug, 2008 09:44:10

Message: 2 of 3

Hi Xiaolu,

The message that you receive from fmincon indicates that fmincon has not
been able to find a solution that satisfies all the constraints in your
problem. This can mean one of two things, either

1) There are no feasible solutions in the problem
2) There are feasible solutions, but fmincon has not been able to find any

Given the constraints you state, I think case 2) applies. It often helps if
you provide an initial point, X0, which is feasible. With the constraints
you state below, you could use X0 = [1 1 0 ... 0] as a feasible initial
point.

However, I've noticed a couple of extra things here. It looks like you are
trying to maximize (x' * rtn - (1/2) * x' * sigma * x) and you are doing
that by minimizing (x' * rtn - (1/2) * x' *
> sigma * x)^(-1). You say that this is the same thing, and I think it is
> not necessarily the same. You should minimize -(x' * rtn - (1/2) * x' *
> sigma * x), which is equivalent to the maximization you require. At the
> end of this post is a simple example which illustrates that max f(x) is
> not necessarily the same as min (1/f(x)).

Also, is there another way of writing the sum(abs(x)) = 2 constraint? If you
can replace it by a linear constraint or set of linear constraints in some
way, then you could use the function, quadprog, which is better suited to
quadratic problems.

Hope this helps.

Best regards,

Paul

p.s. Consider maximizing a simpler function, f(x) = 5*x*exp(-x) -1 over the
range [0.2, 1.4]. This has a maximum at x = 1.

f = @(x) 5*x.*exp(-x) - 1;
x = 0.2:0.01:1.4;
plot(x, f(x));

Now try minimize the function 1/f(x) over the same interval. This function
is in fact unbounded in the range [0.2, 1.4], it tends to minus infinity at
approximately x = 0.26

hold on
plot(x, 1./f(x), 'r');

Minimizing 1/f(x) in this case will not necessarily give the same answer as
max f(x).

"Xiaolu Wang" <wangxiaolu83@yahoo.com.cn> wrote in message
news:g94oet$qdq$1@fred.mathworks.com...
> I've been working on optimizing some utility function under
> constraint by fmincon(). But the result doesn't make any
> sense and there's something saying :
>
> Optimization terminated: no feasible solution found.
> Magnitude of search direction less than 2*options.TolX but
> constraints are not satisfied.
>
> Does anyone know why this happens and how to get rid of it?
>
> the utility function I'm working on is:
> (x' * rtn - (1/2) * x' * sigma * x)
> where rtn is a vector of expected return of assets and
> sigma is the covariance matrix of assets. In order to
> optimize it, I use fmincon() on (x' * rtn - (1/2) * x' *
> sigma * x)^(-1), which is the same thing.
>
>
> the constraints are:
> ones(N,1)'*x = 0;
> -ones(N,1)<x<ones(N,1);
> sum(abs(x)) = 2.
>
> many thanks
>


Subject: Help! Anyone knows about fmincon?

From: Xiaolu Wang

Date: 28 Aug, 2008 13:11:02

Message: 3 of 3

Hi Paul,

Thanks a lot for your help! They are really useful. As you
suggested, I set x0 = [1;1;0;0;0;0;0;0;0;0] as my initial
guess and it worked!

Thanks again for your help!

Best Regards,
Xiaolu

"Paul Kerr-Delworth" <Paul.Kerr-Delworth@mathworks.co.uk>
wrote in message <g95s1b$4q9$1@fred.mathworks.com>...
> Hi Xiaolu,
>
> The message that you receive from fmincon indicates that
fmincon has not
> been able to find a solution that satisfies all the
constraints in your
> problem. This can mean one of two things, either
>
> 1) There are no feasible solutions in the problem
> 2) There are feasible solutions, but fmincon has not been
able to find any
>
> Given the constraints you state, I think case 2) applies.
It often helps if
> you provide an initial point, X0, which is feasible. With
the constraints
> you state below, you could use X0 = [1 1 0 ... 0] as a
feasible initial
> point.
>
> However, I've noticed a couple of extra things here. It
looks like you are
> trying to maximize (x' * rtn - (1/2) * x' * sigma * x)
and you are doing
> that by minimizing (x' * rtn - (1/2) * x' *
> > sigma * x)^(-1). You say that this is the same thing,
and I think it is
> > not necessarily the same. You should minimize -(x' *
rtn - (1/2) * x' *
> > sigma * x), which is equivalent to the maximization you
require. At the
> > end of this post is a simple example which illustrates
that max f(x) is
> > not necessarily the same as min (1/f(x)).
>
> Also, is there another way of writing the sum(abs(x)) = 2
constraint? If you
> can replace it by a linear constraint or set of linear
constraints in some
> way, then you could use the function, quadprog, which is
better suited to
> quadratic problems.
>
> Hope this helps.
>
> Best regards,
>
> Paul
>
> p.s. Consider maximizing a simpler function, f(x) =
5*x*exp(-x) -1 over the
> range [0.2, 1.4]. This has a maximum at x = 1.
>
> f = @(x) 5*x.*exp(-x) - 1;
> x = 0.2:0.01:1.4;
> plot(x, f(x));
>
> Now try minimize the function 1/f(x) over the same
interval. This function
> is in fact unbounded in the range [0.2, 1.4], it tends to
minus infinity at
> approximately x = 0.26
>
> hold on
> plot(x, 1./f(x), 'r');
>
> Minimizing 1/f(x) in this case will not necessarily give
the same answer as
> max f(x).
>
> "Xiaolu Wang" <wangxiaolu83@yahoo.com.cn> wrote in
message
> news:g94oet$qdq$1@fred.mathworks.com...
> > I've been working on optimizing some utility function
under
> > constraint by fmincon(). But the result doesn't make any
> > sense and there's something saying :
> >
> > Optimization terminated: no feasible solution found.
> > Magnitude of search direction less than 2*options.TolX
but
> > constraints are not satisfied.
> >
> > Does anyone know why this happens and how to get rid of
it?
> >
> > the utility function I'm working on is:
> > (x' * rtn - (1/2) * x' * sigma * x)
> > where rtn is a vector of expected return of assets and
> > sigma is the covariance matrix of assets. In order to
> > optimize it, I use fmincon() on (x' * rtn - (1/2) * x' *
> > sigma * x)^(-1), which is the same thing.
> >
> >
> > the constraints are:
> > ones(N,1)'*x = 0;
> > -ones(N,1)<x<ones(N,1);
> > sum(abs(x)) = 2.
> >
> > many thanks
> >
>
>

Tags for this Thread

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.

rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com