How to optimize an objective function with strict inequality constraints?
14 ビュー (過去 30 日間)
古いコメントを表示
Objective function =x(2)*(-10)-x(1)*70+240
subjected to : 3<=x(1) ; x(2)<=8
I try to optimize this objective function using penality function method.
x0=[0;0];
c(1)=50; % penality parameter
for k=1:1:25
f=@(x)(x(2)*(-10)-(x(1))*70+240+(c(k).*((3-x(1))^2+(x(2)-8)^2))); % converting constrained problem into unconstarined
[x,fval]=fminunc(f,x0);
c(k+1)=1.5*c(k); % penality parameter updation
k=k+1;
end
disp(x)
By using this penality function method,solution obtained is 3 & 8, it is boundary values.(I also used fmincon tool and KKT condtion, but got values as like this)
But I need a solution of 3<x(1)<x(2)<8 (ie ,values between 3 &8)
Is there any other method to solve this problem?Please help me to solve this problem
3 件のコメント
James Tursa
2022 年 5 月 18 日
編集済み: James Tursa
2022 年 5 月 18 日
@ancy s george Please clarify your inequalities because you have stated two different things:
3<=x(1) and x(2)<=8
3 < x(1) < x(2) < 8
Which is it?
Also, you cannot have strict "less than" or "greater than" in optimization problems like this in any practical way. If the optimum occurs at the boundary (e.g., x(1) = 3) are you going to insist you want the number "next to 3" since exactly 3 is not allowed? On a truly continuous number line there is no number next to 3 of course, so this has no practical meaning. And using something like 3+eps(3) for computing purposes may or may not have a practical use in your particular application.
Please clarify.
採用された回答
Matt J
2022 年 5 月 29 日
編集済み: Matt J
2022 年 5 月 29 日
The original problem with the unnecessary 240 term dropped is,
Objective function =-70*x1-10*x2
subjected to : 3<=x(1) ; x(2)<=8
Making a change of variables,
y1=x1-3, y2=8-x2
and also applying the monotonic transform to the objective function and the problem becomes
Objective function =atan(-70*y1 + 10*y2)+pi/2
subjected to : y1,y2>=0
Make yet another change of variables,
y1=-log(z1)
y2=exp(z2)
and the problem becomes
Objective function =atan(-70*log(z1) + 10*exp(z2)) +pi/2
subjected to : 0<=z1<=1
We can minimize this with fmincon:
fun=@(z) atan(70*log(z(1))+10*exp(z(2)))+pi/2;
opts=optimoptions('fmincon','StepTolerance',1e-16,'OptimalityTolerance',1e-16,...
'FunctionTolerance', 1e-16,'MaxIterations',1e5,'MaxFunEvals',1e10);
[z,fval,exitflag,output]=fmincon(fun,[0.5,0],[],[],[],[],[0,-inf],[1,inf],[],opts);
fval
Checking bounds on the original variables x1,x2 are strictly satisfied:
x1=3-log(z(1))
x2=8-exp(z(2))
その他の回答 (1 件)
Walter Roberson
2022 年 5 月 28 日
x(2)*(-10)-x(1)*70+24
That is a linear function. The derivative with respect to either variable can be taken easily and will be -70 with respect to x1 or -10 with respect to x(2). The optimal value will therefore occur either at one of the infinities or at the bounds.
If x(1) is +inf and x(2) is finite then the objective is -inf. That combination is permitted by the boundary conditions, which give a lower bound on x(1) and an upper bound on x(2).
You penalized incorrectly with a quadratic penalty on a linear function, which overwhelmed the function itself.
2 件のコメント
Walter Roberson
2022 年 5 月 29 日
編集済み: Walter Roberson
2022 年 5 月 29 日
f = -10*x2 - 70*x1 + 24
df/x2 = -10
solve(df/x2, x2) = solve(-10,x2) = empty
There are no critical points. Therefore the most important minimum with respect to x2 is at the maximum permitted x2 which is +8 minus epsilon
By similar logic there are no critical points for x1 and the minimum is at the maximum permitted x1 which is +inf. If you constrain x1 to also be < 8 then it would be +8 minus epsilon
Let us consider (3,8)which is the solution your code produces. -10*8 - 70*3 + 24 = -80 - 210 + 24
Compare to (8,8) which gives -10*8 - 70*8 + 24 = -80 - 560 + 24 which is clearly lower.
Your penalty is not properly constructed.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!