RDMREopt.jl

Documentation for RDMREopt.jl

Example

using RDMREopt
using Xpress
using Distributions

u1 = Uncertainty(
    name="Financial.elec_cost_escalation_pct",
    distribution=Uniform(-0.01, 0.03)    
)
u2 = Uncertainty(
    name="ElectricUtility.outage_start_time_steps",
    distribution=Uniform(1, 8000),
    is_integer=true,
    is_vector=true  # passes one time step to each REopt model
)
u3 = Uncertainty(
    name="PV.size_kw",
    distribution=Normal(500, 50)    
)
u4 = Uncertainty(
    "ElectricLoad.loads_kw",
    [
        ones(8760) .* 8.0,
        ones(8760) .* 9.0,
        ones(8760) .* 10.0,
    ]
)
uncertainties = [u1, u2, u3, u4]

metrics = [
    "Financial.lcc",
    "PV.lcoe_per_kwh"
    "probability_of_survival_10_time_steps"
]

scenarios = Scenarios(
    "base_scenario.json",
    uncertainties,
    metrics;
    Nscenarios=10,
    Nparallel=6
);

rs, outage_sim_results = RDMREopt.run_threaded_scenarios(scenarios, Xpress.Optimizer; remove_series=true);

df = dicts_to_dataframe(rs)
save_dataframe_as_csv(df, "results.csv")
save_opt_and_outage_sim_results_as_json("results.json", rs, outage_sim_results)

Inputs

Uncertainty

RDMREopt.UncertaintyType
Uncertainty(name::String, distribution::Distribution{Univariate, Continuous})

Keyword struct for defining input uncertainties.

  • The name argument can be any REeopt input
  • The distribution argument can be any of the type Distribution{Univariate, Continuous} from Distributions.jl.

Example

u1 = Uncertainty(
    name="Financial.elec_cost_escalation_pct",
    distribution=Uniform(-0.01, 0.03)    
)

Distribution types

You can view all of the possible distributions with:

subtypes(Distribution{Univariate, Continuous})

Custom sample sets

For the special case of ElectricLoad.loads_kw we allow one to provide a sample set of load profiles. The sample set is sampled uniformly. To use this capability define an Uncertainty as follows:

u4 = Uncertainty(
    "ElectricLoad.loads_kw",
    [
        ones(8760) .* 8.0,  # replace these vectors with your load profile samples
        ones(8760) .* 9.0,
        ones(8760) .* 10.0,
    ]
)
source

Scenarios

RDMREopt.ScenariosType
Scenarios(
    base_scenario::AbstractDict, 
    uncertainties::AbstractVector{Uncertainty},
    metrics::AbstractVector{String};
    Nscenarios::Int=100,
    Nparallel::Int=1,
    ngens::Int=100
)

Args

  • base_scenario::AbstractDict a Dict` that defines the base REopt Scenario (see REopt docs for more)
  • uncertainties::AbstractVector{Uncertainty} vector of Uncertaintys
  • metrics::AbstractVector{String} vector of output metrics (TODO use these for analysis tools)

Keyword Args

  • Nscenarios::Int number of scenarios to sample from Latin Hypercube
  • Nparallel::Int number of scenarios to run in parallel (when using Run Threaded Scenarios)
  • ngens::Int hyperparameter of LatinHypercubeSampling.LHCoptim, used to create Latin Hypercube of samples
source
Scenarios(
    fp::String, 
    uncertainties::AbstractVector{Uncertainty},
    metrics::AbstractVector{String};
    Nscenarios::Int=100,
    Nparallel::Int=1,
    ngens::Int=100
)

Args

  • fp::String path to a JSON file that defines the base REopt Scenario (see REopt docs for more)
  • uncertainties::AbstractVector{Uncertainty} vector of Uncertaintys
  • metrics::AbstractVector{String} vector of output metrics (TODO use these for analysis tools)

Keyword Args

  • Nscenarios::Int number of scenarios to sample from Latin Hypercube
  • Nparallel::Int number of scenarios to run in parallel (when using Run Threaded Scenarios)
  • ngens::Int hyperparameter of LatinHypercubeSampling.LHCoptim, used to create Latin Hypercube of samples
source

Running REopt Scenarios

Run Serial Scenarios

RDMREopt.run_serial_scenariosFunction
run_serial_scenarios(s::Scenarios, optimizer; remove_series=false)

Run the REopt scenarios one at a time in for loop and return a vector of dictionaries for results.

If remove_series is true then all time series results are removed from the dictionaries, which will keep memory use lower and make the results compatible with rectangular data stores.

source

Run Threaded Scenarios

RDMREopt.run_threaded_scenariosFunction
run_threaded_scenarios(s::Scenarios, optimizer; remove_series=false)

Run batches of REopt scenarios in parallel according to Scenarios.Nparallel and return a vector of dictionaries for results.

If remove_series is true then all time series results are removed from the dictionaries, which will keep memory use lower and make the results compatible with rectangular data stores.

source

Analyzing Results

RDMREopt.save_opt_and_outage_sim_results_as_jsonFunction
save_opt_and_outage_sim_results_as_json(file_name::String, results::Vector{<:Dict}, outage_sim_results::Vector{<:Dict})

Combine optimization and outage simulator results and save them to JSON using file_name.

source