Opened 6 years ago

Closed 4 years ago

#5171 closed defect (fixed)

EvaluateFunctions.getStatementLHSScalar generates too large lists

Reported by: perost Owned by: vwaurich
Priority: high Milestone: 1.16.0
Component: Backend Version: v1.13.0-dev-nightly
Keywords: Cc: m.thorade@…

Description

There seems to be some issues with how EvaluateFunctions.getStatementLHSScalar generates the list of assigned scalars in a statement. This affects the HelmholtzMedia library in particular, for example the model HelmholtzMedia.Examples.ConvergenceTest.SinglePhase_setState_b (note: only works with -d=newInst).

SinglePhase_setState_b uses the function HelmholtzMedia.Interfaces.PartialHelmholtzMedium which contains two large if-statements. When EvaluateFunctions.evaluateFunctions_updateStatement processes the second of these if-statements it uses getStatementLHSScalar to generate a list of outputs (currently EvaluateFunctions.mo:2664):

  lhs_expl := List.fold1(statements, getStatementLHSScalar, funcTree, {});

This generates a list of 2,874,978 expressions, which seems a bit excessive. Obviously this causes the compiler to slow to a crawl, and this is just one of many such lists generated by getStatementLHSScalar. The list of outputs generated seem to be full of gibberish such as f.rt.r.i.liq.s.rd.rt.r.it.liq.d.Tsat.Tsat, which I assume isn't intended.

(I optimized the code a bit in 765d7e8 since List.unique would otherwise take forever on the large lists generated, but the huge lists generated are still a big issue.)

Change History (4)

comment:1 Changed 6 years ago by casella

  • Cc m.thorade@… added

comment:2 Changed 6 years ago by perost

Possibly fixed in 14f391f, we'll see what the outcome of the library testing is. The largest generated list now contains 129 elements, rather than close to 3 million. But instead of running out of time or memory like before the mentioned model now triggers a stack overflow, so there's still some issues when it comes to HelmholtzMedia.

comment:3 Changed 4 years ago by matthis.thorade@…

comment:4 Changed 4 years ago by casella

  • Milestone changed from Future to 1.16.0
  • Resolution set to fixed
  • Status changed from new to closed

I guess we can close this ticket.

Regarding the initialization issues, you may want to wait until #5770 is fixed.

Note: See TracTickets for help on using tickets.