Julia syntax for calculating a scenario

To calculate a scenario with NEMO, use the calculatescenario function. The only required argument is dbpath; NEMO provides a default value for all other arguments.

NemoMod.calculatescenarioFunction
calculatescenario(dbpath::String; jumpmodel::JuMP.Model = Model(Cbc.Optimizer),
    calcyears::Array{Int, 1} = Array{Int, 1}(),
    varstosave::String = "vdemandnn, vnewcapacity, vtotalcapacityannual,
        vproductionbytechnologyannual, vproductionnn, vusebytechnologyannual,
        vusenn, vtotaldiscountedcost",
    restrictvars::Bool = true, reportzeros::Bool = false,
    continuoustransmission::Bool = false,
    forcemip::Bool = false, startvalsdbpath::String = "",
    startvalsvars::String = "", precalcresultspath::String = "",
    quiet::Bool = false
)

Calculates a scenario specified in a scenario database. Returns a MathOptInterface.TerminationStatusCode indicating the termination status reported by the solver used for the calculation (e.g., OPTIMAL::TerminationStatusCode = 1).

Arguments

  • dbpath::String: Path to the scenario database, which must be a SQLite version 3 database that implements NEMO's scenario database structure. See NEMO's documentation on scenario databases for details. Empty scenario databases can be generated with NEMO's createnemodb function.
  • jumpmodel::JuMP.Model: JuMP model object specifying the solver to be used for the calculation. Examples: Model(optimizer_with_attributes(GLPK.Optimizer, "presolve" => true)), Model(CPLEX.Optimizer), Model(optimizer_with_attributes(Gurobi.Optimizer, "NumericFocus" => 1)). Note that the solver's Julia package (Julia wrapper) must be installed. See the documentation for JuMP for information on how to specify a solver and set solver options.
  • calcyears::Array{Int, 1}: Years to include in the calculation (a subset of the years specified in the scenario database). All years in the database are included if this argument is omitted.
  • varstosave::String: Comma-delimited list of output variables whose results should be saved in the scenario database when the scenario is calculated. See NEMO's documentation on outputs for information on the variables that are available.
  • restrictvars::Bool: Indicates whether NEMO should conduct additional data analysis to limit the set of variables created in the optimization problem for the scenario. By default, to improve performance, NEMO selectively creates certain variables to avoid combinations of subscripts that do not exist in the scenario's data. This option increases the stringency of this filtering. It requires more processing time as the problem is built, but it can substantially reduce the solve time for large models.
  • reportzeros::Bool: Indicates whether results saved in the scenario database should include values equal to zero. Specifying false can substantially improve the performance of large models.
  • continuoustransmission::Bool: Indicates whether continuous (true) or binary (false) variables are used to represent investment decisions for candidate transmission lines. Not relevant in scenarios that do not model transmission.
  • forcemip::Bool: Forces NEMO to formulate the optimization problem for the scenario as a mixed-integer problem. This can improve performance with some solvers (e.g., CPLEX, Mosek). If this option is set to false, the input parameters for the scenario (i.e., in the scenario database) determine whether the optimization problem is mixed-integer.
  • startvalsdbpath::String: Path to a previously calculated scenario database from which NEMO should take starting values for variables in the optimization problem formulated in this function. This argument is used in conjunction with startvalsvars.
  • startvalsvars::String: Comma-delimited list of variables for which starting values should be set. See NEMO's documentation on outputs for information on the variables that are available. NEMO takes starting values from output variable results saved in the database identified by startvalsdbpath. Saved results are matched to variables in the optimization problem using the variables' subscripts, and starting values are set with JuMP's set_start_value function. If startvalsvars is an empty string, NEMO sets starting values for all variables present in both the optimization problem and the startvalsdbpath database.
  • precalcresultspath::String: Path to a previously calculated scenario database that NEMO should copy over the database specified by dbpath. This argument can also be a directory containing previously calculated scenario databases, in which case NEMO copies any file in the directory with the same name as the dbpath database. The intent of the argument is to short-circuit calculations in situations where valid results already exist.
  • quiet::Bool: Suppresses low-priority status messages (which are otherwise printed to STDOUT).
source

To access calculatescenario within Julia, you must first tell Julia you want to use NEMO. This is done with the using command.

julia> using NemoMod

julia> NemoMod.calculatescenario("c:/temp/scenario_db.sqlite")

If you want to provide a value for the jumpmodel argument, make sure to include JuMP and your solver's Julia package in the using command. For example:

julia> using NemoMod, JuMP, CPLEX

julia> NemoMod.calculatescenario("c:/temp/scenario_db.sqlite"; jumpmodel = Model(CPLEX.Optimizer), forcemip = true)