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:
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 件のコメント
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/483386-optimization-of-9-unknown-with-9-nonlinear-constraints-by-fmincom#comment_752333
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/483386-optimization-of-9-unknown-with-9-nonlinear-constraints-by-fmincom#comment_752333
サインインしてコメントする。