oemof.solph.models

Solph Optimization Models.

exception oemof.solph._models.LoggingError[source]

Bases: BaseException

Raised when the wrong logging level is used.

class oemof.solph._models.Model(*args, **kwds)[source]

Bases: ConcreteModel

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

  • 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

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.

PERIODS

A set with all investment periods of the given time horizon.

TIMEINDEX

A set with all time indices of the given time horizon, whereby time indices are defined as a tuple consisting of the period and the timestep. E.g. (2, 10) would be timestep 10 (which is exactly the same as in the TIMESTEPS set) and which is in period 2.

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, TIMEINDEX. 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._converter.ConverterBlock'>, <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'>]
get_cluster_index(cluster_type, offset)[source]

Return cluster index for original or typical periods with or without offset

get_timestep_from_tsam_timestep(p, ik, g)[source]

Return original timestep from cluster-based timestep

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', allow_nonoptimal=False, solve_kwargs=None, cmdline_options=None)[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.

  • allow_nonoptimal (bool) – False: If no optimal solution is found, an error will be risen. True: If no optimal solution is found, there will be a warning. This is an option for experts. There will be no results in case no optimum is found.

  • 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}