Open cxbrooks opened 12 years ago
There was a bug where running
$PTII/ptolemy/data/ontologies/test/auto/MonotonicityAnalysis.xml
and then running
$PTII/ptolemy/data/ontologies/test/auto/MultiplyDivideUnits.xml
resulted in a stack trace:
Caused by: ptolemy.kernel.util.InternalErrorException: Because: Invalid dimension concept: Position in .TestUnitsSolver.TestUnitsOntology.Velocity at ptolemy.data.ontologies.OntologySolver.invokeSolver(OntologySolver.java:201)
In turns out the problem was objects are being adding to the static Constants Hashtable
The constructor to ptolemy/data/ontologies/lattice/adapters/monotonicityAnalysis/MonotonicityConceptFunction.java calls --start-- /** Add the concepts from the domain ontologies as constants
I updated OntologySolverBase to have:
public static void cleanConstants() {
RecordToken constants = Constants.constants();
System.out.println("OntologySolverBase: Constants: " + constants);
Set
The problem is that when we parse the second model, we check to see if a Constant is present.
For example, the two models share a Constant named "Position".
When I run the second model, I can see that parsing looks for Position:
java.lang.Exception: COnstant.get() Position
at ptolemy.data.expr.Constants.get(Constants.java:127)
at ptolemy.data.expr.ParseTreeEvaluator.visitLeafNode(ParseTreeEvaluator.java:708)
at ptolemy.data.expr.ASTPtLeafNode.visit(ASTPtLeafNode.java:125)
at ptolemy.data.expr.ParseTreeEvaluator.evaluateParseTree(ParseTreeEvaluator.java:105)
at ptolemy.data.expr.Variable._evaluate(Variable.java:1650)
at ptolemy.data.expr.Variable._propagate(Variable.java:1738)
at ptolemy.data.expr.Variable.validate(Variable.java:1436)
at ptolemy.moml.MoMLParser.endDocument(MoMLParser.java:802)
at com.microstar.xml.XmlParser.doParse(XmlParser.java:162)
at com.microstar.xml.XmlParser.parse(XmlParser.java:132)
at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1556)
at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1492)
at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1436)
at ptolemy.moml.MoMLParser._findOrParse(MoMLParser.java:5002)
at ptolemy.moml.MoMLParser._attemptToFindMoMLClass(MoMLParser.java:3870)
at ptolemy.moml.MoMLParser._createEntity(MoMLParser.java:4093)
at ptolemy.moml.MoMLParser.startElement(MoMLParser.java:2697)
at com.microstar.xml.XmlParser.parseElement(XmlParser.java:921)
at com.microstar.xml.XmlParser.parseContent(XmlParser.java:1104)
at com.microstar.xml.XmlParser.parseElement(XmlParser.java:924)
at com.microstar.xml.XmlParser.parseDocument(XmlParser.java:481)
at com.microstar.xml.XmlParser.doParse(XmlParser.java:159)
at com.microstar.xml.XmlParser.parse(XmlParser.java:132)
at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1540)
at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1492)
at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1436)
at ptolemy.moml.MoMLModelAttribute.configure(MoMLModelAttribute.java:179)
at ptolemy.data.ontologies.OntologySolver.configure(OntologySolver.java:131)
at ptolemy.moml.MoMLModelAttribute.attributeChanged(MoMLModelAttribute.java:135)
at ptolemy.data.expr.Variable._setTokenAndNotify(Variable.java:1998)
at ptolemy.data.expr.Variable._evaluate(Variable.java:1652)
at ptolemy.data.expr.Variable._propagate(Variable.java:1738)
at ptolemy.data.expr.Variable.validate(Variable.java:1436)
at ptolemy.moml.MoMLParser.endDocument(MoMLParser.java:802)
at com.microstar.xml.XmlParser.doParse(XmlParser.java:162)
at com.microstar.xml.XmlParser.parse(XmlParser.java:132)
at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1540)
at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1492)
at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1436)
at ptolemy.moml.MoMLSimpleApplication.<init>(MoMLSimpleApplication.java:115)
at ptolemy.moml.MoMLSimpleApplication.main(MoMLSimpleApplication.java:280)
ptolemy.data.ontologies.OntologySolver.configure(OntologySolver.java:131)
is the only ontology class in the stack trace. It seems wrong to clear the Constants in that method, but it works.
Ben Lickly correctly pointed out that it is still the case that if two Ontology models are opened, then they will share data via the static Constants object.
Probably we should have a separate Constants object that is contained by the Workspace.
Note: the issue was created automatically with bugzilla2github tool
Original bug ID: BZ#522 From: @cxbrooks Reported version: 9.1.devel CC: pt-dev@chess.eecs.berkeley.edu