oemof.solph.models¶
Solph Optimization Models.
- class oemof.solph._models.BaseModel(*args, **kwds)[source]¶
Bases:
ConcreteModel
The BaseModel for other solph-models (Model)
- Parameters:
energysystem (EnergySystem object or (experimental) list) – Object that holds the nodes of an oemof energy system graph. Experimental: If a list is passed, the list needs to hold EnergySystem objects and a cellular structure is assumed. In this case, the first element needs to be the upmost energy cell (structurally containing all other cells).
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 (upmost energy cell for cellular structures)
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.
- 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(*args, **kwds)[source]¶
Bases:
BaseModel
An energy system model for operational and/or investment optimization.
- Parameters:
energysystem (EnergySystem object or (experimental) list) – Object that holds the nodes of an oemof energy system graph. Experimental: If a list is passed, the list needs to hold EnergySystem objects and a cellular structure is assumed. In this case, the first element needs to be the upmost energy cell (structurally containing all other cells).
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
discount_rate (float or None) – The rate used for discounting in a multi-period model. A 2% discount rate needs to be defined as 0.02.
Note
The discount rate is only applicable for a multi-period model.
If you want to work with costs data in nominal terms, you should specify a discount rate.
By default, there is a discount rate of 2% in a multi-period model.
If you want to provide your costs data in real terms, just specify discount_rate = 0, i.e. effectively there will be no discounting.
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'>]¶