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
1f64708b
Commit
1f64708b
authored
Jun 7, 2024
by
Christoph von Oy
Browse files
Options
Downloads
Patches
Plain Diff
Added capacity to connections
parent
5c6699a7
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
topology.py
+23
-2
23 additions, 2 deletions
topology.py
with
23 additions
and
2 deletions
topology.py
+
23
−
2
View file @
1f64708b
...
...
@@ -64,10 +64,11 @@ class Connector:
class
Connection
:
def
__init__
(
self
,
in_flows
,
out_flows
,
loss_factor
):
def
__init__
(
self
,
in_flows
,
out_flows
,
loss_factor
,
capacity
):
self
.
in_flows
=
in_flows
self
.
out_flows
=
out_flows
self
.
loss_factor
=
loss_factor
self
.
capacity
=
capacity
# def replace_flow(self, flow, replacement):
# if flow in self.in_flows:
...
...
@@ -173,7 +174,13 @@ class Topology:
loss_factor
=
connection
[
"
loss_factor
"
]
else
:
loss_factor
=
0.0
self
.
_connections
.
append
(
Connection
(
in_flows
,
out_flows
,
loss_factor
))
if
"
capacity
"
in
connection
:
capacity
=
connection
[
"
capacity
"
]
else
:
capacity
=
None
self
.
_connections
.
append
(
Connection
(
in_flows
,
out_flows
,
loss_factor
,
capacity
)
)
# self._removed_flows = dict()
...
...
@@ -418,6 +425,20 @@ class Topology:
o_block
.
add
(
str
(
i
)
+
"
_sum
"
,
pyo
.
Constraint
(
o_block
.
T
,
rule
=
rule
))
if
connection
.
capacity
is
not
None
:
capacity
=
connection
.
capacity
def
rule
(
m
,
t
):
return
(
pyo
.
quicksum
(
o_block
.
component_dict
[
in_flow
][
t
]
for
in_flow
in
connection
.
in_flows
)
<=
capacity
)
o_block
.
add
(
str
(
i
)
+
"
_capacity
"
,
pyo
.
Constraint
(
o_block
.
T
,
rule
=
rule
))
for
logic_name
,
logic
in
self
.
_additional_model_logic
.
items
():
if
logic
[
"
type
"
]
==
"
ConnectorEnable
"
:
enable
=
logic
[
"
enable
"
]
...
...
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