Help - Search - Members - Calendar
Full Version: Mauss: "Modelica Instance Creation"
Modelica Forum > Modelica > Modelica
mr_mitch
Hi everybody!
Currently, I am working on a Java library to process Modelica models. An important part in this is creating instances. Jakob Mauss presented an excellent article on this during the Modelica Conference 2005 (see http://www.modelica.org/events/Conference2...Session6c1.pdf). I ran into a problem implementing his approach however. If anyone of you guys can help me on this I'll be happy to hear from you.

In his paper, Mauss presents the procedure qualify() on page 514. It is meant to take an unqualified Modification and return a qualified one. For that, each Reference has to be replaced "by either a qualified reference QRef or a Class". My question is the following: Which field and what class is best suited to store them?
In the UML diagram he shows on the first page, ElementModification has a field ref of type Reference. A simple approach is to make this field an Object, which then allows to carry along the original Reference, but also QRef or Class.
Another approach is to create new classes such as qualified modification, QMod, and qualified element modification, QElementMod, with additional fields.

Does anyone have some remarks on this? My major is not computer science but engineering, so perhaps a solution is not so far away...

For now, I started implementing the first approach (using a field "Object ref" in ElementModification), but right now I am busy debugging the code as I run into unwanted infinite recursive loops...

Thanks,

Michael
mr_mitch
Hi,
I tried to understand the problems I am having with the first approach (making the field ref in ElementModification an Object).
The problem arises when I elaborate Ele1000 as listed in the Mauss paper. Check this out:
1) To add an elaborated version of each base class (here: Ele), I first have to get the base class via getClass()
2) In getClass(), I have to qualify the Modification of the extend clause, which is (Resistor.r = 1000)
3) In qualify(), I have to look up the Reference of each unqualified modification. Here, the Reference is Resistor.r.
4) Looking the Reference (Resistor.r) up, means first looking up the identifier (Resistor).
5) When looking up the identifier (Resistor) we realize that the class (Ele100) only comes with a single extends clause and no element with the given identifier (Resistor). Therefore, we look at the base classes given by extends clauses and find Ele as one of them. In order to look for the identifier (Resistor) in it, we have to get the base class. This is done via getClass(), taking us back to step 2).

My current implementation therefore results in an infinite loop. Does someone have some remarks on this? My problem are somehow related to qualify(), I am afraid.

I attach a more detailed explanation of the steps given above. It's in one of those weird Microsoft formats, open it with Internet Explorer where available (I tried OneNote today.....)

Thanks and regards MICHAEL
mr_mitch
Hi,
After finding my mistake I feel that I should add some explanations here, too. rolleyes.gif
As I already suspected, my mistake was in qualify() and in the concept of a qualified modification. When qualifying the modification (a=expr1, b=expr2)=expr3 only the expressions expr1, expr2, and expr3 have to be qualified, not the identifiers/references a and b.
Using the example given by Mauss in his paper, the qualified modification should be (Reference(id="r" next=null) = QRef(host = x, ref = "r2k")) and not as I suspected in my first posting (QRef(host = x, ref = "r") = QRef(host = x, ref = "r2k")).
This, of course, makes a lot of sense when you think about it --- but I did not get it initially. I hope that this explanation makes it clear to everybody else, too.

Regards MICHAEL
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.