facing problem in optimization using GA
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi all
i want the value of p(t),q(t) and a(t) and the value of t from 1 to 25 with minimizing a function z, code is given below,
function z=opt19(p,q,a)
M=100;
r=0.8;
alpha=0.45;
beta=0.75;
gama=0.1;
d=0.004;
h=0.4;
n=100;
nn=15;
x = zeros(nn,1);
a = zeros(nn,1);
p = zeros(nn,1);
c = zeros(nn,1);
q = zeros(nn,1);
lembda = zeros(nn,1);
delT=1;
x(1)=2;
c(1)=1580;
lembda(1)=150;
for t=1:nn-1
p(t)=c(t)+lembda(t)+1/d;
q(t)=exp(1/x(t)-1)*log10(c(t)/n);
c(t)=n*q(t)^x(t)-1;
a(t)=(p(t)-c(t)+lembda(t)*beta*(M-x(t))*exp(-d*p(t))*exp(h*q(t)));
z=((p(t)-1200+150)*(-0.004)*(0.45+0.75*log10(abs(a(t)))+0.1*2)*(100-2)*exp(-(.004)*p(t))*exp(.4*q(t))...
+(0.45+0.75*log10(abs(a(t)))+0.1*2)*(100-2)*exp(-(.004)*p(t))*exp(.4*q(t)))^(2)...
+((p(t)-1200+150)*0.4*(0.45+0.75*log10(abs(a(t)))+0.1*2)*(100-2)*exp(-(.004)*p(t))*exp(.4*q(t))...
+100*(2-1)*q(t)^(2-2)*(0.45+0.75*log10(abs(a(t)))+0.1*2)*(100-2)*exp(-(.004)*p(t))*exp(.4*q(t)))^(2)+...
((p(t)-1200+150)*0.75/a(t)*(100-2*exp(-(.004)*p(t))*exp(.4*q(t))-1))^(2);
x(t+delT)=x(t)+delT*(alpha+beta*log10(abs(a(t)))+gama*x(t))*(M-x(t))*exp(-d*p(t))*exp(h*q(t));
gx=exp(-d*p(t))*exp(h*q(t))*(gama*M-alpha-beta*log10(a(t))-2*gama*x(t));
cx=n*q(t)^(x(t)-1)*log10(q(t));
g=(alpha+beta*log10(a(t))+gama*x(t))*(M-x(t))*exp(-d*p(t))*exp(h*q(t));
lembda(t+delT)=lembda(t)+delT*(r*lembda(t)-gx*(p(t)-c(t)+lembda(t))+cx*g);
end
my problem is how to write objective function, i wrote the code please tell me how i will solve my problem please.
Thank you.
0 Kommentare
Antworten (1)
Alan Weiss
am 2 Jul. 2012
Your code accepts arguments p, q, and a, and then overwrites them with different values (zeros(nn,1)). So I am not sure what your optimization variables are.
In any case, fmincon wants a single variable. I don't know what your variables are, but suppose they are the p, q, and a variables. Then you would write an objective function file such as
function f = objfun(x)
p = x(1:13);
q = x(14:26);
a = x(27:end);
(...calculations using p, q, and a go here)
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
Siehe auch
Kategorien
Mehr zu Genetic Algorithm finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!