Optimization of vectors with optimization toolbox
7 ビュー (過去 30 日間)
古いコメントを表示
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:
- i would like to add 2 more constrains, about domega/dt and for dT/dt. any one have idea how to do that?
- when i try to solve this problem, i get :The problem is non-convex. how sould i continue?
- 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 件のコメント
回答 (1 件)
Matt J
2020 年 12 月 21 日
編集済み: Matt J
2020 年 12 月 21 日
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);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Get Started with Optimization Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!