Monday, November 7, 2011

cost minimization matlab

http://www.cds.caltech.edu/~mtao/ACM11/Lecture4.m



function f = myfun(x)
c1=1.1*(510+7.2*abs(x(1))+0.00142*x(1)^2);
c2=1.4*(310+7.85*abs(x(2))+0.00194*x(2)^2);
c3=1.5*(78+7.97*abs(x(3))+0.00482*x(3)^2);
f = abs(c1)+abs(c2)+abs(c3);

x0=[600,400,200];  %initial guess
lb=[150,100,50]; %lower bound
ub=[600,400,200]; %upper bound
x = fmincon('myfun',x0,[],[],[1,1,1],[1000],lb,ub)
 %demand = p1+p2+p3=100mw, subject to lower, upper bound
x =  600.0000  339.2842   60.7158
>> y=myfun(x)
y = 1.1220e+004 %total cost

No comments:

Post a Comment