-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: piecewise constraints #569
Changes from 13 commits
e052989
f8c0870
ab3f55b
4e5e644
d7e83ac
d90da69
d176dfe
fd091e4
ba70e5b
2199240
ec05159
b912279
d8946ac
881cb89
22559b0
b2ba3a6
1f9c8b1
53e7d44
e1b17b6
52043a9
1c596e1
5b6202e
3bb0535
9405c35
c0f8993
4188d06
4c7e198
d276c63
33f1f2d
ff81669
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# title: Piecewise linear costs - economies of scale | ||
# | ||
# description: | | ||
# Add a piecewise cost function that reduces the incremental increase in investment costs with increasing technology rated capacity. | ||
# This emulates "economies of scale", where the more of a technology there is deployed, the less expensive each additional investment in deployment. | ||
# | ||
# New indexed parameters: | ||
# | ||
# - `piecewise_cost_investment_x` (defining the new set `breakpoints`) | ||
# - `piecewise_cost_investment_y` (defining the new set `breakpoints`) | ||
# | ||
# --- | ||
|
||
variables: | ||
piecewise_cost_investment: | ||
description: Investment cost that increases monotonically | ||
foreach: [nodes, techs, carriers, costs] | ||
where: any(piecewise_cost_investment_x, over=breakpoints) AND any(piecewise_cost_investment_y, over=breakpoints) | ||
bounds: | ||
min: 0 | ||
max: .inf | ||
|
||
piecewise_constraints: | ||
sos2_piecewise_costs: | ||
description: > | ||
Set investment costs values along a piecewise curve using special ordered sets of type 2 (SOS2). | ||
brynpickering marked this conversation as resolved.
Show resolved
Hide resolved
|
||
foreach: [nodes, techs, carriers, costs] | ||
where: any(piecewise_cost_investment_x, over=breakpoints) AND any(piecewise_cost_investment_y, over=breakpoints) | ||
x_expression: flow_cap | ||
x_values: piecewise_cost_investment_x | ||
y_expression: piecewise_cost_investment | ||
y_values: piecewise_cost_investment_y |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -736,15 +736,12 @@ def as_math_string(self) -> str: | |
evaluated = self.as_array() | ||
self.eval_attrs["references"].add(self.name) | ||
|
||
if evaluated.shape: | ||
dims = rf"_\text{{{','.join(str(i).removesuffix('s') for i in evaluated.dims)}}}" | ||
if evaluated.attrs["obj_type"] != "string": | ||
data_var_string = evaluated.attrs["math_repr"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the yaml attribute above: this seems like it's only used by the Not something to fix in this PR, but is this desired? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the math representation? I guess it is only of use to the LaTeX backend. Definitely something to clean up at some point There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct! |
||
else: | ||
dims = "" | ||
if evaluated.attrs["obj_type"] in ["global_expressions", "variables"]: | ||
formatted_name = rf"\textbf{{{self.name}}}" | ||
elif evaluated.attrs["obj_type"] == "parameters": | ||
formatted_name = rf"\textit{{{self.name}}}" | ||
return formatted_name + dims | ||
data_var_string = rf"\text{{{self.name}}}" | ||
|
||
return data_var_string | ||
|
||
def as_array(self) -> xr.DataArray: | ||
backend_interface = self.eval_attrs["backend_interface"] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice-to-have: not sure if this belongs here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we need a quick intro to everything you can do in Calliope v0.7, which we don't have at the moment. Hence why some new functionality is described in
migrating.md
, as it's where existing users are most likely to go first. I'll leave it in until we have this intro page that @sjpfenninger might be putting together.