@@ 1151-1170 (lines=20) @@ | ||
1148 | ||
1149 | return self.minimum_rule |
|
1150 | ||
1151 | def _maximum_investment_constraint(self): |
|
1152 | """Constraint factory for a maximum investment""" |
|
1153 | m = self.parent_block() |
|
1154 | ||
1155 | def _max_invest_rule(_): |
|
1156 | """Rule definition for applying a minimum investment""" |
|
1157 | for i, o in self.NON_CONVEX_INVESTFLOWS: |
|
1158 | for p in m.PERIODS: |
|
1159 | expr = self.invest[i, o, p] <= ( |
|
1160 | m.flows[i, o].investment.maximum[p] |
|
1161 | * self.invest_status[i, o, p] |
|
1162 | ) |
|
1163 | self.maximum_rule.add((i, o, p), expr) |
|
1164 | ||
1165 | self.maximum_rule = Constraint( |
|
1166 | self.NON_CONVEX_INVESTFLOWS, m.PERIODS, noruleinit=True |
|
1167 | ) |
|
1168 | self.maximum_rule_build = BuildAction(rule=_max_invest_rule) |
|
1169 | ||
1170 | return self.maximum_rule |
|
1171 |
@@ 360-383 (lines=24) @@ | ||
357 | ||
358 | return self.minimum_investment |
|
359 | ||
360 | def _maximum_invest_constraint(self): |
|
361 | r""" |
|
362 | .. math:: |
|
363 | P_{invest} \le P_{invest, max} \cdot Y_{invest, status} |
|
364 | """ |
|
365 | m = self.parent_block() |
|
366 | ||
367 | def _max_invest_rule(_): |
|
368 | """Rule definition for applying a minimum investment""" |
|
369 | for i, o in self.OFFSET_INVEST_NON_CONVEX_FLOWS: |
|
370 | for p in m.PERIODS: |
|
371 | expr = ( |
|
372 | self.invest[i, o, p] |
|
373 | <= m.flows[i, o].investment.maximum[p] |
|
374 | * self.invest_status[i, o, p] |
|
375 | ) |
|
376 | self.maximum_investment.add((i, o, p), expr) |
|
377 | ||
378 | self.maximum_investment = Constraint( |
|
379 | self.INVEST_NON_CONVEX_FLOWS, m.PERIODS, noruleinit=True |
|
380 | ) |
|
381 | self.maximum_rule_build = BuildAction(rule=_max_invest_rule) |
|
382 | ||
383 | return self.maximum_investment |
|
384 |