Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Model Library
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FOCUS
Model Library
Commits
496162cd
Commit
496162cd
authored
1 month ago
by
Najet Nsir
Browse files
Options
Downloads
Patches
Plain Diff
add operation and capital cost variables for results
parent
780de187
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
component/core.py
+22
-1
22 additions, 1 deletion
component/core.py
with
22 additions
and
1 deletion
component/core.py
+
22
−
1
View file @
496162cd
...
...
@@ -252,7 +252,8 @@ class AbstractComponent:
if
self
.
capacity
is
None
:
return
[]
else
:
return
[(
self
.
name
+
"
.capacity
"
,
VariableKind
.
UNINDEXED
)]
return
[(
self
.
name
+
"
.capacity
"
,
VariableKind
.
UNINDEXED
),(
self
.
name
+
"
.capital_cost
"
,
VariableKind
.
UNINDEXED
)]
# TODO make these functions into generator functions
def
non_state_base_variable_names
(
self
):
...
...
@@ -264,6 +265,7 @@ class AbstractComponent:
def
add_design_variables
(
self
,
d_block
):
if
self
.
capacity
is
not
None
:
d_block
.
add
(
self
.
name
+
"
.capital_cost
"
,
pyo
.
Var
())
if
isinstance
(
self
.
capacity
,
tuple
):
d_block
.
add
(
self
.
name
+
"
.capacity
"
,
pyo
.
Var
(
bounds
=
self
.
capacity
))
elif
isinstance
(
self
.
capacity
,
(
int
,
float
)):
...
...
@@ -402,6 +404,13 @@ class AbstractComponent:
T_N
=
T
f_b
=
self
.
factor_effort_maintenance_operation
self_design_annuity
=
design_annuity
(
A_0
,
T
,
T_N
,
r
,
q
,
f_b
)
if
self
.
capacity
is
not
None
:
d_annuity
=
model
.
component_dict
[
self
.
name
+
"
.capital_cost
"
]
def
rule
(
m
):
return
d_annuity
==
self_design_annuity
model
.
add
(
self
.
name
+
"
.cost_design_annuity
"
,
pyo
.
Constraint
(
rule
=
rule
))
return
self_design_annuity
...
...
@@ -417,6 +426,15 @@ class AbstractComponent:
self_operational_annuity
=
0.0
else
:
self_operational_annuity
=
operational_annuity
(
T
,
r
,
q
,
A_V
)
model
.
add
(
self
.
name
+
"
.operation_cost
"
,
pyo
.
Var
())
o_annuity
=
model
.
component_dict
[
self
.
name
+
"
.operation_cost
"
]
def
rule
(
m
):
return
o_annuity
==
self_operational_annuity
/
pyo
.
quicksum
(
model
.
step_size
(
t
)
for
t
in
model
.
T
)
*
365
*
24
model
.
add
(
self
.
name
+
"
.cost_operation_annuity
"
,
pyo
.
Constraint
(
rule
=
rule
))
return
self_operational_annuity
...
...
@@ -758,6 +776,7 @@ class BaseGrid(AbstractComponent):
return
[
(
self
.
name
+
"
.input_1
"
,
VariableKind
.
INDEXED
),
(
self
.
name
+
"
.output_1
"
,
VariableKind
.
INDEXED
),
(
self
.
name
+
"
.operation_cost
"
,
VariableKind
.
UNINDEXED
),
]
def
add_non_state_variables
(
self
,
o_block
):
...
...
@@ -767,6 +786,8 @@ class BaseGrid(AbstractComponent):
output
=
pyo
.
Var
(
o_block
.
T
,
bounds
=
(
0
,
None
))
o_block
.
add
(
self
.
name
+
"
.output_1
"
,
output
)
def
add_non_state_model
(
self
,
d_block
,
o_block
):
input
=
o_block
.
component_dict
[
self
.
name
+
"
.input_1
"
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment