How to optimize an objective function with strict inequality constraints?

8 views (last 30 days)
ancy s george on 18 May 2022
Edited: Matt J on 29 May 2022
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)
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)
3 CommentsShow 1 older commentHide 1 older comment
James Tursa on 18 May 2022
Edited: James Tursa on 18 May 2022
@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.
ancy s george on 28 May 2022
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 on 29 May 2022
Edited: Matt J on 29 May 2022
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
ancy s george on 29 May 2022
Thank you sir for your great effort.

Walter Roberson on 28 May 2022
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.
Walter Roberson on 29 May 2022
Edited: Walter Roberson on 29 May 2022
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.
ancy s george on 29 May 2022
Ok sir,Thank you