API

Functions

AnyMOD.createOptModel!Function
createOptModel!(model_object::anyModel)

Create all elements of the model's underlying optimization problem except for the objective function.

source
AnyMOD.setObjective!Function

Set the objective of the model's underlying optimization problem.

setObjective!(obj_dic::Union{Dict{Symbol,Float64},Symbol}, model_object::anyModel)

obj_dic is a keyword argument that specifies the respective objective. To perform a multi-criteria optimization, it can also be a dictionary with the keywords as keys and weights as values. So far, the only supported key-word is :costs.

source
AnyMOD.reportResultsFunction
reportResults(reportType::Symbol, model_object::anyModel; rtnOpt::Tuple = (:csv,))

Writes results to .csv file with content depending on reportType. Available types are :summary, :exchange, and :costs. See Analysed results.

source
AnyMOD.printObjectFunction
printObject(print_df::DataFrame, model_object::anyModel)

Writes a DataFrame of parameters, constraints, or variables to a .csv file in readable format (strings instead of ids). See Individual elements.

source
AnyMOD.printDualsFunction
printDuals(print_df::DataFrame, model_object::anyModel)

Writes duals of a constraint DataFrame to a .csv file in readable format (strings instead of ids). See Individual elements.

source
AnyMOD.printIISFunction
printIIS(model_object::anyModel)

Uses Gurobi's computeIIS function to determine the constraints of the optimization problem that cause infeasibility.

source
AnyMOD.plotTreeFunction
plotTree(tree_sym::Symbol, model_object::anyModel)

Plots the hierarchical tree of nodes for the set specified by tree_sym. See Node trees.

source
AnyMOD.plotEnergyFlowFunction
plotEnergyFlow(plotType::Symbol, model_object::anyModel)

Plots the energy flow in a model. Set plotType to :graph for a qualitative node graph or to :sankey for a quantitative Sankey diagram. See Energy flow.

source
AnyMOD.moveNode!Function
moveNode!(model_object::anyModel, newPos_arr::Union{Array{Tuple{String,Array{Float64,1}},1},Tuple{String,Array{Float64,1}}})

Moves a node within the current layout of the node graph created with plotEnergyFlow. See Energy flow.

source

Types

AnyMOD.anyModelType
mutable struct anyModel <: AbstractModel
	options::modOptions
	report::Array{Tuple,1}
	optModel::Model
	lock::ReentrantLock
	supTs::NamedTuple{(:lvl,:step,:sca),Tuple{Int,Tuple{Vararg{Int,N} where N},Dict{Tuple{Int,Int},Float64}}}
	cInfo::Dict{Int,NamedTuple{(:tsDis,:tsExp,:rDis,:rExp,:eq),Tuple{Int,Int,Int,Int,Bool}}}
	sets::Dict{Symbol,Tree}
	parts::NamedTuple{(:tech,:trd,:exc,:bal,:lim,:obj),Tuple{Dict{Symbol,TechPart},OthPart,OthPart,OthPart,OthPart,OthPart}}
	graInfo::graInfo
end

The core model object containing all related data and subordinate objects.

Fields

  • options: model options provided as keyword arguments to constructor
  • report: entries for writing to the reporting file Error handling
  • optModel::Model: the actual JuMP object of the model's underlying optimization problem
  • lock: lock used for multi-threading
  • supTs: information and mappings for superordinate time-steps
  • cInfo: information on resolution of energy carriers
  • sets: sets organized as Tree objects (see Sets and Mappings)
  • parts::NamedTuple: all part objects of the model (see Parts)
  • graInfo::graInfo: properties for creation of plots and graphics, can be used to adjust colors and labels (see Styling)

Constructor

anyModel(inDir::Union{String,Array{String,1}},outDir::String; kwargs)

See Model object for a detailed list of arguments.

source
AnyMOD.TechPartType
mutable struct TechPart <: AbstractModelPart
	name::Tuple{Vararg{String,N} where N}
	par::Dict{Symbol,ParElement}
	var::Dict{Symbol,DataFrame}
	cns::Dict{Symbol,DataFrame}
	carrier::NamedTuple
	balLvl::NamedTuple{(:exp,:ref),Tuple{Tuple{Int,Int},Union{Nothing,Tuple{Int,Int}}}}
	capaRestr::DataFrame
	actSt::Tuple
	type::Symbol
	disAgg::Bool
	modes::Tuple{Vararg{Int,N} where N}
	TechPart(name::Tuple{Vararg{String,N} where N}) = new(name,Dict{Symbol,ParElement}(),Dict{Symbol,DataFrame}(),Dict{Symbol,DataFrame}())
	TechPart() = new()
end

Type used for technology model parts.

General fields

  • par: dictionary of parameters with names as keys (see Parameter list)
  • var: dictionary of variables with names as keys (see Variables)
  • cns: dictionary of constraints with names as key (see Constraints)

Technology specific fields

See Technologies for details.

  • name: full name of technology as a series of nodes from the technology tree
  • carrier: ids of energy carriers assigned to technology by groups (e.g. generation, use, ...)
  • balLvl: temporal and spatial resolution for expansion and conversion balance of the technology
  • capaRestr: specification of capacity restrictions required for technology
  • actSt: ids of carriers actively stored although they are not leafs
  • type: type of technology (stock, mature, or evolving)
  • disAgg: if true, dispatch is modelled at expansion resolution instead of dispatch resolution
  • modes: different operational modes of technology
source
AnyMOD.OthPartType
mutable struct TechPart <: AbstractModelPart
	par::Dict{Symbol,ParElement}
	var::Dict{Symbol,DataFrame}
	cns::Dict{Symbol,DataFrame}
	OthPart() = new(Dict{Symbol,ParElement}(),Dict{Symbol,DataFrame}(),Dict{Symbol,DataFrame}(
end

Type used for 'exchange', 'trade', 'balance', 'limits', and 'objective' model parts.

Fields

  • par: dictionary of parameters with names as keys (see Parameter list)
  • var: dictionary of variables with names as keys (see Variables)
  • cns: dictionary of constraints with names as keys (see Constraints)
source
AnyMOD.NodeType
mutable struct Node
	idx::Int
	val::String
	lvl::Int
	subIdx::Int
	down::Array{Int,1}
end

Type to store nodes of hierarchical trees.

Fields

  • idx: internal node id
  • val: name originally assigned
  • lvl: level of node within hierarchical tree
  • subIdx: numbered position among all nodes sharing the same direct ancestor
  • down: array of children
source
AnyMOD.TreeType
mutable struct Tree
	nodes::Dict{Int,Node}
	srcTup::Dict{Tuple,Array{Int,1}}
	srcStr::Dict{Tuple{String,Int},Array{Int,1}}
	up::Dict{Int,Int}
	height::Int
	Tree() = new(Dict{Int,Node}(),Dict{Tuple,Int}(),Dict{String,Array{Int,1}}(),Dict{Int,Int}(),1)
end

Type to store hierarchical trees.

Fields

  • nodes: dictionary of nodes with node ids as keys
  • srcTup: assigns a tuple of consecutive node names to the corresponding id
  • srcStr: assigns a tuple with a node name and a level to the corresponding id
  • up: assigns the id of each node to the id of its ancestor
  • height: maximum level of tree
source
AnyMOD.ParElementType
mutable struct ParElement
	name::Symbol
    dim::Tuple
    defVal::Union{Nothing,Float64}
    herit::Tuple
    data::DataFrame
	techPre::NamedTuple{(:preset,:mode),Tuple{Symbol,Tuple{Vararg{Symbol,N} where N}}}
end

Type to store parameter data. Includes data and additional information specified in Parameter list.

Fields

  • name::Symbol: name of the parameter
  • dim::Tuple: potential dimensions of parameter data
  • defVal::Union{Nothing,Float64}: default value
  • herit::Tuple: inheritance rules for parameter, see Parameter overview
  • data::DataFrame: parameter data
source
AnyMOD.graInfoType
mutable struct graInfo
	graph::flowGraph
	names::Dict{String,String}
	colors::Dict{String,Tuple{Float64,Float64,Float64}}
end

Type to store information on styling of graphs. See Styling.

Fields

  • graph: saved layout for the qualitative energy flow graph
  • names: assigns names of nodes to labels used in plots
  • colors: assigns names or label of nodes to RGB color specified as tuple of three numbers between 0 and 1
source