Commit b44ea5f3 authored by Jorn Baayen's avatar Jorn Baayen

ModelicaMixin: Check binding attributes of aliases of constant inputs, as the...

ModelicaMixin:  Check binding attributes of aliases of constant inputs, as the original constant input symbol may have been eliminated.
parent 15446de0
...@@ -477,19 +477,17 @@ class ModelicaMixin(OptimizationProblem): ...@@ -477,19 +477,17 @@ class ModelicaMixin(OptimizationProblem):
times = self.times() times = self.times()
for variable in self._mx['constant_inputs']: for variable in self._mx['constant_inputs']:
variable = variable.getName() variable = variable.getName()
var = self._jm_model.getVariable(variable) for alias in self._alias_relation.aliases(variable):
if var.hasAttributeSet('bindingExpression'): var = self._jm_model.getVariable(alias)
value = var.getAttribute('bindingExpression') if var.hasAttributeSet('bindingExpression'):
if not value.isConstant(): value = var.getAttribute('bindingExpression')
[value] = substitute([value], self._mx['parameters'], parameter_values) if not value.isConstant():
constant_inputs[variable] = Timeseries( [value] = substitute([value], self._mx['parameters'], parameter_values)
times, repmat([value], len(times))) constant_inputs[alias] = Timeseries(
if logger.getEffectiveLevel() == logging.DEBUG: times, repmat([value], len(times)))
logger.debug("Read constant input {} from Modelica model".format( if logger.getEffectiveLevel() == logging.DEBUG:
variable)) logger.debug("Read constant input {} from Modelica model".format(
else: alias))
# Value will be provided by a subclass.
pass
return constant_inputs return constant_inputs
......
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