Optimization of 9 unknown with 9 nonlinear constraints by fmincom
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi
I want to find the optimal solution of 9 unknown ( x(1) - x(9) ) with 9 nonlinear constraints, and subject to the minimization of x(9) so I use fmincon to solve it.
Here is my code for the optimization with fmincon:
% main code
fun = @(x) x(9) ;
nonlcon = @unitdisk50;
lb = [0 0 0 0 0 0 0 0 0];
ub = [inf inf inf inf inf inf inf inf inf];
x0 = [0.02 0.64 0.95 1.38 1.72 2.12 2.52 2.9 3.1];
A = [];
b = [];
Aeq = [];
beq = [];
x = fmincon(fun,x0,[],[],[],[],lb,ub,nonlcon)
and the code of function
function [c,ceq] =unitdisk50(x)
J = 2;
w1 = 2.3026;
sigma1 = -0.3364;
w2 = 6.5298;
sigma2 = -3.4136;
c = [x(1)-x(2)+x(3)-x(4)+x(5)-x(6)+x(7)-x(8)+x(9)];
ceq = [1-exp(-sigma1*x(1))*cos(w1*x(1)) + exp(-sigma1*x(2))*cos(w1*x(2)) - exp(-sigma1*x(3))*cos(w1*x(3)) + exp(-sigma1*x(4))*cos(w1*x(4)) - exp(-sigma1*x(5))*cos(w1*x(5)) + exp(-sigma1*x(6))*cos(w1*x(6)) - exp(-sigma1*x(7))*cos(w1*x(7)) + exp(-sigma1*x(8))*cos(w1*x(8)) - exp(-sigma1*x(9))*cos(w1*x(9))
-exp(-sigma1*x(1))*sin(w1*x(1)) + exp(-sigma1*x(2))*sin(w1*x(2)) - exp(-sigma1*x(3))*sin(w1*x(3)) + exp(-sigma1*x(4))*sin(w1*x(4)) - exp(-sigma1*x(5))*sin(w1*x(5)) + exp(-sigma1*x(6))*sin(w1*x(6)) - exp(-sigma1*x(7))*sin(w1*x(7)) + exp(-sigma1*x(8))*sin(w1*x(8)) - exp(-sigma1*x(9))*sin(w1*x(9))
-x(1)*exp(-sigma1*x(1))*cos(w1*x(1)) + x(2)*exp(-sigma1*x(2))*cos(w1*x(2)) - x(3)*exp(-sigma1*x(3))*cos(w1*x(3)) + x(4)*exp(-sigma1*x(4))*cos(w1*x(4)) - x(5)*exp(-sigma1*x(5))*cos(w1*x(5)) + x(6)*exp(-sigma1*x(6))*cos(w1*x(6)) - x(7)*exp(-sigma1*x(7))*cos(w1*x(7)) + x(8)*exp(-sigma1*x(8))*cos(w1*x(8)) - x(9)*exp(-sigma1*x(9))*cos(w1*x(9))
-x(1)*exp(-sigma1*x(1))*sin(w1*x(1)) + x(2)*exp(-sigma1*x(2))*sin(w1*x(2)) - x(3)*exp(-sigma1*x(3))*sin(w1*x(3)) + x(4)*exp(-sigma1*x(4))*sin(w1*x(4)) - x(5)*exp(-sigma1*x(5))*sin(w1*x(5)) + x(6)*exp(-sigma1*x(6))*sin(w1*x(6)) - x(7)*exp(-sigma1*x(7))*sin(w1*x(7)) + x(8)*exp(-sigma1*x(8))*sin(w1*x(8)) - x(9)*exp(-sigma1*x(9))*sin(w1*x(9))
1-exp(-sigma2*x(1))*cos(w2*x(1)) + exp(-sigma2*x(2))*cos(w2*x(2)) - exp(-sigma2*x(3))*cos(w2*x(3)) + exp(-sigma2*x(4))*cos(w2*x(4)) - exp(-sigma2*x(5))*cos(w2*x(5)) + exp(-sigma2*x(6))*cos(w2*x(6)) - exp(-sigma2*x(7))*cos(w2*x(7)) + exp(-sigma2*x(8))*cos(w2*x(8)) - exp(-sigma2*x(9))*cos(w2*x(9))
-exp(-sigma2*x(1))*sin(w2*x(1)) + exp(-sigma2*x(2))*sin(w2*x(2)) - exp(-sigma2*x(3))*sin(w2*x(3)) + exp(-sigma2*x(4))*sin(w2*x(4)) - exp(-sigma2*x(5))*sin(w2*x(5)) + exp(-sigma2*x(6))*sin(w2*x(6)) - exp(-sigma2*x(7))*sin(w2*x(7)) + exp(-sigma2*x(8))*sin(w2*x(8)) - exp(-sigma2*x(9))*sin(w2*x(9))
-x(1)*exp(-sigma2*x(1))*cos(w2*x(1)) + x(2)*exp(-sigma2*x(2))*cos(w2*x(2)) - x(3)*exp(-sigma2*x(3))*cos(w2*x(3)) + x(4)*exp(-sigma2*x(4))*cos(w2*x(4)) - x(5)*exp(-sigma2*x(5))*cos(w2*x(5)) + x(6)*exp(-sigma2*x(6))*cos(w2*x(6)) - x(7)*exp(-sigma2*x(7))*cos(w2*x(7)) + x(8)*exp(-sigma2*x(8))*cos(w2*x(8)) - x(9)*exp(-sigma2*x(9))*cos(w2*x(9))
-x(1)*exp(-sigma2*x(1))*sin(w2*x(1)) + x(2)*exp(-sigma2*x(2))*sin(w2*x(2)) - x(3)*exp(-sigma2*x(3))*sin(w2*x(3)) + x(4)*exp(-sigma2*x(4))*sin(w2*x(4)) - x(5)*exp(-sigma2*x(5))*sin(w2*x(5)) + x(6)*exp(-sigma2*x(6))*sin(w2*x(6)) - x(7)*exp(-sigma2*x(7))*sin(w2*x(7)) + x(8)*exp(-sigma2*x(8))*sin(w2*x(8)) - x(9)*exp(-sigma2*x(9))*sin(w2*x(9))
J*(x(3)-x(2)+x(1)-x(4)+x(5)-x(6)+x(7)-x(8)+x(9))-1
];
Although it has found the solution
x
0.1333 1.0305 1.4458 1.7052 1.8199 2.2065 2.5552 2.8824 2.9252
but it didn't satisfiy the constraint '' J*(x(3)-x(2)+x(1)-x(4)+x(5)-x(6)+x(7)-x(8)+x(9))-1 '')
and it showed that :
'' Converged to an infeasible point.
fmincon stopped because the size of the current step is less than
the default value of the step size tolerance but constraints are not
satisfied to within the default value of the constraint tolerance. ''
Does anyone know how to solve this problem ? This is the first time I use optimal function.
Thanks.
Ray.
댓글 수: 1
Matt J
2019년 10월 3일
Note that these constraints are in fact linear and should not be in your nonlcon function.
J*(x(3)-x(2)+x(1)-x(4)+x(5)-x(6)+x(7)-x(8)+x(9))-1=0
x(1)-x(2)+x(3)-x(4)+x(5)-x(6)+x(7)-x(8)+x(9)<=0
답변 (2개)
Matt J
2019년 10월 3일
편집: Matt J
2019년 10월 3일
It seems highly likely that your problem is over-constrained. With 9 equality constraints and 9 unknowns, you may have enough equations to solve for the unknown uniquely. Who knows if that unique point will also satisfy the remaining inequality constraints in your problem.
댓글 수: 0
Alex Sha
2020년 3월 1일
one inequality constraint is: x(1)-x(2)+x(3)-x(4)+x(5)-x(6)+x(7)-x(8)+x(9)<=0 (1)
while one of equality constraint is: J*(x(3)-x(2)+x(1)-x(4)+x(5)-x(6)+x(7)-x(8)+x(9))-1=0
this same as: x(3)-x(2)+x(1)-x(4)+x(5)-x(6)+x(7)-x(8)+x(9)=1/J=1/2=0.5 (2)
note the left sides of (1) and (2) are exact same, so the inequality constraint and equality constraint are contradictory, therefor there is no solution.
댓글 수: 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!