Examples

To use REopt you will need to have a solver installed. REopt.jl has been tested with Xpress, Cbc, and CPLEX solvers, but it should work with other Linear Progam solvers (for PV and Storage scenarios) or Mixed Integer Linear Program solvers (for scenarios with outages and/or Generators).

Basic

A REopt optimization can be run with three lines:

using REopt, JuMP, Cbc

m = Model(Cbc.Optimizer)
results = run_reopt(m, "test/scenarios/pv_storage.json")

The scenario.json contains a Dict of inputs. For more on the scenario.json see the REopt Inputs section and find examples at test/scenarios. For more examples of how to run REopt, see test_with_cplex.jl and test_with_xpress.jl

To compare the optimized case to a "Business-as-usual" case (with existing techs or no techs), you can run the BAUScenario scenario in parallel by providing two JuMP.Models like so:

m1 = Model(Cbc.Optimizer)
m2 = Model(Cbc.Optimizer)
results = run_reopt([m1,m2], "./scenarios/pv_storage.json")

When the BAUScenario is included as shown above, the outputs will include comparative results such as the net present value and emissions reductions of the optimal system as compared to the BAU Scenario.

BAU Scenario

Note that while two JuMP models are needed to run the BAU and optimized cases in parallel, only a single input dict is used. The BAUScenario will be automatically created based on the input dict.

Advanced

Modifying the mathematical model

Using the build_reopt! method and JuMP methods one can modify the REopt model before optimizing. In the following example we add a cost for curtailed PV power.

using Xpress
using JuMP
using REopt

m = JuMP.Model(Xpress.Optimizer)

p = REoptInputs("scenarios/pv_storage.json");

build_reopt!(m, p)

#= 
replace the original objective, which is to Min the Costs,
with the Costs + 100 * (total curtailed PV power)
=#  
JuMP.@objective(m, Min, m[:Costs] + 100 * sum(m[:dvCurtail]["PV", ts] for ts in p.time_steps));

JuMP.optimize!(m)  # normally this command is called in run_reopt

results = reopt_results(m, p)

One can also add variables and constraints to the model before optimizing using the JuMP commands.

Note

The JuMP. prefixes are not necessary. We include them in the example to show which commands come from JuMP.