Skip to content

Commit

Permalink
Use graph functions to find in and out neighbors (#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
abelsiqueira committed Dec 4, 2023
1 parent 74a2ab9 commit 7ec74c1
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,36 +120,36 @@ function create_model(
model,
incoming_flow[a A, rp RP, B P[(a, rp)]],
sum(
duration(B, B_flow, rp) * flow[(u, v), rp, B_flow] for
(u, v) in F, B_flow graph[u, v].partitions[rp] if
v == a && B_flow[end] B[1] && B[end] B_flow[1]
duration(B, B_flow, rp) * flow[(u, a), rp, B_flow] for
u in inneighbor_labels(graph, a), B_flow graph[u, a].partitions[rp] if
B_flow[end] B[1] && B[end] B_flow[1]
)
)
@expression(
model,
outgoing_flow[a A, rp RP, B P[(a, rp)]],
sum(
duration(B, B_flow, rp) * flow[(u, v), rp, B_flow] for
(u, v) in F, B_flow graph[u, v].partitions[rp] if
u == a && B_flow[end] B[1] && B[end] B_flow[1]
duration(B, B_flow, rp) * flow[(a, v), rp, B_flow] for
v in outneighbor_labels(graph, a), B_flow graph[a, v].partitions[rp] if
B_flow[end] B[1] && B[end] B_flow[1]
)
)
@expression(
model,
incoming_flow_w_efficiency[a A, rp RP, B P[(a, rp)]],
sum(
duration(B, B_flow, rp) * flow[(u, v), rp, B_flow] * graph[u, v].efficiency for
(u, v) in F, B_flow graph[u, v].partitions[rp] if
v == a && B_flow[end] B[1] && B[end] B_flow[1]
duration(B, B_flow, rp) * flow[(u, a), rp, B_flow] * graph[u, a].efficiency for
u in inneighbor_labels(graph, a), B_flow graph[u, a].partitions[rp] if
B_flow[end] B[1] && B[end] B_flow[1]
)
)
@expression(
model,
outgoing_flow_w_efficiency[a A, rp RP, B P[(a, rp)]],
sum(
duration(B, B_flow, rp) * flow[(u, v), rp, B_flow] / graph[u, v].efficiency for
(u, v) in F, B_flow graph[u, v].partitions[rp] if
u == a && B_flow[end] B[1] && B[end] B_flow[1]
duration(B, B_flow, rp) * flow[(a, v), rp, B_flow] / graph[a, v].efficiency for
v in outneighbor_labels(graph, a), B_flow graph[a, v].partitions[rp] if
B_flow[end] B[1] && B[end] B_flow[1]
)
)

Expand Down Expand Up @@ -226,14 +226,14 @@ function create_model(
model,
upper_bound_asset[
a A,
(u, v) F,
v outneighbor_labels(graph, a),
rp RP,
B P[(a, rp)];
!(a Ah Ac) && u == a && (u, v) Ft,
!(a Ah Ac) && (a, v) Ft,
],
sum(
duration(B, B_flow, rp) * flow[(u, v), rp, B_flow] for
B_flow graph[u, v].partitions[rp] if B_flow[end] B[1] && B[end] B_flow[1]
duration(B, B_flow, rp) * flow[(a, v), rp, B_flow] for
B_flow graph[a, v].partitions[rp] if B_flow[end] B[1] && B[end] B_flow[1]
) assets_profile_times_capacity[a, rp, B]
)

Expand Down

0 comments on commit 7ec74c1

Please sign in to comment.