Quadratic Optimization for 4D in for Loop

3 次查看(过去 30 天)
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 个评论
yanqi liu
yanqi liu 2021-12-31
yes,sir,may be write the equations,and we can use loop to generate cmd string,then use eval to get function handle

请先登录,再进行评论。

采纳的回答

yanqi liu
yanqi liu 2021-12-31
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 个评论
MarshallSc
MarshallSc 2021-12-31
编辑:MarshallSc 2021-12-31
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 2022-1-1
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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Solver 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