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 comentarios

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
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 el 21 de Dic. de 2020
Editada: Bruno Luong el 21 de Dic. de 2020
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.
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 el 21 de Dic. de 2020
Editada: Matt J el 21 de Dic. de 2020
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 el 21 de Dic. de 2020
FMINCON?
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

Iniciar sesión para comentar.

Respuestas (1)

Matt J
Matt J el 21 de Dic. de 2020
Editada: Matt J el 21 de Dic. de 2020
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);

Etiquetas

Preguntada:

el 21 de Dic. de 2020

Comentada:

el 21 de Dic. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by