optimization

1 回表示 (過去 30 日間)
Vincent
Vincent 2012 年 1 月 17 日
Hi ! I would like to minimize a linear function F(x)=f1(x)+f2(x)+...+fn(x)(each of f(x) is linear) under linear constraintes gi(x)=bi i=1,..m and nonlinear constraint norm(x)=1 where x is a vector with k-components and norm(x)^2=x(1)^2+...+x(k)^2 is the L-2 norm I don't know which function in matlab I can use for that program. I can't use [fmincon] since fmincon requires the objective function F(x) to be twice differentiable to compute the hessian, neither I can't use linear programing optimization since I have a non linear constraint. Can anyone help me please. Now I use the 2008b matlab version, I don't know if the 2011 version of matlab can do the job [with fmincon]
Any comment will be very helpfull
  1 件のコメント
Paresh kumar Panigrahi
Paresh kumar Panigrahi 2021 年 4 月 7 日
how to calculate weight optimal solution given 10 asset

サインインしてコメントする。

採用された回答

Andrew Newell
Andrew Newell 2012 年 1 月 18 日
A linear function is twice differentiable - the second derivative is zero! So go ahead and use fmincon.

その他の回答 (2 件)

Teja Muppirala
Teja Muppirala 2012 年 1 月 18 日
This type of problem can be easily set up in FMINCON, by employing the nonlinear constraint input parameter.
As a concrete example
Minimize: -2*x1 + 5*x2 + 10*x3
Subject to linear constraint: x1+x2+x3 = 1
And nonlinear constraint: norm([x1 x2 x3]) = 1
This can be solved by:
f = [-2; 5; 10];
x0 = [0; 0; 0];
Aeq = [1 1 1];
beq = 1;
nlcon = @(x) deal([], norm(x)-1)
fmincon(@(x) f'*x, x0, [],[],Aeq,beq,[],[],nlcon)
Which yields:
ans =
0.9400
0.2695
-0.2094
Which appears to be a valid solution.

Vincent
Vincent 2012 年 1 月 18 日
Thanks to both of you Teja and Andrew! Before sending my first message I tried to resolve this problem that I know the result
min f(x)=x(1)+x(2)
subject to :
-1<=x(i)<=1 for i=1,2
x(1)^2+x(2)^2=1
I know that the answer is x=(0,1) or x=(1,0) and fval=1 When I use [Fmincon] i get this result only for x0=[1,0] or x0=[0,1]. For any other starting point x0 like x0=[1,1] or x0=[0.5, 0.5] the solution I get is x=(0.74, 0.74) and fval=1.4 that is not the right answer.
So the solution is very sensitive to how far the starting point is from the right solution , that is my problem

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by