I have a String Parameter with index domain “i” called “ModPrefix” containing prefixes of modules within my project. Each of this modules has a variable with the name “Q”. Now, I would like to access these variables within the definition of a Node called “FacilityNode” like
NetOutflow = ModPrefix(i)::Q
However, this leads to the error
The identifier "Q" has not been declared, but it is declared in the modules [...].
where I replaced the names of the modules with “[...]”.
My idea of a workaround was an if-then-else-statement like
if ( ModPrefix(i) = "prefix1" ) then
elseif ( ModPrefix(i) = "prefix2" ) then
in the case of two modules with prefixes “prefix1” and “prefix2”. However, I would still like to know if there is a way to circumvent it-then-else-statements, since they become ugly in the case of many modules.
Best answer by Chris KuipView original
Hope this helps:
@Chris Kuip !
I forgot to mention that this variable Q is time-dependent, i.e. it is associated with an index “t”. If I use
then I do not get an error but it does not seem to work either, since the variables Q do not appear in the Math Program Inspector. Apparently, they are not added to the model at all. Do you know why?
You will need to create runtime identifiers, and the identifiers should be of type constraint.
Please check out:
With kind regards,