MATLAB Answers


linprog() with many constraints

Helma Maria Tróndheim さんによって質問されました 2019 年 1 月 21 日
最新アクティビティ Helma Maria Tróndheim さんによって コメントされました 2019 年 1 月 22 日
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!

  0 件のコメント

サインイン to comment.




1 件の回答

Alan Weiss
回答者: Alan Weiss
2019 年 1 月 21 日

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

  1 件のコメント

Helma Maria Tróndheim 2019 年 1 月 22 日
Thank you! That solved my problem :)

サインイン to comment.

Translated by