Skip to content
This repository has been archived by the owner on Apr 19, 2020. It is now read-only.

Commit

Permalink
Merge 3468eef into dfd6e5e
Browse files Browse the repository at this point in the history
  • Loading branch information
Gord Stephen committed Aug 23, 2019
2 parents dfd6e5e + 3468eef commit 5a25b18
Show file tree
Hide file tree
Showing 55 changed files with 1,054 additions and 1,440 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ResourceAdequacy"
uuid = "f1bff6d7-bd5f-4f25-88ac-02781f2d51b7"
authors = ["Gord Stephen <gord.stephen@nrel.gov>"]
version = "0.4.3"
version = "0.5.0"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
4 changes: 0 additions & 4 deletions src/ResourceAdequacy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ export
LOLP, LOLE, EUE, ExpectedInterfaceFlow, ExpectedInterfaceUtilization,
val, stderror,

# Distribution extraction specifications
Backcast, REPRA,

# Simulation specifications
NonSequentialCopperplate, SequentialCopperplate,
NonSequentialNetworkFlow, SequentialNetworkFlow,
Expand All @@ -49,7 +46,6 @@ include("simulations/sequentialutils.jl")

# Spec instances
spec_instances = [
("extraction", ["backcast", "repra"]),
("simulation", ["nonsequentialcopperplate", "sequentialcopperplate",
"nonsequentialnetworkflow", "sequentialnetworkflow"]),
("result", ["minimal", "temporal", "spatial", "spatiotemporal", "network"])
Expand Down
21 changes: 0 additions & 21 deletions src/abstractspecs/abstractspecs.jl
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
# Extraction

"""
An abstract parent type for specifying specific methods for extracting VG/load
probability distributions from time series inputs. When defining a new type
`S where {S <: ExtractionSpec}`, you must define methods for the following functions
/ constructors:
- SystemStateDistribution (for nonsequential simulations)
- #TODO: Something for sequential simulations
Check the documentation for each function for required type signatures.
"""
abstract type ExtractionSpec end


# Simulation

abstract type SimulationSequentiality end
Expand Down Expand Up @@ -70,9 +54,7 @@ You must also define the following allied types and their associated methods:
"""
abstract type ResultAccumulator{
V <: Real, # Type of accumulated values
S <: SystemModel, # Type of simulated system
ES <: ExtractionSpec, # Extraction method used in simulation
SS <: SimulationSpec # Simulation being used
} end

Expand All @@ -98,12 +80,9 @@ abstract type Result{
N, # Number of timesteps simulated
L, # Length of each simulation timestep
T <: Period, # Units of each simulation timestep
V <: Real, # Numeric type of value data
ES <: ExtractionSpec, # Prob. distr. extraction method for input time series
SS <: SimulationSpec # Type of simulation that produced the result
} end

# Load abstract methods
include("extraction.jl")
include("simulation.jl")
include("result.jl")
153 changes: 0 additions & 153 deletions src/abstractspecs/extraction.jl

This file was deleted.

9 changes: 4 additions & 5 deletions src/abstractspecs/result.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ end

"""
accumulator(::ExtractionSpec, ::SimulationSpec, ::ResultSpec,
::SystemModel, seed::UInt)::ResultAccumulator
accumulator(::SimulationSpec, ::ResultSpec, ::SystemModel,
seed::UInt)::ResultAccumulator
Returns a `ResultAccumulator` corresponding to the provided `ResultSpec`.
"""
accumulator(::ExtractionSpec, ::SimulationSpec, ::S,
::SystemModel{N,L,T,P,E,V}, seed::UInt
accumulator(::SimulationSpec, ::S, ::SystemModel{N,L,T,P,E}, seed::UInt
) where {N,L,T,P,E,V,S<:ResultSpec} =
error("An `accumulator` method has not been defined for ResultSpec $T")

Expand Down Expand Up @@ -84,7 +83,7 @@ update!(::R, ::SystemOutputStateSummary, t::Int) where {R <: ResultAccumulator}

"""
finalize(::ExtractionSpec, ::SimulationSpec, ::ResultAccumulator)::Result
finalize(::SimulationSpec, ::ResultAccumulator)::Result
Returns a `Result` corresponding to the provided `ResultAccumulator`.
"""
Expand Down
28 changes: 12 additions & 16 deletions src/abstractspecs/simulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ iscopperplate(::S) where {S <: SimulationSpec} =

"""
assess!(::ResultAccumulator, ::ExtractionSpec,
::SimulationSpec, ::SystemModel)
assess!(::ResultAccumulator, ::SimulationSpec, ::SystemModel)
Run a full simulation of `SystemModel` according to `ExtractionSpec` and
Run a full simulation of `SystemModel` according to
`SimulationSpec`, storing the results in `ResultAccumulator`.
"""
assess!(::ResultAccumulator, ::ExtractionSpec, ::S, ::SystemModel
assess!(::ResultAccumulator, ::S, ::SystemModel
) where {S <: SimulationSpec} =
error("assess! not yet defined for SimulationSpec $S")

Expand All @@ -34,37 +33,34 @@ assess!(::ResultAccumulator, ::S, ::SystemInputStateDistribution, t::Int
) where {S <: SimulationSpec} =
error("assess! not yet defined for SimulationSpec $S")

function assess(extractionspec::ExtractionSpec,
simulationspec::SimulationSpec{NonSequential},
function assess(simulationspec::SimulationSpec{NonSequential},
resultspec::ResultSpec,
system::SystemModel,
seed::UInt=rand(UInt))
system::SystemModel{N},
seed::UInt=rand(UInt)) where {N}

acc = accumulator(extractionspec, simulationspec, resultspec, system, seed)
acc = accumulator(simulationspec, resultspec, system, seed)

#TODO: If storage devices exist, warn that they may be ignored or
# treated as firm capacity - need to decide how exactly that
# should work first though...

statedistrs = extract(extractionspec, system, iscopperplate(simulationspec))
Threads.@threads for (t, statedistr) in collect(enumerate(statedistrs))
assess!(acc, simulationspec, statedistr, t)
Threads.@threads for t in 1:N
assess!(acc, simulationspec, system, t)
end

return finalize(acc)

end

function assess(extractionspec::ExtractionSpec,
simulationspec::SimulationSpec{Sequential},
function assess(simulationspec::SimulationSpec{Sequential},
resultspec::ResultSpec,
system::SystemModel,
seed::UInt=rand(UInt))

acc = accumulator(extractionspec, simulationspec, resultspec, system, seed)
acc = accumulator(simulationspec, resultspec, system, seed)

Threads.@threads for i in 1:simulationspec.nsamples
assess!(acc, extractionspec, simulationspec, system, i)
assess!(acc, simulationspec, system, i)
end

return finalize(acc)
Expand Down
29 changes: 0 additions & 29 deletions src/extractions/backcast.jl

This file was deleted.

0 comments on commit 5a25b18

Please sign in to comment.