Thread Subject: Problem with fmincon

Subject: Problem with fmincon

From: Julien BERNU

Date: 26 Nov, 2009 09:30:20

Message: 1 of 5

Hi,

I have a problem with a program using fmincon: after several iterations the real-valued x vector (seeking the minimum of the obj function) becomes complex which makes the program crash at the next iteration.
How is that possible and how could I correct this???

NB:
My obj function does work with complex numbers but the final result R must mathematically be real. I've checked that this might not be exactly the case, probably because of numerical aberrations: I typically get |Im R / Re R|~10^-15. Hence at the end of my function I force R=real(R) and check that R is then real each time my obj function is called (including the call just before x becomes complex).

Any advice?

Thanks!

Subject: Problem with fmincon

From: Julien BERNU

Date: 26 Nov, 2009 10:02:03

Message: 2 of 5

Problem solved:
I forgot to clean as well the numerical aberrations in my nonlinear constraints.

Subject: Problem with fmincon

From: anis riahi

Date: 15 Dec, 2009 09:02:35

Message: 3 of 5

i have the same problem. i wanna find the optimum of complex vector but it seems that fmincon work only with real parameters?
How can I manage this problem ?

Subject: Problem with fmincon

From: Steven Lord

Date: 15 Dec, 2009 14:33:17

Message: 4 of 5


"anis riahi" <riahianis1@gmail.com> wrote in message
news:hg7jbb$k7a$1@fred.mathworks.com...
>i have the same problem. i wanna find the optimum of complex vector but it
>seems that fmincon work only with real parameters?
> How can I manage this problem ?

Convert your problem from one in N complex parameters into one in 2*N real
parameters; inside your objective function, convert the 2*N-element real
vector into an N-element complex vector and use the complex vector to
evaluate the objective.

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

Subject: Problem with fmincon

From: Matt J

Date: 15 Dec, 2009 16:02:04

Message: 5 of 5

"Steven Lord" <slord@mathworks.com> wrote in message <hg86nc$ka2$1@fred.mathworks.com>...
>
> "anis riahi" <riahianis1@gmail.com> wrote in message
> news:hg7jbb$k7a$1@fred.mathworks.com...
> >i have the same problem. i wanna find the optimum of complex vector but it
> >seems that fmincon work only with real parameters?
> > How can I manage this problem ?
>
> Convert your problem from one in N complex parameters into one in 2*N real
> parameters; inside your objective function, convert the 2*N-element real
> vector into an N-element complex vector and use the complex vector to
> evaluate the objective.

Just remember as well to make sure that the objective returns a purely real-valued result, i.e., if you are calculating the value of the objective (or its gradient etc...) using complex arithmetic operations, be sure to strip away any residual complex part of the result arising from round-off errors and so forth.

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 complex... Julien BERNU 26 Nov, 2009 04:34:06
rssFeed for this Thread

Contact us at files@mathworks.com