# How to optimize an objective function with strict inequality constraints?

11 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)
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.
##### 2 CommentsShowHide 1 older comment
ancy s george on 29 May 2022
Ok sir,Thank you