help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Optimization in Octave


From: Urs Hackstein
Subject: Re: Optimization in Octave
Date: Wed, 12 Mar 2014 12:41:00 +0100

2014-03-10 13:52 GMT+01:00, Urs Hackstein <address@hidden>:
> 2014-02-28 13:55 GMT+01:00, Julien Bect <address@hidden>:
>> On 28/02/2014 12:07, Juan Pablo Carbajal wrote:
>>> On Fri, Feb 28, 2014 at 11:45 AM, Urs Hackstein
>>> <address@hidden> wrote:
>>>> Dear all,
>>>>
>>>> we have the following optimization problem: Given a (nonlinear, but
>>>> almost everywhere differentiable) function
>>>>
>>>> p:[0.5,20]^4*[5,200]\to\mathbb{C}
>>>>
>>>> we want to find the maximum of
>>>>
>>>> Re(p(x_1,x_2,x_3,x_4,x_5))
>>>>
>>>> for fixed imaginary part
>>>> Im(p(x_1,x_2,x_3,x_4,x_5))=y_0.
>>>> Is it possible to solve this problem using Octave?
>>>> Thanks a lot in advance!
>>>>
>>>> Best regards,
>>>>
>>>> Urs Hackstein
>>>> _______________________________________________
>>>> Help-octave mailing list
>>>> address@hidden
>>>> https://mailman.cae.wisc.edu/listinfo/help-octave
>>> If you have the function, and you want to fix the imaginary part, then
>>> you have a real function. If it is differentiable, I see no problem
>>> using gradient based methods. If it is not differentiable then you can
>>> use ga, or in prticular cma-es
>>> https://www.lri.fr/~hansen/cmaes_inmatlab.html
>>
>> I would rather say that this is an *equality constrained* problem with 5
>> variables and 1 equality constraint.
>>
>> In Octave core, you can try sqp to solve it. Something like :
>>
>>      F = @(x)(real (p (x(1), x(2), x(3), x(4), x(5)));
>>      G = @(x)(imag (p (x(1), x(2), x(3), x(4), x(5)) - y_0);
>>
>>      lb = [0.5 0.5 0.5 0.5 5];
>>      ub = [20 20 20 20 200];
>>
>>      x_opt = sqp (x_init, F, G, [], lb, ub)
>>
>> Type "help sqp" for more details. You can also provide the gradient, if
>> you have it.
>>
>> If sqp doesn't work for you, have a look at the optim package
>> <http://octave.sourceforge.net/optim/index.html> or NLopt
>> <http://ab-initio.mit.edu/wiki/index.php/NLopt>.
>>
>> @++
>> Julien
>>
>>
>
> Dear Julien,
>
> thanks a lot for your explanations. I tried to formulate my problem as
> a function with variable y_0 using sqp in the meantime, but I receive
> still an error that I don't understand.
>
> My attempt was the following:
>
> function x_opt=opt(b)
>
> x_init = 5*ones(5,1);
> lbound = [0.5,0.5,0.5,0.5,5]';
> ubound = [20,20,20,20,200]';
> F=@(x)(real(p(x(1),x(2),x(3),x(4),x(5))));
> G=@(x)(imag(p(x(1),x(2),x(3),x(4),x(5)))-b);
> h=@(x) (1.85.*x(1:2,1) - x(3:4,1))
> x_opt=sqp(x_init,F,G,h,lbound,ubound,500)
>
> and the error is
>
> error: qp: equality constraint matrix must be full row rank
> error: called from:
> error:   /usr/local/share/octave/3.6.4/m/optimization/qp.m at line
> 325, column 11
> error:   /usr/local/share/octave/3.6.4/m/optimization/sqp.m at line
> 414, column 32
> error:   /home/hackstein/............./opt.m at line 11, column 6
>
> What am I missing?
>
> Thanks a lot in advance.
>
> Best regards,
>
> Urs Hackstein
>

Dear all,

I made two observations in the meantime. Maybe they are helpful.

First, the program runs through for some values for b, for some others
not. If it runs through, it seems to return the minimal value for F,
not the maximum. Thus changing F to
F=@(x)(1/(real(p(x(1),x(2),x(3),x(4),x(5))))); gives better results,
but not the optimal values. For example, opt(9.9454e+10) returns
-2.5657e+11 + 9.9454 e+10i, but p(3,8,1.5,4,62)=-1.1198e+11+9.9454
e+10i is significantly better. Maybe -2.5657e+11 is a local maximum of
the real part of p for
fixed imaginary part 9.9454e+10, but how can we reach the absolute maximum?

Second, the error reported in the previous post seems to disappear if
we change F to
F=@(x)(1/(real(p(x(1),x(2),x(3),x(4),x(5)))));

Any ideas?

Best regards,

Urs Hackstein


reply via email to

[Prev in Thread] Current Thread [Next in Thread]