oemof.solph.models

Solph Optimization Models.

class oemof.solph._models.BaseModel(energysystem, **kwargs)[source]

Bases: pyomo.core.base.PyomoModel.ConcreteModel

The BaseModel for other solph-models (Model, MultiPeriodModel, etc.)

Parameters:
  • energysystem (EnergySystem object) – Object that holds the nodes of an oemof energy system graph
  • constraint_groups (list (optional)) – Solph looks for these groups in the given energy system and uses them to create the constraints of the optimization problem. Defaults to Model.CONSTRAINTS
  • objective_weighting (array like (optional)) – Weights used for temporal objective function expressions. If nothing is passed timeincrement will be used which is calculated from the freq length of the energy system timeindex or can be directly passed as a sequence.
  • auto_construct (boolean) – If this value is true, the set, variables, constraints, etc. are added, automatically when instantiating the model. For sequential model building process set this value to False and use methods _add_parent_block_sets, _add_parent_block_variables, _add_blocks, _add_objective
Variables:
  • timeincrement (sequence) – Time increments.
  • flows (dict) – Flows of the model.
  • name (str) – Name of the model.
  • es (solph.EnergySystem) – Energy system of the model.
  • meta (pyomo.opt.results.results_.SolverResults or None) – Solver results.
  • dual (pyomo.core.base.suffix.Suffix or None) – Store the dual variables of the model if pyomo suffix is set to IMPORT
  • rc (pyomo.core.base.suffix.Suffix or None) – Store the reduced costs of the model if pyomo suffix is set to IMPORT
CONSTRAINT_GROUPS = []
receive_duals()[source]

Method sets solver suffix to extract information about dual variables from solver. Shadow prices (duals) and reduced costs (rc) are set as attributes of the model.

relax_problem()[source]

Relaxes integer variables to reals of optimization model self.

results()[source]

Returns a nested dictionary of the results of this optimization. See the processing module for more information on results extraction.

solve(solver='cbc', solver_io='lp', **kwargs)[source]

Takes care of communication with solver to solve the model.

Parameters:
  • solver (string) – solver to be used e.g. “cbc”, “glpk”,”gurobi”,”cplex”
  • solver_io (string) – pyomo solver interface file format: “lp”,”python”,”nl”, etc.
  • **kwargs (keyword arguments) – Possible keys can be set see below:
Other Parameters:
 
  • solve_kwargs (dict) – Other arguments for the pyomo.opt.SolverFactory.solve() method Example : {“tee”:True}
  • cmdline_options (dict) – Dictionary with command line options for solver e.g. {“mipgap”:”0.01”} results in “–mipgap 0.01” {“interior”:” “} results in “–interior” Gurobi solver takes numeric parameter values such as {“method”: 2}
exception oemof.solph._models.LoggingError[source]

Bases: BaseException

Raised when the wrong logging level is used.

class oemof.solph._models.Model(energysystem, **kwargs)[source]

Bases: oemof.solph._models.BaseModel

An energy system model for operational and/or investment optimization.

Parameters:
  • energysystem (EnergySystem object) – Object that holds the nodes of an oemof energy system graph
  • constraint_groups (list) – Solph looks for these groups in the given energy system and uses them to create the constraints of the optimization problem. Defaults to Model.CONSTRAINT_GROUPS

The following basic sets are created:

NODES
A set with all nodes of the given energy system.
TIMESTEPS
A set with all timesteps of the given time horizon.
FLOWS
A 2 dimensional set with all flows. Index: (source, target)

The following basic variables are created:

flow
Flow from source to target indexed by FLOWS, TIMESTEPS. Note: Bounds of this variable are set depending on attributes of the corresponding flow object.
CONSTRAINT_GROUPS = [<class 'oemof.solph.buses._bus.BusBlock'>, <class 'oemof.solph.components._transformer.TransformerBlock'>, <class 'oemof.solph.flows._investment_flow_block.InvestmentFlowBlock'>, <class 'oemof.solph.flows._simple_flow_block.SimpleFlowBlock'>, <class 'oemof.solph.flows._non_convex_flow_block.NonConvexFlowBlock'>, <class 'oemof.solph.flows._invest_non_convex_flow_block.InvestNonConvexFlowBlock'>]