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!

 採用された回答

Alan Weiss
Alan Weiss 2019 年 1 月 21 日

0 投票

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
Helma Maria Tróndheim 2019 年 1 月 22 日
Thank you! That solved my problem :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLinear Programming and Mixed-Integer Linear Programming についてさらに検索

製品

リリース

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by