Opened 9 years ago

Closed 7 years ago

#3750 closed defect (worksforme)

Compilation Problem for model modifier with constrainedby and inheritance

Reported by: dongping Owned by: somebody
Priority: high Milestone: 1.12.0
Component: *unknown* Version: v1.9.4-dev-nightly
Keywords: Cc:

Description

Suppose we have model M1 which has a replaceable component C1, and M1 uses modifiers and constrainedby to specified the value of all the parameters.

M2 inherits from M1 and replaced C1 with C2. C2 has less parameters than C1. It shouldn't be a problem that the model M2 works, since M1 used constrainedby.

And OM-nightly works as it should.

However, a certain model M3 which uses C3 doesn't compile.

Problem details:

We have three different models:

  • ModelicaByExample.Architectures.ThermalControl.Examples.ExpandableModel (short 1_ExpandableModel)
  • A model which extends 1_ExpandableModel ModelicaByExample.Architectures.ThermalControl.Examples.OnOffVariant (short 2_OnOffVariant)
  • and then a model which extends 2_OnOffVariant ModelicaByExample.Architectures.ThermalControl.Examples.HysteresisVariant (short 3_HysteresisVariant)

The 1_ExpandableModel uses a replaceable component variant V1_ExpandablePIControl which has the most parameters, and 1_ExpandableModel specified them as following:

    redeclare replaceable Implementations.ExpandablePIControl
      controller(setpoint=300, k=20, T=1)
      constrainedby Interfaces.ControlSystem_WithExpandableBus);

Then 2_OnOffVariant uses a component V2_OnOffControl which has less parameters, and so far so good:

    redeclare replaceable
      Implementations.OnOffControl controller(setpoint=300));

Then 3_HysteresisVariant uses a component V3_OnOffControl_WithHysteresis, and somehow it doesn't work

  extends OnOffVariant(redeclare Implementations.OnOffControl_WithHysteresis
      controller(setpoint=300, bandwidth=1));

Here is the discussion with Mike Tiller and @perost for reference:
https://github.com/xogeny/ModelicaBook/pull/295

Bug Reproduction:

I failed to make a simplified version, so the I tried to make the reproduction step easier:

mkdir test_constrainedby && cd test_constrainedby
git clone https://github.com/xie-dongping/ModelicaBook && cd ModelicaBook 
git checkout modifier 
echo "loadFile(\"ModelicaByExample/package.mo\");simulate(ModelicaByExample.Architectures.ThermalControl.Examples.HysteresisVariant);" > test.mos
omc test.mos

and you can see the model doesn't work and the flattening failed.

If we remove the modifier, the incompatibility surely isn't a problem:

git checkout no_error
git diff modifier..no_error
omc test.mos

Surely, there are workarounds to make the model works, and I'm not sure if we had any misunderstanding about the specification. So I really would like to hear what you think. Thanks in advance!

Change History (5)

comment:1 Changed 9 years ago by dietmarw

  • Milestone changed from Future to 1.9.5

comment:2 Changed 9 years ago by sjoelund.se

  • Milestone changed from 1.9.5 to 1.10.0

Milestone renamed

comment:3 Changed 8 years ago by sjoelund.se

  • Milestone changed from 1.10.0 to 1.11.0

Ticket retargeted after milestone closed

comment:4 Changed 8 years ago by sjoelund.se

  • Milestone changed from 1.11.0 to 1.12.0

Milestone moved to 1.12.0 due to 1.11.0 already being released.

comment:5 Changed 7 years ago by casella

  • Resolution set to worksforme
  • Status changed from new to closed

I tried this test case with OpenModelica-v1.13.0-dev-63-g453e1c7-64bit and it worked fine.

Note: See TracTickets for help on using tickets.