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):
times = self.times()
for variable in self._mx['constant_inputs']:
variable = variable.getName()
var = self._jm_model.getVariable(variable)
if var.hasAttributeSet('bindingExpression'):
value = var.getAttribute('bindingExpression')
if not value.isConstant():
[value] = substitute([value], self._mx['parameters'], parameter_values)
constant_inputs[variable] = Timeseries(
times, repmat([value], len(times)))
if logger.getEffectiveLevel() == logging.DEBUG:
logger.debug("Read constant input {} from Modelica model".format(
variable))
else:
# Value will be provided by a subclass.
pass
for alias in self._alias_relation.aliases(variable):
var = self._jm_model.getVariable(alias)
if var.hasAttributeSet('bindingExpression'):
value = var.getAttribute('bindingExpression')
if not value.isConstant():
[value] = substitute([value], self._mx['parameters'], parameter_values)
constant_inputs[alias] = Timeseries(
times, repmat([value], len(times)))
if logger.getEffectiveLevel() == logging.DEBUG:
logger.debug("Read constant input {} from Modelica model".format(
alias))
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