variables = {'as','aw','ah'};N = length(variables);%create variables for indexing
for v = 1:Neval([variables{v},' = ', num2str(v),';']);end%Defining the lower bounds
lb = zeros(size(variables));lb([as,aw,ah]) = [0,0,0];%Defining the upper bounds
ub = Inf(size(variables));ub([as,aw,ah]) = [Ns,Nw,Nh];%Entrying linear inequality constraints
A = zeros(2,3);A(1,[as,aw,ah]) = [-Ps(i),-Pw(i),-Ph(i)];b(1) = -P_load(i);A(2,[as,aw,ah]) = [Ps(i),Pw(i),Ph(i)];b(2) = P_max;%Linear Equality Constraints
Aeq=[];beq=[];%Objective Function
f = zeros(size(variables));f([as aw ah]) = [Cus*Ps(i)*T Cuw*Pw(i)*T Cuh*Ph(i)*T];%Solving the problem with linprog
[x fval] = linprog(f,A,b,Aeq,beq,lb,ub);for d = 1:Nfprintf('%12.2f \t%s\n',x(d),variables{d});end;aso(i)=x(1), awo(i)=x(2), aho(i)=x(3);P_Supply(i)=aso(i)*Ps(i)+awo(i)*Pw(i)+aho(i)*Ph(i);cost(i)=fval/P_Supply(i);
MATLAB: Please, I have limited time for a project. I’ll like to know what this code does
optimization
Best Answer