Skip to content

Commit

Permalink
Document time_slice
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelma committed Nov 30, 2023
1 parent 7ce23ac commit bdecc3f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/docs_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ using DataFrames
function write_sets_and_variables(mathpath)
variables = DataFrame(CSV.File(joinpath(mathpath, "variables.csv")))
variables.variable_name_latex = replace.(variables.variable_name, r"_" => "\\_")
variables.variable_name_latex .= "``v_{" .* variables.variable_name_latex .* "} ``"
variables.variable_name_latex .= "``v^{" .* variables.variable_name_latex .* "} ``"
variables.indices .= replace.(variables.indices, r"_" => "\\_")
variable_string = "# Variables \n"
for i in 1:size(variables, 1)
Expand Down
1 change: 1 addition & 0 deletions docs/src/library.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Depth = 3
run_spineopt
write_report_from_intermediate_results
generate_forced_availability_factor
time_slice
```

TODO
Expand Down
28 changes: 19 additions & 9 deletions src/data_structure/temporal_structure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,6 @@ struct TOverlapsT
overlapping_time_slices::Dict{TimeSlice,Array{TimeSlice,1}}
end

"""
(::TimeSliceSet)(;temporal_block=anything, t=anything)
An `Array` of time slices *in the model*.
# Keyword arguments
- `temporal_block`: only return time slices in this block.
- `t`: only return time slices in this collection.
"""
(h::TimeSliceSet)(; temporal_block=anything, t=anything) = h(temporal_block, t)
(h::TimeSliceSet)(::Anything, ::Anything) = h.time_slices
(h::TimeSliceSet)(temporal_block::Object, ::Anything) = h.block_time_slices[temporal_block]
Expand Down Expand Up @@ -562,15 +553,34 @@ function to_time_slice(m::Model; t::TimeSlice)
end

current_window(m::Model) = m.ext[:spineopt].temporal_structure[:current_window]

"""
time_slice(m; temporal_block=anything, t=anything)
An `Array` of `TimeSlice`s in model `m`.
# Keyword arguments
- `temporal_block`: only return time slices in this block or blocks.
- `t`: only return time slices from this collection.
"""
time_slice(m::Model; kwargs...) = m.ext[:spineopt].temporal_structure[:time_slice](; kwargs...)

history_time_slice(m::Model; kwargs...) = m.ext[:spineopt].temporal_structure[:history_time_slice](; kwargs...)

t_history_t(m::Model; t::TimeSlice) = get(m.ext[:spineopt].temporal_structure[:t_history_t], t, nothing)

t_before_t(m::Model; kwargs...) = m.ext[:spineopt].temporal_structure[:t_before_t](; kwargs...)

t_in_t(m::Model; kwargs...) = m.ext[:spineopt].temporal_structure[:t_in_t](; kwargs...)

t_in_t_excl(m::Model; kwargs...) = m.ext[:spineopt].temporal_structure[:t_in_t_excl](; kwargs...)

t_overlaps_t(m::Model; t::TimeSlice) = m.ext[:spineopt].temporal_structure[:t_overlaps_t](t)

t_overlaps_t_excl(m::Model; t::TimeSlice) = m.ext[:spineopt].temporal_structure[:t_overlaps_t_excl](t)

representative_time_slice(m, t) = get(m.ext[:spineopt].temporal_structure[:representative_time_slice], t, t)

function output_time_slices(m::Model; output::Object)
get(m.ext[:spineopt].temporal_structure[:output_time_slices], output, nothing)
end
Expand Down

0 comments on commit bdecc3f

Please sign in to comment.