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
Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance. Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance. Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance. Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance. Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance. Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance. Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance. Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance. Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance. Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance. Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance. Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance. Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance. Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance. Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance. Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance. Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance. Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance. Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance. Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance. Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance. Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance. Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance. Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance. Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance.
disp(x)
3.0000 8.0000
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
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.
ancy s george
ancy s george 2022년 5월 28일
Ok sir,my constraints is 3<=x(1) and x(2)<=8.
Sir,my doubt is ,Is there any possibility to get a solution in between this range?.That is is there any case,it is converges to other than 3 and 8.

댓글을 달려면 로그인하십시오.

채택된 답변

Matt J
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);
Local minimum possible. Constraints satisfied. fmincon stopped because the size of the current step is less than the value of the step size tolerance and constraints are satisfied to within the value of the constraint tolerance.
fval
fval = 4.2221e-04
Checking bounds on the original variables x1,x2 are strictly satisfied:
x1=3-log(z(1))
x1 = 36.9695
x2=8-exp(z(2))
x2 = 7.0606

추가 답변 (1개)

Walter Roberson
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
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Optimization에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by