general package¶
Please, have a look to the following general modules
Elements module¶
This module includes the optimization elements (quantities, constraints and objectives) formulated in LP or MILP :
- Quantity : related to the decision variable or parameter
- Constraint : related to the optimization problem constraints
- Objective : related to the objective function
Copyright 2018 G2Elab / MAGE
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
class
omegalpes.general.optimisation.elements.
Constraint
(exp, name='CST0', description='', active=True, parent=None)[source]¶ Bases:
object
Description
Class that defines a constraint objectAttributes
- name: name of the constraint
- description: a description of the constraint
- active: False = non-active constraint; True = active constraint
- exp: (str) : expression of the constraint
- parent: (unit) : this constraint belongs to this unit
Note
Make sure that all the modifications on Constraints are made before adding the unit to the Model (OptimisationModel.addUnit()).
-
class
omegalpes.general.optimisation.elements.
DynamicConstraint
(exp_t, t_range='for t in time.I', name='DCST0', description='dynamic constraint', active=True, parent=None)[source]¶ Bases:
omegalpes.general.optimisation.elements.Constraint
** Description **
Defining a constraint depending on the time. NB : Mandatory for PuLP
-
class
omegalpes.general.optimisation.elements.
ExtDynConstraint
(exp_t, t_range='for t in time.I', name='EDCST0', active=True, description='Non-physical and dynamic constraint', parent=None)[source]¶ Bases:
omegalpes.general.optimisation.elements.DynamicConstraint
,omegalpes.general.optimisation.elements.ExternalConstraint
** Description **
Defining a constraint both external and dynamic (see: DynamicConstraint, ExternalConstraint)
-
class
omegalpes.general.optimisation.elements.
ExternalConstraint
(exp, name='ExCST0', description='', active=True, parent=None)[source]¶ Bases:
omegalpes.general.optimisation.elements.Constraint
** Description **
- Defining a special type of constraint : the external constraint
- This constraint does not translate a physical constraint
- This constraint defines an external constraint, which could be relaxed
-
class
omegalpes.general.optimisation.elements.
HourlyDynamicConstraint
(exp_t, time, init_h: int = 0, final_h: int = 24, name='HDCST0', description='hourly dynamic constraint', active=True, parent=None)[source]¶ Bases:
omegalpes.general.optimisation.elements.DynamicConstraint
** Description **
Class that defines an dynamic contraint for a time range
Ex : Constraint applying between 7am and 10pm
ex_cst = HourlyDynamicConstraint(exp_t, time, init_h=7, final_h=22, name=’ex_cst’)
Attributes
- name (str) : name of the constraint
- exp_t (str) : expression of the constraint
- init_h (int) : hour of beginning of the constraint [0-23]
- final_h (int) : hour of end of the constraint [1-24]
- description (str) : description of the constraint
- active (bool) : defines if the constraint is active or not
- parent (Unit) : parent of the constraint
-
class
omegalpes.general.optimisation.elements.
Objective
(exp, name='OBJ0', description='', active=True, weight=1, unit='s.u.', parent=None)[source]¶ Bases:
object
Description
Class that defines an optimisation objectiveAttributes
- name (str) :
- description (str) :
- active (bool) :
- exp (str) :
- weight (float) : weighted factor of the objective
- parent (unit)
- unit (str) : unit of the cost expression
Note
Make sure that all the modifications on Objectives are made before adding the unit to the OptimisationModel, otherwise, it won’t be taken into account
-
class
omegalpes.general.optimisation.elements.
Quantity
(name='var0', opt=True, unit='s.u', vlen=None, value=None, description='', vtype='Continuous', lb=None, ub=None, parent=None)[source]¶ Bases:
object
” Description
Class that defines what is a quantity. A quantity can wether be a decision variable or a parameter, depending on the opt parameterAttributes
- name (str) : the name of the quantity
- description (str) : a description of the meaning of the quantity
- vtype (PuLP) : the variable type, depending on PuLP :
- LpBinary (binary variable)
- LpInteger (integer variable)
- LpContinuous (continuous variable)
- vlen (int) : size of the variable
- unit (str) : unit of the quantity
- opt (binary) :
- True: this is an optimization variable
- False: this is a constant - a parameter
- value (float, list, dict) : value (unused if opt=True)
- ub, lb : upper and lower bounds
- parent (Unit) : the quantity belongs to this unit
Note
Make sure that all the modifications on Quantity are made before adding the unit to the Model
Model module¶
Copyright 2018 G2Elab / MAGE
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
class
omegalpes.general.optimisation.model.
OptimisationModel
(time, name='optimisation_model')[source]¶ Bases:
pulp.pulp.LpProblem
** Description **
This module includes the optimization model formulated in LP or MILP based on the package PuLP (LpProblem)-
add_nodes
(*nodes)[source]¶ Add nodes and all connected units to the model Check that the time is the same for the model and all the units
Parameters: nodes – EnergyNode
-
add_nodes_and_actors
(*nodes_or_actors)[source]¶ Add nodes, actors and all connected units to the model Check that the time is the same for the model and all the units
Parameters: nodes_or_actors – EnergyNode or Actor type
-
Units module¶
” Copyright 2018 G2Elab / MAGE
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
class
omegalpes.general.optimisation.units.
Unit
(name='U0', description='General unit')[source]¶ Bases:
object
Description
Unit class is used as an “abstract class”, i.e. it defines some general attributes and methods but doesn’t contain variable, constraint nor objective. In the OMEGAlpes package, all the subsystem models are represented by a unit. A model is then generated adding Unit to it. Variable, objective and constraints declarations are usually done using the __init__ method of the Unit class.Attributes
- name
- description
Methods
- __str__: defines the
- __repr__: defines the unit with its name
- add_unit_attributes_in_lists
- get_constraints_list
- get_constraints_name_list
- get_objectives_list
- get_objectives_name_list
- get_quantities_list
- get_quantities_name_list
Note
The Unit class shouldn’t be instantiated in a python script, except if you want to create your own model from the beginning. In this case, one should consider creating a new class NewModel(Unit).
-
add_unit_attributes_in_lists
() → None[source]¶ - Adds :
- The name of the Quantity elements contained in the unit to the list of quantities self.quantities_list
- The name of the Constraint elements contained in the unit to the list of constraints self.constraints_list
- The name of the Objective elements contained in the unit to the list of objectives self.objectives_list
Plots module¶
This module includes the display tools
Copyright 2018 G2Elab / MAGE
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
omegalpes.general.plots.
plot_node_energetic_flows
(node)[source]¶ ** Description ** This function allows to plot the energy flows through an EnergyNode
- The display is realized :
- with histograms for production and storage flow
- with dashed curve for consumption flow
Parameters: node – EnergyNode
-
omegalpes.general.plots.
plot_quantity
(time, q, fig=None, ax=None, color=None)[source]¶ Description
Function that plots a OMEGALPES.general.optimisation.elements.QuantityAttributes
- q is the Quantity
- fig could be None, a matplotlib.pyplot.Figure or Axes for multiple
- plots
Returns
- arg1 the matplotlib.pyplot.Figure handle object
- arg2 the matplotlib.pyplot.Axes handle object
- arg3 the matplotlib.pyplot.Line2D handle object
Time module¶
Copyright 2018 G2Elab / MAGE
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
class
omegalpes.general.time.
TimeUnit
(start='01/01/2018', end=None, periods=None, dt=1)[source]¶ Bases:
object
Description
Class defining the studied time period.Attributes
- DATES : dated list of simulation steps
- DT : delta t between values in hours (int or float), i.e. 1/6 will be 10 minutes.
- LEN : number of simulation steps (length of DATES)
- I : index of time ([0 : LEN])
-
get_date_for_index
(index)[source]¶ Getting a date for a given index
Parameters: index – int value for the index of the wanted dated, between 0 and LEN (it must be in the studied period)
-
get_days
¶ Getting days for the studied period
Return all_days: list of days of the studied period
-
get_index_for_date
(date='YYYY-MM-DD HH:MM:SS')[source]¶ Getting the index associated with a date
Parameters: date – date the index of is wanted. Format YYYY-MM-DD HH:MM:SS, must be within the studied period and consistent with the timestep value
-
get_index_for_date_range
(starting_date='YYYY-MM-DD HH:MM:SS', end=None, periods=None)[source]¶ Getting a list of index for a date range
Parameters: - starting_date – starting date of the wanted index
- end – ending date of the wanted index
- periods – number of periods from the starting_date of the wanted index
Return index_list: list of indexes for the given dates
Utils module¶
- Description
- This module includes the utils
- To save results
- To define easily absolute value for quantity
Copyright 2018 G2Elab / MAGE
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
omegalpes.general.utils.
def_abs_value
(quantity, q_min, q_max)[source]¶ Parameters: - quantity – Quantity whose absolute value is wanted
- q_min – Minimal value of the quantity (negative value)
- q_max – Maximal value of the quantity (positive value)
Returns: A new Quantity whose values equal absolute values of the initial Quantity