필터 지우기
필터 지우기

Quadratic Optimization for 4D in for Loop

조회 수: 5 (최근 30일)
MarshallSc
MarshallSc 2021년 12월 31일
댓글: yanqi liu 2022년 1월 1일
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