@@ -183,9 +183,14 @@ and Vector{<:Link}.
183183 - [`check_time_structure`](@ref) to identify time profiles at the highest level that
184184 are not equivalent to the provided timestructure.
185185
186- In addition, all links are directly checked to have in the fields `:from` and `:to` nodes
187- that are present in the Node vector as extracted through the function [`get_nodes`](@ref)
188- and that these nodes have input (`:to`) or output (`:from`).
186+ In addition, all links are directly checked:
187+
188+ - The nodes in the fields `:from` and `:to` are present in the Node vector as extracted
189+ through the function [`get_nodes`](@ref).
190+ - The node in the field `:from` has output and the node in the field `:to` has input.
191+ - The [`inputs`](@ref) of the link are included in the [`outputs`](@ref) of the `:from`
192+ node and the [`outputs`](@ref) of the link are included in the [`inputs`](@ref) of the
193+ `:to` node.
189194"""
190195function check_elements (
191196 log_by_element,
@@ -237,19 +242,31 @@ function check_elements(
237242 " The node in the field `:from` is not included in the Node vector. As a consequence," *
238243 " the link would not be utilized in the model."
239244 )
245+ @assert_or_log (
246+ has_output (l. from),
247+ " The node in the field `:from` does not allow for outputs."
248+ )
249+ @assert_or_log (
250+ all (p_in ∈ outputs (l. from) for p_in ∈ inputs (l)),
251+ " Not all resources specifed as `inputs` of the link are specified as `outputs` " *
252+ " of the node in the field `:from`. As a consequence, the link could potentially " *
253+ " be not utilized in the model."
254+ )
240255 @assert_or_log (
241256 l. to ∈ 𝒩,
242257 " The node in the field `:to` is not included in the Node vector. As a consequence," *
243258 " the link would not be utilized in the model."
244259 )
245- @assert_or_log (
246- has_output (l. from),
247- " The node in the field `:from` does not allow for outputs."
248- )
249260 @assert_or_log (
250261 has_input (l. to),
251262 " The node in the field `:to` does not allow for inputs."
252263 )
264+ @assert_or_log (
265+ all (p_out ∈ inputs (l. to) for p_out ∈ outputs (l)),
266+ " Not all resources specifed as `outputs` of the link are specified as `inputs` " *
267+ " of the node in the field `:to`. As a consequence, the link could potentially " *
268+ " not be utilized in the model."
269+ )
253270
254271 # Check the links, the link data, and the time structure
255272 check_link (l, 𝒯, modeltype, check_timeprofiles)
@@ -985,17 +1002,29 @@ function check_node_data(
9851002end
9861003
9871004"""
988- check_link(n::Link, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)
1005+ check_link(l::Link, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)
1006+ check_link(l::Direct, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)
9891007
9901008Check that the fields of a [`Link`](@ref) corresponds to required structure. The default
9911009functionality does not check anthing, aside from the checks performed in [`check_elements`](@ref).
9921010
1011+ ## Checks `Direct`
1012+ - The functions [`inputs`](@ref) and [`outputs`](@ref) must be non-empty.
1013+
9931014!!! tip "Creating a new link type"
9941015 When developing a new link with new checks, it is important to create a new method for
9951016 `check_link`.
9961017"""
997- check_link (n:: Link , 𝒯, modeltype:: EnergyModel , check_timeprofiles:: Bool ) = nothing
1018+ check_link (l:: Link , 𝒯, modeltype:: EnergyModel , check_timeprofiles:: Bool ) = nothing
1019+ function check_link (l:: Direct , 𝒯, modeltype:: EnergyModel , check_timeprofiles:: Bool )
9981020
1021+ @assert_or_log (
1022+ ! isempty (link_res (l)),
1023+ " The functions `inputs` and `outputs` return an empty `Vector`. This implies that " *
1024+ " the nodes in the fields `:from` and `:to` do not have common `Resources` as " *
1025+ " `outputs` and `inputs`, respectively. Hence, the link will not be used."
1026+ )
1027+ end
9991028"""
10001029 check_link_data(l::Link, data::ExtensionData, 𝒯, modeltype::EnergyModel, check_timeprofiles::Bool)
10011030
0 commit comments