Skip to content

Commit 0692c5c

Browse files
committed
Revert some unnecessary changes and fix doc output
* Revert changes for create_link * `total_duration` is added to SimpleTimes, and the docstring is updated to reflect this.
1 parent 11263a2 commit 0692c5c

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

docs/src/how-to/utilize-timestruct.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ op_number = length(op_duration)
3939
operational_periods = SimpleTimes(op_number, op_duration)
4040
4141
# output
42-
SimpleTimes{Int64}(11, [4, 2, 1, 1, 2, 4, 2, 1, 1, 2, 4])
42+
SimpleTimes{Int64}(11, [4, 2, 1, 1, 2, 4, 2, 1, 1, 2, 4], 24)
4343
```
4444

4545
In this case, we model the day not with hourly resolution, but only have hourly resolution in the morning and afternoon.
@@ -60,7 +60,7 @@ Instead, one can also write
6060
operational_periods = SimpleTimes(op_duration)
6161
6262
# output
63-
SimpleTimes{Int64}(11, [4, 2, 1, 1, 2, 4, 2, 1, 1, 2, 4])
63+
SimpleTimes{Int64}(11, [4, 2, 1, 1, 2, 4, 2, 1, 1, 2, 4], 24)
6464
```
6565

6666
and a constructor will automatically deduce that there have to be 11 operational periods.

src/model.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -646,13 +646,15 @@ function constraints_couple(m, 𝒩::Vector{<:Node}, ℒ::Vector{<:Link}, 𝒫,
646646
for n 𝒩
647647
ℒᶠʳᵒᵐ, ℒᵗᵒ = link_sub(ℒ, n)
648648

649+
# Constraint for output flowrate and input links.
649650
if has_output(n)
650651
@constraint(m, [t 𝒯, p outputs(n)],
651652
m[:flow_out][n, t, p] ==
652653
sum(m[:link_in][l, t, p] for l ℒᶠʳᵒᵐ if p inputs(l))
653654
)
654655
end
655656

657+
# Constraint for input flowrate and output links.
656658
if has_input(n)
657659
@constraint(m, [t 𝒯, p inputs(n)],
658660
m[:flow_in][n, t, p] ==
@@ -991,7 +993,7 @@ available node except if one wants to include as well transport between differen
991993
function create_node(m, n::Availability, 𝒯, 𝒫, modeltype::EnergyModel)
992994

993995
@constraint(m, [t 𝒯, p inputs(n)],
994-
m[:flow_in][n, t, p] == m[:flow_out][n, t, p]
996+
m[:flow_in][n, t, p] == m[:flow_out][n, t, p]
995997
)
996998
end
997999

@@ -1015,17 +1017,17 @@ function create_link(m, l::Link, 𝒯, 𝒫, modeltype::EnergyModel)
10151017
)
10161018
return create_link(m, 𝒯, 𝒫, l, modeltype, formulation(l))
10171019
end
1018-
function create_link(m, l::Direct, 𝒯, 𝒫::Vector{<:Resource}, modeltype::EnergyModel)
1020+
function create_link(m, l::Direct, 𝒯, 𝒫, modeltype::EnergyModel)
10191021

10201022
@constraint(m, [t 𝒯, p link_res(l)],
1021-
m[:link_out][l, t, p] == m[:link_in][l, t, p]
1023+
m[:link_out][l, t, p] == m[:link_in][l, t, p]
10221024
)
10231025
end
1024-
function create_link(m, l::Link, 𝒯, 𝒫::Vector{<:Resource}, modeltype::EnergyModel, formulation::Formulation)
1026+
function create_link(m, 𝒯, 𝒫, l::Link, modeltype::EnergyModel, formulation::Formulation)
10251027

10261028
# Generic link in which each output corresponds to the input
10271029
@constraint(m, [t 𝒯, p link_res(l)],
1028-
m[:link_out][l, t, p] == m[:link_in][l, t, p]
1030+
m[:link_out][l, t, p] == m[:link_in][l, t, p]
10291031
)
10301032

10311033
# Call of the function for limiting the capacity to the maximum installed capacity

0 commit comments

Comments
 (0)