Commit b9a30ca4 authored by Tjerk Vreeken's avatar Tjerk Vreeken

Fix failing constraint() call before optimize()

When using GoalProgrammingMixin, it was not possible to call constraint()
or path_constraints() in e.g. pre(). This is because the subproblem
constraint variables were not fully initialized yet; they were not
indexable with "ensemble_member". Only when optimize() was called were
the variables properly initialized.
parent 5b1d8e4e
......@@ -17,6 +17,16 @@ from .timeseries import Timeseries
logger = logging.getLogger("rtctools")
class _EmptyEnsembleList(list):
An indexable object containing infinitely many empty lists.
Only to be used as a placeholder.
def __getitem__(self, key):
return []
class Goal(metaclass=ABCMeta):
Base class for lexicographic goal programming goals.
......@@ -316,8 +326,8 @@ class GoalProgrammingMixin(OptimizationProblem, metaclass=ABCMeta):
self.__subproblem_path_epsilons = []
self.__subproblem_path_timeseries = []
self.__subproblem_objectives = []
self.__subproblem_constraints = []
self.__subproblem_path_constraints = []
self.__subproblem_constraints = _EmptyEnsembleList()
self.__subproblem_path_constraints = _EmptyEnsembleList()
self.__original_constant_input_keys = {}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment