Optimization of vectors with optimization toolbox

hello, new to optimization toolbox here :)
i wolud like to optimize 2 vectors:
omega (100X1)
T (100X1)
i have 2 constrains on this vectors
-200<omega>200
-60<T<60
H it's a matrix equal to :H = [omega 1 T]
and M = transpose(H)* H;
i wrote my M matrix result alredy.
my code look like this:
omega = optimvar('omega',100,'LowerBound',-200,'UpperBound',200);
T = optimvar('Temperature',100,'LowerBound',-60,'UpperBound',60);
t = transpose(0:1:100-1);
M = [sum(omega.*omega) sum(omega) sum(omega.*T) ; ...
sum(omega) sum(ones(length(omega),1)) sum(T) ;
sum(omega.*T) sum(T) sum(T.*T) ];
i want to optimize omega and T with this two objective functions
1.trace(M)
2.Det(M)
J1 = trace(M);
J2 = det(M);
prob = optimproblem("ObjectiveSense",'maximize');
prob.Objective =J1;
sol = solve(prob)
my questions:
  1. i would like to add 2 more constrains, about domega/dt and for dT/dt. any one have idea how to do that?
  2. when i try to solve this problem, i get :The problem is non-convex. how sould i continue?
  3. when i try to calculate det(M) i get this error : Check for missing argument or incorrect argument data type in call to function 'det'. can i even use this function with optimization varible ?

7 件のコメント

Walter Roberson
Walter Roberson 2020 年 12 月 21 日
No, det() is not defined for optimvar .
Fortunately you have a 3 x 3 system so you can construct the determinant
M1_1 = sum(omega.^2)
M1_2 = sum(omega)
M1_3 = sum(omega.*T)
and so on
detM = M1_1*M2_2*M3_3 - M1_1*M2_3*M3_2 - M1_2*M2_1*M3_3 + M1_2*M2_3*M3_1 + M1_3*M2_1*M3_2 - M1_3*M2_2*M3_1
eden meirovich
eden meirovich 2020 年 12 月 21 日
is there another way? i'm working with 3X3 system now, but later on i will have 7X7 or 8X8 systems even.
is there a way to use the symbolic tool box maybe?
Bruno Luong
Bruno Luong 2020 年 12 月 21 日
編集済み: Bruno Luong 2020 年 12 月 21 日
Use solver based rather than problem based.
BTW I can't see t is used anywhere.
You might revise how you formulate the optimization problem.
eden meirovich
eden meirovich 2020 年 12 月 21 日
t is just a vector steps time.
do you have an idea which solver shoud i use for this kind of problem?
Matt J
Matt J 2020 年 12 月 21 日
編集済み: Matt J 2020 年 12 月 21 日
i want to optimize omega and T with this two objective functions...
The solutions are trivially omega=T=zeros(100,1) for both objective functions, unless the constraints on the derivatives that you intend to impose bound at least some of the derivatves strictly away from zero.
Bruno Luong
Bruno Luong 2020 年 12 月 21 日
FMINCON?
eden meirovich
eden meirovich 2020 年 12 月 21 日
i know the solution (i try to max the trace and the det, not minimize).
i just want to get this "easy" one, before i continue to one i don't know

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

回答 (1 件)

Matt J
Matt J 2020 年 12 月 21 日
編集済み: Matt J 2020 年 12 月 21 日

0 投票

i would like to add 2 more constrains, about domega/dt and for dT/dt. any one have idea how to do that?
You can use diff() to implement constraints on numerical derivatives, e.g.,
omega = optimvar('omega',100,'LowerBound',-200,'UpperBound',200);
T = optimvar('Temperature',100,'LowerBound',-60,'UpperBound',60);
domega=diff(omega); %derivatives
dT=diff(T);
C.con_domega=lower_domega<=domega & domega<=upper_domega; %bounds on derivatives
C.con_dT=lower_dT<=dT & dT<=upper_dT
As long as all these constraints are linear, you can then use prob2matrices,
to assist in the conversion from the problem-based to the solver-based framework. E.g.,
sol0.omega=omega0; %initial guesses
sol0.T=T0;
prob=prob2matrices({omega,T},'Constraints',C,'sol0',sol0);
prob.x0=reshape(prob.x0,[],2);
prob.solver='fmincon';
prob.fun=@(x) sum(x.^2,'all'); %equivalent to trace M
x1=fmincon(prob);
e = ones(length(omega),1);
prob.fun=@(x) det([x,e].' * [x,e]);
x2=fmincon(prob);

タグ

質問済み:

2020 年 12 月 21 日

コメント済み:

2020 年 12 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by