# 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",
numprocs::Int = 0, targetprocs::Array{Int, 1} = Array{Int, 1}(),
restrictvars::Bool = true, reportzeros::Bool = false, continuoustransmission::Bool = false,
forcemip::Bool = false, quiet::Bool = false
)

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

Arguments

• dbpath::String: Path to the scenario database (must be a SQLite version 3 database).
• jumpmodel::JuMP.Model: JuMP model object specifying the solver to be used. 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 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.
• numprocs::Int: Number of Julia processes to use for parallelized operations within this function. Ignored if targetprocs is specified. Should be a positive integer or 0 for half the number of logical processors on the executing machine (i.e., half of Sys.CPU_THREADS). When numprocs is in effect, NEMO selects processes for parallel operations from Distributed.procs(). Processes are taken in the order they appear in this array. If there are not enough processes defined in Distributed.procs(), NEMO adds processes on the local host as needed. Note that solvers may use a different number of parallel processes than NEMO depending on their design and parameters.
• targetprocs::Array{Int, 1}: Identifiers of Julia processes that should be used for parallelized operations within this function. Note that solvers may use a different number of parallel processes than NEMO depending on their design and parameters.
• restrictvars::Bool: Indicates whether NEMO should conduct additional data analysis to limit the set of model variables created 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 model 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). 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.
• 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)