# linprog() with many constraints

10 ビュー (過去 30 日間)
Helma Maria Tróndheim 2019 年 1 月 21 日
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?

#### 0 件のコメント

サインイン to comment.

### 採用された回答

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.

### その他の回答 (0 件)

サインイン してこの質問に回答します。

R2018b