Commit fca79f10 authored by Teresa Piovesan's avatar Teresa Piovesan

Check that initial state is within bounds

Ensure that constraints added to the states at t0 are sane. Else the problem is
infeasible.
parent 206dc3cb
......@@ -976,6 +976,10 @@ class CollocatedIntegratedOptimizationProblem(OptimizationProblem, metaclass=ABC
initial_state_constraint_states.append(sym)
val = self.interpolate(
t0, history_timeseries.times, history_timeseries.values, np.nan, np.nan)
if val < self.bounds()[variable][0] or val > self.bounds()[variable][1]:
raise Exception(
"Variable {} has an initial state {} which is not within the bounds [{},{}]"
.format(variable, val, self.bounds()[variable][0], self.bounds()[variable][1]))
val /= self.variable_nominal(variable)
initial_state_constraint_values.append(val)
......
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