Quadratic Optimization for 4D in for Loop

3 visualizaciones (últimos 30 días)
MarshallSc
MarshallSc el 31 de Dic. de 2021
Comentada: yanqi liu el 1 de En. de 2022
I need to find the roots (complex in nature) of an objective function in 4D by using quadratic optimization for the function below:
a = [0.0068 0.0036 0.000299 0.0151]; b = [0.0086 0.00453 0.0016 0.00872]
f = @(xj,xk) a(i) - (x(j)*x(k)) * b(l); %i,j,k,l = 1:4 - simple eqn: f = @(x1,x2) a(1) - (x(2)*x(3)) * b(4)
The problem that I have is that I don't know how to write it in a for loop or permutation manner that each loop takes a specific value of the (a,b) and (xj,xk) from 1:4. Basically it's a nonlinear coordinate transformation. Since my X(i) * X(j) makes the problem quadratic, I need to perform an approximation using the only equality constraint such (imposing the symmetry of the potential function - (i,j) and (k,l) pair become exchangeable):
(x(j)*x(k)) * b(l) + (x(i)*x(l)) * b(k) + (x(k)*x(j)) * b(j) + (x(l)*x(i)) * b(i) =< a(i) + a(j) + a(k) + a(l)
That's my only constraint for optimization that minimizes the objective function. I tried using fmincon but I don't know how to use it in a loop for the equation and the constraint.
I'd appreciate it if someone can help me! Thank you!
  1 comentario
yanqi liu
yanqi liu el 31 de Dic. de 2021
yes,sir,may be write the equations,and we can use loop to generate cmd string,then use eval to get function handle

Iniciar sesión para comentar.

Respuesta aceptada

yanqi liu
yanqi liu el 31 de Dic. de 2021
clc; clear all; close all;
a = [0.0068 0.0036 0.000299 0.0151];
b = [0.0086 0.00453 0.0016 0.00872];
% f = @(xj,xk) a(i) - (x(j)*x(k)) * b(l); %i,j,k,l = 1:4 - simple eqn: f = @(x1,x2) a(1) - (x(2)*x(3)) * b(4)
for i = 1 : length(a)
eqi = sprintf('f=@(x1,x2) %f- (x(1)*x(2))*%f;', a(i), b(i));
disp(eqi)
end
f=@(x1,x2) 0.006800- (x(1)*x(2))*0.008600; f=@(x1,x2) 0.003600- (x(1)*x(2))*0.004530; f=@(x1,x2) 0.000299- (x(1)*x(2))*0.001600; f=@(x1,x2) 0.015100- (x(1)*x(2))*0.008720;
  2 comentarios
MarshallSc
MarshallSc el 31 de Dic. de 2021
Editada: MarshallSc el 31 de Dic. de 2021
Thanks Yanqi for your answer. Do you know how I can incoporate this pemutated equation to solve for the quadratic optimization to find the minimum values of Xs? a & b are just the coefficient of the second order polynomial.
I'm a little bit lost as to what should be done. I'd appreciate it.
yanqi liu
yanqi liu el 1 de En. de 2022
yes,sir,may be it is non-linear optimization,use fmincon to get compute,may be write your equations in handwriting,we can make some debug

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by