MATLAB: Linprog() with many constraints

constraintslinprogMATLABoptimiseoptimize

Hi,
I'm trying to optimise the energy mixture in a power system. I've the following problem:
____________________________________
prob = optimproblem('Objective',(Inv_w/LT_w*Pcap_w+Fix_w*(Pcap_w+18)+sum(Var_w*(Pcap_w+18)*Ppu_w)+ Inv_s/LT_s*Pcap_s+Fix_s*Pcap_s+sum(Var_s*Pcap_s*Ppu_s)+Inv_t/LT_t*Pcap_t+Fix_t*Pcap_t+sum(Var_t*Pcap_t*Ppu_t)),'ObjectiveSense','min');
____________________________________
The production has to meet the demand at any hour throughout the year. I know I can set one constraint for each hour manually, but I doubt this is the most efficient use of my time:
____________________________________
prob.Constraints.c1 = (Pcap_w+Kw)*Ppu_w(1)+Pcap_s*Ppu_s(1)+Pcap_t*Ppu_t(1) >= demand(1);
prob.Constraints.c2 = (Pcap_w+Kw)*Ppu_w(2)+Pcap_s*Ppu_s(2)+Pcap_t*Ppu_t(2) >= demand(2);
.
.
.
prob.Constraints.c8760 = (Pcap_w+Kw)*Ppu_w(8760)+Pcap_s*Ppu_s(8760)+Pcap_t*Ppu_t(8760) >= demand(8760);
____________________________________
Is there any way I can set the constraints for each hour throughout a loop or something?
Thanks on advance!

Best Answer

Did you try
constr = (Pcap_w+Kw)*Ppu_w + Pcap_s*Ppu_s + Pcap_t*Ppu_t >= demand;
prob.Constraints.constr = constr;
Alan Weiss
MATLAB mathematical toolbox documentation
Related Question