pycity_scheduling.algorithms package
Submodules
pycity_scheduling.algorithms.algorithm module
The pycity_scheduling framework
Copyright (C) 2025, 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.algorithms.algorithm.DistributedAlgorithm(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex')
Bases:
OptimizationAlgorithm
Base class for all distributed optimization algorithms.
These algorithms can divide the optimization problem into sub-problems.
- class pycity_scheduling.algorithms.algorithm.IterationAlgorithm(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex')
Bases:
OptimizationAlgorithm
Base class for all optimization algorithms that solve the problem iteratively.
- class pycity_scheduling.algorithms.algorithm.OptimizationAlgorithm(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex')
Bases:
object
Base class for all optimization algorithms.
This class provides functionality common to all algorithms which are able to optimize City Districts.
- Parameters:
city_district (CityDistrict)
solver (str, optional) – Solver to use for solving (sub-)problems.
solver_options (dict, optional) –
Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance, solve.
__call__ is the function being called when generating an instance with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized.
set_instance is called when a pyomo Model is set as an instance of a persistent solver.
solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
mode (str, optional) –
Specifies which set of constraints to use.
convex : Use linear, i.e., convex, constraints
integer : May use non-linear, i.e., mixed-integer, constraints
Methods
solve
([full_update, beta, robustness, debug])Solves the city district for the current op_horizon.
- solve(full_update=True, beta=1, robustness=None, debug=False)
Solves the city district for the current op_horizon.
- Parameters:
full_update (bool, optional) – Should be true if the city district models were changed or update_model should be called to update the city district models. Disabling the full_update can give a small performance gain.
beta (float, optional) – Tradeoff factor between system and customer objective. The customer objective is multiplied with beta.
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
debug (bool, optional) – Specify whether detailed debug information shall be printed.
- Returns:
results – Dictionary of performance values of the algorithm.
- Return type:
- Raises:
NonoptimalError – If no feasible solution for the city district is found or a solver problem is encountered.
- class pycity_scheduling.algorithms.algorithm.SolverNode(solver, solver_options, entities, mode='convex', robustness=None)
Bases:
object
Node which can be used to solve all entities provided to it.
Provides an abstraction layer for algorithms, so entities can be assigned to nodes and optimized easily.
- Parameters:
solver (str) – Solver to use for solving (sub)problems.
solver_options (dict, optional) –
Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve.
__call__ is the function being called when generating an instance with the pyomo SolverFactory. Additionally to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized.
set_instance is called when a pyomo Model is set as an instance of a persistent solver.
solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
entities (list) – List of entities which should be optimized by this node.
mode (str, optional) –
Specifies which set of constraints to use.
convex : Use linear constraints
integer : May use non-linear constraints
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
Methods
Only propagate the constraints update of the model.
full_update
([robustness])Execute the update_model function and propagate other model changes.
Only propagate the objective value update of the model.
solve
([debug])Call the solver to solve this nodes optimization problem.
- constr_update()
Only propagate the constraints update of the model.
- full_update(robustness=None)
Execute the update_model function and propagate other model changes.
- Parameters:
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
- obj_update()
Only propagate the objective value update of the model.
pycity_scheduling.algorithms.algorithm_ray module
The pycity_scheduling framework
Copyright (C) 2025, 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.algorithms.algorithm_ray.RaySolverNode(solver, solver_options, entities, node_index=0, op_horizon=0, mode='convex', robustness=None)
Bases:
object
Base class for a Ray Node which can be used to solve all entities provided to it with in a ray cluster.
Provides an abstraction layer for algorithms, so entities can be assigned to nodes and optimized easily.
- Parameters:
solver (str) – Solver to use for solving (sub)problems.
solver_options (dict, optional) –
Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve. - __call__ is the function being called when generating an instance
with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized.
set_instance is called when a pyomo Model is set as an instance of a persistent solver.
solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
entities (list) – List of entities which should be optimized by this node.
mode (str, optional) –
Specifies which set of constraints to use.
convex : Use linear constraints
integer : May use non-linear constraints
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
Methods
constr_update
(*[, _ray_trace_ctx])Only propagate the constraints update of the model
full_update
([robustness, _ray_trace_ctx])Execute the update_model function and propagate other model changes.
get_all_schedules
(*[, _ray_trace_ctx])Retrives all schedules of each entity and asset on the node
obj_update
(index, *[, _ray_trace_ctx])Only propagate the objective value update of the model
In this step other post-processing can be done
set_model_betas
(params, *[, _ray_trace_ctx])Sets the model betas for every entity on the remote node
exit
get_objective
- constr_update(*, _ray_trace_ctx=None)
Only propagate the constraints update of the model
- exit(*, _ray_trace_ctx=None)
- full_update(robustness=None, *, _ray_trace_ctx=None)
Execute the update_model function and propagate other model changes.
- Parameters:
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
- get_all_schedules(*, _ray_trace_ctx=None)
Retrives all schedules of each entity and asset on the node
- get_objective(*, _ray_trace_ctx=None)
- obj_update(index, *, _ray_trace_ctx=None)
Only propagate the objective value update of the model
- postsolve()
In this step other post-processing can be done
- set_model_betas(params, *, _ray_trace_ctx=None)
Sets the model betas for every entity on the remote node
- pycity_scheduling.algorithms.algorithm_ray.get_beta(params, entity)
Returns the beta value for a specific entity
- pycity_scheduling.algorithms.algorithm_ray.list_into_n_chunks(lst, n)
pycity_scheduling.algorithms.central_optimization_algorithm module
The pycity_scheduling framework
Copyright (C) 2025, 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.algorithms.central_optimization_algorithm.CentralOptimization(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', robustness=None)
Bases:
OptimizationAlgorithm
Implementation of the reference Central Optimization algorithm.
Only creates one model and calls the solver once. Combines the objectives of all entities.
pycity_scheduling.algorithms.derivative_free_aladin_algorithm module
The pycity_scheduling framework
Copyright (C) 2025, 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.algorithms.derivative_free_aladin_algorithm.DerivativeFreeALADIN(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', eps_primal=0.001, eps_dual=0.001, rho=0.5, alpha=1.0, hessian_scaling=1.0, max_iterations=10000, robustness=None)
Bases:
IterationAlgorithm
,DistributedAlgorithm
Implementation of the distributed ALADIN algorithm. Specifically, this class implements the derivative-free ALADIN as described in [1].
- Parameters:
city_district (CityDistrict)
solver (str, optional) – Solver to use for solving (sub)problems.
solver_options (dict, optional) – Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve. __call__ is the function being called when generating an instance with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized. set_instance is called when a pyomo Model is set as an instance of a persistent solver. solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
mode (str, optional) – Specifies which set of constraints to use. - convex : Use linear constraints - integer : May use non-linear constraints
eps_primal (float, optional) – Primal stopping criterion for the ALADIN algorithm.
eps_dual (float, optional) – Dual stopping criterion for the ALADIN algorithm.
rho (float, optional) – Penalty term parameter for the ALADIN algorithm.
alpha (float, optional) – Step size parameter for the ALADIN algorithm.
max_iterations (int, optional) – Maximum number of ALADIN iterations.
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
References
[1] “Distributed Optimization and Control with ALADIN” by Boris Houska and Yuning Jiang Online: https://faculty.sist.shanghaitech.edu.cn/faculty/boris/paper/AladinChapter.pdf (accessed on 2024/02/13)
pycity_scheduling.algorithms.derivative_free_aladin_algorithm_ray module
The pycity_scheduling framework
Copyright (C) 2025, 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.algorithms.derivative_free_aladin_algorithm_ray.DerivativeFreeALADINRay(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', eps_primal=0.001, eps_dual=0.001, rho=0.5, alpha=1.0, hessian_scaling=1.0, max_iterations=10000, robustness=None, ray_cpu_count=None)
Bases:
IterationAlgorithm
,DistributedAlgorithm
Implementation of the distributed ALADIN algorithm using ray.io parallelization. Specifically, this class implements the derivative-free ALADIN as described in [1].
- Parameters:
city_district (CityDistrict)
solver (str, optional) – Solver to use for solving (sub)problems.
solver_options (dict, optional) – Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve. __call__ is the function being called when generating an instance with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized. set_instance is called when a pyomo Model is set as an instance of a persistent solver. solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
mode (str, optional) – Specifies which set of constraints to use. - convex : Use linear constraints - integer : May use non-linear constraints
eps_primal (float, optional) – Primal stopping criterion for the ALADIN algorithm.
eps_dual (float, optional) – Dual stopping criterion for the ALADIN algorithm.
rho (float, optional) – Penalty term parameter for the ALADIN algorithm.
alpha (float, optional) – Step size parameter for the ALADIN algorithm.
max_iterations (int, optional) – Maximum number of ALADIN iterations.
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
ray_cpu_count (int, optional) – Number of CPU cores to be used by ray for parallelization. Default: Detect the number of CPUs automatically.
References
[1] “Distributed Optimization and Control with ALADIN” by Boris Houska and Yuning Jiang Online: https://faculty.sist.shanghaitech.edu.cn/faculty/boris/paper/AladinChapter.pdf (accessed on 2024/02/13)
pycity_scheduling.algorithms.derivative_free_aladin_algorithm_ray_Hvet module
The pycity_scheduling framework
Copyright (C) 2025, 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.algorithms.derivative_free_aladin_algorithm_ray_Hvet.DerivativeFreeALADINRay_Hvet(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', eps_primal=0.001, eps_dual=0.001, rho=0.5, alpha=1.0, hessian_scaling=1.0, max_iterations=10000, robustness=None, ray_cpu_count=None)
Bases:
IterationAlgorithm
,DistributedAlgorithm
Implementation of the distributed ALADIN algorithm using ray.io parallelization and an improved implementation for sparse Hessian matrices and gradients. Specifically, this class implements the derivative-free ALADIN as described in [1].
- Parameters:
city_district (CityDistrict)
solver (str, optional) – Solver to use for solving (sub)problems.
solver_options (dict, optional) – Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve. __call__ is the function being called when generating an instance with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized. set_instance is called when a pyomo Model is set as an instance of a persistent solver. solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
mode (str, optional) – Specifies which set of constraints to use. - convex : Use linear constraints - integer : May use non-linear constraints
eps_primal (float, optional) – Primal stopping criterion for the ALADIN algorithm.
eps_dual (float, optional) – Dual stopping criterion for the ALADIN algorithm.
rho (float, optional) – Penalty term parameter for the ALADIN algorithm.
alpha (float, optional) – Step size parameter for the ALADIN algorithm.
max_iterations (int, optional) – Maximum number of ALADIN iterations.
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
ray_cpu_count (int, optional) – Number of CPU cores to be used by ray for parallelization. Default: Detect the number of CPUs automatically.
References
[1] “Distributed Optimization and Control with ALADIN” by Boris Houska and Yuning Jiang Online: https://faculty.sist.shanghaitech.edu.cn/faculty/boris/paper/AladinChapter.pdf (accessed on 2024/02/13)
pycity_scheduling.algorithms.dual_decomposition_algorithm module
The pycity_scheduling framework
Copyright (C) 2025, 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.algorithms.dual_decomposition_algorithm.DualDecomposition(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', eps_primal=0.1, rho=2.0, max_iterations=10000, robustness=None)
Bases:
IterationAlgorithm
,DistributedAlgorithm
Implementation of the distributed Dual Decomposition algorithm as described in [1].
- Parameters:
city_district (CityDistrict)
solver (str, optional) – Solver to use for solving (sub)problems.
solver_options (dict, optional) – Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve. __call__ is the function being called when generating an instance with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized. set_instance is called when a pyomo Model is set as an instance of a persistent solver. solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
mode (str, optional) – Specifies which set of constraints to use. - convex : Use linear constraints - integer : May use non-linear constraints
eps_primal (float, optional) – Primal stopping criterion for the dual decomposition algorithm.
rho (float, optional) – Step size for the dual decomposition algorithm.
max_iterations (int, optional) – Maximum number of ADMM iterations.
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
References
[1] “Distributed Optimization for Scheduling Electrical Demand in Complex City Districts” by M. Diekerhof, S. Schwarz, F. Martin, A. Monti in IEEE Systems Journal, vol. 12, no. 4, pp. 3226-3237, Dec. 2018.
pycity_scheduling.algorithms.dual_decomposition_algorithm_mpi module
The pycity_scheduling framework
Copyright (C) 2025, 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.algorithms.dual_decomposition_algorithm_mpi.DualDecompositionMPI(city_district, mpi_interface, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', eps_primal=0.1, rho=2.0, max_iterations=10000, robustness=None)
Bases:
IterationAlgorithm
,DistributedAlgorithm
Implementation of the distributed Dual Decomposition algorithm as described in [1] using parallel computations with MPI.
- Parameters:
city_district (CityDistrict)
mpi_interface (MPIInterface) – MPI Interface to use for solving the Dual Decomposition subproblems in parallel.
solver (str, optional) – Solver to use for solving the (sub)problems.
solver_options (dict, optional) – Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve. __call__ is the function being called when generating an instance with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized. set_instance is called when a pyomo Model is set as an instance of a persistent solver. solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
mode (str, optional) – Specifies which set of constraints to use. - convex : Use linear constraints - integer : May use non-linear constraints
eps_primal (float, optional) – Primal stopping criterion for the dual decomposition algorithm.
rho (float, optional) – Step size for the dual decomposition algorithm.
max_iterations (int, optional) – Maximum number of dual decomposition iterations.
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
References
[1] “Distributed Optimization for Scheduling Electrical Demand in Complex City Districts” by M. Diekerhof, S. Schwarz, F. Martin, A. Monti in IEEE Systems Journal, vol. 12, no. 4, pp. 3226-3237, Dec. 2018.
pycity_scheduling.algorithms.dual_decomposition_algorithm_ray module
The pycity_scheduling framework
Copyright (C) 2025, 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.algorithms.dual_decomposition_algorithm_ray.DualDecompositionRay(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', eps_primal=0.1, rho=2.0, max_iterations=10000, robustness=None, ray_cpu_count=None)
Bases:
IterationAlgorithm
,DistributedAlgorithm
Implementation of the distributed Dual Decomposition algorithm using ray.io parallelization.
- Parameters:
city_district (CityDistrict)
solver (str, optional) – Solver to use for solving (sub)problems.
solver_options (dict, optional) – Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve. __call__ is the function being called when generating an instance with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized. set_instance is called when a pyomo Model is set as an instance of a persistent solver. solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
mode (str, optional) – Specifies which set of constraints to use. - convex : Use linear constraints - integer : May use non-linear constraints
eps_primal (float, optional) – Primal stopping criterion for the dual decomposition algorithm.
rho (float, optional) – Step size for the dual decomposition algorithm.
max_iterations (int, optional) – Maximum number of ADMM iterations.
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
ray_cpu_count (int, optional) – Number of CPU cores to be used by ray for parallelization. Default: Detect the number of CPUs automatically.
pycity_scheduling.algorithms.exchange_admm_algorithm module
The pycity_scheduling framework
Copyright (C) 2025, 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.algorithms.exchange_admm_algorithm.ExchangeADMM(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', eps_primal=0.1, eps_dual=1.0, rho=2.0, max_iterations=10000, robustness=None)
Bases:
IterationAlgorithm
,DistributedAlgorithm
Implementation of the distributed ADMM algorithm. This class implements the Exchange ADMM as described in [1] and [2].
- Parameters:
city_district (CityDistrict)
solver (str, optional) – Solver to use for solving (sub)problems.
solver_options (dict, optional) – Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve. __call__ is the function being called when generating an instance with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized. set_instance is called when a pyomo Model is set as an instance of a persistent solver. solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
mode (str, optional) – Specifies which set of constraints to use. - convex : Use linear constraints - integer : May use non-linear constraints
eps_primal (float, optional) – Primal stopping criterion for the ADMM algorithm.
eps_dual (float, optional) – Dual stopping criterion for the ADMM algorithm.
rho (float, optional) – Step size for the ADMM algorithm.
max_iterations (int, optional) – Maximum number of ADMM iterations.
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
References
[1] “Alternating Direction Method of Multipliers for Decentralized Electric Vehicle Charging Control” by Jose Rivera, Philipp Wolfrum, Sandra Hirche, Christoph Goebel, and Hans-Arno Jacobsen Online: https://mediatum.ub.tum.de/doc/1187583/1187583.pdf (accessed on 2020/09/28)
[2] “Distributed Optimization and Statistical Learning via the Alternating Direction Method of Multipliers” by Stephen Boyd, Neal Parikh, Eric Chu, Borja Peleato, and Jonathan Eckstein Online: https://web.stanford.edu/~boyd/papers/pdf/admm_distr_stats.pdf (accessed on 2023/10/09)
pycity_scheduling.algorithms.exchange_admm_algorithm_mpi module
The pycity_scheduling framework
Copyright (C) 2025, 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.algorithms.exchange_admm_algorithm_mpi.ExchangeADMMMPI(city_district, mpi_interface, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', eps_primal=0.1, eps_dual=1.0, rho=2.0, max_iterations=10000, robustness=None)
Bases:
IterationAlgorithm
,DistributedAlgorithm
Implementation of the distributed ADMM algorithm using parallel computations with MPI. This class implements the Exchange ADMM as described in [1] and [2].
- Parameters:
city_district (CityDistrict)
mpi_interface (MPIInterface) – MPI Interface to use for solving the Exchange ADMM subproblems in parallel.
solver (str, optional) – Solver to use for solving (sub)problems.
solver_options (dict, optional) – Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve. __call__ is the function being called when generating an instance with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized. set_instance is called when a pyomo Model is set as an instance of a persistent solver. solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
mode (str, optional) – Specifies which set of constraints to use. - convex : Use linear constraints - integer : May use non-linear constraints
eps_primal (float, optional) – Primal stopping criterion for the ADMM algorithm.
eps_dual (float, optional) – Dual stopping criterion for the ADMM algorithm.
rho (float, optional) – Step size for the ADMM algorithm.
max_iterations (int, optional) – Maximum number of ADMM iterations.
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
References
[1] “Alternating Direction Method of Multipliers for Decentralized Electric Vehicle Charging Control” by Jose Rivera, Philipp Wolfrum, Sandra Hirche, Christoph Goebel, and Hans-Arno Jacobsen Online: https://mediatum.ub.tum.de/doc/1187583/1187583.pdf (accessed on 2020/09/28)
[2] “Distributed Optimization and Statistical Learning via the Alternating Direction Method of Multipliers” by Stephen Boyd, Neal Parikh, Eric Chu, Borja Peleato, and Jonathan Eckstein Online: https://web.stanford.edu/~boyd/papers/pdf/admm_distr_stats.pdf (accessed on 2023/10/09)
pycity_scheduling.algorithms.exchange_admm_algorithm_ray module
The pycity_scheduling framework
Copyright (C) 2025, 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.algorithms.exchange_admm_algorithm_ray.ExchangeADMMRay(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', eps_primal=0.1, eps_dual=1.0, rho=2.0, max_iterations=10000, robustness=None, ray_cpu_count=None)
Bases:
IterationAlgorithm
,DistributedAlgorithm
Implementation of the distributed ADMM algorithm using ray.io parallelization. This class implements the Exchange ADMM as described in [1].
- Parameters:
city_district (CityDistrict)
solver (str, optional) – Solver to use for solving (sub)problems.
solver_options (dict, optional) – Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve. __call__ is the function being called when generating an instance with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized. set_instance is called when a pyomo Model is set as an instance of a persistent solver. solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
mode (str, optional) – Specifies which set of constraints to use. - convex : Use linear constraints - integer : May use non-linear constraints
eps_primal (float, optional) – Primal stopping criterion for the ADMM algorithm.
eps_dual (float, optional) – Dual stopping criterion for the ADMM algorithm.
rho (float, optional) – Step size for the ADMM algorithm.
max_iterations (int, optional) – Maximum number of ADMM iterations.
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
ray_cpu_count (int, optional) – Number of CPU cores to be used by ray for parallelization. Default: Detect the number of CPUs automatically.
References
[1] “Alternating Direction Method of Multipliers for Decentralized Electric Vehicle Charging Control” by Jose Rivera, Philipp Wolfrum, Sandra Hirche, Christoph Goebel, and Hans-Arno Jacobsen Online: https://mediatum.ub.tum.de/doc/1187583/1187583.pdf (accessed on 2020/09/28)
[2] “Distributed Optimization and Statistical Learning via the Alternating Direction Method of Multipliers” by Stephen Boyd, Neal Parikh, Eric Chu, Borja Peleato, and Jonathan Eckstein Online: https://web.stanford.edu/~boyd/papers/pdf/admm_distr_stats.pdf (accessed on 2023/10/09)
pycity_scheduling.algorithms.exchange_miqp_admm_algorithm module
The pycity_scheduling framework
Copyright (C) 2025, 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.algorithms.exchange_miqp_admm_algorithm.ExchangeMIQPADMM(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', x_update_mode='constrained', eps_exch_primal=0.01, eps_exch_dual=0.1, gamma=1.0, gamma_incr=1.0, rho=2.0, varying_penalty_parameter=False, tau_incr=2.0, tau_decr=2.0, mu=10.0, max_iterations=10000, robustness=None)
Bases:
IterationAlgorithm
,DistributedAlgorithm
Implementation of the Exchange MIQP ADMM algorithm.
Implements the Exchange MIQP ADMM algorithm described in [1], [2], and [3].
- Parameters:
city_district (CityDistrict)
solver (str, optional) – Solver to use for solving (sub)problems.
solver_options (dict, optional) – Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve. __call__ is the function being called when generating an instance with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized. set_instance is called when a pyomo Model is set as an instance of a persistent solver. solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
mode (str, optional) – Specifies which set of constraints to use. - convex : Use linear constraints - integer : May use non-linear constraints
eps_exch_primal (float, optional) – Primal stopping criterion for the ADMM algorithm.
eps_exch_dual (float, optional) – Dual stopping criterion for the ADMM algorithm.
gamma (float, optional) – Exchange MIQP ADMM scaling parameter
gamma_incr (float, optional) – Varying scaling parameter scheme increase parameter
rho (float, optional) – Stepsize for the ADMM algorithm.
varying_penalty_parameter (bool, optional) – Apply a varying penalty parameter scheme, see [3] - chapter 3.4.1
tau_incr (float, optional) – Varying penalty parameter scheme increase parameter
tau_decr (float, optional) – Varying penalty parameter scheme decrease parameter
mu (float, optional) – Varying penalty parameter scheme conditional change parameter
max_iterations (int, optional) – Maximum number of ADMM iterations.
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
References
[1] “Alternating Direction Method of Multipliers for Decentralized Electric Vehicle Charging Control” by Jose Rivera, Philipp Wolfrum, Sandra Hirche, Christoph Goebel, and Hans-Arno Jacobsen Online: https://mediatum.ub.tum.de/doc/1187583/1187583.pdf (accessed on 2020/09/28)
[2] “A simple effective heuristic for embedded mixed-integer quadratic programming” by Reza Takapoui, Nicholas Moehle, Stephen Boyd, and Alberto Bemporad Online: https://web.stanford.edu/~boyd/papers/pdf/miqp_admm.pdf (accessed on 2023/09/06)
[3] “Distributed Optimization and Statistical Learning via the Alternating Direction Method of Multipliers” by Stephen Boyd, Neal Parikh, Eric Chu, Borja Peleato, and Jonathan Eckstein Online: https://web.stanford.edu/~boyd/papers/pdf/admm_distr_stats.pdf (accessed on 2023/10/09)
Methods
activate_constraints
deactivate_constraints
fix_variables
print_model
release_variables
- activate_constraints()
- deactivate_constraints()
- fix_variables()
- print_model()
- release_variables()
pycity_scheduling.algorithms.exchange_miqp_admm_algorithm_mpi module
The pycity_scheduling framework
Copyright (C) 2025, 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.algorithms.exchange_miqp_admm_algorithm_mpi.ExchangeMIQPADMMMPI(city_district, mpi_interface, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', x_update_mode='constrained', eps_exch_primal=0.01, eps_exch_dual=0.1, gamma=1.0, gamma_incr=1.0, rho=2.0, varying_penalty_parameter=False, tau_incr=2.0, tau_decr=2.0, mu=10.0, max_iterations=10000, robustness=None)
Bases:
IterationAlgorithm
,DistributedAlgorithm
Implementation of the Exchange MIQP ADMM algorithm.
Implements the Exchange MIQP ADMM algorithm described in [1], [2], and [3] using parallel computations with MPI.
- Parameters:
city_district (CityDistrict)
mpi_interface (MPIInterface) – MPI Interface to use for solving the MIQP ADMM subproblems in parallel.
solver (str, optional) – Solver to use for solving (sub)problems.
solver_options (dict, optional) – Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve. __call__ is the function being called when generating an instance with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized. set_instance is called when a pyomo Model is set as an instance of a persistent solver. solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
mode (str, optional) – Specifies which set of constraints to use. - convex : Use linear constraints - integer : May use non-linear constraints
eps_exch_primal (float, optional) – Primal stopping criterion for the ADMM algorithm.
eps_exch_dual (float, optional) – Dual stopping criterion for the ADMM algorithm.
gamma (float, optional) – Exchange MIQP ADMM scaling parameter
gamma_incr (float, optional) – Varying scaling parameter scheme increase parameter
rho (float, optional) – Stepsize for the ADMM algorithm.
varying_penalty_parameter (bool, optional) – Apply a varying penalty parameter scheme, see [3] - chapter 3.4.1
tau_incr (float, optional) – Varying penalty parameter scheme increase parameter
tau_decr (float, optional) – Varying penalty parameter scheme decrease parameter
mu (float, optional) – Varying penalty parameter scheme conditional change parameter
max_iterations (int, optional) – Maximum number of ADMM iterations.
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
References
[1] “Alternating Direction Method of Multipliers for Decentralized Electric Vehicle Charging Control” by Jose Rivera, Philipp Wolfrum, Sandra Hirche, Christoph Goebel, and Hans-Arno Jacobsen Online: https://mediatum.ub.tum.de/doc/1187583/1187583.pdf (accessed on 2020/09/28)
[2] “A simple effective heuristic for embedded mixed-integer quadratic programming” by Reza Takapoui, Nicholas Moehle, Stephen Boyd, and Alberto Bemporad Online: https://web.stanford.edu/~boyd/papers/pdf/miqp_admm.pdf (accessed on 2023/09/06)
[3] “Distributed Optimization and Statistical Learning via the Alternating Direction Method of Multipliers” by Stephen Boyd, Neal Parikh, Eric Chu, Borja Peleato, and Jonathan Eckstein Online: https://web.stanford.edu/~boyd/papers/pdf/admm_distr_stats.pdf (accessed on 2023/10/09)
Methods
activate_constraints
deactivate_constraints
fix_variables
print_model
release_variables
- activate_constraints()
- deactivate_constraints()
- fix_variables()
- print_model()
- release_variables()
pycity_scheduling.algorithms.exchange_miqp_admm_algorithm_ray module
The pycity_scheduling framework
Copyright (C) 2025, 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.algorithms.exchange_miqp_admm_algorithm_ray.ExchangeMIQPADMMRay(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', x_update_mode='constrained', eps_exch_primal=0.01, eps_exch_dual=0.1, gamma=1.0, gamma_incr=1.0, rho=2.0, varying_penalty_parameter=False, tau_incr=2.0, tau_decr=2.0, mu=10.0, max_iterations=10000, robustness=None, ray_cpu_count=None)
Bases:
IterationAlgorithm
,DistributedAlgorithm
Implementation of the Exchange MIQP ADMM algorithm.
Implements the Exchange MIQP ADMM algorithm described in [1], [2], and [3] using parallel computations with Ray.
- Parameters:
city_district (CityDistrict)
solver (str, optional) – Solver to use for solving (sub)problems.
solver_options (dict, optional) – Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve. __call__ is the function being called when generating an instance with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized. set_instance is called when a pyomo Model is set as an instance of a persistent solver. solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
mode (str, optional) – Specifies which set of constraints to use. - convex : Use linear constraints - integer : May use non-linear constraints
eps_exch_primal (float, optional) – Primal stopping criterion for the ADMM algorithm.
eps_exch_dual (float, optional) – Dual stopping criterion for the ADMM algorithm.
gamma (float, optional) – Exchange MIQP ADMM scaling parameter
gamma_incr (float, optional) – Varying scaling parameter scheme increase parameter
rho (float, optional) – Stepsize for the ADMM algorithm.
varying_penalty_parameter (bool, optional) – Apply a varying penalty parameter scheme, see [3] - chapter 3.4.1
tau_incr (float, optional) – Varying penalty parameter scheme increase parameter
tau_decr (float, optional) – Varying penalty parameter scheme decrease parameter
mu (float, optional) – Varying penalty parameter scheme conditional change parameter
max_iterations (int, optional) – Maximum number of ADMM iterations.
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
ray_cpu_count (int, optional) – Number of CPU cores to be used by ray for parallelization. Default: Detect the number of CPUs automatically.
References
[1] “Alternating Direction Method of Multipliers for Decentralized Electric Vehicle Charging Control” by Jose Rivera, Philipp Wolfrum, Sandra Hirche, Christoph Goebel, and Hans-Arno Jacobsen Online: https://mediatum.ub.tum.de/doc/1187583/1187583.pdf (accessed on 2020/09/28)
[2] “A simple effective heuristic for embedded mixed-integer quadratic programming” by Reza Takapoui, Nicholas Moehle, Stephen Boyd, and Alberto Bemporad Online: https://web.stanford.edu/~boyd/papers/pdf/miqp_admm.pdf (accessed on 2023/09/06)
[3] “Distributed Optimization and Statistical Learning via the Alternating Direction Method of Multipliers” by Stephen Boyd, Neal Parikh, Eric Chu, Borja Peleato, and Jonathan Eckstein Online: https://web.stanford.edu/~boyd/papers/pdf/admm_distr_stats.pdf (accessed on 2023/10/09)
Methods
activate_constraints
deactivate_constraints
fix_variables
release_variables
- activate_constraints()
- deactivate_constraints()
- fix_variables()
- release_variables()
pycity_scheduling.algorithms.local_optimization_algorithm module
The pycity_scheduling framework
Copyright (C) 2025, 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.algorithms.local_optimization_algorithm.LocalOptimization(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', robustness=None)
Bases:
DistributedAlgorithm
Implementation of the reference Local Optimization algorithm.
Schedule all nodes (i.e., buildings) in city_district on their own.
pycity_scheduling.algorithms.stand_alone_optimization_algorithm module
The pycity_scheduling framework
Copyright (C) 2025, 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.algorithms.stand_alone_optimization_algorithm.StandAlone(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', robustness=None)
Bases:
LocalOptimization
Implementation of the reference Stand-alone Optimization algorithm.
Schedule all entities (i.e., devices) in city_district on their own.
Module contents
The pycity_scheduling framework
Copyright (C) 2025, 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.algorithms.CentralOptimization(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', robustness=None)
Bases:
OptimizationAlgorithm
Implementation of the reference Central Optimization algorithm.
Only creates one model and calls the solver once. Combines the objectives of all entities.
- class pycity_scheduling.algorithms.DerivativeFreeALADIN(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', eps_primal=0.001, eps_dual=0.001, rho=0.5, alpha=1.0, hessian_scaling=1.0, max_iterations=10000, robustness=None)
Bases:
IterationAlgorithm
,DistributedAlgorithm
Implementation of the distributed ALADIN algorithm. Specifically, this class implements the derivative-free ALADIN as described in [1].
- Parameters:
city_district (CityDistrict)
solver (str, optional) – Solver to use for solving (sub)problems.
solver_options (dict, optional) – Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve. __call__ is the function being called when generating an instance with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized. set_instance is called when a pyomo Model is set as an instance of a persistent solver. solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
mode (str, optional) – Specifies which set of constraints to use. - convex : Use linear constraints - integer : May use non-linear constraints
eps_primal (float, optional) – Primal stopping criterion for the ALADIN algorithm.
eps_dual (float, optional) – Dual stopping criterion for the ALADIN algorithm.
rho (float, optional) – Penalty term parameter for the ALADIN algorithm.
alpha (float, optional) – Step size parameter for the ALADIN algorithm.
max_iterations (int, optional) – Maximum number of ALADIN iterations.
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
References
[1] “Distributed Optimization and Control with ALADIN” by Boris Houska and Yuning Jiang Online: https://faculty.sist.shanghaitech.edu.cn/faculty/boris/paper/AladinChapter.pdf (accessed on 2024/02/13)
- class pycity_scheduling.algorithms.DerivativeFreeALADINRay(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', eps_primal=0.001, eps_dual=0.001, rho=0.5, alpha=1.0, hessian_scaling=1.0, max_iterations=10000, robustness=None, ray_cpu_count=None)
Bases:
IterationAlgorithm
,DistributedAlgorithm
Implementation of the distributed ALADIN algorithm using ray.io parallelization. Specifically, this class implements the derivative-free ALADIN as described in [1].
- Parameters:
city_district (CityDistrict)
solver (str, optional) – Solver to use for solving (sub)problems.
solver_options (dict, optional) – Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve. __call__ is the function being called when generating an instance with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized. set_instance is called when a pyomo Model is set as an instance of a persistent solver. solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
mode (str, optional) – Specifies which set of constraints to use. - convex : Use linear constraints - integer : May use non-linear constraints
eps_primal (float, optional) – Primal stopping criterion for the ALADIN algorithm.
eps_dual (float, optional) – Dual stopping criterion for the ALADIN algorithm.
rho (float, optional) – Penalty term parameter for the ALADIN algorithm.
alpha (float, optional) – Step size parameter for the ALADIN algorithm.
max_iterations (int, optional) – Maximum number of ALADIN iterations.
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
ray_cpu_count (int, optional) – Number of CPU cores to be used by ray for parallelization. Default: Detect the number of CPUs automatically.
References
[1] “Distributed Optimization and Control with ALADIN” by Boris Houska and Yuning Jiang Online: https://faculty.sist.shanghaitech.edu.cn/faculty/boris/paper/AladinChapter.pdf (accessed on 2024/02/13)
- class pycity_scheduling.algorithms.DerivativeFreeALADINRay_Hvet(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', eps_primal=0.001, eps_dual=0.001, rho=0.5, alpha=1.0, hessian_scaling=1.0, max_iterations=10000, robustness=None, ray_cpu_count=None)
Bases:
IterationAlgorithm
,DistributedAlgorithm
Implementation of the distributed ALADIN algorithm using ray.io parallelization and an improved implementation for sparse Hessian matrices and gradients. Specifically, this class implements the derivative-free ALADIN as described in [1].
- Parameters:
city_district (CityDistrict)
solver (str, optional) – Solver to use for solving (sub)problems.
solver_options (dict, optional) – Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve. __call__ is the function being called when generating an instance with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized. set_instance is called when a pyomo Model is set as an instance of a persistent solver. solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
mode (str, optional) – Specifies which set of constraints to use. - convex : Use linear constraints - integer : May use non-linear constraints
eps_primal (float, optional) – Primal stopping criterion for the ALADIN algorithm.
eps_dual (float, optional) – Dual stopping criterion for the ALADIN algorithm.
rho (float, optional) – Penalty term parameter for the ALADIN algorithm.
alpha (float, optional) – Step size parameter for the ALADIN algorithm.
max_iterations (int, optional) – Maximum number of ALADIN iterations.
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
ray_cpu_count (int, optional) – Number of CPU cores to be used by ray for parallelization. Default: Detect the number of CPUs automatically.
References
[1] “Distributed Optimization and Control with ALADIN” by Boris Houska and Yuning Jiang Online: https://faculty.sist.shanghaitech.edu.cn/faculty/boris/paper/AladinChapter.pdf (accessed on 2024/02/13)
- class pycity_scheduling.algorithms.DualDecomposition(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', eps_primal=0.1, rho=2.0, max_iterations=10000, robustness=None)
Bases:
IterationAlgorithm
,DistributedAlgorithm
Implementation of the distributed Dual Decomposition algorithm as described in [1].
- Parameters:
city_district (CityDistrict)
solver (str, optional) – Solver to use for solving (sub)problems.
solver_options (dict, optional) – Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve. __call__ is the function being called when generating an instance with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized. set_instance is called when a pyomo Model is set as an instance of a persistent solver. solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
mode (str, optional) – Specifies which set of constraints to use. - convex : Use linear constraints - integer : May use non-linear constraints
eps_primal (float, optional) – Primal stopping criterion for the dual decomposition algorithm.
rho (float, optional) – Step size for the dual decomposition algorithm.
max_iterations (int, optional) – Maximum number of ADMM iterations.
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
References
[1] “Distributed Optimization for Scheduling Electrical Demand in Complex City Districts” by M. Diekerhof, S. Schwarz, F. Martin, A. Monti in IEEE Systems Journal, vol. 12, no. 4, pp. 3226-3237, Dec. 2018.
- class pycity_scheduling.algorithms.DualDecompositionMPI(city_district, mpi_interface, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', eps_primal=0.1, rho=2.0, max_iterations=10000, robustness=None)
Bases:
IterationAlgorithm
,DistributedAlgorithm
Implementation of the distributed Dual Decomposition algorithm as described in [1] using parallel computations with MPI.
- Parameters:
city_district (CityDistrict)
mpi_interface (MPIInterface) – MPI Interface to use for solving the Dual Decomposition subproblems in parallel.
solver (str, optional) – Solver to use for solving the (sub)problems.
solver_options (dict, optional) – Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve. __call__ is the function being called when generating an instance with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized. set_instance is called when a pyomo Model is set as an instance of a persistent solver. solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
mode (str, optional) – Specifies which set of constraints to use. - convex : Use linear constraints - integer : May use non-linear constraints
eps_primal (float, optional) – Primal stopping criterion for the dual decomposition algorithm.
rho (float, optional) – Step size for the dual decomposition algorithm.
max_iterations (int, optional) – Maximum number of dual decomposition iterations.
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
References
[1] “Distributed Optimization for Scheduling Electrical Demand in Complex City Districts” by M. Diekerhof, S. Schwarz, F. Martin, A. Monti in IEEE Systems Journal, vol. 12, no. 4, pp. 3226-3237, Dec. 2018.
- class pycity_scheduling.algorithms.DualDecompositionRay(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', eps_primal=0.1, rho=2.0, max_iterations=10000, robustness=None, ray_cpu_count=None)
Bases:
IterationAlgorithm
,DistributedAlgorithm
Implementation of the distributed Dual Decomposition algorithm using ray.io parallelization.
- Parameters:
city_district (CityDistrict)
solver (str, optional) – Solver to use for solving (sub)problems.
solver_options (dict, optional) – Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve. __call__ is the function being called when generating an instance with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized. set_instance is called when a pyomo Model is set as an instance of a persistent solver. solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
mode (str, optional) – Specifies which set of constraints to use. - convex : Use linear constraints - integer : May use non-linear constraints
eps_primal (float, optional) – Primal stopping criterion for the dual decomposition algorithm.
rho (float, optional) – Step size for the dual decomposition algorithm.
max_iterations (int, optional) – Maximum number of ADMM iterations.
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
ray_cpu_count (int, optional) – Number of CPU cores to be used by ray for parallelization. Default: Detect the number of CPUs automatically.
- class pycity_scheduling.algorithms.ExchangeADMM(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', eps_primal=0.1, eps_dual=1.0, rho=2.0, max_iterations=10000, robustness=None)
Bases:
IterationAlgorithm
,DistributedAlgorithm
Implementation of the distributed ADMM algorithm. This class implements the Exchange ADMM as described in [1] and [2].
- Parameters:
city_district (CityDistrict)
solver (str, optional) – Solver to use for solving (sub)problems.
solver_options (dict, optional) – Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve. __call__ is the function being called when generating an instance with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized. set_instance is called when a pyomo Model is set as an instance of a persistent solver. solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
mode (str, optional) – Specifies which set of constraints to use. - convex : Use linear constraints - integer : May use non-linear constraints
eps_primal (float, optional) – Primal stopping criterion for the ADMM algorithm.
eps_dual (float, optional) – Dual stopping criterion for the ADMM algorithm.
rho (float, optional) – Step size for the ADMM algorithm.
max_iterations (int, optional) – Maximum number of ADMM iterations.
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
References
[1] “Alternating Direction Method of Multipliers for Decentralized Electric Vehicle Charging Control” by Jose Rivera, Philipp Wolfrum, Sandra Hirche, Christoph Goebel, and Hans-Arno Jacobsen Online: https://mediatum.ub.tum.de/doc/1187583/1187583.pdf (accessed on 2020/09/28)
[2] “Distributed Optimization and Statistical Learning via the Alternating Direction Method of Multipliers” by Stephen Boyd, Neal Parikh, Eric Chu, Borja Peleato, and Jonathan Eckstein Online: https://web.stanford.edu/~boyd/papers/pdf/admm_distr_stats.pdf (accessed on 2023/10/09)
- class pycity_scheduling.algorithms.ExchangeADMMMPI(city_district, mpi_interface, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', eps_primal=0.1, eps_dual=1.0, rho=2.0, max_iterations=10000, robustness=None)
Bases:
IterationAlgorithm
,DistributedAlgorithm
Implementation of the distributed ADMM algorithm using parallel computations with MPI. This class implements the Exchange ADMM as described in [1] and [2].
- Parameters:
city_district (CityDistrict)
mpi_interface (MPIInterface) – MPI Interface to use for solving the Exchange ADMM subproblems in parallel.
solver (str, optional) – Solver to use for solving (sub)problems.
solver_options (dict, optional) – Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve. __call__ is the function being called when generating an instance with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized. set_instance is called when a pyomo Model is set as an instance of a persistent solver. solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
mode (str, optional) – Specifies which set of constraints to use. - convex : Use linear constraints - integer : May use non-linear constraints
eps_primal (float, optional) – Primal stopping criterion for the ADMM algorithm.
eps_dual (float, optional) – Dual stopping criterion for the ADMM algorithm.
rho (float, optional) – Step size for the ADMM algorithm.
max_iterations (int, optional) – Maximum number of ADMM iterations.
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
References
[1] “Alternating Direction Method of Multipliers for Decentralized Electric Vehicle Charging Control” by Jose Rivera, Philipp Wolfrum, Sandra Hirche, Christoph Goebel, and Hans-Arno Jacobsen Online: https://mediatum.ub.tum.de/doc/1187583/1187583.pdf (accessed on 2020/09/28)
[2] “Distributed Optimization and Statistical Learning via the Alternating Direction Method of Multipliers” by Stephen Boyd, Neal Parikh, Eric Chu, Borja Peleato, and Jonathan Eckstein Online: https://web.stanford.edu/~boyd/papers/pdf/admm_distr_stats.pdf (accessed on 2023/10/09)
- class pycity_scheduling.algorithms.ExchangeADMMRay(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', eps_primal=0.1, eps_dual=1.0, rho=2.0, max_iterations=10000, robustness=None, ray_cpu_count=None)
Bases:
IterationAlgorithm
,DistributedAlgorithm
Implementation of the distributed ADMM algorithm using ray.io parallelization. This class implements the Exchange ADMM as described in [1].
- Parameters:
city_district (CityDistrict)
solver (str, optional) – Solver to use for solving (sub)problems.
solver_options (dict, optional) – Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve. __call__ is the function being called when generating an instance with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized. set_instance is called when a pyomo Model is set as an instance of a persistent solver. solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
mode (str, optional) – Specifies which set of constraints to use. - convex : Use linear constraints - integer : May use non-linear constraints
eps_primal (float, optional) – Primal stopping criterion for the ADMM algorithm.
eps_dual (float, optional) – Dual stopping criterion for the ADMM algorithm.
rho (float, optional) – Step size for the ADMM algorithm.
max_iterations (int, optional) – Maximum number of ADMM iterations.
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
ray_cpu_count (int, optional) – Number of CPU cores to be used by ray for parallelization. Default: Detect the number of CPUs automatically.
References
[1] “Alternating Direction Method of Multipliers for Decentralized Electric Vehicle Charging Control” by Jose Rivera, Philipp Wolfrum, Sandra Hirche, Christoph Goebel, and Hans-Arno Jacobsen Online: https://mediatum.ub.tum.de/doc/1187583/1187583.pdf (accessed on 2020/09/28)
[2] “Distributed Optimization and Statistical Learning via the Alternating Direction Method of Multipliers” by Stephen Boyd, Neal Parikh, Eric Chu, Borja Peleato, and Jonathan Eckstein Online: https://web.stanford.edu/~boyd/papers/pdf/admm_distr_stats.pdf (accessed on 2023/10/09)
- class pycity_scheduling.algorithms.ExchangeMIQPADMM(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', x_update_mode='constrained', eps_exch_primal=0.01, eps_exch_dual=0.1, gamma=1.0, gamma_incr=1.0, rho=2.0, varying_penalty_parameter=False, tau_incr=2.0, tau_decr=2.0, mu=10.0, max_iterations=10000, robustness=None)
Bases:
IterationAlgorithm
,DistributedAlgorithm
Implementation of the Exchange MIQP ADMM algorithm.
Implements the Exchange MIQP ADMM algorithm described in [1], [2], and [3].
- Parameters:
city_district (CityDistrict)
solver (str, optional) – Solver to use for solving (sub)problems.
solver_options (dict, optional) – Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve. __call__ is the function being called when generating an instance with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized. set_instance is called when a pyomo Model is set as an instance of a persistent solver. solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
mode (str, optional) – Specifies which set of constraints to use. - convex : Use linear constraints - integer : May use non-linear constraints
eps_exch_primal (float, optional) – Primal stopping criterion for the ADMM algorithm.
eps_exch_dual (float, optional) – Dual stopping criterion for the ADMM algorithm.
gamma (float, optional) – Exchange MIQP ADMM scaling parameter
gamma_incr (float, optional) – Varying scaling parameter scheme increase parameter
rho (float, optional) – Stepsize for the ADMM algorithm.
varying_penalty_parameter (bool, optional) – Apply a varying penalty parameter scheme, see [3] - chapter 3.4.1
tau_incr (float, optional) – Varying penalty parameter scheme increase parameter
tau_decr (float, optional) – Varying penalty parameter scheme decrease parameter
mu (float, optional) – Varying penalty parameter scheme conditional change parameter
max_iterations (int, optional) – Maximum number of ADMM iterations.
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
References
[1] “Alternating Direction Method of Multipliers for Decentralized Electric Vehicle Charging Control” by Jose Rivera, Philipp Wolfrum, Sandra Hirche, Christoph Goebel, and Hans-Arno Jacobsen Online: https://mediatum.ub.tum.de/doc/1187583/1187583.pdf (accessed on 2020/09/28)
[2] “A simple effective heuristic for embedded mixed-integer quadratic programming” by Reza Takapoui, Nicholas Moehle, Stephen Boyd, and Alberto Bemporad Online: https://web.stanford.edu/~boyd/papers/pdf/miqp_admm.pdf (accessed on 2023/09/06)
[3] “Distributed Optimization and Statistical Learning via the Alternating Direction Method of Multipliers” by Stephen Boyd, Neal Parikh, Eric Chu, Borja Peleato, and Jonathan Eckstein Online: https://web.stanford.edu/~boyd/papers/pdf/admm_distr_stats.pdf (accessed on 2023/10/09)
Methods
activate_constraints
deactivate_constraints
fix_variables
print_model
release_variables
- activate_constraints()
- deactivate_constraints()
- fix_variables()
- print_model()
- release_variables()
- class pycity_scheduling.algorithms.ExchangeMIQPADMMMPI(city_district, mpi_interface, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', x_update_mode='constrained', eps_exch_primal=0.01, eps_exch_dual=0.1, gamma=1.0, gamma_incr=1.0, rho=2.0, varying_penalty_parameter=False, tau_incr=2.0, tau_decr=2.0, mu=10.0, max_iterations=10000, robustness=None)
Bases:
IterationAlgorithm
,DistributedAlgorithm
Implementation of the Exchange MIQP ADMM algorithm.
Implements the Exchange MIQP ADMM algorithm described in [1], [2], and [3] using parallel computations with MPI.
- Parameters:
city_district (CityDistrict)
mpi_interface (MPIInterface) – MPI Interface to use for solving the MIQP ADMM subproblems in parallel.
solver (str, optional) – Solver to use for solving (sub)problems.
solver_options (dict, optional) – Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve. __call__ is the function being called when generating an instance with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized. set_instance is called when a pyomo Model is set as an instance of a persistent solver. solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
mode (str, optional) – Specifies which set of constraints to use. - convex : Use linear constraints - integer : May use non-linear constraints
eps_exch_primal (float, optional) – Primal stopping criterion for the ADMM algorithm.
eps_exch_dual (float, optional) – Dual stopping criterion for the ADMM algorithm.
gamma (float, optional) – Exchange MIQP ADMM scaling parameter
gamma_incr (float, optional) – Varying scaling parameter scheme increase parameter
rho (float, optional) – Stepsize for the ADMM algorithm.
varying_penalty_parameter (bool, optional) – Apply a varying penalty parameter scheme, see [3] - chapter 3.4.1
tau_incr (float, optional) – Varying penalty parameter scheme increase parameter
tau_decr (float, optional) – Varying penalty parameter scheme decrease parameter
mu (float, optional) – Varying penalty parameter scheme conditional change parameter
max_iterations (int, optional) – Maximum number of ADMM iterations.
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
References
[1] “Alternating Direction Method of Multipliers for Decentralized Electric Vehicle Charging Control” by Jose Rivera, Philipp Wolfrum, Sandra Hirche, Christoph Goebel, and Hans-Arno Jacobsen Online: https://mediatum.ub.tum.de/doc/1187583/1187583.pdf (accessed on 2020/09/28)
[2] “A simple effective heuristic for embedded mixed-integer quadratic programming” by Reza Takapoui, Nicholas Moehle, Stephen Boyd, and Alberto Bemporad Online: https://web.stanford.edu/~boyd/papers/pdf/miqp_admm.pdf (accessed on 2023/09/06)
[3] “Distributed Optimization and Statistical Learning via the Alternating Direction Method of Multipliers” by Stephen Boyd, Neal Parikh, Eric Chu, Borja Peleato, and Jonathan Eckstein Online: https://web.stanford.edu/~boyd/papers/pdf/admm_distr_stats.pdf (accessed on 2023/10/09)
Methods
activate_constraints
deactivate_constraints
fix_variables
print_model
release_variables
- activate_constraints()
- deactivate_constraints()
- fix_variables()
- print_model()
- release_variables()
- class pycity_scheduling.algorithms.ExchangeMIQPADMMRay(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', x_update_mode='constrained', eps_exch_primal=0.01, eps_exch_dual=0.1, gamma=1.0, gamma_incr=1.0, rho=2.0, varying_penalty_parameter=False, tau_incr=2.0, tau_decr=2.0, mu=10.0, max_iterations=10000, robustness=None, ray_cpu_count=None)
Bases:
IterationAlgorithm
,DistributedAlgorithm
Implementation of the Exchange MIQP ADMM algorithm.
Implements the Exchange MIQP ADMM algorithm described in [1], [2], and [3] using parallel computations with Ray.
- Parameters:
city_district (CityDistrict)
solver (str, optional) – Solver to use for solving (sub)problems.
solver_options (dict, optional) – Options to pass to calls to the solver. Keys are the name of the functions being called and are one of __call__, set_instance_, solve. __call__ is the function being called when generating an instance with the pyomo SolverFactory. In addition to the options provided, node_ids is passed to this call containing the IDs of the entities being optimized. set_instance is called when a pyomo Model is set as an instance of a persistent solver. solve is called to perform an optimization. If not set, save_results and load_solutions may be set to false to provide a speedup.
mode (str, optional) – Specifies which set of constraints to use. - convex : Use linear constraints - integer : May use non-linear constraints
eps_exch_primal (float, optional) – Primal stopping criterion for the ADMM algorithm.
eps_exch_dual (float, optional) – Dual stopping criterion for the ADMM algorithm.
gamma (float, optional) – Exchange MIQP ADMM scaling parameter
gamma_incr (float, optional) – Varying scaling parameter scheme increase parameter
rho (float, optional) – Stepsize for the ADMM algorithm.
varying_penalty_parameter (bool, optional) – Apply a varying penalty parameter scheme, see [3] - chapter 3.4.1
tau_incr (float, optional) – Varying penalty parameter scheme increase parameter
tau_decr (float, optional) – Varying penalty parameter scheme decrease parameter
mu (float, optional) – Varying penalty parameter scheme conditional change parameter
max_iterations (int, optional) – Maximum number of ADMM iterations.
robustness (tuple, optional) – Tuple of two floats. First entry defines how many time steps are protected from deviations. Second entry defines the magnitude of deviations which are considered.
ray_cpu_count (int, optional) – Number of CPU cores to be used by ray for parallelization. Default: Detect the number of CPUs automatically.
References
[1] “Alternating Direction Method of Multipliers for Decentralized Electric Vehicle Charging Control” by Jose Rivera, Philipp Wolfrum, Sandra Hirche, Christoph Goebel, and Hans-Arno Jacobsen Online: https://mediatum.ub.tum.de/doc/1187583/1187583.pdf (accessed on 2020/09/28)
[2] “A simple effective heuristic for embedded mixed-integer quadratic programming” by Reza Takapoui, Nicholas Moehle, Stephen Boyd, and Alberto Bemporad Online: https://web.stanford.edu/~boyd/papers/pdf/miqp_admm.pdf (accessed on 2023/09/06)
[3] “Distributed Optimization and Statistical Learning via the Alternating Direction Method of Multipliers” by Stephen Boyd, Neal Parikh, Eric Chu, Borja Peleato, and Jonathan Eckstein Online: https://web.stanford.edu/~boyd/papers/pdf/admm_distr_stats.pdf (accessed on 2023/10/09)
Methods
activate_constraints
deactivate_constraints
fix_variables
release_variables
- activate_constraints()
- deactivate_constraints()
- fix_variables()
- release_variables()
- class pycity_scheduling.algorithms.LocalOptimization(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', robustness=None)
Bases:
DistributedAlgorithm
Implementation of the reference Local Optimization algorithm.
Schedule all nodes (i.e., buildings) in city_district on their own.
- class pycity_scheduling.algorithms.StandAlone(city_district, solver='gurobi_persistent', solver_options={'solve': {'options': {'LogToConsole': 0, 'Logfile': '', 'MIPGap': 0.0001, 'Method': -1, 'OutputFlag': 0, 'TimeLimit': 86400}}}, mode='convex', robustness=None)
Bases:
LocalOptimization
Implementation of the reference Stand-alone Optimization algorithm.
Schedule all entities (i.e., devices) in city_district on their own.