Skip to content

Commit

Permalink
[NB] update record parameter bindings (#11871)
Browse files Browse the repository at this point in the history
- do not create record element binding equations if the record itself is bound to avoid duplicate binding equations
  • Loading branch information
kabdelhak committed Jan 24, 2024
1 parent 00dc993 commit 6707167
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions OMCompiler/Compiler/NBackEnd/Modules/1_Main/NBInitialization.mo
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,18 @@ public
protected
list<Pointer<Equation>> parameter_eqs = {};
list<Pointer<Variable>> initial_param_vars = {};
Pointer<Variable> parent;
Boolean skip_record_element;
algorithm

for var in VariablePointers.toList(parameters) loop

// check if the variable is a record element with bound parent
skip_record_element := match BVariable.getParent(var)
case SOME(parent) then BVariable.isBound(parent);
else false;
end match;

// parse records slightly different
if BVariable.isKnownRecord(var) then
// only consider non constant parameter bindings
Expand All @@ -268,8 +277,8 @@ public
end for;
end if;

// all other variables that are not records
elseif not BVariable.isRecord(var) then
// all other variables that are not records and not record elements to be skipped
elseif not (BVariable.isRecord(var) or skip_record_element) then
// only consider non constant parameter bindings
if (BVariable.getBindingVariability(var) > NFPrefixes.Variability.STRUCTURAL_PARAMETER) then
// add variable to initial unknowns
Expand Down

0 comments on commit 6707167

Please sign in to comment.