local optimisation deterministic optimisation

Hello
I need to get a deterministic optimisation for an equation from text :
f= x(1)* x(2)
bounded by
10 <= x(1)<=100
5<=x(2)<=20
there is a constraints which is
((Th=q=17;
Tc=325;
K=100; are given constant ))
Th = Tc+q*x(2)/K*x(1)
Th<= 345;
The code is :
% ObjectiveFunction = @simple_fitness;
fun = @objfun;
A = [];
b = [];
Aeq = [];
beq = [];
lb = [10 5]; % Lower bound
ub = [100 20]; % Upper bound
% lb=[]
% ub=[]
nvars = 2; % Number of variables
% ConstraintFunction = @t;
% [x,fval] = ga(ObjectiveFunction,nvars,[],[],[],[],LB,UB, ...
% ConstraintFunction);
x0 = [10 20];
[x,fval] = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,@confun);
% [x,fval] =ga(fun,4,A,b,Aeq,beq,lb,ub,@confun);
% display (fval)
%%%%%%%%%%%%%%%%%%%%%%%%
%%% objective function %%%%%%%%%%%
function f = objfun(x)
f = x(1)*x(2);
end
%%%%%%%%%Constraints%%%%%%
function [c,ceq] = confun(x)
% Nonlinear inequality constraints
q=17
Tc=325
K=100
% Th=Tc-q*x(2)/K*x(1);
c=(Tc-q*x(2)/K*x(1))-345;
% Nonlinear equality constraints
ceq = [];
end
%%%%%%%%%%%%%%%
I have got the results that min fvalue = 50 coresponding to this value x1=5 and x2=10
while the answer should be fvalue =212.5 and x1=42.5 ; x2=5.
would you help me to sor out this problem please.

6 Commenti

Matt J
Matt J il 22 Set 2020
Modificato: Matt J il 22 Set 2020
Because your x(1) and x(2) are bounded to strictly positive intervals, you can rewrite your nonlinear constraint as a linear constraint,
(Tc-345)*x(1)+(q/K)*x(2)<=0
which will improve the efficiency and reliability of the optimization
[x,fval] = fmincon(fun,x0,[Tc-345,+q/K],0,Aeq,beq,lb,ub)
While it doesn't seem to affect the solution in this case, you should be aware that the sign on "q" is different where you wrote your constraint here,
Th = Tc+q*x(2)/K*x(1)
Th<= 345;
as compared to where you wrote it in your code
c=(Tc-q*x(2)/K*x(1))-345;
Thank you for your reply
The condition exactly is Th should be less than 345 (Th<345)
and Th can be found from ( Th=Tc+q*x(2)/(k*x(1)))
so the paper results is more accurate than my results if we comapre : Th
his results were : x(2)=5 ; x(1) =42.5 this is results in Th = 325 + ((17*5)/(100*42.5)) = 325.02
while my results : x(2) = 5 ; x(1) =10 this is results in Th =325 + (( 17*5/100*10))= 325.85
so i think there is more than one points for minimisation we need to look for the local minimum optimum point .
Regards
Hazim
Matt J
Matt J il 22 Set 2020
Modificato: Matt J il 22 Set 2020
I don't see what your comparison of Th is supposed to show. Both versions of x satisfy Th<345 and that's all fmincon is responsible for ensuring.
Yes i agree with you ; if i want to use loop and compute the Th based on x1 and x2 obtained from optimsation results for example if can i let the program to compare Th and change the x0 to be x1 and x2 corresponding to minmum f and the loop should compare the Th .
Regards
Hazim
Hazim Hamad's comment moved here:
I think the problem with constraints because when I make change on the constraints the solution not affaected.
Regards
Hazim

Accedi per commentare.

Risposte (1)

Matt J
Matt J il 22 Set 2020
Modificato: Matt J il 22 Set 2020
fvalue = 50 is clearly a better (i.e. lower) objective value than 212.5, so there is every reason to believe that x1=42.5 x2=5 is not the solution.

3 Commenti

I wonder if they are intended to find a maxima instead of minima ?
it is minmum but the Th should be less the 345 and because the Th obtained from his results is 325.02 and my results Th is 325.85 so his results is bettter .
thanks
Matt J
Matt J il 22 Set 2020
Modificato: Matt J il 22 Set 2020
If one solution can be better than another based on Th, then it should be made part of the objective function somehow. There is nothing currently in the way the problem is set up to make the optimization prefer a specific value of Th.

Accedi per commentare.

Categorie

Prodotti

Release

R2020a

Richiesto:

il 22 Set 2020

Commentato:

il 23 Set 2020

Community Treasure Hunt

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

Start Hunting!

Translated by