Commit 62b2f760 authored by Jesse VanderWees's avatar Jesse VanderWees 🐘

Merge branch 'master' of https://gitlab.com/deltares/rtc-tools into improve_examples

# Conflicts:
#	rtctools/optimization/collocated_integrated_optimization_problem.pyx
parents b72a0e00 e5692adf
build
\ No newline at end of file
build
*.pyc
*.so
*.c
\ No newline at end of file
......@@ -153,8 +153,7 @@ class ControlTreeMixin(OptimizationProblem):
# (variable, (ensemble member, step)) -> control_index
self._control_indices = {}
count = 0
for control_input in self.dae_variables['control_inputs']:
control_input = control_input.getName()
for control_input in self.controls:
times = self.times(control_input)
self._control_indices[control_input] = np.zeros(
(self.ensemble_size, len(times)), dtype=np.int16)
......@@ -186,9 +185,7 @@ class ControlTreeMixin(OptimizationProblem):
for ensemble_member in range(self.ensemble_size):
seed = self.seed(ensemble_member)
for variable in self.dae_variables['control_inputs']:
variable = variable.getName()
for variable in self.controls:
times = self.times(variable)
discrete[self._control_indices[variable][
......@@ -234,8 +231,7 @@ class ControlTreeMixin(OptimizationProblem):
# Extract control inputs
results = {}
for variable in self.dae_variables['control_inputs']:
variable = variable.getName()
for variable in self.controls:
results[variable] = np.array(self.variable_nominal(
variable) * X[self._control_indices[variable][ensemble_member, :], 0]).ravel()
......@@ -255,8 +251,7 @@ class ControlTreeMixin(OptimizationProblem):
t0 = self.initial_time
X = self.solver_input
for control_input in self.dae_variables['control_inputs']:
control_input = control_input.getName()
for control_input in self.controls:
times = self.times(control_input)
for alias in self.variable_aliases(control_input):
if alias.name == variable:
......
......@@ -303,7 +303,11 @@ class ModelicaMixin(OptimizationProblem):
try:
return self._aliases[variable]
except KeyError:
return [Alias(variable, False)]
# We do not use setdefault() here, as we would then always allocate
# the alias and the list, even if they would not be required.
l = [Alias(variable, False)]
self._aliases[variable] = l
return l
def variable_nominal(self, variable):
return self._nominals.get(variable, 1)
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