pycity_scheduling.util package

Submodules

pycity_scheduling.util.debug module

The pycity_scheduling framework

Copyright (C) 2022, Institute for Automation of Complex Power Systems (ACS), E.ON Energy Research Center (E.ON ERC), RWTH Aachen University

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

pycity_scheduling.util.debug.analyze_model(model, optimizer, result, options={})

Analyze a model which is not optimal.

Parameters:
  • model (pyomo.ConcreteModel) – Model with status != OPTIMAL

  • optimizer (OptSolver) – The solver that was used for optimization and is used for analyzes

  • result (SolverResults) – The not optimal result that was returned by the solver

  • options (str, optional) – Options which should be passed to the solver when analyzing

pycity_scheduling.util.debug.print_district(cd, lvl=1)

Hierarchically print a city district.

Parameters:
  • cd (pycity_scheduling.classes.CityDistrict) –

  • lvl (int, optional) –

    • 0 : Only print city district.

    • 1 : Only print city district and buildings.

    • 2 : Print city district, buildings and all their devices.

pycity_scheduling.util.factory module

pycity_scheduling.util.generic_constraints module

The pycity_scheduling framework

Copyright (C) 2022, Institute for Automation of Complex Power Systems (ACS), E.ON Energy Research Center (E.ON ERC), RWTH Aachen University

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

class pycity_scheduling.util.generic_constraints.Constraint

Bases: object

Base class for all generic constraints.

This class provides functionality common to all generic constraints. Generic constraints can be easily added to an entity block.

Methods

apply(model[, mode])

Apply constraint to block during populate_model method call.

apply(model, mode='')

Apply constraint to block during populate_model method call.

Parameters:
  • model (pyomo.Block) – The block corresponding to the entity the constraint should be applied to.

  • mode (str, optional) –

    Specifies which set of constraints to use.

    • convex : Use linear constraints

    • integer : May use integer variables

class pycity_scheduling.util.generic_constraints.LowerActivationLimit(o, var_name, lower_activation_limit, var_nom)

Bases: Constraint

Constraint Class for adding lower activation limits

This class provides functionality to add lower activation limits to entities. Adds no new constraints and variables if not in integer mode or if not required. A new state schedule is also created for the entity.

Notes

  • In integer mode the following constraints are added:

\[State \geq \frac{var}{var\_nom} \geq State * lower\_activation\_limit\]

Methods

apply(m[, mode])

Apply constraint to block during populate_model method call.

apply(m, mode='')

Apply constraint to block during populate_model method call.

Parameters:
  • model (pyomo.Block) – The block corresponding to the entity the constraint should be applied to.

  • mode (str, optional) –

    Specifies which set of constraints to use.

    • convex : Use linear constraints

    • integer : May use integer variables

pycity_scheduling.util.metric module

pycity_scheduling.util.plot_schedules module

pycity_scheduling.util.signals module

pycity_scheduling.util.write_schedules module

The pycity_scheduling framework

Copyright (C) 2022, Institute for Automation of Complex Power Systems (ACS), E.ON Energy Research Center (E.ON ERC), RWTH Aachen University

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

pycity_scheduling.util.write_schedules.schedule_to_csv(input_list, file_name, delimiter=';', schedule=None)

Write the optimized schedule of all entities to a CSV file.

Parameters:
  • input_list (list) – List of entities.

  • file_name (str or file-like object) – Specify the file name or an open file where the csv should be saved in. If file_name is a string and it does not have the .csv extension it will be appended.

  • delimiter (str) – CSV file delimiter character.

  • schedule (str or list, optional) –

    Schedule or list of schedules to save.

    • None : Current schedule of entity

    • ’default’ : Normal schedule

    • ’ref’ : Reference schedule

pycity_scheduling.util.write_schedules.schedule_to_dict(input_list, schedule=None)

Create a dictionary containing a reference to the optimized schedules.

Parameters:
  • input_list (list) – List of entities.

  • schedule (str or list, optional) –

    Schedule or list of schedules to save.

    • None : Current schedule of entity

    • ’default’ : Normal schedule

    • ’ref’ : Reference schedule

pycity_scheduling.util.write_schedules.schedule_to_json(input_list, file_name, schedule=None)

Write the optimized schedule of all entities to a json file.

Parameters:
  • input_list (list) – List of entities.

  • file_name (str or file-like object) – Specify the file name or an open file where the json should be saved in. If file_name is a string and it does not have the .json extension it will be appended.

  • schedule (str or list, optional) –

    Schedule or list of schedules to save.

    • None : Current schedule of entity

    • ’default’ : Normal schedule

    • ’ref’ : Reference schedule

Module contents

The pycity_scheduling framework

Copyright (C) 2022, Institute for Automation of Complex Power Systems (ACS), E.ON Energy Research Center (E.ON ERC), RWTH Aachen University

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

pycity_scheduling.util.calculate_flexibility_potential(city_district, algorithm='central', reference_algorithm='stand-alone')

Calculate and quantify the operational flexibility potential for a certain city district.

Parameters:
  • city_district (pycity_scheduling.classes.CityDistrict) – District for which the flexibility potential should be quantified.

  • algorithm (str) – Define which algorithm should be used for the flexibility potential quantification purposes. Must be one of ‘exchange-admm’, ‘dual-decomposition’, ‘stand-alone’, ‘local’ or ‘central’. Default: ‘central’.

  • reference_algorithm (str) – Define which algorithm should be used as the reference for the flexibility potential quantification purposes. Must be one of ‘exchange-admm’, ‘dual-decomposition’, ‘stand-alone’, ‘local’ or ‘central’. Default: ‘stand-alone’.

Returns:

City district operational flexibility potential in kWh.

Return type:

float

pycity_scheduling.util.compute_profile(timer, profile, pattern=None)

Compute a load series profile for an electrical vehicle.

Parameters:
  • timer (pycity_scheduling.classes.Timer) –

  • profile (array of binaries) –

    Indicator when electrical vehicle can be charged.

    • profile[t] == 0: EV cannot be charged in t

    • profile[t] == 1: EV can be charged in t

    It must contain at least one 0 otherwise the model will become infeasible. Its length has to be consistent with pattern.

  • pattern (str, optional) –

    Define how the profile is to be used.

    • None : Profile matches simulation horizon.

    • ’daily’ : Profile matches one day.

    • ’weekly’ : Profile matches one week.

Return type:

numpy.ndarray

pycity_scheduling.util.extract_pyomo_value(variable, var_type=None)

Extract a single values out of the pyomo Variable after optimization.

Parameters:
  • variable (pyomo.Var) – Variable to extract value from.

  • var_type (type, optional) –

    Type with which variable should be stored. Defaults to Domain of pyomo Variable Container or float.

    • float : Store values as floating point numbers.

    • int : Store values as integers (rounding down if necessary).

    • bool : Store values as binary values.

Returns:

Extracted value from the pyomo Variable or the closest value to zero if stale.

Return type:

float or int or bool

Raises:

SchedulingError – If value to extract is not feasible.

pycity_scheduling.util.extract_pyomo_values(variable, var_type=None)

Extract values out of the pyomo Variable container after optimization.

Parameters:
  • variable (pyomo.Var) – Variable container to extract values from.

  • var_type (type, optional) –

    Type with which variable should be stored. Defaults to Domain of pyomo Variable Container or float.

    • float : Store values as floating point numbers.

    • int : Store values as integers (rounding down if necessary).

    • bool : Store values as binary values.

Returns:

If the Variable container is indexed an array containing the extracted values is returned. If the Variable container is not indexed returns the single extracted value.

Return type:

numpy.ndarray or float or int or bool

Raises:

SchedulingError – If values to extract are not feasible.