Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

fmincon error

2 views
Skip to first unread message

Vishnu

unread,
Dec 27, 2009, 6:27:02 AM12/27/09
to
Hi all,
Using fmincon, I want to minimize a function y=f transpose*G* f where f is a vector of length 6. G is a matrix. I have constraints like A*f= B and f>= 0. I have two doubts:
1. Should the second 'constraint' f>= 0 be passed as a constarint or it be given in the form of bound with 'lower bound = 0'? What is the difference?
2. I tried both means, using optimset('Algorithm','active-set').
I get a error message "Optimization terminated: no feasible solution found. Magnitude of search direction less than 2*options.TolX but constraints are not satisfied".
What could be the reason? Any help is appreciated please.

John D'Errico

unread,
Dec 27, 2009, 7:18:03 AM12/27/09
to
"Vishnu " <hivishnuswor...@rediffmail.com> wrote in message <hh7ga6$955$1...@fred.mathworks.com>...

> Hi all,
> Using fmincon, I want to minimize a function y=f transpose*G* f where f is a vector of length 6. G is a matrix. I have constraints like A*f= B and f>= 0. I have two doubts:
> 1. Should the second 'constraint' f>= 0 be passed as a constarint or it be given in the form of bound with 'lower bound = 0'? What is the difference?

No real difference in the final result, but possibly
a difference in efficiency. Use the bounds. There
is no good reason to force fmincon to do extra work,
to deal with a more general class of constraints than
it needs to though.


> 2. I tried both means, using optimset('Algorithm','active-set').
> I get a error message "Optimization terminated: no feasible solution found. Magnitude of search direction less than 2*options.TolX but constraints are not satisfied".
> What could be the reason? Any help is appreciated please.

What could be the reason? Get better starting values.
It is even possible that no solution exists to the set
of constraints that you have formed. That is the
meaning of this message - that no solution was found
that satisfies the constraints.

Rethink your problem. Decide if there is a flaw with
the problem formulation, or if the flaw is in your
coding of the problem. If there is no flaw, then GET
BETTER STARTING VALUES. If you can't do this, then
go back to rethinking your problem.

John

Matt J

unread,
Dec 27, 2009, 8:42:04 AM12/27/09
to
"Vishnu " <hivishnuswor...@rediffmail.com> wrote in message <hh7ga6$955$1...@fred.mathworks.com>...
> Hi all,
> Using fmincon, I want to minimize a function y=f transpose*G* f where f is a vector of length 6. G is a matrix. I have constraints like A*f= B and f>= 0. I have two doubts:
========

On a side note, why not use quadprog() as opposed to fmincon

Vishnu

unread,
Dec 31, 2009, 1:22:03 AM12/31/09
to
Hi Matt
Many thanks for replying. Now I have one more question to ask. If there are 6 variables and I am particular that only TWO of them - say Var1 and Var4 SHOULD follow certain bounds and other variables are 'free' to move, how to specify that in fmincon? Any ideas please?
Thanks in advance

Matt J

unread,
Dec 31, 2009, 1:44:04 AM12/31/09
to
"Vishnu " <hivishnuswor...@rediffmail.com> wrote in message <hhhfua$gio$1...@fred.mathworks.com>...

> Hi Matt
> Many thanks for replying. Now I have one more question to ask. If there are 6 variables and I am particular that only TWO of them - say Var1 and Var4 SHOULD follow certain bounds and other variables are 'free' to move, how to specify that in fmincon? Any ideas please?
> Thanks in advance

Specify lower and upper bounds of -inf and inf on the free variables.

Bruno Luong

unread,
Dec 31, 2009, 3:00:20 AM12/31/09
to
"John D'Errico" <wood...@rochester.rr.com> wrote in message <hh7j9r$go2$1...@fred.mathworks.com>...

> If there is no flaw, then GET
> BETTER STARTING VALUES.

John, does then starting value matter when the function is convex?

Bruno

Vishnu

unread,
Dec 31, 2009, 3:06:04 AM12/31/09
to
"Vishnu " <hivishnuswor...@rediffmail.com> wrote in message <hh7ga6$955$1...@fred.mathworks.com>...

Vishnu

unread,
Dec 31, 2009, 3:16:03 AM12/31/09
to
Hi Matt
Thanks again..As stated earlier,I have 6 variables and var 2 and var 4 are to follow strict bounds. You suggested using -inf inf for the unbounded variables.
The original code I wrote is this:
x=fmincon(@obfun11,x0,H,b,GL,A,0,900,[],options)
Now I understand that 0,900 specified above apply to ONLY the first variable, not for all variables..I got this clue from here:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/265989#695158

Now, coming back to my question and your reply, should I rewrite the code as:

x=fmincon(@obfun11,x0,H,b,GL,A,-inf,inf,0,900,inf,inf,300,1600...options)?
(.... to mean other variables)
Kindly note that the only second and fourth var have been bounded.
Is this syntax correct? Will fmincon understand that each pair of these is the bound values for each variable?

Bruno Luong

unread,
Dec 31, 2009, 3:28:02 AM12/31/09
to
"Vishnu " <hivishnuswor...@rediffmail.com> wrote in message <hhhmk3$8db$1...@fred.mathworks.com>...

> Hi Matt
> Thanks again..As stated earlier,I have 6 variables and var 2 and var 4 are to follow strict bounds. You suggested using -inf inf for the unbounded variables.
> The original code I wrote is this:
> x=fmincon(@obfun11,x0,H,b,GL,A,0,900,[],options)
> Now I understand that 0,900 specified above apply to ONLY the first variable, not for all variables..I got this clue from here:
> http://www.mathworks.com/matlabcentral/newsreader/view_thread/265989#695158
>
> Now, coming back to my question and your reply, should I rewrite the code as:
>
> x=fmincon(@obfun11,x0,H,b,GL,A,-inf,inf,0,900,inf,inf,300,1600...options)?
> (.... to mean other variables)

No. Put the lower and upper bound as vectors:

lo = [-inf 0 -inf 0 0 0]';
up = [inf 900 inf 1600 ...]';

x = fmincon(..., lo, up)

Bruno

Alan Weiss

unread,
Dec 31, 2009, 7:35:21 AM12/31/09
to
I am very interested in finding out why you have this question.
Obviously, the documentation has been inadequate for you. How can I make
things clearer? I am quite serious, and would appreciate any comments
about the areas of documentation that are unclear.

Perhaps it is simply that you cannot find the relevant areas of
documentation, but once found they are satisfactory. For bounds, see
http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/brhkghv-11.html#brhkghv-13

For fmincon syntax, see
http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/fmincon.html

If you had trouble locating these sections, I would appreciate knowing
how you looked for them. Did you use a keyword search? Did you look in
the Optimization Toolbox User's Guide table of contents? Is there a term
you were looking for, such as "bounds" or "limits" or "minimum" that did
not give you satisfactory results?

Thanks in advance for any information,

Alan Weiss
MATLAB mathematical toolbox documentation

Vishnu

unread,
Jan 3, 2010, 12:32:03 AM1/3/10
to
Hi Alan and Bruno
Many thanks and wish you a happy new year. Alan, yes I could not locate those sections of the document earlier. Thanks for info.
When I run the code, i get a message " No feasible point found.."I also get a set of values for the vaiable vector 'x'. When there is no feasible point found, what do these numbers represent? Can these be used as the 'result'? (Intersetingly 4 out of 6 such variable values are nearly or exactly the same as the upper bound specified on them.)
Any explanation please.
Regards
Vishnu

Matt J

unread,
Jan 3, 2010, 10:45:04 AM1/3/10
to
"Vishnu " <hivishnuswor...@rediffmail.com> wrote in message <hhpa4j$67l$1...@fred.mathworks.com>...


As John asked you already, are you sure a feasible point exists for this problem? If you know a feasible point, why not initialize from there and see what happens? Again though, I wonder why you are not using quadprog() instead of fmincon() seeing as your problem is a QP.

0 new messages