local optimisation deterministic optimisation
조회 수: 3 (최근 30일)
이전 댓글 표시
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
Matt J
2020년 9월 23일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Function Creation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!