]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Merge changes from trunk
authorjkauttio <jkauttio@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 31 Mar 2014 07:59:55 +0000 (07:59 +0000)
committerjkauttio <jkauttio@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 31 Mar 2014 07:59:55 +0000 (07:59 +0000)
refs #2924

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/branches@29220 ac1ea38d-2e2b-0410-8846-a27921b304fc

123 files changed:
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Addition.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/And.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Application.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Argument.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ArgumentList.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Array.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ArraySliceExpression.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Assignment.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Constant.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Declaration.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Derivate.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Derivative.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Division.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ElementwiseProduct.java [new file with mode: 0644]
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/EnumElementsVariableBase.java [new file with mode: 0644]
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/EnumSizeVariableBase.java [new file with mode: 0644]
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Environment.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Equals.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ForArray.java [new file with mode: 0644]
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ForIndex.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Frame.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Function.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/GreaterOrEqualThan.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/GreaterThan.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/IEnvironment.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/IExpression.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/IFrame.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/IfThenElse.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/LessOrEqualThan.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/LessThan.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/LineReader.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Model.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/MultiStatement.java [new file with mode: 0644]
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Multiplication.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Negation.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/NodeClass.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/NotEquals.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/NullModification.java [new file with mode: 0644]
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Or.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ParameterDeclaration.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Parser.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Solver.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/SolverUtils.java [new file with mode: 0644]
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Statement.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Subtraction.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/TimeVariable.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Variable.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/VariableBase.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/VariableDeclaration.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelParser.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelParserTokenManager.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelParserTreeConstants.java
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelicaParser.jj
dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelicaParser.jjt
dev-jkauttio/org.simantics.modelica/src/org/simantics/modelica/ModelicaManager.java
dev-jkauttio/org.simantics.modelica/src/org/simantics/modelica/data/SimulationResult.java
dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Bathtub.sysdyn
dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Ceiling.sysdyn [new file with mode: 0644]
dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Decay.sysdyn
dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Extrapolation.sysdyn [new file with mode: 0644]
dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Extrapolation.sysdynModule [new file with mode: 0644]
dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Floor.sysdyn [new file with mode: 0644]
dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/MoleculeFunctions.sysdynFunctions [new file with mode: 0644]
dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Multivariate Anchoring And Adjustment.sysdyn [new file with mode: 0644]
dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Protected Sea Ancoring And Adjustment.sysdyn [new file with mode: 0644]
dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Sea Anchoring And Adjustment.sysdyn [new file with mode: 0644]
dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Smooth.sysdyn
dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Smooth.sysdynModule
dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/SmoothThirdOrder.sysdyn
dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/SmoothThirdOrder.sysdynModule
dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Tester For Molecules.sysdyn
dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Trend.sysdyn [new file with mode: 0644]
dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Trend.sysdynModule [new file with mode: 0644]
dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Univariate Anchoring And Adjustment.sysdyn [new file with mode: 0644]
dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/WeighedAverage.sysdyn [new file with mode: 0644]
dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/sampleModels/Discovery And Exploitation Of Resources.sysdyn
dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/sampleModels/Global Carbon Cycle.sysdyn
dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/sampleModels/Predator And Limited Prey.sysdyn
dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/sampleModels/Resource Exploitation Use Recycling.sysdyn
dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/sampleModels/Tourists Environments And Hotel Facilities.sysdyn
dev-jkauttio/org.simantics.sysdyn.ontology/graph.tg
dev-jkauttio/org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph
dev-jkauttio/org.simantics.sysdyn.ontology/graph/SysdynFunctions.pgraph
dev-jkauttio/org.simantics.sysdyn.ontology/graph/VensimFunctions.pgraph
dev-jkauttio/org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java
dev-jkauttio/org.simantics.sysdyn.ui/icons/equalizer.png [new file with mode: 0644]
dev-jkauttio/org.simantics.sysdyn.ui/plugin.properties
dev-jkauttio/org.simantics.sysdyn.ui/plugin.xml
dev-jkauttio/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/routing/DependencyRouter.java
dev-jkauttio/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/DependencyConnectionFactory.java
dev-jkauttio/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/connections/DependencyNode.java
dev-jkauttio/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/function/ModulesSearchFunction.java
dev-jkauttio/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SynthesisSimulation.java [new file with mode: 0644]
dev-jkauttio/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SysdynExperimentActivator.java
dev-jkauttio/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ToggleSimulation.java
dev-jkauttio/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/exports/ExportModelHandler.java
dev-jkauttio/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/listeners/SysdynExperimentListener.java
dev-jkauttio/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/preferences/SysdynDiagramPreferencePage.java
dev-jkauttio/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/preferences/SysdynDiagramPreferences.java
dev-jkauttio/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/preferences/SysdynDiagramPreferencesInitializer.java
dev-jkauttio/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java
dev-jkauttio/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ConfigurationTab.java
dev-jkauttio/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/DelayExpression.java
dev-jkauttio/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/TrendView.java
dev-jkauttio/org.simantics.sysdyn/scl/Sysdyn.scl
dev-jkauttio/org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariable.java
dev-jkauttio/org.simantics.sysdyn/src/org/simantics/sysdyn/expressionParser/ExpressionParser.java
dev-jkauttio/org.simantics.sysdyn/src/org/simantics/sysdyn/expressionParser/ExpressionParser.jj
dev-jkauttio/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/OldSysdynExperiment.java
dev-jkauttio/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiments.java [new file with mode: 0644]
dev-jkauttio/org.simantics.sysdyn/src/org/simantics/sysdyn/modelParser/ModelParser.java
dev-jkauttio/org.simantics.sysdyn/src/org/simantics/sysdyn/modelParser/ModelicaParser.jj
dev-jkauttio/org.simantics.sysdyn/src/org/simantics/sysdyn/modelica/ModelicaWriter.java
dev-jkauttio/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Shadow.java
dev-jkauttio/org.simantics.sysdyn/src/org/simantics/sysdyn/solver/InternalSolver.java
dev-jkauttio/org.simantics.sysdyn/src/org/simantics/sysdyn/solver/SysdynSimulationJob.java
dev-jkauttio/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/DocumentationUtils.java
dev-jkauttio/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/Function.java
dev-jkauttio/org.simantics.sysdyn/testModels/MaintenanceModel_2012-12-03.tg [new file with mode: 0644]
dev-jkauttio/org.simantics.sysdyn/testModels/Model1412Health.tg [new file with mode: 0644]
dev-jkauttio/org.simantics.sysdyn/testModels/WorkModel_2012-12-03.tg [new file with mode: 0644]
dev-jkauttio/org.simantics.sysdyn/testModels/openprod_demo_2012-12-03.tg [new file with mode: 0644]
dev-jkauttio/org.simantics.sysdyn/testModels/references.txt [new file with mode: 0644]

index abf31cb45acb08823f340653ab9d7d5d28f1f44a..27ee6841018a5f8788a7df75d5b6e6a6fdb2c49e 100644 (file)
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.Collection;\r
+import java.util.Iterator;\r
+import java.util.Map;\r
+\r
 public class Addition implements IExpression {\r
        \r
     public IExpression exp1;\r
@@ -27,9 +31,34 @@ public class Addition implements IExpression {
     \r
        @Override\r
        public Object evaluate(IEnvironment environment) {\r
-               Double d1 = (Double)exp1.evaluate(environment);\r
-               Double d2 = (Double)exp2.evaluate(environment);\r
-               return d1 + d2;\r
+               Object o1 = exp1.evaluate(environment);\r
+               Object o2 = exp2.evaluate(environment);\r
+               if(o1 instanceof Double && o2 instanceof Double) {\r
+                       return (Double)o1 + (Double)o2;\r
+               }\r
+               if(o1 instanceof Array && o2 instanceof Array) {\r
+                       Array la = (Array)o1;\r
+                       Array ra = (Array)o2;\r
+                       return la.add(ra);\r
+               }\r
+               throw new IllegalStateException();\r
+       }\r
+       \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               return new Addition(exp1.withBase(frame, prefix), exp2.withBase(frame, prefix));\r
        }\r
     \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               exp1 = exp1.rewrite(frame, copies);\r
+               exp2 = exp2.rewrite(frame, copies);\r
+               return this;\r
+       }\r
+       \r
 }\r
index 0ed114b9d77581384a455d32f037a3a79cae27dd..d77a191c0972e1653f330af130da141fef10bfe4 100644 (file)
 package fi.semantum.sysdyn.solver;\r
 \r
 import java.util.ArrayList;\r
+import java.util.Map;\r
 \r
 public class And implements IExpression {\r
        \r
-    public ArrayList<IExpression> exps;\r
+    public IExpression[] exps;\r
     \r
     public And(ArrayList<IExpression> exps) {\r
-       this.exps = exps;\r
+       this.exps = exps.toArray(new IExpression[exps.size()]);\r
     }\r
     \r
     @Override\r
     public String toString() {\r
        StringBuilder b = new StringBuilder();\r
-       b.append(exps.get(0));\r
-       for(int i=1;i<exps.size();i++) {\r
+       b.append(exps[0]);\r
+       for(int i=1;i<exps.length;i++) {\r
                b.append(" and ");\r
-               b.append(exps.get(i));\r
+               b.append(exps[i]);\r
        }\r
        return b.toString();\r
     }\r
@@ -36,5 +37,26 @@ public class And implements IExpression {
                for(IExpression e : exps) \r
                        if(!(Boolean)e.evaluate(environment)) return false;\r
                return true;\r
-       }    \r
+       }\r
+       \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               ArrayList<IExpression> ne = new ArrayList<IExpression>();\r
+               for(IExpression e : exps) ne.add(e.withBase(frame, prefix));\r
+               return new And(ne);\r
+       }\r
+    \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               for(int i=0;i<exps.length;i++) {\r
+                       exps[i] = exps[i].rewrite(frame, copies);\r
+               }\r
+               return this;\r
+       }\r
+       \r
 }\r
index 4160663c58e0eb93e7e1048de34550781e3dca7f..c9c2282c923e576c1896f88607db1b94f93cab41 100644 (file)
@@ -10,6 +10,8 @@
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.Map;\r
+\r
 public class Application implements IExpression {\r
 \r
        public String name;\r
@@ -30,4 +32,20 @@ public class Application implements IExpression {
                return environment.getSystem().evaluateFunction(environment, name, args);\r
        }\r
        \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               return new Application(name, args.withBase(frame, prefix));\r
+       }\r
+    \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               args = args.rewrite(frame, copies);\r
+               return this;\r
+       }\r
+       \r
 }\r
index e5258945d5eda22a1527f98766f4eb2bd1cdc65e..3a7013f4eddc77158f81711c13845a7935135c06 100644 (file)
@@ -10,6 +10,8 @@
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.Map;\r
+\r
 public class Argument implements IExpression {\r
 \r
        public String name;\r
@@ -30,4 +32,19 @@ public class Argument implements IExpression {
                throw new UnsupportedOperationException();\r
        }\r
        \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               return new Argument(prefix+name, modification.withBase(frame, prefix));\r
+       }\r
+    \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
+       public Argument rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               modification = modification.rewrite(frame, copies);\r
+               return this;\r
+       }\r
+       \r
 }\r
index 9766f08404042b4b5e8a97d3036bd8605716e2cd..02d4d439690b6544607c008626aa9d25431e2149 100644 (file)
 package fi.semantum.sysdyn.solver;\r
 \r
 import java.util.ArrayList;\r
+import java.util.Map;\r
 \r
 public class ArgumentList {\r
        \r
-    public ArrayList<Argument> args;\r
+    public Argument[] args;\r
+    public String op;\r
     \r
     public ArgumentList(ArrayList<Argument> args) {\r
-       this.args = args;\r
+       this.args = args.toArray(new Argument[args.size()]);\r
+       this.op = "";\r
     }\r
 \r
-    public ArgumentList() {\r
-       this.args = new ArrayList<Argument>();\r
+    public ArgumentList(ArrayList<Argument> args, String op) {\r
+       this.args = args.toArray(new Argument[args.size()]);\r
+       this.op = op;\r
+    }\r
+\r
+    public ArgumentList(String op) {\r
+       this.args = new Argument[0];\r
+       this.op = op;\r
     }\r
 \r
     @Override\r
     public String toString() {\r
-       if(args.size() == 0) return "()";\r
+       if(args.length == 0) return "()";\r
        StringBuilder b = new StringBuilder();\r
-       b.append("(" + args.get(0));\r
-       for(int i=1;i<args.size();i++) {\r
+       b.append("(" + args[0]);\r
+       for(int i=1;i<args.length;i++) {\r
                b.append(", ");\r
-               b.append(args.get(i));\r
+               b.append(args[i]);\r
        }\r
        b.append(")");\r
        return b.toString();\r
     }\r
     \r
+    public ArgumentList withBase(IFrame frame, String prefix) {\r
+       ArrayList<Argument> a2 = new ArrayList<Argument>();\r
+       for(Argument a : args) a2.add((Argument)a.withBase(frame, prefix));\r
+       return new ArgumentList(a2, op);\r
+    }\r
+    \r
+       public ArgumentList rewrite(IFrame frame, Map<String,VariableBase> copies) {\r
+               for(int i=0;i<args.length;i++)\r
+                       args[i] = args[i].rewrite(frame, copies);\r
+               return this;\r
+       }\r
+    \r
 }\r
index eeb952b8a93606a17f9e9c6cf83319f9fd56bc62..72fcd4050e1532c88b1aceb62e6baf7f6fd98607 100644 (file)
@@ -12,6 +12,10 @@ package fi.semantum.sysdyn.solver;
 \r
 import java.util.ArrayList;\r
 import java.util.Collection;\r
+import java.util.Iterator;\r
+import java.util.Map;\r
+\r
+import fi.semantum.sysdyn.solver.SolverUtils.Slice;\r
 \r
 public class Array implements IExpression {\r
 \r
@@ -21,9 +25,10 @@ public class Array implements IExpression {
                \r
        }\r
        \r
-       public void addElement(Object element) {\r
+       public Array addElement(Object element) {\r
                if(element instanceof Constant) addElement(((Constant)element).value);\r
                else elements.add(element);\r
+               return this;\r
        }\r
        \r
        public void setElement(int index, Object element) {\r
@@ -74,4 +79,152 @@ public class Array implements IExpression {
                for(int i=0;i<needed;i++) addElement(subArray ? new Array() : null);\r
        }\r
        \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               Array result = new Array();\r
+               for(Object o : elements) {\r
+                       if(o instanceof Array) {\r
+                               result.addElement(((Array)o).withBase(frame, prefix));\r
+                       } else {\r
+                               if(o instanceof IExpression) {\r
+                                       IExpression exp = (IExpression)o;\r
+                                       result.addElement(exp.withBase(frame, prefix));\r
+                               } else {\r
+                                       result.addElement(o);\r
+                               }\r
+                       }\r
+               }\r
+               return result;\r
+       }\r
+    \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               for(int i=0;i<elements.size();i++) {\r
+                       Object element = elements.get(i);\r
+                       if(element instanceof IExpression) {\r
+                               elements.set(i, ((IExpression)element).rewrite(frame, copies));\r
+                       }\r
+               }\r
+               return this;\r
+       }\r
+       \r
+       public int dimension() {\r
+               int result = 0;\r
+               for(int i=0;i<elements.size();i++) {\r
+                       Object element = elements.get(i);\r
+                       if(element instanceof Array) {\r
+                               result += ((Array)element).dimension();\r
+                       } else {\r
+                               result++;\r
+                       }\r
+               }\r
+               return result;\r
+       }\r
+       \r
+       public Array mul(double d) {\r
+               Array result = new Array();\r
+               for(Object o : elements) {\r
+               if(o instanceof Double) {\r
+                       result.addElement((Double)o*d);\r
+               } else if (o instanceof Array) {\r
+                       result.addElement(((Array)o).mul(d));\r
+               } else {\r
+                       throw new IllegalStateException();\r
+               }\r
+               }\r
+               return result;\r
+       }\r
+       \r
+       public boolean validateDimensions(int[] dimensions, int index) {\r
+               if(elements.size() != dimensions[index]) return false;\r
+               if(index < dimensions.length-1) {\r
+                       for(Object o : elements) {\r
+                               if(!(o instanceof Array)) return false;\r
+                               Array arr = (Array)o;\r
+                               if(!arr.validateDimensions(dimensions, index+1)) return false;\r
+                       }\r
+               } else {\r
+                       for(Object o : elements) {\r
+                               if((o instanceof Array)) return false;\r
+                       }\r
+               }\r
+               return true;\r
+       }\r
+\r
+       public Array slice(Slice[] indices) {\r
+               \r
+               if(indices.length == 1) {\r
+                       Array result = new Array();\r
+                       for(int i=indices[0].start;i<=indices[0].end;i++) {\r
+                               result.addElement(element(i));\r
+                       }\r
+                       return result;\r
+               }\r
+               \r
+               if(indices.length != 2) throw new IllegalStateException();\r
+               \r
+               if(indices[1] == Slice.FULL) {\r
+                       return (Array)elements.get(indices[0].start);\r
+               } else {\r
+                       Array result = new Array();\r
+                       for(Object o : elements) {\r
+                               Array a = (Array)o;\r
+                               result.addElement(a.element(indices[1].start));\r
+                       }\r
+                       return result;\r
+               }\r
+               \r
+       }\r
+       \r
+       public Array add(Array other) {\r
+               Array result = new Array();\r
+               Collection<Object> lae = elements();\r
+               Collection<Object> rae = other.elements();\r
+               if(lae.size() != rae.size()) throw new IllegalStateException();\r
+               Iterator<Object> li = lae.iterator();\r
+               Iterator<Object> ri = rae.iterator();\r
+               for(int i=0;i<lae.size();i++) {\r
+                       Object l = li.next();\r
+                       Object r = ri.next();\r
+                       if(l instanceof Double && r instanceof Double) {\r
+                               result.addElement(((Double)l)+((Double)r));\r
+                       } else if (l instanceof Array && r instanceof Array) {\r
+                               Array arr = (Array)l;\r
+                               Array otherArr = (Array)r;\r
+                               result.addElement(arr.add(otherArr));\r
+                       } else {\r
+                               throw new IllegalStateException();\r
+                       }\r
+               }\r
+               return result;\r
+       }\r
+\r
+       public Array mul(Array other) {\r
+               Array result = new Array();\r
+               Collection<Object> lae = elements();\r
+               Collection<Object> rae = other.elements();\r
+               if(lae.size() != rae.size()) throw new IllegalStateException();\r
+               Iterator<Object> li = lae.iterator();\r
+               Iterator<Object> ri = rae.iterator();\r
+               for(int i=0;i<lae.size();i++) {\r
+                       Object l = li.next();\r
+                       Object r = ri.next();\r
+                       if(l instanceof Double && r instanceof Double) {\r
+                               result.addElement(((Double)l)*((Double)r));\r
+                       } else if (l instanceof Array && r instanceof Array) {\r
+                               Array arr = (Array)l;\r
+                               Array otherArr = (Array)r;\r
+                               result.addElement(arr.add(otherArr));\r
+                       } else {\r
+                               throw new IllegalStateException();\r
+                       }\r
+               }\r
+               return result;\r
+       }\r
+       \r
 }\r
index b5074cbea5f90dc1fc10b43d992298dede9370d7..b2813e698071da7e4b4a7c1e1342055b00b24961 100644 (file)
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.Map;\r
+\r
 public class ArraySliceExpression implements IExpression {\r
 \r
-       final public IExpression start;\r
-       final public IExpression end;\r
+       public IExpression start;\r
+       public IExpression end;\r
        \r
        public ArraySliceExpression(IExpression start, IExpression end) {\r
                this.start = start;\r
@@ -35,4 +37,21 @@ public class ArraySliceExpression implements IExpression {
                return result;\r
        }\r
        \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               return new ArraySliceExpression(start.withBase(frame, prefix), end.withBase(frame, prefix));\r
+       }\r
+    \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               start = start.rewrite(frame, copies);\r
+               end = end.rewrite(frame, copies);\r
+               return this;\r
+       }\r
+       \r
 }\r
index aec5233a0159269ff6a05f61957ace94ab85bd2e..fd7f1d06932b6016278a7dcf4474a9cf88e15aa3 100644 (file)
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import org.omg.PortableInterceptor.SUCCESSFUL;\r
+\r
 public class Assignment {\r
        \r
        public Variable target;\r
+       public IExpression[] subscripts;\r
     public IExpression expression;\r
     public boolean assigned = false;\r
     \r
-    public Assignment(Variable target, IExpression expression) {\r
+    public Assignment(Variable target, IExpression[] subscripts, IExpression expression) {\r
        this.target = target;\r
+       this.subscripts = subscripts;\r
        this.expression = expression;\r
     }\r
     \r
@@ -26,4 +30,15 @@ public class Assignment {
        return target + " = " + expression;\r
     }\r
     \r
+    public Assignment withBase(IFrame frame, String prefix) {\r
+       if(subscripts != null) {\r
+               IExpression[] subscripts2 = new IExpression[subscripts.length];\r
+               for(int i=0;i<subscripts.length;i++)\r
+                       subscripts2[i] = subscripts[i].withBase(frame, prefix);\r
+               return new Assignment(target.withBase(frame, prefix), subscripts2, expression.withBase(frame, prefix));\r
+       } else {\r
+               return new Assignment(target.withBase(frame, prefix), null, expression.withBase(frame, prefix));\r
+       }\r
+    }\r
+    \r
 }\r
index 652f27f272d0e6aee5b0e7482d1903f29d9e9012..d00f236293d2da28c44a8653674bb8606d5112b7 100644 (file)
@@ -10,6 +10,8 @@
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.Map;\r
+\r
 public class Constant implements IExpression {\r
 \r
        public Object value;\r
@@ -32,4 +34,20 @@ public class Constant implements IExpression {
                return value;\r
        }\r
        \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               return this;\r
+       }\r
+    \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               return this;\r
+       }\r
+       \r
 }\r
+\r
index 16d45c0325069c3a20859c9becb0e1c61d1e706a..a1490f5270d93fdf7ae7e6069f3b40b234718a5c 100644 (file)
@@ -11,6 +11,8 @@
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.Map;\r
+\r
 public class Declaration implements IExpression {\r
 \r
        public Variable variable;\r
@@ -31,4 +33,19 @@ public class Declaration implements IExpression {
                throw new UnsupportedOperationException();\r
        }\r
        \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               throw new UnsupportedOperationException();\r
+       }\r
+    \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               throw new UnsupportedOperationException();\r
+       }\r
+       \r
 }\r
index 8afcf24c9f200c344b8ceb3efc9db39a3a9f1cc2..426e3fa72ad39adb9d53aaddfaa902e827b28f87 100644 (file)
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.Map;\r
+\r
 public class Derivate implements IExpression {\r
 \r
        private Variable variable;\r
+       private IExpression[] subscripts;\r
        private IExpression e;\r
        \r
-       public Derivate(Variable variable, IExpression e) {\r
+       public Derivate(Variable variable, IExpression[] subscripts, IExpression e) {\r
                this.variable = variable;\r
+               this.subscripts = subscripts;\r
                this.e = e;\r
        }\r
        \r
@@ -24,7 +28,7 @@ public class Derivate implements IExpression {
        public Object evaluate(IEnvironment _environment) {\r
                Environment environment = (Environment)_environment;\r
 //             Double old = (Double)environment.getValue(variable.name + variable.subscriptKey());\r
-               Double old = (Double)environment.getValue(variable.index(_environment));\r
+               Double old = (Double)environment.getValue(variable.base.index(_environment, subscripts));\r
                return old+environment.step*(Double)e.evaluate(environment);\r
        }\r
        \r
@@ -32,5 +36,32 @@ public class Derivate implements IExpression {
        public String toString() {\r
                return e.toString();\r
        }       \r
+\r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               if(subscripts != null) {\r
+               IExpression[] subscripts2 = new IExpression[subscripts.length];\r
+               for(int i=0;i<subscripts.length;i++)\r
+                       subscripts2[i] = subscripts[i].withBase(frame, prefix);\r
+                       return new Derivate((Variable)variable.withBase(frame, prefix), subscripts2, e.withBase(frame, prefix));\r
+               } else {\r
+                       return new Derivate((Variable)variable.withBase(frame, prefix), null, e.withBase(frame, prefix));\r
+               }\r
+       }\r
+    \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               if(subscripts != null) {\r
+                       for(int i=0;i<subscripts.length;i++)\r
+                               subscripts[i] = subscripts[i].rewrite(frame, copies);\r
+               }\r
+               e = e.rewrite(frame, copies);\r
+               return this;\r
+       }\r
        \r
 }\r
index b2abae337b73e7d501e1846a70341ea2c0b058dd..51dbf974ae394ed64f8f4d62efc603e1fee3a814 100644 (file)
@@ -10,7 +10,9 @@
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
-public class Derivative {\r
+import java.util.Map;\r
+\r
+public class Derivative implements IExpression {\r
 \r
        Variable variable;\r
        \r
@@ -22,5 +24,25 @@ public class Derivative {
        public String toString() {\r
                return "der(" + variable.toString() + ")";\r
        }\r
+\r
+       @Override\r
+       public Object evaluate(IEnvironment environment) {\r
+               throw new UnsupportedOperationException();\r
+       }\r
+       \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               throw new UnsupportedOperationException();\r
+       }\r
+    \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               throw new UnsupportedOperationException();\r
+       }\r
        \r
 }\r
index 34ee4e4c0ce0eb8660704cefecadfd564a94cf62..0f643949c853c569ec05cb762de3be69c7e4096f 100644 (file)
@@ -10,6 +10,8 @@
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.Map;\r
+\r
 public class Division implements IExpression {\r
        \r
     public IExpression exp1;\r
@@ -26,7 +28,15 @@ public class Division implements IExpression {
     }\r
     \r
     private Array arrayDiv(Array a, Double d) {\r
-       return a;\r
+       Array result = new Array();\r
+       for(Object o : a.elements()) {\r
+               if(o instanceof Double) {\r
+                       result.addElement((Double)o/d);\r
+               } else {\r
+                       throw new IllegalStateException();\r
+               }\r
+       }\r
+       return result;\r
     }\r
     \r
        @Override\r
@@ -39,4 +49,21 @@ public class Division implements IExpression {
                else throw new UnsupportedOperationException();\r
        }\r
        \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               return new Division(exp1.withBase(frame, prefix), exp2.withBase(frame, prefix));\r
+       }\r
+    \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+\r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               exp1 = exp1.rewrite(frame, copies);\r
+               exp2 = exp2.rewrite(frame, copies);\r
+               return this;\r
+       }\r
+       \r
 }\r
diff --git a/dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ElementwiseProduct.java b/dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ElementwiseProduct.java
new file mode 100644 (file)
index 0000000..d8d3aaf
--- /dev/null
@@ -0,0 +1,71 @@
+/*******************************************************************************\r
+ * Copyright (c) 2013 Semantum Oy.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     Semantum Oy - initial API and implementation\r
+ *******************************************************************************/\r
+package fi.semantum.sysdyn.solver;\r
+\r
+import java.util.Collection;\r
+import java.util.Iterator;\r
+import java.util.Map;\r
+\r
+public class ElementwiseProduct implements IExpression {\r
+       \r
+    public IExpression exp1;\r
+    public IExpression exp2;\r
+    \r
+    public ElementwiseProduct(IExpression exp1, IExpression exp2) {\r
+       this.exp1 = exp1;\r
+       this.exp2 = exp2;\r
+    }\r
+    \r
+    @Override\r
+    public String toString() {\r
+       return exp1 + " * " + exp2;\r
+    }\r
+    \r
+       @Override\r
+       public Object evaluate(IEnvironment environment) {\r
+               Object left = exp1.evaluate(environment);\r
+               Object right = exp2.evaluate(environment);\r
+               if(left instanceof Array && right instanceof Array) {\r
+                       Array la = (Array)left;\r
+                       Array ra = (Array)right;\r
+                       Collection<Object> lae = la.elements();\r
+                       Collection<Object> rae = ra.elements();\r
+                       if(lae.size() != rae.size()) throw new UnsupportedOperationException();\r
+                       Iterator<Object> li = lae.iterator();\r
+                       Iterator<Object> ri = rae.iterator();\r
+                       Array result = new Array();\r
+                       for(int i=0;i<lae.size();i++) {\r
+                               double ld = (Double)li.next();\r
+                               double rd = (Double)ri.next();\r
+                               result.addElement(ld*rd);\r
+                       }\r
+                       return result;\r
+               } else throw new UnsupportedOperationException();\r
+       }\r
+       \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               return new ElementwiseProduct(exp1.withBase(frame, prefix), exp2.withBase(frame, prefix));\r
+       }\r
+    \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               exp1 = exp1.rewrite(frame, copies);\r
+               exp2 = exp2.rewrite(frame, copies);\r
+               return this;\r
+       }\r
+\r
+}\r
diff --git a/dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/EnumElementsVariableBase.java b/dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/EnumElementsVariableBase.java
new file mode 100644 (file)
index 0000000..d80d5df
--- /dev/null
@@ -0,0 +1,46 @@
+/*******************************************************************************\r
+ * Copyright (c) 2013 VTT Technical Research Centre of Finland.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package fi.semantum.sysdyn.solver;\r
+\r
+public class EnumElementsVariableBase extends VariableBase {\r
+\r
+       private Array result;\r
+       \r
+       public EnumElementsVariableBase(Model clazz) {\r
+               super("elements");\r
+               result = new Array();\r
+               for(VariableDeclaration vd : clazz.variables) {\r
+                       Constant c = (Constant)vd.modification.args[0].modification;\r
+                       result.addElement(c.value);\r
+               }\r
+       }\r
+\r
+       public EnumElementsVariableBase(String name, Array result) {\r
+               super(name);\r
+               this.result = result;\r
+       }\r
+\r
+       @Override\r
+       public Object evaluate(IEnvironment environment, IExpression[] subscripts) {\r
+               return result;\r
+       }\r
+\r
+       @Override\r
+       VariableBase withBase(String prefix) {\r
+               return new EnumElementsVariableBase(prefix+name, result);\r
+       }\r
+       \r
+       @Override\r
+       public IExpression getPossibleConstant() {\r
+               return result;\r
+       }\r
+       \r
+}\r
diff --git a/dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/EnumSizeVariableBase.java b/dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/EnumSizeVariableBase.java
new file mode 100644 (file)
index 0000000..6ed388f
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************\r
+ * Copyright (c) 2013 VTT Technical Research Centre of Finland.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package fi.semantum.sysdyn.solver;\r
+\r
+public class EnumSizeVariableBase extends VariableBase {\r
+\r
+       private Double value;\r
+       \r
+       public EnumSizeVariableBase(Model clazz) {\r
+               super("size");\r
+               value = (double)clazz.variables.size();\r
+       }\r
+\r
+       public EnumSizeVariableBase(String name, double value) {\r
+               super(name);\r
+               this.value = value;\r
+       }\r
+\r
+       @Override\r
+       public Object evaluate(IEnvironment environment, IExpression[] subscripts) {\r
+               return value;\r
+       }       \r
+\r
+       @Override\r
+       VariableBase withBase(String prefix) {\r
+               return new EnumSizeVariableBase(prefix+name, value);\r
+       }\r
+       \r
+       @Override\r
+       public IExpression getPossibleConstant() {\r
+               return new Constant(value.toString());\r
+       }\r
+       \r
+}\r
index 5f5db469ff222579c918a0c8d010a9e61c68d4cc..1e1474087b83459f5546e51194c2acb2ced72856 100644 (file)
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
 import java.util.HashMap;\r
+import java.util.Iterator;\r
+import java.util.Map;\r
 import java.util.TreeMap;\r
 \r
 interface Fn {\r
        public Object evaluate(IEnvironment environment, int argc);\r
+       public Object evaluateInput(IEnvironment environment, int argPosition);\r
        public void setLocals(IEnvironment environment);\r
        public int offset();\r
        public Variable[] parameters();\r
 }\r
 \r
 abstract class Fn1 implements Fn {\r
+\r
+       Variable[] parameters;\r
        \r
-       static Variable[] parameters;\r
-       \r
-       static {\r
-               parameters = new Variable[5];\r
-               parameters[0] = new Variable(new VariableBase("", 0));\r
-               parameters[1] = new Variable(new VariableBase("", 1));\r
-               parameters[2] = new Variable(new VariableBase("", 2));\r
-               parameters[3] = new Variable(new VariableBase("", 3));\r
-               parameters[4] = new Variable(new VariableBase("", 4));\r
+       public Fn1(int pCount) {\r
+               parameters = new Variable[pCount];\r
+               for(int i=0;i<pCount;i++)\r
+                       parameters[i] = new Variable(new VariableBase("", i));\r
        }\r
        \r
        public int offset() {\r
@@ -46,14 +48,23 @@ abstract class Fn1 implements Fn {
        public void setLocals(IEnvironment environment) {\r
        }\r
        \r
+       @Override\r
+       public Object evaluateInput(IEnvironment environment, int argPosition) {\r
+               // Function frame size is constant - this is called when padding is needed\r
+               return null;\r
+       }\r
+       \r
 }\r
 \r
-public class Environment implements IEnvironment, ISystem {\r
+final public class Environment implements IEnvironment, ISystem {\r
        \r
+       final Map<String,Object> named = new HashMap<String,Object>();\r
+\r
        public Model model;\r
        public final double step;\r
        public double time;\r
        public boolean initial = true;\r
+       public int size;\r
        \r
        public Object[] valueTable;\r
 \r
@@ -64,7 +75,7 @@ public class Environment implements IEnvironment, ISystem {
                this.step = step;\r
                this.time = start;\r
                \r
-               model.functions.put("size", new Fn1() {\r
+               model.functions.put("size", new Fn1(2) {\r
 \r
                        @Override\r
                        public Object evaluate(IEnvironment environment, int argc) {\r
@@ -74,18 +85,44 @@ public class Environment implements IEnvironment, ISystem {
                        }\r
                        \r
                });\r
-               model.functions.put("zidz", new Fn1() {\r
+               model.functions.put("zidz", new Fn1(2) {\r
 \r
-                       @Override\r
-                       public Object evaluate(IEnvironment environment, int argc) {\r
-                               Double p1 = (Double)environment.getValue(0);\r
-                               Double p2 = (Double)environment.getValue(1);\r
+                       private Object evaluate(Double p1, Double p2) {\r
                                if(Math.abs(p2) < 1e-12) return 0.0;\r
                                else return p1 / p2;\r
                        }\r
                        \r
+                       @Override\r
+                       public Object evaluate(IEnvironment environment, int argc) {\r
+                               Object o1 = environment.getValue(0);\r
+                               Object o2 = environment.getValue(1);\r
+                               \r
+                               if(o1 instanceof Double && o2 instanceof Double) {\r
+                                       return evaluate((Double)o1, (Double)o2);\r
+                               }\r
+                               if(o1 instanceof Array && o2 instanceof Array) {\r
+                                       Array la = (Array)o1;\r
+                                       Array ra = (Array)o2;\r
+                                       Collection<Object> lae = la.elements();\r
+                                       Collection<Object> rae = ra.elements();\r
+                                       if(lae.size() != rae.size()) throw new UnsupportedOperationException();\r
+                                       Iterator<Object> li = lae.iterator();\r
+                                       Iterator<Object> ri = rae.iterator();\r
+                                       Array result = new Array();\r
+                                       for(int i=0;i<lae.size();i++) {\r
+                                               double ld = (Double)li.next();\r
+                                               double rd = (Double)ri.next();\r
+                                               result.addElement(evaluate(ld,rd));\r
+                                       }\r
+                                       return result;\r
+                               }\r
+                               throw new IllegalStateException();\r
+                               \r
+                               \r
+                       }\r
+                       \r
                });\r
-               model.functions.put("xidz", new Fn1() {\r
+               model.functions.put("xidz", new Fn1(3) {\r
 \r
                        @Override\r
                        public Object evaluate(IEnvironment environment, int argc) {\r
@@ -97,7 +134,7 @@ public class Environment implements IEnvironment, ISystem {
                        }\r
                        \r
                });\r
-               model.functions.put("availabilityExternal", new Fn1() {\r
+               model.functions.put("availabilityExternal", new Fn1(4) {\r
 \r
                        @Override\r
                        public Object evaluate(IEnvironment environment, int argc) {\r
@@ -113,7 +150,7 @@ public class Environment implements IEnvironment, ISystem {
                        }\r
                        \r
                });\r
-               model.functions.put("pre", new Fn1() {\r
+               model.functions.put("pre", new Fn1(1) {\r
 \r
                        @Override\r
                        public Object evaluate(IEnvironment environment, int argc) {\r
@@ -123,7 +160,7 @@ public class Environment implements IEnvironment, ISystem {
                        }\r
                        \r
                });\r
-               model.functions.put("fill", new Fn1() {\r
+               model.functions.put("fill", new Fn1(3) {\r
 \r
                        @Override\r
                        public Object evaluate(IEnvironment environment, int argc) {\r
@@ -150,7 +187,7 @@ public class Environment implements IEnvironment, ISystem {
                        }\r
                        \r
                });\r
-               model.functions.put("randomNumber", new Fn1() {\r
+               model.functions.put("randomNumber", new Fn1(2) {\r
 \r
                        @Override\r
                        public Object evaluate(IEnvironment environment, int argc) {\r
@@ -160,7 +197,7 @@ public class Environment implements IEnvironment, ISystem {
                        }\r
                        \r
                });\r
-               model.functions.put("initial", new Fn1() {\r
+               model.functions.put("initial", new Fn1(0) {\r
 \r
                        @Override\r
                        public Object evaluate(IEnvironment _environment, int argc) {\r
@@ -168,7 +205,7 @@ public class Environment implements IEnvironment, ISystem {
                        }\r
                        \r
                });\r
-               model.functions.put("noEvent", new Fn1() {\r
+               model.functions.put("noEvent", new Fn1(1) {\r
 \r
                        @Override\r
                        public Object evaluate(IEnvironment environment, int argc) {\r
@@ -178,7 +215,7 @@ public class Environment implements IEnvironment, ISystem {
                        }\r
                        \r
                });\r
-               model.functions.put("min", new Fn1() {\r
+               model.functions.put("min", new Fn1(5) {\r
 \r
                        @Override\r
                        public Object evaluate(IEnvironment environment, int argc) {\r
@@ -191,7 +228,7 @@ public class Environment implements IEnvironment, ISystem {
                        }\r
                        \r
                });\r
-               model.functions.put("max", new Fn1() {\r
+               model.functions.put("max", new Fn1(5) {\r
 \r
                        @Override\r
                        public Object evaluate(IEnvironment environment, int argc) {\r
@@ -204,7 +241,7 @@ public class Environment implements IEnvironment, ISystem {
                        }\r
                        \r
                });\r
-               model.functions.put("integer", new Fn1() {\r
+               model.functions.put("integer", new Fn1(1) {\r
 \r
                        @Override\r
                        public Object evaluate(IEnvironment environment, int argc) {\r
@@ -215,7 +252,20 @@ public class Environment implements IEnvironment, ISystem {
                        }\r
                        \r
                });\r
-               model.functions.put("delay", new Fn1() {\r
+               model.functions.put("sum", new Fn1(1) {\r
+\r
+                       @Override\r
+                       public Object evaluate(IEnvironment environment, int argc) {\r
+                               Object value = environment.getValue(0);\r
+                               Array arr = (Array)value;\r
+                               double res = 0;\r
+                               for(Object o : arr.elements())\r
+                                       res += (Double)o;\r
+                               return res;\r
+                       }\r
+                       \r
+               });\r
+               model.functions.put("delay", new Fn1(4) {\r
                        \r
                        @Override\r
                        public Object evaluate(IEnvironment _environment, int argc) {\r
@@ -239,6 +289,30 @@ public class Environment implements IEnvironment, ISystem {
                        }\r
                        \r
                });             \r
+               model.functions.put("cat", new Fn1(10) {\r
+                       \r
+                       @Override\r
+                       public Object evaluate(IEnvironment _environment, int argc) {\r
+                       \r
+                               Double dim = (Double)_environment.getValue(0);\r
+                               \r
+                               Array array = new Array();\r
+                               for(int i=1;i<argc;i++) {\r
+                                       Object ar = _environment.getValue(i);\r
+                                       if (ar instanceof Array) {\r
+                                               Array a = (Array)ar;\r
+                                               for(Object o : a.elements())\r
+                                                       array.addElement(o);\r
+                                       } else {\r
+                                               throw new IllegalStateException();\r
+                                       }\r
+                               }\r
+                               \r
+                               return array;\r
+                               \r
+                       }\r
+                       \r
+               });             \r
        }\r
        \r
        public TreeMap<Double,Double> getHistory(String ident) {\r
@@ -260,9 +334,17 @@ public class Environment implements IEnvironment, ISystem {
                valueTable[key] = value;\r
        }\r
        \r
+       public void put(String key, Object value) {\r
+               named.put(key, value);\r
+       }\r
+\r
+       public void setSize(int size) {\r
+               this.size = size;\r
+       }\r
+       \r
        @Override\r
        public int offset() {\r
-               return model.names.size();\r
+               return size;\r
        }\r
        \r
        @Override\r
@@ -283,30 +365,106 @@ public class Environment implements IEnvironment, ISystem {
        public double time() {\r
                return time;\r
        }\r
+\r
+       double[] valueArray;\r
+       \r
+       public void addIndexed(int dimensions[], ArrayList<String> keys, String prefix, int d) {\r
+\r
+               if(d == dimensions.length) {\r
+                       keys.add(prefix);\r
+                       return;\r
+               }\r
+\r
+               for(int i=0;i<dimensions[d];i++) {\r
+                       String prefix2 = prefix + "[" + i + "]";\r
+                       addIndexed(dimensions, keys, prefix2, d+1);\r
+               }\r
+               \r
+       }\r
        \r
+       public void addVariable(String name, int[] dimensions, ArrayList<String> keys) {\r
+\r
+//             int dimensions[] = base.dimensions;\r
+               if(dimensions == null) {\r
+                       keys.add(name);\r
+               } else {\r
+                       addIndexed(dimensions, keys, name, 0);\r
+               }\r
+\r
+       }\r
+       \r
+       public void addVariable(Variable var, ArrayList<String> keys) {\r
+               addVariable(var.base.name, var.base.dimensions, keys);\r
+       }\r
+\r
+       public String[] getValueKeyArray() {\r
+               \r
+               ArrayList<String> keys = new ArrayList<String>();\r
+               \r
+               for (int i = 0; i < model.assignmentArray.length; i++) {\r
+                       addVariable(model.assignmentArray[i].target, keys);\r
+               }\r
+               \r
+               for (int i = 0; i < model.derivativeArray.length; i++) {\r
+                       addVariable(model.derivativeArray[i].target, keys);\r
+               }\r
+               \r
+               // NOTE: there is room for optimization as parameter values that do not\r
+               // change should only be obtained once (and parameter values that do\r
+               // change are (possibly) included in assignments or derivatives)\r
+               for(int i = 0; i < model.parameterArray.length; i++) {\r
+                       addVariable(model.parameterArray[i].variable, keys);\r
+               }\r
+               \r
+               for(Map.Entry<String,VariableBase> entry : model.copies.entrySet()) {\r
+                       addVariable(entry.getKey(), entry.getValue().dimensions, keys);\r
+               }\r
+\r
+               valueArray = new double[keys.size()];\r
+               \r
+               return keys.toArray(new String[keys.size()]);\r
+               \r
+       }\r
+\r
        // TODO: this is probably not smart at all, figure out a better way to obtain results\r
-       public HashMap<String, Double> getValueMap() {\r
-               HashMap<String, Double> values = new HashMap<String, Double>();\r
+       public double[] getValueArray() {\r
+               \r
+               int offset = 0;\r
                \r
                for (int i = 0; i < model.assignmentArray.length; i++) {\r
                        Variable v = model.assignmentArray[i].target;\r
-                       values.put(v.toString(), (Double)getValue(v.index(this)));\r
+                       for(int index=0;index<v.base.dimension();index++)\r
+                               valueArray[offset++] = (Double)getValue(v.base.index(this, null)+index);\r
                }\r
                \r
                for (int i = 0; i < model.derivativeArray.length; i++) {\r
                        Variable v = model.derivativeArray[i].target;\r
-                       values.put(v.toString(), (Double)getValue(v.index(this)));\r
+                       for(int index=0;index<v.base.dimension();index++)\r
+                               valueArray[offset++] = (Double)getValue(v.base.index(this, null)+index);\r
                }\r
                \r
                // NOTE: there is room for optimization as parameter values that do not\r
                // change should only be obtained once (and parameter values that do\r
                // change are (possibly) included in assignments or derivatives)\r
-               for (ParameterDeclaration p : model.parameters) {\r
-                       Variable v = p.variable;\r
-                       values.put(v.toString(), (Double)getValue(v.index(this)));\r
+               for(int i = 0; i < model.parameterArray.length; i++) {\r
+                       Variable v = model.parameterArray[i].variable;\r
+                       for(int index=0;index<v.base.dimension();index++)\r
+                               valueArray[offset++] = (Double)getValue(v.base.index(this, null)+index);\r
                }\r
+\r
+               for(Map.Entry<String,VariableBase> entry : model.copies.entrySet()) {\r
+                       VariableBase base = entry.getValue();\r
+                       for(int index=0;index<base.dimension();index++)\r
+                               valueArray[offset++] = (Double)getValue(base.index(this, null)+index);\r
+               }\r
+               \r
+               return valueArray;\r
                \r
-               return values;\r
+       }\r
+\r
+       @Override\r
+       public Object getNamedValue(String key) {\r
+               return named.get(key);\r
        }\r
 \r
 }\r
index a27a813624209da1ce7bb3952181ad44059be22b..a92ed1a32adf2bf2282756e1e1fdadee78d7a43e 100644 (file)
@@ -10,6 +10,8 @@
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.Map;\r
+\r
 public class Equals implements IExpression {\r
        \r
     public IExpression exp1;\r
@@ -27,8 +29,30 @@ public class Equals implements IExpression {
     \r
        @Override\r
        public Object evaluate(IEnvironment environment) {\r
-               return ((Double)exp1.evaluate(environment)) == ((Double)exp2.evaluate(environment));\r
+               Object v1 = exp1.evaluate(environment);\r
+               Object v2 = exp2.evaluate(environment);\r
+               if(!(v1 instanceof Double))\r
+                       throw new IllegalStateException();\r
+               if(!(v2 instanceof Double))\r
+                       throw new IllegalStateException();\r
+               return (v1.equals(v2));\r
        }\r
 \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               return new Equals(exp1.withBase(frame, prefix), exp2.withBase(frame, prefix));\r
+       }\r
     \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               exp1 = exp1.rewrite(frame, copies);\r
+               exp2 = exp2.rewrite(frame, copies);\r
+               return this;\r
+       }\r
+\r
 }\r
diff --git a/dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ForArray.java b/dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/ForArray.java
new file mode 100644 (file)
index 0000000..1f66818
--- /dev/null
@@ -0,0 +1,113 @@
+/*******************************************************************************\r
+ * Copyright (c) 2013 Semantum Oy.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     Semantum Oy - initial API and implementation\r
+ *******************************************************************************/\r
+package fi.semantum.sysdyn.solver;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Map;\r
+\r
+public class ForArray implements IExpression {\r
+\r
+       private ArrayList<Object> elements = new ArrayList<Object>();\r
+\r
+       public ForArray() {\r
+               \r
+       }\r
+\r
+       public ForArray(ArrayList<Object> elements) {\r
+               this.elements = elements;\r
+       }\r
+\r
+       public void addElement(Object element) {\r
+               if(element instanceof Constant) addElement(((Constant)element).value);\r
+               else elements.add(element);\r
+       }\r
+       \r
+       public void setElement(int index, Object element) {\r
+               elements.set(index, element);\r
+       }\r
+\r
+       @Override\r
+       public Object evaluate(IEnvironment environment) {\r
+               return evaluated(environment);\r
+       }\r
+       \r
+       public Array evaluated(IEnvironment environment) {\r
+               \r
+               Array result = new Array();\r
+               \r
+               IExpression exp = (IExpression)elements.get(0);\r
+               Argument arg = (Argument)elements.get(1);\r
+               \r
+               Array indices = (Array)arg.modification.evaluate(environment);\r
+               for(Object o : indices.elements()) {\r
+                       environment.put(arg.name, o);\r
+//                     Frame f = new Frame(environment, 1);\r
+//                     f.put(arg.name, o);\r
+                       result.addElement(exp.evaluate(environment));\r
+               }\r
+               \r
+               return result;\r
+               \r
+       }\r
+       \r
+       @Override\r
+       public String toString() {\r
+               return elements.toString();\r
+       }\r
+       \r
+       public int size(int col) {\r
+               return elements.size();\r
+       }\r
+       \r
+       public Object element(int index) {\r
+               return elements.get(index);\r
+       }\r
+       \r
+       public Collection<Object> elements() {\r
+               return elements;\r
+       }\r
+       \r
+       public void ensureIndex(int index, boolean subArray) {\r
+               int needed = (index+1-elements.size());\r
+               for(int i=0;i<needed;i++) addElement(subArray ? new ForArray() : null);\r
+       }\r
+       \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               ArrayList<Object> e = new ArrayList<Object>();\r
+               for(Object o : elements) {\r
+                       if(o instanceof IExpression) {\r
+                               e.add(((IExpression)o).withBase(frame, prefix));\r
+                       } else {\r
+                               e.add(o);\r
+                       }\r
+               }\r
+               return new ForArray(e);\r
+       }\r
+    \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               for(int i=0;i<elements.size();i++) {\r
+                       Object o = elements.get(i);\r
+                       if(o instanceof IExpression) {\r
+                               elements.set(i, ((IExpression)o).rewrite(frame, copies));\r
+                       }\r
+               }\r
+               return this;\r
+       }\r
+       \r
+}\r
index d4a14eb1f499d74dc4cd8592f17b20ac481f9671..919508166ee4968cd6c8ee7d9ac1c697e5682e5c 100644 (file)
@@ -12,12 +12,15 @@ package fi.semantum.sysdyn.solver;
 \r
 public class ForIndex {\r
        \r
+       public String name;\r
        public VariableBase base;\r
        public IExpression expression;\r
        \r
        public ForIndex(Function function, String name, IExpression expression) {\r
                this.expression = expression;\r
-               this.base = function.addIndex(name, this);\r
+               this.name = name;\r
+               if(function != null)\r
+                       this.base = function.addIndex(name, this);\r
        }\r
        \r
 }\r
index a3b15785726f3f84bea62a46e0ade11d1dd1b3d2..178bf2a046929413a5eae64681a855c40e1c8623 100644 (file)
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
 public class Frame implements IEnvironment {\r
        \r
        final public IEnvironment parent;\r
        final private int offset;\r
+       Map<String,Object> named;\r
        \r
        public Frame(IEnvironment parent, int offset) {\r
                this.parent = parent;\r
@@ -29,11 +33,22 @@ public class Frame implements IEnvironment {
        public void put(int index, Object value) {\r
                parent.put(parent.offset() + index, value);\r
        }\r
+\r
+       public void put(String key, Object value) {\r
+               if(named == null) named = new HashMap<String,Object>();\r
+               named.put(key, value);\r
+       }\r
        \r
        @Override\r
        public Object getValue(int index) {\r
                return parent.getValue(parent.offset() + index);\r
        }\r
+\r
+       @Override\r
+       public Object getNamedValue(String key) {\r
+               if(named == null) return null;\r
+               return named.get(key);\r
+       }\r
        \r
        @Override\r
        public ISystem getSystem() {\r
index 925a192f988128dfffb9fbe261c8a5db07b911f5..3c32e6e98901dd2f076cefd6813a419c6249dc83 100644 (file)
 package fi.semantum.sysdyn.solver;\r
 \r
 import java.util.ArrayList;\r
-import java.util.Arrays;\r
 import java.util.HashMap;\r
 import java.util.Map;\r
 \r
-public class Function implements Fn, IFrame {\r
+final public class Function implements Fn, IFrame {\r
        \r
        public static final boolean PRINT = false;\r
        \r
@@ -69,6 +68,11 @@ public class Function implements Fn, IFrame {
                return base;\r
        }\r
        \r
+       @Override\r
+       public VariableBase getBase(VariableBase base, String prefix) {\r
+               throw new IllegalStateException();\r
+       }\r
+       \r
        public void prepare() {\r
                int nextIndex = 0;\r
                if(PRINT)\r
@@ -84,15 +88,15 @@ public class Function implements Fn, IFrame {
                for(int i=0;i<inputs.size();i++) {\r
                        VariableDeclaration decl = inputs.get(i);\r
                        parameters[i] = decl.variable;\r
-                       decl.variable.base.tellSubscripts(decl.variable.subscripts);\r
+                       decl.variable.base.tellSubscripts(decl.variable.subscripts, null);\r
                }\r
                for(int i=0;i<outputs.size();i++) {\r
                        VariableDeclaration decl = outputs.get(i);\r
-                       decl.variable.base.tellSubscripts(decl.variable.subscripts);\r
+                       decl.variable.base.tellSubscripts(decl.variable.subscripts, null);\r
                }\r
                for(int i=0;i<internals.size();i++) {\r
                        VariableDeclaration decl = internals.get(i);\r
-                       decl.variable.base.tellSubscripts(decl.variable.subscripts);\r
+                       decl.variable.base.tellSubscripts(decl.variable.subscripts, null);\r
                }\r
        }\r
        \r
@@ -106,4 +110,15 @@ public class Function implements Fn, IFrame {
                return parameters;\r
        }\r
        \r
+       @Override\r
+       public Object evaluateInput(IEnvironment environment, int argPosition) {\r
+               VariableDeclaration decl = inputs.get(argPosition);\r
+               return decl.modification.args[0].modification.evaluate(environment);\r
+       }\r
+       \r
+       @Override\r
+       public Model getClass(String name) {\r
+               return null;\r
+       }\r
+       \r
 }\r
index 3f9fcf561df39bccf4b6f3f0139a2b87a8ed0e44..6d4620146e00ef9748e6b4e8b59a080178d52cc0 100644 (file)
@@ -10,6 +10,8 @@
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.Map;\r
+\r
 public class GreaterOrEqualThan implements IExpression {\r
        \r
     public IExpression exp1;\r
@@ -30,5 +32,21 @@ public class GreaterOrEqualThan implements IExpression {
                return ((Double)exp1.evaluate(environment)) >= ((Double)exp2.evaluate(environment));\r
        }\r
 \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               return new GreaterOrEqualThan(exp1.withBase(frame, prefix), exp2.withBase(frame, prefix));\r
+       }\r
     \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               exp1 = exp1.rewrite(frame, copies);\r
+               exp2 = exp2.rewrite(frame, copies);\r
+               return this;\r
+       }\r
+       \r
 }\r
index 195547164601176d26d044dd88e0ab4b9fe32835..21d81acc5364a2d24a351c8137e1c67692fedac4 100644 (file)
@@ -10,6 +10,8 @@
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.Map;\r
+\r
 public class GreaterThan implements IExpression {\r
        \r
     public IExpression exp1;\r
@@ -30,5 +32,21 @@ public class GreaterThan implements IExpression {
                return ((Double)exp1.evaluate(environment)) > ((Double)exp2.evaluate(environment));\r
        }\r
 \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               return new GreaterThan(exp1.withBase(frame, prefix), exp2.withBase(frame, prefix));\r
+       }\r
     \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               exp1 = exp1.rewrite(frame, copies);\r
+               exp2 = exp2.rewrite(frame, copies);\r
+               return this;\r
+       }\r
+       \r
 }\r
index 71b6b7388336f4286bc38d0cf7fd46a0cb2b4f9f..036c1e9fa22ada0b27270457b150353ea512b8c7 100644 (file)
@@ -13,8 +13,9 @@ package fi.semantum.sysdyn.solver;
 public interface IEnvironment {\r
 \r
 //     Object getValue(String key);\r
+       Object getNamedValue(String key);\r
        Object getValue(int index);\r
-//     void put(String key, Object value);\r
+       void put(String key, Object value);\r
        void put(int index, Object value);\r
 //     Object evaluateFunction(IEnvironment parent, String name, ArgumentList args);\r
        \r
index e03d07ca18a2a86e822bc86cf5aaabe5ce6e3d93..6377a3ad513eea1e391f9fa29b02c2f199e5f959 100644 (file)
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.Map;\r
+\r
 public interface IExpression {\r
 \r
        public Object evaluate(IEnvironment environment);\r
+       public IExpression withBase(IFrame frame, String prefix);\r
+       public Object getPossibleConstant();\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies);\r
        \r
 }\r
index 7edb141436aa33824ecd79f2901dd1ae113c8d3a..805ef557891e192be3abcaadfabc694bcf61ed4e 100644 (file)
@@ -12,4 +12,6 @@ package fi.semantum.sysdyn.solver;
 \r
 public interface IFrame {\r
        public VariableBase getBase(String name);\r
+       public VariableBase getBase(VariableBase base, String prefix);\r
+       public Model getClass(String name);\r
 }\r
index 72aafc65e3eca71ae1346262775cee3610130a49..2176faf49c1be298a0078e83119195a91504bc54 100644 (file)
@@ -10,6 +10,8 @@
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.Map;\r
+\r
 public class IfThenElse implements IExpression {\r
        \r
     public IExpression exp;\r
@@ -36,4 +38,22 @@ public class IfThenElse implements IExpression {
                }\r
        }\r
     \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               return new IfThenElse(exp.withBase(frame, prefix), t.withBase(frame, prefix), e.withBase(frame, prefix));\r
+       }\r
+    \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               exp = exp.rewrite(frame, copies);\r
+               t = t.rewrite(frame, copies);\r
+               e = e.rewrite(frame, copies);\r
+               return this;\r
+       }\r
+       \r
 }\r
index 33295cd1f54ab93aa4fbb0a82fe79a5640f1101d..7c2f28707e198cfb44c0d5dc24a0ffa8c9a1cc72 100644 (file)
@@ -10,6 +10,8 @@
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.Map;\r
+\r
 public class LessOrEqualThan implements IExpression {\r
        \r
     public IExpression exp1;\r
@@ -32,5 +34,21 @@ public class LessOrEqualThan implements IExpression {
                return d1 <= d2;\r
        }\r
 \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               return new LessOrEqualThan(exp1.withBase(frame, prefix), exp2.withBase(frame, prefix));\r
+       }\r
     \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               exp1 = exp1.rewrite(frame, copies);\r
+               exp2 = exp2.rewrite(frame, copies);\r
+               return this;\r
+       }\r
+       \r
 }\r
index 6a3aea887eb349e507f6a56aca106f03dbf58fc7..9a8085384eda48bd838361a633bd577df4567a44 100644 (file)
@@ -10,6 +10,8 @@
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.Map;\r
+\r
 public class LessThan implements IExpression {\r
        \r
     public IExpression exp1;\r
@@ -32,4 +34,21 @@ public class LessThan implements IExpression {
                return ((Double)left) < ((Double)right);\r
        }\r
     \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               return new LessThan(exp1.withBase(frame, prefix), exp2.withBase(frame, prefix));\r
+       }\r
+    \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               exp1 = exp1.rewrite(frame, copies);\r
+               exp2 = exp2.rewrite(frame, copies);\r
+               return this;\r
+       }\r
+       \r
 }\r
index 1dc522fddbe8a35bd110b90a87376d3d115818a7..d4e2f420942cd228f7bd62fd0f8f0ff5f8ad1593 100644 (file)
@@ -12,6 +12,7 @@ package fi.semantum.sysdyn.solver;
 \r
 import java.io.StringReader;\r
 \r
+import fi.semantum.sysdyn.solver.Model.Globals;\r
 import fi.semantum.sysdyn.solver.parser.ModelParser;\r
 import fi.semantum.sysdyn.solver.parser.Node;\r
 import fi.semantum.sysdyn.solver.parser.SimpleNode;\r
@@ -38,7 +39,7 @@ public class LineReader {
        public LineReader(String input, NodeCache cache) {\r
                chars = input.toCharArray();\r
                this.cache = cache;\r
-               model = new Model();\r
+               model = new Model(new Globals(), "", false);\r
                parser = new Parser();\r
        }\r
        \r
@@ -89,7 +90,6 @@ public class LineReader {
                        cache.store(line, (SimpleNode)node);\r
                }               \r
                \r
-               parser.currentFrame = model;\r
                parser.walk((SimpleNode)node, 0, model);\r
                \r
        }\r
@@ -118,7 +118,6 @@ public class LineReader {
                        cache.store(line, (SimpleNode)node);\r
                }               \r
                \r
-               parser.currentFrame = model;\r
                parser.walk((SimpleNode)node, 0, model);\r
                \r
        }\r
@@ -142,7 +141,6 @@ public class LineReader {
                        cache.store(line, (SimpleNode)node);\r
                }               \r
                \r
-               parser.currentFrame = model;\r
                parser.walk((SimpleNode)node, 0, model);\r
                \r
        }\r
index 54580e00581019c05275603145fdbe02ac70ea20..4aa58463633d37cf502f165bf9ce6e3a2378444d 100644 (file)
@@ -14,9 +14,14 @@ import java.util.ArrayList;
 import java.util.Arrays;\r
 import java.util.HashMap;\r
 import java.util.Map;\r
+import java.util.TreeMap;\r
 \r
 class Model implements IFrame {\r
        \r
+       static class Globals {\r
+               public Map<String,Model> classes = new HashMap<String,Model>();\r
+       }\r
+       \r
        final public static boolean PRINT = false;\r
        \r
        public boolean initial = false;\r
@@ -26,9 +31,26 @@ class Model implements IFrame {
        public ArrayList<ParameterDeclaration> parameters = new ArrayList<ParameterDeclaration>();\r
        public ArrayList<VariableDeclaration> variables = new ArrayList<VariableDeclaration>();\r
        public Map<String,Fn> functions = new HashMap<String,Fn>();\r
+       public Map<String,VariableBase> copies;\r
        \r
        public Assignment[] assignmentArray;\r
        public Assignment[] derivativeArray;\r
+       public ParameterDeclaration[] parameterArray;\r
+       \r
+       public final Globals globals;\r
+       \r
+       public String name;\r
+       public boolean isEnumClass;\r
+       \r
+       public Model(Globals globals, String name, boolean isEnumClass) {\r
+               this.globals = globals;\r
+               this.name = name;\r
+               this.isEnumClass = isEnumClass;\r
+       }\r
+       \r
+       public void addVariable(VariableDeclaration vd) {\r
+               this.variables.add(vd);\r
+       }\r
        \r
        public Fn getFunction(String name) {\r
                return functions.get(name);\r
@@ -36,10 +58,24 @@ class Model implements IFrame {
        \r
        public HashMap<String,VariableBase> names = new HashMap<String,VariableBase>();\r
        \r
+       public VariableBase getBase(VariableBase original, String prefix) {\r
+               VariableBase base = names.get(prefix+original.name);\r
+               if(base != null) return base;\r
+               base = original.withBase(prefix);\r
+               names.put(base.name, base);\r
+               return base;\r
+       }\r
+       \r
        public VariableBase getBase(String name) {\r
                VariableBase base = names.get(name);\r
                if(base == null) {\r
-                       base = new VariableBase(name);\r
+                       \r
+                       if(isEnumClass) {\r
+                               if("size".equals(name)) base = new EnumSizeVariableBase(this);\r
+                               else if("elements".equals(name)) base = new EnumElementsVariableBase(this);\r
+                       } \r
+                       \r
+                       if(base == null) base = new VariableBase(name);\r
                        names.put(name, base);\r
                }\r
                return base;\r
@@ -57,14 +93,14 @@ class Model implements IFrame {
                        Frame frame = new Frame(environment, fn.offset());\r
 \r
                        ArrayList<Object> argh = new ArrayList<Object>();\r
-                       argh.add(args.args.get(0).modification.toString());\r
-                       for(int i=0;i<args.args.size();i++) {\r
-                               argh.add(args.args.get(i).modification.evaluate(environment));\r
+                       argh.add(args.args[0].modification.toString());\r
+                       for(int i=0;i<args.args.length;i++) {\r
+                               argh.add(args.args[1].modification.evaluate(environment));\r
                        }\r
                        \r
                        Variable[] parameters = fn.parameters();\r
                        \r
-                       for(int i=0;i<args.args.size()+1;i++) {\r
+                       for(int i=0;i<args.args.length+1;i++) {\r
                                Variable var = parameters[i];\r
                                Object value = argh.get(i);\r
                                var.assignPlain(frame, value);\r
@@ -72,34 +108,100 @@ class Model implements IFrame {
 \r
                        fn.setLocals(frame);\r
                        \r
-                       return fn.evaluate(frame, args.args.size()+1);\r
+                       return fn.evaluate(frame, args.args.length+1);\r
                        \r
                } else {\r
                        \r
                        Frame frame = new Frame(environment, fn.offset());\r
                        \r
                        ArrayList<Object> argh = new ArrayList<Object>();\r
-                       for(int i=0;i<args.args.size();i++) {\r
-                               Object arg = args.args.get(i).modification.evaluate(environment);\r
+                       for(int i=0;i<args.args.length;i++) {\r
+                               Object arg = args.args[i].modification.evaluate(environment);\r
+                               if(arg == null) throw new IllegalStateException("No value for " + args.args[i].modification);\r
                                argh.add(arg);\r
                        }\r
                        \r
                        Variable[] parameters = fn.parameters();\r
                        \r
-                       for(int i=0;i<args.args.size();i++) {\r
+                       for(int i=0;i<parameters.length;i++) {\r
                                Variable var = parameters[i];\r
-                               Object value = argh.get(i);\r
-                               var.assignPlain(frame, value);\r
+                               if(i < argh.size()) {\r
+                                       Object value = argh.get(i);\r
+                                       var.assignPlain(frame, value);\r
+                               } else {\r
+                                       Object value = fn.evaluateInput(environment, i);\r
+                                       var.assignPlain(frame, value);\r
+                               }\r
                        }\r
                        \r
                        fn.setLocals(frame);\r
 \r
-                       return fn.evaluate(frame, args.args.size());\r
+                       return fn.evaluate(frame, args.args.length);\r
                        \r
                }\r
                        \r
        }\r
        \r
+       private VariableBase resolveCopy(Map<String,VariableBase> work, VariableBase target) {\r
+               VariableBase deep = work.get(target.name);\r
+               if(deep == null) return target;\r
+               return resolveCopy(work, target);\r
+       }\r
+       \r
+       private void rewrite() {\r
+\r
+               ArrayList<ParameterDeclaration> parameterCopies = new ArrayList<ParameterDeclaration>();\r
+               ArrayList<Assignment> variableCopies = new ArrayList<Assignment>();\r
+\r
+               HashMap<String,VariableBase> work = new HashMap<String,VariableBase>();\r
+               \r
+               for(ParameterDeclaration pd : parameters) {\r
+                       if(pd.modification instanceof Variable) {\r
+                               Variable var = (Variable)pd.modification;\r
+                               if(!SolverUtils.isFullSubscript(var.subscripts)) continue;\r
+                               if(!SolverUtils.isFullSubscript(pd.variable.subscripts)) continue;\r
+                               parameterCopies.add(pd);\r
+                               work.put(pd.variable.base.name, var.base);\r
+                       }\r
+               }\r
+               for(Assignment ass : assignments) {\r
+                       if(ass.expression instanceof Variable) {\r
+                               Variable var = (Variable)ass.expression;\r
+                               if(!SolverUtils.isFullSubscript(var.subscripts)) continue;\r
+                               if(!SolverUtils.isFullSubscript(ass.target.subscripts)) continue;\r
+                               variableCopies.add(ass);\r
+                               work.put(ass.target.base.name, var.base);\r
+                       }\r
+               }\r
+\r
+               parameters.removeAll(parameterCopies);\r
+               assignments.removeAll(variableCopies);\r
+\r
+               copies = new TreeMap<String,VariableBase>();\r
+               for(String key : work.keySet()) {\r
+                       VariableBase b = resolveCopy(work, work.get(key));\r
+                       copies.put(key, b);\r
+               }\r
+\r
+               for(VariableDeclaration vd : variables) {\r
+                       vd.modification = vd.modification.rewrite(this, copies);\r
+                       vd.variable = (Variable)vd.variable.rewrite(this, copies);\r
+               }\r
+               for(ParameterDeclaration pd : parameters) {\r
+                       pd.modification = pd.modification.rewrite(this, copies);\r
+               }\r
+               for(Assignment ass : assignments) {\r
+                       ass.expression = ass.expression.rewrite(this, copies);\r
+               }\r
+               for(Assignment ass : derivatives) {\r
+                       ass.expression = ass.expression.rewrite(this, copies);\r
+               }\r
+               for(Assignment ass : initials) {\r
+                       ass.expression = ass.expression.rewrite(this, copies);\r
+               }\r
+               \r
+       }\r
+       \r
        public int prepare() {\r
 \r
                if(PRINT) {\r
@@ -107,19 +209,32 @@ class Model implements IFrame {
                        System.err.println("==================");\r
                }\r
                \r
-               for(VariableDeclaration vd : variables) {\r
-                       vd.variable.base.tellSubscripts(vd.variable.subscripts);\r
-               }\r
-               for(ParameterDeclaration pd : parameters) {\r
-                       pd.variable.base.tellSubscripts(pd.variable.subscripts);\r
+               rewrite();\r
+               \r
+               boolean done = true;\r
+               \r
+               for(int i=0;i<50;i++) {\r
+                       done = true;\r
+                       for(VariableDeclaration vd : variables) {\r
+                               done &= vd.variable.base.tellSubscripts(vd.variable.subscripts, null);\r
+                       }\r
+                       for(ParameterDeclaration pd : parameters) {\r
+                               done &= pd.variable.base.tellSubscripts(pd.variable.subscripts, pd.modification);\r
+                       }\r
+                       if(done) break;\r
                }\r
+               \r
+               if(!done) throw new IllegalStateException();\r
+               \r
                int nextIndex = 0;\r
                for(Map.Entry<String, VariableBase> entry : names.entrySet()) {\r
                        VariableBase base = entry.getValue();\r
                        base.index = nextIndex;\r
                        if(PRINT)\r
                                System.err.println("Variable: " + entry.getKey() + " " + base.index + " " + Arrays.toString(base.dimensions));\r
-                       nextIndex += base.dimension();\r
+                       int dim = base.dimension();\r
+                       if(dim == -1) dim = 1;\r
+                       nextIndex += dim;\r
                }\r
                \r
                if(PRINT)\r
@@ -129,4 +244,94 @@ class Model implements IFrame {
                \r
        }\r
        \r
+       public void prettyPrint() {\r
+\r
+               System.err.println("initials");\r
+               for(Assignment a : initials) {\r
+                       System.err.println("-"+a);\r
+               }\r
+               System.err.println("assignments");\r
+               for(Assignment a : assignments) {\r
+                       System.err.println("-"+a);\r
+               }\r
+               System.err.println("derivatives");\r
+               for(Assignment a : derivatives) {\r
+                       System.err.println("-"+a);\r
+               }\r
+               System.err.println("parameters");\r
+               for(ParameterDeclaration a : parameters) {\r
+                       System.err.println("-"+a);\r
+               }\r
+               System.err.println("variables");\r
+               for(VariableDeclaration a : variables) {\r
+                       System.err.println("-"+a);\r
+               }\r
+               System.err.println("functions");\r
+               for(Map.Entry<String, Fn> a : functions.entrySet()) {\r
+                       System.err.println("-"+a.getKey() + " " + a.getValue());\r
+               }\r
+               \r
+       }\r
+       \r
+       @Override\r
+       public Model getClass(String name) {\r
+               return globals.classes.get(name);\r
+       }\r
+       \r
+       public boolean instantiateClass(String type_specifier, Declaration decl, IFrame currentFrame) {\r
+               \r
+               Model clazz = globals.classes.get(type_specifier);\r
+               if(clazz == null) return false;\r
+\r
+               Map<String,IExpression> modifications = new HashMap<String,IExpression>();\r
+               if(decl.modification instanceof ArgumentList) {\r
+                       ArgumentList args = (ArgumentList)decl.modification;\r
+                       for(Argument a : args.args) {\r
+                               modifications.put(a.name, a.modification);\r
+                       }\r
+               }\r
+               \r
+               for(VariableDeclaration vd : clazz.variables) {\r
+                       String base = decl.variable.base.name + ".";\r
+                       Variable var2 = vd.variable.withBase(currentFrame, base);\r
+                       VariableDeclaration vd2 = new VariableDeclaration(var2, vd.direction, vd.type, vd.modification.withBase(currentFrame, base));\r
+                       variables.add(vd2);\r
+               }\r
+               for(ParameterDeclaration pd : clazz.parameters) {\r
+                       IExpression modi = modifications.get(pd.variable.base.name);\r
+                       if(modi != null) {\r
+                               String base = decl.variable.base.name + ".";\r
+                               Variable var2 = pd.variable.withBase(currentFrame, base);\r
+                               var2.subscripts = null;\r
+                               ParameterDeclaration pd2 = new ParameterDeclaration(var2, modi);\r
+                               parameters.add(pd2);\r
+                               modifications.remove(pd.variable.base.name);\r
+                       } else {\r
+                               String base = decl.variable.base.name + ".";\r
+                               Variable var2 = pd.variable.withBase(currentFrame, base);\r
+                               ParameterDeclaration pd2 = new ParameterDeclaration(var2, pd.modification.withBase(currentFrame, base));\r
+                               parameters.add(pd2);\r
+                       }\r
+               }\r
+               \r
+               if(!modifications.isEmpty())\r
+                       throw new IllegalStateException();\r
+               \r
+               for(Assignment ass : clazz.assignments) {\r
+                       Assignment ass2 = ass.withBase(currentFrame, decl.variable.base.name + ".");\r
+                       assignments.add(ass2);\r
+               }\r
+               for(Assignment ass : clazz.initials) {\r
+                       Assignment ass2 = ass.withBase(currentFrame, decl.variable.base.name + ".");\r
+                       initials.add(ass2);\r
+               }\r
+               for(Assignment ass : clazz.derivatives) {\r
+                       Assignment ass2 = ass.withBase(currentFrame, decl.variable.base.name + ".");\r
+                       derivatives.add(ass2);\r
+               }\r
+               \r
+               return true;\r
+               \r
+       }\r
+       \r
 }
\ No newline at end of file
diff --git a/dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/MultiStatement.java b/dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/MultiStatement.java
new file mode 100644 (file)
index 0000000..fd878fd
--- /dev/null
@@ -0,0 +1,40 @@
+/*******************************************************************************\r
+ * Copyright (c) 2013 Semantum Oy.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     Semantum Oy - initial API and implementation\r
+ *******************************************************************************/\r
+package fi.semantum.sysdyn.solver;\r
+\r
+import java.util.ArrayList;\r
+\r
+public class MultiStatement implements IStatement {\r
+       \r
+       public ArrayList<Variable> targets;\r
+       public Variable fn;\r
+    public ArgumentList args;\r
+    \r
+    public MultiStatement(ArrayList<Variable> targets, Variable fn, ArgumentList args) {\r
+       this.targets = targets;\r
+       this.fn = fn;\r
+       this.args = args;\r
+    }\r
+    \r
+    @Override\r
+    public String toString() {\r
+       return targets + " := " + fn + " " + args;\r
+    }\r
+    \r
+    @Override\r
+    public void evaluate(IEnvironment environment) {\r
+       ArrayList<Object> values = (ArrayList<Object>)environment.getSystem().evaluateFunction(environment, fn.base.name, args);\r
+       for(int i=0;i<targets.size();i++) {\r
+               targets.get(i).assignPlain(environment, values.get(i));\r
+       }\r
+    }\r
+    \r
+}\r
index 8721c27d76b3c3486ae74024f9ef30d970425b8c..00397a37d3cefa148736d570a415ac051a0f099d 100644 (file)
@@ -10,6 +10,8 @@
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.Map;\r
+\r
 public class Multiplication implements IExpression {\r
        \r
     public IExpression exp1;\r
@@ -24,18 +26,40 @@ public class Multiplication implements IExpression {
     public String toString() {\r
        return exp1 + " * " + exp2;\r
     }\r
-\r
-    private Array arrayMul(Array a, Double d) {\r
-       return a;\r
-    }\r
     \r
        @Override\r
        public Object evaluate(IEnvironment environment) {\r
                Object left = exp1.evaluate(environment);\r
                Object right = exp2.evaluate(environment);\r
-               if(left instanceof Double && right instanceof Double) return ((Double)left)*((Double)right);\r
-               else if (left instanceof Array && right instanceof Double) return arrayMul((Array)left, (Double)right);\r
-               else if (left instanceof Double && right instanceof Array) return arrayMul((Array)right, (Double)left);\r
-               else throw new UnsupportedOperationException();\r
+               if(left instanceof Double && right instanceof Double) {\r
+                       return ((Double)left)*((Double)right);\r
+               } \r
+               else if(left instanceof Array && right instanceof Array) {\r
+                       Array la = (Array)left;\r
+                       Array ra = (Array)right;\r
+                       return la.mul(ra);\r
+               }\r
+               else if (left instanceof Array && right instanceof Double) return ((Array)left).mul((Double)right);\r
+               else if (left instanceof Double && right instanceof Array) return ((Array)right).mul((Double)left);\r
+               throw new IllegalStateException();\r
+               \r
        }\r
+       \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               return new Multiplication(exp1.withBase(frame, prefix), exp2.withBase(frame, prefix));\r
+       }\r
+    \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               exp1 = exp1.rewrite(frame, copies);\r
+               exp2 = exp2.rewrite(frame, copies);\r
+               return this;\r
+       }\r
+       \r
 }\r
index d20354dd3b8e3cb34f340564ce00e6ccbd8ae982..cdf125bae2928a02ff74428a53ffa10917d0b65e 100644 (file)
@@ -10,6 +10,8 @@
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.Map;\r
+\r
 public class Negation implements IExpression {\r
        \r
     public IExpression exp;\r
@@ -28,4 +30,20 @@ public class Negation implements IExpression {
                return -((Double)exp.evaluate(environment));\r
        }\r
     \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               return new Negation(exp.withBase(frame, prefix));\r
+       }\r
+    \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               exp = exp.rewrite(frame, copies);\r
+               return this;\r
+       }\r
+       \r
 }\r
index 2d8c909a84aeaaf3e4ba442038f51a80b2dd724d..33415ec587043de52b068e1c94c8c4416ac8970f 100644 (file)
@@ -22,6 +22,7 @@ public enum NodeClass {
        while_statement,\r
        statement,\r
        name,\r
+       element,\r
        element_list,\r
        element_modification,\r
        function_arguments,\r
@@ -48,7 +49,9 @@ public enum NodeClass {
        add_op,\r
        mul_op,\r
        rel_op,\r
-       der_initial;\r
+       der_initial,\r
+       output_expression_list,\r
+       extends_clause;\r
        \r
        private NodeClass() {\r
                Parser.nodeNameMap.put(toString(), this);\r
index e5bee880bed978665c978e0909fbf03c62cc419e..41ca66a5b47c03d5fd420c47d0df38e4c88d9ed5 100644 (file)
@@ -10,6 +10,8 @@
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.Map;\r
+\r
 public class NotEquals implements IExpression {\r
        \r
     public IExpression exp1;\r
@@ -30,5 +32,21 @@ public class NotEquals implements IExpression {
                return ((Double)exp1.evaluate(environment)) != ((Double)exp2.evaluate(environment));\r
        }\r
 \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               return new NotEquals(exp1.withBase(frame, prefix), exp2.withBase(frame, prefix));\r
+       }\r
     \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               exp1 = exp1.rewrite(frame, copies);\r
+               exp2 = exp2.rewrite(frame, copies);\r
+               return this;\r
+       }\r
+       \r
 }\r
diff --git a/dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/NullModification.java b/dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/NullModification.java
new file mode 100644 (file)
index 0000000..287d618
--- /dev/null
@@ -0,0 +1,27 @@
+package fi.semantum.sysdyn.solver;\r
+\r
+import java.util.Map;\r
+\r
+public class NullModification implements IExpression {\r
+\r
+       @Override\r
+       public Object evaluate(IEnvironment environment) {\r
+               return null;\r
+       }\r
+\r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               return this;\r
+       }\r
+\r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return this;\r
+       }\r
+       \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               return this;\r
+       }\r
+\r
+}\r
index 1e72912a718503f238aca7c9294930e113cae94f..e08c3282151961afb82cd2cba52f1683e22cd629 100644 (file)
 package fi.semantum.sysdyn.solver;\r
 \r
 import java.util.ArrayList;\r
+import java.util.Map;\r
 \r
 public class Or implements IExpression {\r
        \r
-    public ArrayList<IExpression> exps;\r
+    public IExpression[] exps;\r
     \r
     public Or(ArrayList<IExpression> exps) {\r
-       this.exps = exps;\r
+       this.exps = exps.toArray(new IExpression[exps.size()]);\r
     }\r
     \r
     @Override\r
     public String toString() {\r
        StringBuilder b = new StringBuilder();\r
-       b.append(exps.get(0));\r
-       for(int i=1;i<exps.size();i++) {\r
+       b.append(exps[0]);\r
+       for(int i=1;i<exps.length;i++) {\r
                b.append(" or ");\r
-               b.append(exps.get(i));\r
+               b.append(exps[i]);\r
        }\r
        return b.toString();\r
     }\r
@@ -36,5 +37,26 @@ public class Or implements IExpression {
                for(IExpression e : exps) \r
                        if((Boolean)e.evaluate(environment)) return true;\r
                return false;\r
-       }    \r
+       }\r
+       \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               ArrayList<IExpression> ne = new ArrayList<IExpression>();\r
+               for(IExpression e : exps) ne.add(e.withBase(frame, prefix));\r
+               return new Or(ne);\r
+       }\r
+    \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               for(int i=0;i<exps.length;i++) {\r
+                       exps[i] = exps[i].rewrite(frame, copies);\r
+               }\r
+               return this;\r
+       }\r
+       \r
 }\r
index 1c3b04571335dc0ff331b1abc67fc7a0fe7ade9d..1aa811f74d0af9b2430286b906c6ac30438ef06f 100644 (file)
@@ -10,6 +10,8 @@
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.Map;\r
+\r
 \r
 public class ParameterDeclaration implements IExpression {\r
 \r
@@ -32,4 +34,19 @@ public class ParameterDeclaration implements IExpression {
                throw new UnsupportedOperationException();\r
        }\r
        \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               throw new UnsupportedOperationException();\r
+       }\r
+    \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               throw new UnsupportedOperationException();\r
+       }\r
+       \r
 }\r
index 0b1f5aad6b127e5916808af5e4271dac4028e386..cbfac5e79952a71a6aaa3fba2ad92b6f5aa59aaf 100644 (file)
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.io.File;\r
+import java.io.StringReader;\r
 import java.util.ArrayList;\r
 import java.util.HashMap;\r
 import java.util.Map;\r
 \r
+import org.simantics.utils.FileUtils;\r
+\r
+import fi.semantum.sysdyn.solver.Model.Globals;\r
+import fi.semantum.sysdyn.solver.parser.ModelParser;\r
 import fi.semantum.sysdyn.solver.parser.SimpleNode;\r
 \r
 public class Parser {\r
        \r
-       public IFrame currentFrame;\r
+//     public IFrame currentFrame;\r
 \r
        private int PRINT = 0;\r
        \r
-       public Object walk(SimpleNode n, int indent, Model model) {\r
+       public Object walk(SimpleNode n, int indent, IFrame model) {\r
                Object result = walk_(n, indent, model);\r
                if(PRINT > 0) {\r
                        for(int i=0;i<indent;i++) System.err.print(" ");\r
@@ -34,32 +40,35 @@ public class Parser {
        \r
        static Map<String, NodeClass> nodeNameMap = new HashMap<String, NodeClass>();\r
        \r
-       public Object walk_(SimpleNode n, int indent, Model model) {\r
+       public Object walk_(SimpleNode n, int indent, IFrame frame) {\r
 \r
+               Model model = frame instanceof Model ? (Model)frame : null;\r
+               \r
                // TODO: most of this should probably be implemented in the parser\r
                \r
                NodeClass nc = NodeClass.of(n.toString());\r
                \r
                if (nc == null) {\r
-                       if(n.jjtGetNumChildren() == 1) return walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+                       if(n.jjtGetNumChildren() == 1) return walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
                        // not sure if this is ever called\r
                        for(int i=0;i<n.jjtGetNumChildren();i++) {\r
-                               walk((SimpleNode)n.jjtGetChild(i),indent+2, model);\r
+                               walk((SimpleNode)n.jjtGetChild(i),indent+2, frame);\r
                        }\r
                        return null;\r
                }\r
                \r
                switch(nc) {\r
                case assignment:\r
-                       Object v = (Object)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
-                       IExpression exp = (IExpression)walk((SimpleNode)n.jjtGetChild(1), indent+2, model);\r
+                       Object v = (Object)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+                       IExpression exp = (IExpression)walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
                        if(v instanceof Derivative) {\r
                                Derivative der = (Derivative)v;\r
-                               Assignment eq = new Assignment(der.variable,new Derivate(der.variable, exp));\r
+                               Assignment eq = new Assignment(der.variable, der.variable.subscripts, new Derivate(der.variable, der.variable.subscripts, exp));\r
                                model.derivatives.add(eq);\r
                                return eq;\r
                        } else {\r
-                               Assignment eq = new Assignment((Variable)v,exp);\r
+                               Variable var = (Variable)v;\r
+                               Assignment eq = new Assignment(var, var.subscripts, exp);\r
                                if(model.initial)\r
                                        model.initials.add(eq);\r
                                else\r
@@ -69,86 +78,149 @@ public class Parser {
                case equation_section:\r
                        if("initial".equals(n.op)) {\r
                                model.initial = true;\r
+                               for(int i=0;i<n.jjtGetNumChildren();i++) {\r
+                                       walk((SimpleNode)n.jjtGetChild(i),indent+2, frame);\r
+                               }\r
                        } else {\r
                                model.initial = false;\r
+                               for(int i=0;i<n.jjtGetNumChildren();i++) {\r
+                                       walk((SimpleNode)n.jjtGetChild(i),indent+2, frame);\r
+                               }\r
                        }\r
-                       break;\r
+                       return null;\r
                case composition:\r
-                       if(n.jjtGetNumChildren() == 1) return walk((SimpleNode)n.jjtGetChild(0),indent+2, model);\r
+                       if(n.jjtGetNumChildren() == 1) return walk((SimpleNode)n.jjtGetChild(0),indent+2, frame);\r
                        ArrayList<Object> comps = new ArrayList<Object>();\r
                        for(int i=0;i<n.jjtGetNumChildren();i++) {\r
-                               comps.add(walk((SimpleNode)n.jjtGetChild(i),indent+2, model));\r
+                               comps.add(walk((SimpleNode)n.jjtGetChild(i),indent+2, frame));\r
                        }\r
                        return comps;\r
                case for_index:\r
-                       return new ForIndex((Function)currentFrame, n.op, (IExpression)walk((SimpleNode)n.jjtGetChild(0),indent+2, model));\r
+                       if(frame instanceof Function)\r
+                               return new ForIndex((Function)frame, n.op, (IExpression)walk((SimpleNode)n.jjtGetChild(0),indent+2, frame));\r
+                       else\r
+                               return new ForIndex(null, n.op, (IExpression)walk((SimpleNode)n.jjtGetChild(0),indent+2, frame));\r
                case for_indices:\r
                        ArrayList<ForIndex> indices = new ArrayList<ForIndex>();\r
                        for(int i=0;i<n.jjtGetNumChildren();i++) {\r
-                               indices.add((ForIndex)walk((SimpleNode)n.jjtGetChild(i),indent+2, model));\r
+                               indices.add((ForIndex)walk((SimpleNode)n.jjtGetChild(i),indent+2, frame));\r
                        }\r
                        return indices;\r
                case for_statement:\r
-                       ArrayList<ForIndex> indices2 = (ArrayList<ForIndex>)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+                       ArrayList<ForIndex> indices2 = (ArrayList<ForIndex>)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
                        ArrayList<IStatement> stms = new ArrayList<IStatement>();\r
                        for(int i=1;i<n.jjtGetNumChildren();i++) {\r
-                               stms.add((IStatement)walk((SimpleNode)n.jjtGetChild(i),indent+2, model));\r
+                               stms.add((IStatement)walk((SimpleNode)n.jjtGetChild(i),indent+2, frame));\r
                        }\r
                        return new ForStatement(indices2, new StatementList(stms));\r
                case if_statement:\r
-                       IExpression condition = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+                       IExpression condition = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
                        ArrayList<IStatement> thens = new ArrayList<IStatement>();\r
                        ArrayList<IStatement> elses = new ArrayList<IStatement>();\r
                        for(int i=1;i<n.jjtGetNumChildren();i++) {\r
                                SimpleNode child = (SimpleNode)n.jjtGetChild(i);\r
-                               if("then_statement".equals(child.toString())) thens.add((IStatement)walk(child, indent+2, model));\r
-                               else if("else_statement".equals(child.toString())) elses.add((IStatement)walk(child, indent+2, model));\r
+                               if("then_statement".equals(child.toString())) thens.add((IStatement)walk(child, indent+2, frame));\r
+                               else if("else_statement".equals(child.toString())) elses.add((IStatement)walk(child, indent+2, frame));\r
                        }\r
                        return new IfStatement(condition, new StatementList(thens), new StatementList(elses));\r
                case while_statement:\r
-                       IExpression expression = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+                       IExpression expression = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
                        ArrayList<IStatement> whiles = new ArrayList<IStatement>();\r
                        for(int i=1;i<n.jjtGetNumChildren();i++) {\r
-                               whiles.add((IStatement)walk((SimpleNode)n.jjtGetChild(i),indent+2, model));\r
+                               whiles.add((IStatement)walk((SimpleNode)n.jjtGetChild(i),indent+2, frame));\r
                        }\r
                        return new While(expression, new StatementList(whiles));\r
                case statement:\r
-                       if(n.jjtGetNumChildren() == 1) return (IStatement)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
-                       Variable variable = (Variable)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
-                       IExpression expression2 = (IExpression)walk((SimpleNode)n.jjtGetChild(1), indent+2, model);\r
-                       return new Statement(variable, expression2);\r
+                       \r
+//                     ( component_reference() ( ":=" expression() | function_call_args() )\r
+//                                     | "(" output_expression_list() ")" ":=" component_reference() function_call_args()\r
+//                                     | "break"\r
+//                                     | "return"\r
+//                                     | if_statement()\r
+//                                     | for_statement()\r
+//                                     | while_statement()\r
+//                                     | when_statement() )\r
+//                             comment() \r
+                       \r
+                       if(n.jjtGetNumChildren() == 1) {\r
+                               return (IStatement)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+                       } else if (n.jjtGetNumChildren() == 2) {\r
+                               SimpleNode n0 = (SimpleNode)n.jjtGetChild(1);\r
+                               if(n0.toString().equals("expression")) {\r
+                                       Variable variable = (Variable)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+                                       IExpression expression2 = (IExpression)walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
+                                       return new Statement(variable, variable.subscripts, expression2);\r
+                               } else if (n0.toString().equals("function_call_args")) {\r
+                                       throw new IllegalStateException();\r
+                               } else {\r
+                                       throw new IllegalStateException();\r
+                               }\r
+                       } else if (n.jjtGetNumChildren() == 3) {\r
+                               ArrayList<Variable> vars = (ArrayList<Variable>)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+                               Variable fn = (Variable)walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
+                               ArgumentList args = (ArgumentList)walk((SimpleNode)n.jjtGetChild(2), indent+2, frame);\r
+                               return new MultiStatement(vars, fn, args);\r
+                       } else {\r
+                               throw new IllegalStateException();\r
+                       }\r
+               case output_expression_list:\r
+                       ArrayList<Variable> vars = new ArrayList<Variable>();\r
+                       for(int i=0;i<n.jjtGetNumChildren();i++) {\r
+                               vars.add((Variable)walk((SimpleNode)n.jjtGetChild(i),indent+2, frame));\r
+                       }\r
+                       return vars;\r
                case name:\r
                        return n.op;\r
                case element_list:\r
                        ArrayList<Object> elements = new ArrayList<Object>();\r
                        for(int i=0;i<n.jjtGetNumChildren();i++) {\r
-                               elements.add(walk((SimpleNode)n.jjtGetChild(i),indent+2, model));\r
+                               elements.add(walk((SimpleNode)n.jjtGetChild(i),indent+2, frame));\r
                        }\r
                        return elements;\r
+               case element:\r
+//                     if("inner".equals(n.op)) {\r
+//                             return null;\r
+//                     } else {\r
+                               return walk((SimpleNode)n.jjtGetChild(0),indent+2, frame);\r
+//                     }\r
                case element_modification:\r
                        if(n.jjtGetNumChildren() == 2) {\r
-                               String name = (String)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
-                               IExpression modification = (IExpression)walk((SimpleNode)n.jjtGetChild(1), indent+2, model);\r
+                               String name = (String)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+                               IExpression modification = (IExpression)walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
                                return new Argument(name, modification);\r
                        }\r
                        break;\r
                case function_arguments:\r
-                       ArgumentList arguments = new ArgumentList();\r
+                       //ArgumentList arguments = new ArgumentList(n.op);\r
+                       \r
+                       ArrayList<Argument> arguments = new ArrayList<Argument>();\r
+                       \r
                        for(int i=0;i<n.jjtGetNumChildren();i++) {\r
-                               Object o = walk((SimpleNode)n.jjtGetChild(i),indent+2, model);\r
+                               Object o = walk((SimpleNode)n.jjtGetChild(i),indent+2, frame);\r
                                if(o instanceof ArgumentList) {\r
-                                       arguments.args.addAll(((ArgumentList)o).args);\r
+                                       for(Argument a : ((ArgumentList)o).args)\r
+                                               arguments.add(a);\r
                                } else if (o instanceof IExpression) {\r
-                                       arguments.args.add(new Argument("", (IExpression)o));\r
+                                       arguments.add(new Argument("", (IExpression)o));\r
+                               } else if (o instanceof ArrayList) {\r
+                                       ArrayList list = (ArrayList)o;\r
+                                       for(Object o2 : list) {\r
+                                               if(o2 instanceof Argument) {\r
+                                                       arguments.add((Argument)o2);\r
+                                               } else if (o2 instanceof ForIndex) {\r
+                                                       ForIndex fi = (ForIndex)o2;\r
+                                                       arguments.add(new Argument(fi.name, fi.expression));\r
+                                               }\r
+                                       }\r
                                } else {\r
                                        return null;\r
                                }\r
                        }\r
-                       return arguments;\r
+                       return new ArgumentList(arguments, n.op);\r
                case argument_list:\r
                        ArrayList<Argument> args = new ArrayList<Argument>();\r
                        for(int i=0;i<n.jjtGetNumChildren();i++) {\r
-                               args.add((Argument)walk((SimpleNode)n.jjtGetChild(i),indent+2, model));\r
+                               args.add((Argument)walk((SimpleNode)n.jjtGetChild(i),indent+2, frame));\r
                        }\r
                        return new ArgumentList(args);\r
                case type_prefix:\r
@@ -156,67 +228,88 @@ public class Parser {
                case algorithm_section:\r
                        ArrayList<IStatement> statements = new ArrayList<IStatement>();\r
                        for(int i=0;i<n.jjtGetNumChildren();i++) {\r
-                               statements.add((IStatement)walk((SimpleNode)n.jjtGetChild(i),indent+2, model));\r
+                               statements.add((IStatement)walk((SimpleNode)n.jjtGetChild(i),indent+2, frame));\r
                        }\r
                        return new StatementList(statements);\r
                case subscript:\r
                        if(n.jjtGetNumChildren() == 0)\r
                                return new Constant("-1.0");\r
                        if(n.jjtGetNumChildren() == 1)\r
-                               return walk((SimpleNode)n.jjtGetChild(0),indent+2, model);\r
+                               return walk((SimpleNode)n.jjtGetChild(0),indent+2, frame);\r
                        throw new IllegalStateException();\r
                case subscript_2:\r
                        throw new IllegalStateException();\r
                case component_clause:\r
-                       String type_prefix = (String)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
-                       String type_specifier = (String)walk((SimpleNode)n.jjtGetChild(1), indent+2, model);\r
-                       Object third = walk((SimpleNode)n.jjtGetChild(2), indent+2, model);\r
+                       String type_prefix = (String)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+                       String type_specifier = (String)walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
+                       Object third = walk((SimpleNode)n.jjtGetChild(2), indent+2, frame);\r
                        IExpression[] subscripts = (third instanceof IExpression[])? (IExpression[])third : null;\r
                        int declarationStart = (third instanceof IExpression[]) ? 3 : 2;\r
                        ArrayList<Object> clauses = new ArrayList<Object>();\r
                        for(int i=declarationStart;i<n.jjtGetNumChildren();i++) {\r
-                               Declaration decl = (Declaration)walk((SimpleNode)n.jjtGetChild(i), indent+2, model);\r
+                               \r
+                               Declaration decl = (Declaration)walk((SimpleNode)n.jjtGetChild(i), indent+2, frame);\r
                                if(subscripts != null)\r
                                        decl.variable.subscripts = subscripts;\r
+                               \r
                                if("parameter".equals(type_prefix)) {\r
+                                       \r
                                        ParameterDeclaration pd = new ParameterDeclaration(decl.variable, (IExpression)decl.modification);\r
                                        model.parameters.add(pd);\r
                                        clauses.add(pd);\r
+                                       \r
                                } else {\r
-                                       if(decl.modification instanceof ArgumentList) {\r
-                                               VariableDeclaration vd = new VariableDeclaration(decl.variable, type_prefix, type_specifier, (ArgumentList)decl.modification);\r
-                                               if(currentFrame == model) model.variables.add(vd);\r
-                                               clauses.add(vd);\r
-                                       } else  {\r
-                                               VariableDeclaration vd = new VariableDeclaration(decl.variable, type_prefix, type_specifier, new ArgumentList(new ArrayList<Argument>()));\r
-                                               if(currentFrame == model) model.variables.add(vd);\r
-                                               clauses.add(vd);\r
+                                       \r
+                                       boolean wasClass = model == null ? false : model.instantiateClass(type_specifier, decl, frame);\r
+                                       if(!wasClass) {\r
+                                               \r
+                                               if(decl.modification instanceof ArgumentList) {\r
+                                                       VariableDeclaration vd = new VariableDeclaration(decl.variable, type_prefix, type_specifier, (ArgumentList)decl.modification);\r
+                                                       if(model != null)\r
+                                                               model.addVariable(vd);\r
+                                                       clauses.add(vd);\r
+                                               } else if (decl.modification instanceof IExpression) {\r
+                                                       ArrayList<Argument> as = new ArrayList<Argument>();\r
+                                                       as.add(new Argument("", (IExpression)decl.modification));\r
+                                                       ArgumentList al = new ArgumentList(as);\r
+                                                       VariableDeclaration vd = new VariableDeclaration(decl.variable, type_prefix, type_specifier, al);\r
+                                                       if(model != null)\r
+                                                               model.addVariable(vd);\r
+                                                       clauses.add(vd);\r
+                                               } else  {\r
+                                                       VariableDeclaration vd = new VariableDeclaration(decl.variable, type_prefix, type_specifier, new ArgumentList(new ArrayList<Argument>()));\r
+                                                       if(model != null)\r
+                                                               model.addVariable(vd);\r
+                                                       clauses.add(vd);\r
+                                               }\r
+                                               \r
                                        }\r
+                                       \r
                                }\r
                        }\r
                        return clauses;\r
                case component_declaration:\r
-                       return (Declaration)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+                       return (Declaration)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
                case array_subscripts:\r
                        IExpression[] subs = new IExpression[n.jjtGetNumChildren()];\r
                        for(int i=0;i<n.jjtGetNumChildren();i++) {\r
-                               subs[i] = (IExpression)walk((SimpleNode)n.jjtGetChild(i),indent+2, model);\r
+                               subs[i] = (IExpression)walk((SimpleNode)n.jjtGetChild(i),indent+2, frame);\r
                        }\r
                        return subs;\r
                case declaration:\r
                        if(n.jjtGetNumChildren() == 0) {\r
-                               return new Declaration(new Variable(currentFrame, n.op, null), null);\r
+                               return new Declaration(new Variable(frame, n.op, null), null);\r
                        } else if(n.jjtGetNumChildren() == 1) {\r
-                               Object o = walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+                               Object o = walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
                                if(o instanceof IExpression[]) {\r
-                                       return new Declaration(new Variable(currentFrame, n.op, (IExpression[])o), null);\r
+                                       return new Declaration(new Variable(frame, n.op, (IExpression[])o), null);\r
                                } else {\r
-                                       return new Declaration(new Variable(currentFrame, n.op, null), o);\r
+                                       return new Declaration(new Variable(frame, n.op, null), o);\r
                                }\r
                        } else if(n.jjtGetNumChildren() == 2) {\r
-                               IExpression[] subscripts2 = (IExpression[])walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
-                               Object modification = walk((SimpleNode)n.jjtGetChild(1), indent+2, model);\r
-                               return new Declaration(new Variable(currentFrame, n.op,subscripts2), modification);\r
+                               IExpression[] subscripts2 = (IExpression[])walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+                               Object modification = walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
+                               return new Declaration(new Variable(frame, n.op,subscripts2), modification);\r
                        } else {\r
                                StringBuilder b = new StringBuilder();\r
                                b.append("declaration: ");\r
@@ -231,8 +324,7 @@ public class Parser {
                                String functionName = child.op;\r
                                ArrayList<IStatement> stms2 = new ArrayList<IStatement>();\r
                                Function function = new Function(functionName, new StatementList(stms2));\r
-                               currentFrame = function;\r
-                               ArrayList<Object> composition = (ArrayList<Object>)walk(child, indent+2, model);\r
+                               ArrayList<Object> composition = (ArrayList<Object>)walk(child, indent+2, function);\r
                                for(int i=1;i<composition.size();i++) {\r
                                        Object comp = composition.get(i);\r
                                        if(comp instanceof IStatement) {\r
@@ -240,56 +332,104 @@ public class Parser {
                                        } else if(comp instanceof ArrayList) {\r
                                                ArrayList<Object> declarations = (ArrayList<Object>)composition.get(i);\r
                                                for(Object os_ : declarations) {\r
-                                                       ArrayList<Object> os = (ArrayList<Object>)os_;\r
-                                                       for(Object o : os) {\r
-                                                               VariableDeclaration decl = (VariableDeclaration)o;\r
-                                                               function.internals.add(decl);\r
+                                                       if(os_ instanceof VariableDeclaration) {\r
+                                                               VariableDeclaration decl = (VariableDeclaration)os_;\r
+                                                               if("input".equals(decl.direction)) function.inputs.add(decl);\r
+                                                               else if ("output".equals(decl.direction)) function.outputs.add(decl);\r
+                                                               else throw new IllegalStateException();\r
+                                                       } else {\r
+                                                               ArrayList<Object> os = (ArrayList<Object>)os_;\r
+                                                               for(Object o : os) {\r
+                                                                       VariableDeclaration decl = (VariableDeclaration)o;\r
+                                                                       function.internals.add(decl);\r
+                                                               }\r
                                                        }\r
                                                }\r
                                        }\r
                                }\r
                                ArrayList<Object> declarations = (ArrayList<Object>)composition.get(0);\r
                                for(Object os_ : declarations) {\r
-                                       ArrayList<Object> os = (ArrayList<Object>)os_;\r
-                                       for(Object o : os) {\r
-                                               VariableDeclaration decl = (VariableDeclaration)o;\r
+                                       if(os_ instanceof VariableDeclaration) {\r
+                                               VariableDeclaration decl = (VariableDeclaration)os_;\r
                                                if("input".equals(decl.direction)) function.inputs.add(decl);\r
                                                else if ("output".equals(decl.direction)) function.outputs.add(decl);\r
                                                else throw new IllegalStateException();\r
+                                       } else {\r
+                                               ArrayList<Object> os = (ArrayList<Object>)os_;\r
+                                               for(Object o : os) {\r
+                                                       VariableDeclaration decl = (VariableDeclaration)o;\r
+                                                       if("input".equals(decl.direction)) function.inputs.add(decl);\r
+                                                       else if ("output".equals(decl.direction)) function.outputs.add(decl);\r
+                                                       else throw new IllegalStateException();\r
+                                               }\r
                                        }\r
                                }\r
                                model.functions.put(functionName, function);\r
-                               currentFrame = model;\r
                                return function;\r
+                               \r
+                       } else if("model".equals(n.op)) {\r
+\r
+                               if(n.jjtGetNumChildren() == 1) {\r
+                                       return walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+                               } else {\r
+                                       System.err.println("undefined children for class_definition model");    \r
+                               }\r
+                               return null;\r
+                               \r
+                       } else if("class".equals(n.op)) {\r
+                               \r
+                               SimpleNode specifier = (SimpleNode)n.jjtGetChild(0); \r
+                               Model clazz = new Model(model.globals, specifier.op, false);\r
+                               model.globals.classes.put(specifier.op, clazz);\r
+                               walk(specifier, indent+2, clazz);\r
+                               \r
+                               if(clazz.isEnumClass) {\r
+                                       Variable sizeVariable = new Variable(clazz, "size", null);\r
+                                       Variable elementsVariable = new Variable(clazz, "elements", new IExpression[] { new Constant(""+clazz.variables.size()) });\r
+                                       clazz.parameters.add(new ParameterDeclaration(sizeVariable, sizeVariable.getPossibleConstant()));\r
+                                       clazz.parameters.add(new ParameterDeclaration(elementsVariable, elementsVariable.getPossibleConstant()));\r
+                               }\r
+                               \r
+                               return null;\r
+                               \r
+                       } else {\r
+                               System.err.println("class_definition " + n.op);\r
                        }\r
                        break;\r
                case array:\r
-                       Array array = new Array();\r
                        if(n.jjtGetNumChildren() == 1) {\r
-                               ArgumentList al = (ArgumentList)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
-                               for(Argument arg : al.args) array.addElement(arg.modification);\r
+                               ArgumentList al = (ArgumentList)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+                               if("for".equals(al.op)) {\r
+                                       ForArray array = new ForArray();\r
+                                       array.addElement(al.args[0].modification);\r
+                                       array.addElement(al.args[1]);\r
+                                       return array;\r
+                               } else {\r
+                                       Array array = new Array();\r
+                                       for(Argument arg : al.args) array.addElement(arg.modification);\r
+                                       return array;\r
+                               }\r
                        }\r
-                       return array;\r
                case primary:\r
                        if(n.op != null) {\r
                                return Utils.parsePrimitive(n.op);\r
                        } else {\r
-                               return walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+                               return walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
                        }\r
                case component_reference:\r
                        if(n.jjtGetNumChildren() == 1) {\r
-                               return new Variable(currentFrame, n.op, (IExpression[])walk((SimpleNode)n.jjtGetChild(0), indent+2, model));\r
+                               return Variable.make(frame, n.op, (IExpression[])walk((SimpleNode)n.jjtGetChild(0), indent+2, frame));\r
                        } else {\r
                                if ("time".equals(n.op)) {\r
                                        return new TimeVariable();\r
                                }\r
-                               return new Variable(currentFrame, n.op, null);\r
+                               return Variable.make(frame, n.op, null);\r
                        }\r
                case relation:\r
                        if(n.jjtGetNumChildren() == 3) {\r
-                               IExpression exp1 = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
-                               String op = (String)walk((SimpleNode)n.jjtGetChild(1), indent+2, model);\r
-                               IExpression exp2 = (IExpression)walk((SimpleNode)n.jjtGetChild(2), indent+2, model);\r
+                               IExpression exp1 = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+                               String op = (String)walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
+                               IExpression exp2 = (IExpression)walk((SimpleNode)n.jjtGetChild(2), indent+2, frame);\r
                                String trimmed = op != null ? op.trim() : null;\r
                                if("<".equals(trimmed)) {\r
                                        return new LessThan(exp1, exp2);\r
@@ -306,13 +446,13 @@ public class Parser {
                                }\r
                                else return null;\r
                        } else {\r
-                               return walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+                               return walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
                        }\r
                case simple_expression:\r
-                       if(n.jjtGetNumChildren() == 1) return walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+                       if(n.jjtGetNumChildren() == 1) return walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
                        else if(n.jjtGetNumChildren() == 2) {\r
-                               IExpression start = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, model); \r
-                               IExpression end = (IExpression)walk((SimpleNode)n.jjtGetChild(1), indent+2, model);\r
+                               IExpression start = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame); \r
+                               IExpression end = (IExpression)walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
                                return new ArraySliceExpression(start, end);\r
                        } else {\r
                                throw new UnsupportedOperationException();\r
@@ -321,57 +461,67 @@ public class Parser {
                        if(n.jjtGetNumChildren() > 1) {\r
                                ArrayList<IExpression> logs = new ArrayList<IExpression>();\r
                                for(int i=0;i<n.jjtGetNumChildren();i++) {\r
-                                       logs.add((IExpression)walk((SimpleNode)n.jjtGetChild(i),indent+2, model));\r
+                                       logs.add((IExpression)walk((SimpleNode)n.jjtGetChild(i),indent+2, frame));\r
                                }\r
                                return new Or(logs);\r
                        } else {\r
-                               return walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+                               return walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
                        }\r
                case logical_term:\r
                        if(n.jjtGetNumChildren() > 1) {\r
                                ArrayList<IExpression> terms = new ArrayList<IExpression>();\r
                                for(int i=0;i<n.jjtGetNumChildren();i++) {\r
-                                       terms.add((IExpression)walk((SimpleNode)n.jjtGetChild(i),indent+2, model));\r
+                                       terms.add((IExpression)walk((SimpleNode)n.jjtGetChild(i),indent+2, frame));\r
                                }\r
                                return new And(terms);\r
                        } else {\r
-                               return walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+                               return walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
                        }\r
                case arithmetic_expression:\r
-                       if(n.jjtGetNumChildren() == 2) {\r
+               {\r
+                       int i=0;\r
+                       IExpression left;\r
+                       if(n.jjtGetNumChildren() % 2 == 0) {\r
                                String op = ((String)walk((SimpleNode)n.jjtGetChild(0), indent+2, model)).trim();\r
-                               if("-".equals(op)) return new Negation((IExpression)walk((SimpleNode)n.jjtGetChild(1), indent+2, model));\r
-                       }\r
-                       if(n.jjtGetNumChildren() > 1) {\r
-                               IExpression left = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
-                               for(int i=1;i<n.jjtGetNumChildren();i+=2) {\r
-                                       String op = ((String)walk((SimpleNode)n.jjtGetChild(i), indent+2, model)).trim();\r
-                                       IExpression exp2 = (IExpression)walk((SimpleNode)n.jjtGetChild(i+1), indent+2, model);\r
-                                       if("+".equals(op)) left = new Addition(left, exp2);\r
-                                       else if("-".equals(op)) left = new Subtraction(left, exp2);\r
+                               left = (IExpression)walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
+                               if("-".equals(op)) {\r
+                                       left = new Negation(left);\r
                                }\r
-                               return left;\r
+                               i=2;\r
                        } else {\r
-                               return walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+                               left = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+                               i=1;\r
+                       }\r
+\r
+                       for(;i<n.jjtGetNumChildren();i+=2) {\r
+                               String op = ((String)walk((SimpleNode)n.jjtGetChild(i), indent+2, model)).trim();\r
+                               IExpression exp2 = (IExpression)walk((SimpleNode)n.jjtGetChild(i+1), indent+2, frame);\r
+                               if("+".equals(op)) left = new Addition(left, exp2);\r
+                               else if("-".equals(op)) left = new Subtraction(left, exp2);\r
                        }\r
+\r
+                       return left;\r
+               }\r
+                       \r
                case term:\r
                        if(n.jjtGetNumChildren() > 1) {\r
-                               IExpression term = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+                               IExpression term = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
                                for(int i=1;i<n.jjtGetNumChildren();i+=2) {\r
                                        String op = ((String)walk((SimpleNode)n.jjtGetChild(i), indent+2, model)).trim();\r
-                                       IExpression exp2 = (IExpression)walk((SimpleNode)n.jjtGetChild(i+1), indent+2, model);\r
+                                       IExpression exp2 = (IExpression)walk((SimpleNode)n.jjtGetChild(i+1), indent+2, frame);\r
                                        if("*".equals(op)) term = new Multiplication(term, exp2);\r
+                                       else if(".*".equals(op)) term = new ElementwiseProduct(term, exp2);\r
                                        else if("/".equals(op)) term = new Division(term, exp2);\r
                                }\r
                                return term;\r
                        } else {\r
-                               return walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
+                               return walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
                        }\r
                case if_expression:\r
                        if(n.jjtGetNumChildren() == 3) {\r
-                               IExpression exp1 = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
-                               IExpression exp2 = (IExpression)walk((SimpleNode)n.jjtGetChild(1), indent+2, model);\r
-                               IExpression exp3 = (IExpression)walk((SimpleNode)n.jjtGetChild(2), indent+2, model);\r
+                               IExpression exp1 = (IExpression)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+                               IExpression exp2 = (IExpression)walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
+                               IExpression exp3 = (IExpression)walk((SimpleNode)n.jjtGetChild(2), indent+2, frame);\r
                                return new IfThenElse(exp1, exp2, exp3);\r
                        }\r
                case add_op:\r
@@ -382,21 +532,101 @@ public class Parser {
                        return n.op;\r
                case der_initial:\r
                        if("der".equals(n.op)) {\r
-                               ArgumentList args2 = (ArgumentList)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
-                               if(args2.args.size() == 1) {\r
-                                       return new Derivative((Variable)args2.args.get(0).modification);\r
+                               ArgumentList args2 = (ArgumentList)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+                               if(args2.args.length == 1) {\r
+                                       return new Derivative((Variable)args2.args[0].modification);\r
                                }\r
                        } else if("initial".equals(n.op)) {\r
-                               return new Application("initial", new ArgumentList());\r
+                               return new Application("initial", new ArgumentList(""));\r
                        } else if("application".equals(n.op)) {\r
-                               String name = (String)walk((SimpleNode)n.jjtGetChild(0), indent+2, model);\r
-                               ArgumentList args2 = (ArgumentList)walk((SimpleNode)n.jjtGetChild(1), indent+2, model);\r
+                               String name = (String)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+                               ArgumentList args2 = (ArgumentList)walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
                                return new Application(name, args2);\r
                        }\r
+               case extends_clause:\r
+                       String extendsName = (String)walk((SimpleNode)n.jjtGetChild(0), indent+2, frame);\r
+                       walk((SimpleNode)n.jjtGetChild(1), indent+2, frame);\r
+                       model.isEnumClass = extendsName.equals("Enumeration_class");\r
+                       return null;\r
                }\r
                        \r
+               System.err.println("fall-through " + n);\r
+               \r
                // should not get this far\r
                return null;\r
        }\r
        \r
+       public static final boolean WAIT = false;\r
+       \r
+       public static void main(String[] args) throws Exception {\r
+               \r
+               if(WAIT) {\r
+                       for(int i=0;i<1e12;i++) {\r
+                               int k = System.in.read();\r
+                               if(k==13) break;\r
+                               Thread.sleep(10);\r
+                       }\r
+               }\r
+               \r
+//             NodeCache cache = new NodeCache();\r
+//\r
+////           long start = System.nanoTime();\r
+//\r
+//             File f = new File("C:/Users/Antti Villberg/Downloads/isomalli.txt");\r
+//             String contents = FileUtils.getContents(f);\r
+//             LineReader reader = new LineReader(contents, cache);\r
+//             reader.parse();\r
+//\r
+////           long duration = System.nanoTime()-start;\r
+////           System.err.println("complete parse file in " + 1e-9*duration + "s.");\r
+//\r
+////           start = System.nanoTime();\r
+//\r
+//             if(WAIT) {\r
+//                     for(int i=0;i<1e12;i++) {\r
+//                             int k = System.in.read();\r
+//                             if(k==13) break;\r
+//                             Thread.sleep(10);\r
+//                     }\r
+//             }\r
+\r
+               \r
+\r
+               \r
+               File f1 = new File("d:/sysdynfn.txt");\r
+               String contents1 = FileUtils.getContents(f1);\r
+               File f2 = new File("d:/sysdyntest.txt");\r
+               String contents2 = contents1 + FileUtils.getContents(f2);\r
+               \r
+               StringReader reader = new StringReader(contents2);\r
+               ModelParser modelParser = new ModelParser(reader);\r
+               SimpleNode n = (SimpleNode)modelParser.stored_definition();\r
+           Parser parser = new Parser();\r
+           Model m = new Model(new Globals(), "", false);\r
+               parser.walk(n, 0, m);\r
+               \r
+               m.prettyPrint();\r
+               \r
+               Solver solver = new Solver();\r
+               solver.prepare(contents2);\r
+               \r
+//\r
+//             if(WAIT) {\r
+//                     for(int i=0;i<1e12;i++) {\r
+//                             int k = System.in.read();\r
+//                             if(k==13) break;\r
+//                             Thread.sleep(10);\r
+//                     }\r
+//             }\r
+//\r
+//             long start = System.nanoTime();\r
+               for(int i=0;i<50;i++) {\r
+                       solver.step();\r
+                       solver.printEnvironment();\r
+               }\r
+//             long duration = System.nanoTime()-start;\r
+//             System.err.println("stepped simulation in " + 1e-9*duration + "s.");\r
+               \r
+       }\r
+       \r
 }\r
index 283db97049267050d8e93699aa06de44b06d52bb..bcd050d4a931231b88ea8f9b2343ef97678248a3 100644 (file)
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.io.StringReader;\r
 import java.util.ArrayList;\r
-import java.util.HashMap;\r
+\r
+import fi.semantum.sysdyn.solver.Model.Globals;\r
+import fi.semantum.sysdyn.solver.parser.ModelParser;\r
+import fi.semantum.sysdyn.solver.parser.SimpleNode;\r
 \r
 public class Solver {\r
 \r
@@ -48,13 +52,25 @@ public class Solver {
        }\r
        \r
        public void prepare(String input) throws Exception {\r
-               LineReader reader = new LineReader(input, cache);\r
-               reader.parse();\r
                \r
-               model = reader.model;\r
+               long startNanos = System.nanoTime();\r
+               \r
+//             LineReader reader = new LineReader(input, cache);\r
+//             reader.parse();\r
+//             \r
+//             model = reader.model;\r
+               \r
+               StringReader reader = new StringReader(input);\r
+               ModelParser modelParser = new ModelParser(reader);\r
+               SimpleNode n = (SimpleNode)modelParser.stored_definition();\r
+           Parser parser = new Parser();\r
+           model = new Model(new Globals(), "", false);\r
+               parser.walk(n, 0, model);\r
+               \r
                env = new Environment(model, step, start);\r
                \r
                int size = model.prepare();\r
+               env.setSize(size);\r
                \r
                for(Fn fn : model.functions.values()) {\r
                        if(fn instanceof Function)\r
@@ -65,23 +81,27 @@ public class Solver {
                \r
                model.assignmentArray = model.assignments.toArray(new Assignment[model.assignments.size()]);\r
                model.derivativeArray = model.derivatives.toArray(new Assignment[model.derivatives.size()]);\r
+               model.parameterArray = model.parameters.toArray(new ParameterDeclaration[model.parameters.size()]);\r
                \r
                newValues = new Object[Math.max(model.assignments.size(),model.derivatives.size())];\r
                \r
-               int koss = 1;\r
+               int condition = 1;\r
+               int loops = 0;\r
                \r
-               while(koss > 0) {\r
+               while(condition > 0 && loops++ < 50) {\r
                        \r
-                       koss = 0;\r
+//                     System.err.println("== LOOP " + loops + " ==");\r
+                       \r
+                       condition = 0;\r
 \r
                        for(ParameterDeclaration pd : model.parameters) {\r
                                try {\r
                                        if(!pd.assigned) {\r
-                                               pd.variable.assign(env, pd.modification.evaluate(env));\r
+                                               pd.variable.assign(env, null, pd.modification.evaluate(env));\r
                                                pd.assigned = true;\r
                                        }\r
                                } catch (Exception e) {\r
-                                       koss++;\r
+                                       condition++;\r
                                        if(PRINT_EXCEPTIONS) {\r
                                                e.printStackTrace();\r
                                                System.err.println("failed to assign " + pd.variable.toString());\r
@@ -97,9 +117,19 @@ public class Solver {
                                try {\r
                                        if(!vd.assigned) {\r
                                                for(Argument arg : vd.modification.args) {\r
-                                                       if("start".equals(arg.name)) {\r
+                                                       if(arg.name.endsWith("start")) {\r
                                                                Object value = arg.modification.evaluate(env);\r
-                                                               vd.variable.assign(env, value);\r
+                                                               if(vd.variable.base.dimension() == 1) {\r
+                                                                       vd.variable.assign(env, null, value);\r
+                                                               } else {\r
+                                                                       if(value instanceof Double) {\r
+                                                                               Array array = new Array();\r
+                                                                               for(int i=0;i<vd.variable.base.dimension();i++) array.addElement(value);\r
+                                                                               vd.variable.assign(env, null, array);\r
+                                                                       } else {\r
+                                                                               throw new IllegalStateException();\r
+                                                                       }\r
+                                                               }\r
                                                                // make sure the variable is not initialized \r
                                                                // twice, this is probably not the most \r
                                                                // efficient way\r
@@ -110,10 +140,9 @@ public class Solver {
                                                                }\r
                                                        }\r
                                                }\r
-                                               vd.assigned = true;\r
                                        }\r
                                } catch (Exception e) {\r
-                                       koss++;\r
+                                       condition++;\r
                                        if(PRINT_EXCEPTIONS) {\r
                                                e.printStackTrace();\r
                                                System.err.println("failed to assign " + vd.variable.toString());\r
@@ -125,11 +154,11 @@ public class Solver {
                                try {\r
                                        if(!ass.assigned) {\r
                                                Object value = ass.expression.evaluate(env);\r
-                                               ass.target.assign(env, value);\r
+                                               ass.target.assign(env, ass.subscripts, value);\r
                                                ass.assigned = true;\r
                                        }\r
                                } catch (Exception e) {\r
-                                       koss++;\r
+                                       condition++;\r
                                        if(PRINT_EXCEPTIONS) {\r
                                                e.printStackTrace();\r
                                                System.err.println("failed to assign " + ass.target.toString());\r
@@ -141,10 +170,19 @@ public class Solver {
                env.initial = false;\r
                \r
                ready = true;\r
+               \r
+               long endNanos = System.nanoTime();\r
+               \r
+               System.err.println("Prepared model in " + 1e-6*(endNanos-startNanos) + "ms.");\r
+               \r
+       }\r
+       \r
+       public String[] keys() {\r
+               return env.getValueKeyArray();\r
        }\r
        \r
-       public HashMap<String, Double> values() {\r
-               return env.getValueMap();\r
+       public double[] values() {\r
+               return env.getValueArray();\r
        }\r
        \r
        public void step() {\r
@@ -162,7 +200,7 @@ public class Solver {
                        newValues[i] = assignments[i].expression.evaluate(env);\r
                }\r
                for(int i=0;i<model.assignments.size();i++) {\r
-                       assignments[i].target.assign(env, newValues[i]);\r
+                       assignments[i].target.assign(env, assignments[i].subscripts, newValues[i]);\r
                }\r
 \r
                // Solve derivatives\r
@@ -170,10 +208,19 @@ public class Solver {
                        newValues[i] = derivatives[i].expression.evaluate(env);\r
                }\r
                for(int i=0;i<model.derivatives.size();i++) {\r
-                       derivatives[i].target.assign(env, newValues[i]);\r
+                       derivatives[i].target.assign(env, assignments[i].subscripts, newValues[i]);\r
                }\r
        }\r
        \r
        // TODO: implement some on the fly parameter change stuff for different experiment types\r
        \r
+       public void printEnvironment() {\r
+               String[] keys = keys();\r
+               double[] values = values();\r
+               System.err.println("Environment " + keys.length + " " + values.length);\r
+               for(int i=0;i<keys.length;i++) {\r
+                       System.err.println(keys[i] + " = " + values[i]);\r
+               }\r
+       }\r
+       \r
 }\r
diff --git a/dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/SolverUtils.java b/dev-jkauttio/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/SolverUtils.java
new file mode 100644 (file)
index 0000000..731de2d
--- /dev/null
@@ -0,0 +1,60 @@
+package fi.semantum.sysdyn.solver;\r
+\r
+public class SolverUtils {\r
+\r
+       public static class Slice {\r
+               public static final Slice FULL = new Slice(-2,-1);\r
+               public int start;\r
+               public int end;\r
+               public Slice(int start, int end) {\r
+                       this.start = start;\r
+                       this.end = end;\r
+               }\r
+       }\r
+       \r
+       public static boolean isFullSubscript(IExpression[] subscripts) {\r
+               if(subscripts == null) return true;\r
+               for(int i=0;i<subscripts.length;i++) {\r
+                       if(subscripts[i] instanceof Constant) {\r
+                               Constant c = (Constant)subscripts[i];\r
+                               if(c.value instanceof Double) {\r
+                                       Double d = (Double)c.value;\r
+                                       if(d == -1.0) continue;\r
+                               }\r
+                       }\r
+                       return false;\r
+               }\r
+               return true;\r
+       }\r
+       \r
+       public static boolean isArray(int[] dimensions) {\r
+               return dimensions != null && dimensions != VariableBase.UNINIT;\r
+       }\r
+       \r
+       public static Slice[] parseSubscripts(IEnvironment env, IExpression[] subscripts) {\r
+               Slice[] result = new Slice[subscripts.length];\r
+               for(int i=0;i<subscripts.length;i++) {\r
+                       IExpression e = subscripts[i];\r
+                       if(e instanceof ArraySliceExpression) {\r
+                               ArraySliceExpression ase = (ArraySliceExpression)e;\r
+                               Double start = (Double)ase.start.evaluate(env);\r
+                               Double end = (Double)ase.end.evaluate(env);\r
+                               result[i] = new Slice(start.intValue(), end.intValue());\r
+                       } else {\r
+                               Double v = (Double)e.evaluate(env);\r
+                               int index = v.intValue()-1;\r
+                               if(index == -2) result[i] = Slice.FULL;\r
+                               else result[i] = new Slice(index,index);\r
+                       }\r
+               }\r
+               return result;\r
+       }\r
+       \r
+       public static boolean isSlice(Slice[] subs) {\r
+               for(Slice s : subs) {\r
+                       if(s.start != s.end) return true;\r
+               }\r
+               return false;\r
+       }\r
+       \r
+}\r
index 3b5afcf322744827d9b8ef6cd6f053b965a30254..a3dcd40f80c5c81174479238f4f0d58613e43fe4 100644 (file)
@@ -13,10 +13,12 @@ package fi.semantum.sysdyn.solver;
 public class Statement implements IStatement {\r
        \r
        public Variable target;\r
+       public IExpression[] subscripts;\r
     public IExpression expression;\r
     \r
-    public Statement(Variable target, IExpression expression) {\r
+    public Statement(Variable target, IExpression[] subscripts, IExpression expression) {\r
        this.target = target;\r
+       this.subscripts = subscripts;\r
        this.expression = expression;\r
     }\r
     \r
@@ -28,7 +30,7 @@ public class Statement implements IStatement {
     @Override\r
     public void evaluate(IEnvironment environment) {\r
                Object value = expression.evaluate(environment);\r
-               target.assign(environment, value);\r
+               target.assign(environment, subscripts, value);\r
     }\r
     \r
 }\r
index fcf261e95a3b94c736ea411285d3626871954fa7..f7f8763d32767665308ef28b6d45a39d3d4944bc 100644 (file)
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.Map;\r
+\r
 public class Subtraction implements IExpression {\r
        \r
     public IExpression exp1;\r
     public IExpression exp2;\r
     \r
     public Subtraction(IExpression exp1, IExpression exp2) {\r
+       if(exp1 == null) exp1 = new Constant("0");\r
        this.exp1 = exp1;\r
        this.exp2 = exp2;\r
     }\r
@@ -29,5 +32,22 @@ public class Subtraction implements IExpression {
        public Object evaluate(IEnvironment environment) {\r
                return ((Double)exp1.evaluate(environment)) - ((Double)exp2.evaluate(environment));\r
        }\r
+       \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               return new Subtraction(exp1.withBase(frame, prefix), exp2.withBase(frame, prefix));\r
+       }\r
+    \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
     \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               exp1 = exp1.rewrite(frame, copies);\r
+               exp2 = exp2.rewrite(frame, copies);\r
+               return this;\r
+       }\r
+       \r
 }\r
index c6a7251505345bc2de07de3883dc7cb408d4d95c..d2d3e4c6044f5cf73f41bf242a6139233b26cb60 100644 (file)
@@ -10,6 +10,8 @@
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.Map;\r
+\r
 public class TimeVariable implements IExpression {\r
 \r
        @Override\r
@@ -23,4 +25,19 @@ public class TimeVariable implements IExpression {
                return "time";\r
        }\r
        \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               return this;\r
+       }\r
+    \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+\r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               return this;\r
+       }\r
+       \r
 }\r
index 055310498430f3c606fbfeed92620bf9c35418dd..183d0cc3be23cfada5bb2d5b8841c58fe64aa112 100644 (file)
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.Map;\r
+\r
+\r
+\r
 public class Variable implements IExpression {\r
 \r
        public VariableBase base;\r
@@ -21,30 +25,21 @@ public class Variable implements IExpression {
                this.subscripts = subscripts;\r
        }\r
        \r
+       public static Object make(IFrame frame, String name, IExpression[] subscripts) {\r
+//             Array enumElements = enumerationElements(frame, name);\r
+//             if(enumElements != null) return enumElements;\r
+//             Constant enumSize = enumerationSize(frame, name);\r
+//             if(enumSize != null) return enumSize;\r
+               return new Variable(frame, name, subscripts);\r
+       }\r
+       \r
        public Variable(VariableBase base) {\r
                this.base = base;\r
        }\r
 \r
-       private int makeSubscriptIndex(IEnvironment env) {\r
-               if(base.dimensions == null) return 0;\r
-               int result = 0;\r
-               for(int i=0;i<subscripts.length;i++) {\r
-                       int factor = 1;\r
-                       for(int j=i+1;j<subscripts.length;j++) factor *= base.dimensions[j];\r
-                       IExpression e = subscripts[i];\r
-                       Double v = (Double)e.evaluate(env);\r
-                       int index = v.intValue()-1;\r
-                       if(index == -2) return 0;\r
-                       result += factor*index;\r
-               }\r
-               if(result == -1) throw new IllegalStateException();\r
-               return result;\r
-\r
-       }\r
-       \r
-       public int subscriptIndex(IEnvironment env) {\r
-               if(subscripts == null) return 0;\r
-               return makeSubscriptIndex(env);\r
+       public Variable(VariableBase base, IExpression[] subscripts) {\r
+               this.base = base;\r
+               this.subscripts = subscripts;\r
        }\r
        \r
        @Override\r
@@ -70,7 +65,12 @@ public class Variable implements IExpression {
                                str.append(", ");\r
                        }\r
                        // is the expression inside subscript always a constant?\r
-                       str.append(((Double)((Constant)subscripts[i]).value).intValue());\r
+                       Object sub = subscripts[i];\r
+                       if(sub instanceof Constant) {\r
+                               str.append(((Double)((Constant)sub).value).intValue());\r
+                       } else if (sub instanceof Variable) {\r
+                               str.append(((Variable)sub).base.name);\r
+                       }\r
                }\r
                str.append(']');\r
                return str.toString();\r
@@ -78,7 +78,6 @@ public class Variable implements IExpression {
        \r
        public int assignArray(IEnvironment env, int index, Array value, int asd) {\r
                for(int i=0;i<value.elements().size();i++) {\r
-//                     String s = name + "_" + (i+1);\r
                        Object element = value.element(i);\r
                        if(element instanceof Double) {\r
                                env.put(index+asd++, (Double)element);\r
@@ -94,10 +93,6 @@ public class Variable implements IExpression {
                return asd;\r
        }\r
        \r
-       public int index(IEnvironment env) {\r
-               return base.index + subscriptIndex(env);\r
-       }\r
-       \r
        public void setArrayIndex(IEnvironment environment, Array array, Object value) {\r
                \r
                for(int i=0;i<subscripts.length-1;i++) {\r
@@ -120,29 +115,52 @@ public class Variable implements IExpression {
                \r
        }\r
        \r
-       public Object getArrayIndex(IEnvironment environment, Array array) {\r
-               Object result = array;\r
-               for(IExpression e : subscripts) {\r
-                       int index = Utils.getIndex(e.evaluate(environment));\r
-                       result = ((Array)result).element(index);\r
-               }\r
-               if(result instanceof IExpression) {\r
-                       IExpression exp = (IExpression)result;\r
-                       return exp.evaluate(environment);\r
-               }\r
-               return result;\r
-       }\r
-\r
        public void assignPlain(IEnvironment env, Object value) {\r
                env.put(base.index, value);\r
        }\r
        \r
-       public void assign(IEnvironment env, Object value) {\r
+       private void validateSize(IEnvironment env, IExpression[] subscripts, Object value) {\r
+               \r
+               if(base.isStoredAsArray()) return;\r
+               \r
+               int fullDimension = base.dimension();\r
+               if(fullDimension == 1) {\r
+                       if(!(value instanceof Double)) {\r
+                               Array arr = (Array)value;\r
+                               if(arr.size(0) != 1)\r
+                                       throw new IllegalStateException();\r
+                       }\r
+               } else {\r
+                       if(subscripts == null) {\r
+                               if(!(value instanceof Array))\r
+                                       throw new IllegalStateException();\r
+                               Array arr = (Array)value;\r
+                               int arrDim = arr.dimension();\r
+                               if(arrDim != fullDimension)\r
+                                       throw new IllegalStateException();\r
+                       } else {\r
+                               if(value instanceof Array) {\r
+                                       Array arr = (Array)value;\r
+                                       if(!arr.validateDimensions(base.dimensions, 0))\r
+                                               throw new IllegalStateException();\r
+                               } else {\r
+                                       throw new IllegalStateException();\r
+                               }\r
+                       }\r
+               }\r
+               \r
+               \r
+       }\r
+       \r
+       public void assign(IEnvironment env, IExpression[] subscripts, Object value) {\r
+               \r
+               validateSize(env, subscripts, value);\r
+               \r
                if(value instanceof Array) {\r
                        if(base.isStoredAsArray()) {\r
-                               env.put(index(env), value);\r
+                               env.put(base.index(env, subscripts), value);\r
                        } else {\r
-                               assignArray(env, index(env), (Array)value, 0);\r
+                               assignArray(env, base.index(env, subscripts), (Array)value, 0);\r
                        }\r
                } else {\r
                        if(base.isStoredAsArray()) {\r
@@ -154,31 +172,68 @@ public class Variable implements IExpression {
                                }\r
                                setArrayIndex(env, existing, value);\r
                        } else {\r
-                               env.put(index(env), value);\r
+                               env.put(base.index(env, subscripts), value);\r
                        }\r
                }\r
        }\r
        \r
        @Override\r
        public Object evaluate(IEnvironment environment) {\r
-               if(base.isStoredAsArray()) {\r
-                       Array array = (Array)environment.getValue(base.index);\r
-                       if(hasScalarSubscript()) {\r
-                               Object o = getArrayIndex(environment, array);\r
-                               if(o instanceof Variable) throw new IllegalStateException();\r
-                               return o;\r
-                       }\r
-                       else return array;\r
+               return base.evaluate(environment, subscripts);\r
+       }\r
+\r
+       \r
+//     static Array enumerationElements(IFrame frame, String name) {\r
+//             if(!name.endsWith(".elements")) return null;\r
+//             String prefix = name.replace(".elements", "");\r
+//             Model m = frame.getClass(prefix + "_class");\r
+//             if(m == null) return null;\r
+//             Array result = new Array();\r
+//             for(VariableDeclaration vd : m.variables) {\r
+//                     Constant c = (Constant)vd.modification.args.get(0).modification;\r
+//                     result.addElement(c.value);\r
+//             }\r
+//             return result;\r
+//     }\r
+//     \r
+//     static Constant enumerationSize(IFrame frame, String name) {\r
+//             if(!name.endsWith(".size")) return null;\r
+//             String prefix = name.replace(".size", "");\r
+//             Model m = frame.getClass(prefix + "_class");\r
+//             if(m == null) return null;\r
+//             return new Constant("" + m.variables.size());\r
+//     }\r
+\r
+       public Variable withBase(IFrame frame, String prefix) {\r
+               \r
+               if(subscripts != null) {\r
+                       IExpression[] subscripts2 = new IExpression[subscripts.length];\r
+                       for(int i=0;i<subscripts.length;i++)\r
+                               subscripts2[i] = subscripts[i].withBase(frame, prefix);\r
+                       return new Variable(frame.getBase(base, prefix), subscripts2);\r
                } else {\r
-                       Object result = environment.getValue(index(environment)); \r
-                       if(result == null) throw new UnassignedVariableException("No value for " + base.name);\r
-                       return result;\r
+                       return new Variable(frame.getBase(base, prefix), null);\r
                }\r
        }\r
+    \r
+       @Override\r
+       public IExpression getPossibleConstant() {\r
+               return base.getPossibleConstant();\r
+       }\r
        \r
-       private boolean hasScalarSubscript() {\r
-               if(subscripts == null) return false;\r
-               else return true;\r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               VariableBase copy = copies.get(base.name);\r
+               if(copy == null) {\r
+                       if(subscripts != null) {\r
+                               for(int i=0;i<subscripts.length;i++)\r
+                                       subscripts[i] = subscripts[i].rewrite(frame, copies);\r
+                       }\r
+                       return this;\r
+               }\r
+\r
+               return new Variable(frame.getBase(copy.name), subscripts).rewrite(frame, copies);\r
+               \r
        }\r
        \r
 }\r
index 4e64d7a9d44f848eba590764eff75e3707c2767c..1466574bd3b71002e442951eaed9ba246abe588b 100644 (file)
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.Arrays;\r
+\r
+import fi.semantum.sysdyn.solver.SolverUtils.Slice;\r
+\r
 public class VariableBase {\r
+\r
+       static final int[] UNINIT = new int[0];\r
        \r
        public String name;\r
        public int index;\r
-       public int[] dimensions;\r
+       public int[] dimensions = UNINIT;\r
        public VariableBase(String name) {\r
                this.name = name;\r
        }\r
@@ -22,20 +28,54 @@ public class VariableBase {
                this.name = name;\r
                this.index = index;\r
        }\r
-       public void tellSubscripts(IExpression[] e) {\r
-               if(e == null) return;\r
-               if(dimensions == null) \r
-                       dimensions = new int[e.length];\r
-               for(int i=0;i<e.length;i++) {\r
-                       if(!(e[i] instanceof Constant)) {\r
-                               dimensions[i] = -1;\r
-                       } else {\r
-                               Constant c = (Constant)e[i];\r
-                               int index = ((Double)c.value).intValue();\r
-                               if(index == -1)                dimensions[i] = -1;\r
-                               else if(index > dimensions[i]) dimensions[i] = index;\r
+       public VariableBase(String name, int index, int[] dimensions) {\r
+               this.name = name;\r
+               this.index = index;\r
+               this.dimensions = dimensions;\r
+       }\r
+       public boolean tellSubscripts(IExpression[] e, IExpression modification) {\r
+               \r
+               if(dimensions != UNINIT) return true;\r
+               \r
+               if(e != null) {\r
+                       \r
+                       if(dimensions == UNINIT) \r
+                               dimensions = new int[e.length];\r
+                       \r
+                       if(e.length == 0)\r
+                               throw new IllegalStateException();\r
+                       \r
+                       for(int i=0;i<e.length;i++) {\r
+                               \r
+                               IExpression exp = e[i];\r
+                               Object constant = exp.getPossibleConstant();\r
+                               if(constant != null) exp = (IExpression)constant;\r
+                               \r
+                               if(!(exp instanceof Constant)) {\r
+                                       dimensions[i] = -1;\r
+                               } else {\r
+                                       Constant c = (Constant)exp;\r
+                                       int index = ((Double)c.value).intValue();\r
+                                       if(index == -1) {\r
+                                               if(modification instanceof Array) {\r
+                                                       Array array = (Array)modification;\r
+                                                       dimensions[i] = array.size(i);\r
+                                               } else {\r
+                                                       dimensions[i] = -1;\r
+                                               }\r
+                                       }\r
+                                       else if(index > dimensions[i]) dimensions[i] = index;\r
+                               }\r
                        }\r
+                       \r
+               } else {\r
+                       \r
+                       dimensions = null;\r
+                       \r
                }\r
+               \r
+               return dimensions != UNINIT;\r
+               \r
        }\r
        public int dimension() {\r
                if(dimensions == null) return 1;\r
@@ -48,4 +88,130 @@ public class VariableBase {
                for(int d : dimensions) if(d == -1) return true;\r
                return false;\r
        }\r
+       \r
+       VariableBase withBase(String prefix) {\r
+               return new VariableBase(prefix+name, index, dimensions);\r
+       }\r
+\r
+       private int makeSubscriptIndex(IEnvironment env, IExpression[] subscripts) {\r
+               if(dimensions == null) return 0;\r
+               int result = 0;\r
+               for(int i=0;i<subscripts.length;i++) {\r
+                       int factor = 1;\r
+                       for(int j=i+1;j<subscripts.length;j++) factor *= dimensions[j];\r
+                       IExpression e = subscripts[i];\r
+                       Double v = (Double)e.evaluate(env);\r
+                       int index = v.intValue()-1;\r
+                       if(index == -2) return 0;\r
+                       result += factor*index;\r
+               }\r
+               if(result == -1) throw new IllegalStateException();\r
+               return result;\r
+       }\r
+       \r
+       public int subscriptIndex(IEnvironment env, IExpression[] subscripts) {\r
+               if(subscripts == null) return 0;\r
+               return makeSubscriptIndex(env, subscripts);\r
+       }\r
+       \r
+       public int index(IEnvironment env, IExpression[] subscripts) {\r
+               return index + subscriptIndex(env, subscripts);\r
+       }\r
+       \r
+       public Object getArrayIndex(IEnvironment environment, IExpression[] subscripts, Array array) {\r
+               Object result = array;\r
+               for(IExpression e : subscripts) {\r
+                       int index = Utils.getIndex(e.evaluate(environment));\r
+                       result = ((Array)result).element(index);\r
+               }\r
+               if(result instanceof IExpression) {\r
+                       IExpression exp = (IExpression)result;\r
+                       return exp.evaluate(environment);\r
+               }\r
+               if(result instanceof Array)\r
+                       throw new IllegalStateException();\r
+               return result;\r
+       }\r
+       \r
+       private boolean hasScalarSubscript(IExpression[] subscripts) {\r
+               if(subscripts == null) return false;\r
+               else return true;\r
+       }\r
+       \r
+       public int intoArray(IEnvironment env, int index, int d, Array target) {\r
+\r
+               if(d == dimensions.length-1) {\r
+                       for(int i=0;i<dimensions[d];i++) {\r
+                               Object value = env.getValue(index);\r
+                               if(value == null) {\r
+                                       throw new UnassignedVariableException("No value for " + name);\r
+                               }\r
+                               target.addElement(value);\r
+                               index++;\r
+                       }\r
+                       return index;\r
+               }\r
+               \r
+               for(int i=0;i<dimensions[d];i++) {\r
+                       Array array = new Array();\r
+                       index = intoArray(env, index, d+1, array);\r
+                       target.addElement(array);\r
+               }\r
+               \r
+               return index;\r
+               \r
+       }\r
+       \r
+       public Object evaluate(IEnvironment environment, IExpression[] subscripts) {\r
+               \r
+               if(isStoredAsArray()) {\r
+                       \r
+                       Array array = (Array)environment.getValue(index);\r
+                       if(hasScalarSubscript(subscripts)) {\r
+                               Object o = getArrayIndex(environment, subscripts, array);\r
+                               if(o instanceof Variable) throw new IllegalStateException();\r
+                               if(o instanceof Array)\r
+                                       throw new IllegalStateException();\r
+                               return o;\r
+                       }\r
+                       else return array;\r
+                       \r
+               } else {\r
+                       \r
+                       if(dimension() > 1) {\r
+                               if(subscripts != null) {\r
+                                       \r
+                                       Slice[] sub = SolverUtils.parseSubscripts(environment, subscripts);\r
+                                       if(SolverUtils.isSlice(sub)) {\r
+                                               Array arr = new Array();\r
+                                               intoArray(environment, index, 0, arr);\r
+                                               return arr.slice(sub);\r
+                                       } else { \r
+                                               return environment.getValue(index(environment, subscripts));\r
+                                       }\r
+                                       \r
+                               } else {\r
+                                       Array array = new Array();\r
+                                       intoArray(environment, index, 0, array);\r
+                                       return array;\r
+                               }\r
+                       }\r
+                       \r
+                       Object result = environment.getNamedValue(name);\r
+                       if(result == null) result = environment.getValue(index(environment, subscripts));\r
+                       if(result == null) throw new UnassignedVariableException("No value for " + name);\r
+\r
+                       if(SolverUtils.isArray(dimensions) && subscripts == null) {\r
+                               return new Array().addElement(result);\r
+                       } else {\r
+                               return result;\r
+                       }\r
+                       \r
+               }\r
+       }\r
+       \r
+       public IExpression getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
 }\r
index 02043c750eafd019fd8004925e2ef2f73abd5d4c..08c8a49d78d7b03ef0f231b57ed085039a74ac27 100644 (file)
@@ -10,6 +10,8 @@
  *******************************************************************************/\r
 package fi.semantum.sysdyn.solver;\r
 \r
+import java.util.Map;\r
+\r
 \r
 public class VariableDeclaration implements IExpression {\r
 \r
@@ -36,4 +38,19 @@ public class VariableDeclaration implements IExpression {
                throw new UnsupportedOperationException();\r
        }\r
        \r
+       @Override\r
+       public IExpression withBase(IFrame frame, String prefix) {\r
+               throw new UnsupportedOperationException();\r
+       }\r
+    \r
+       @Override\r
+       public Object getPossibleConstant() {\r
+               return null;\r
+       }\r
+       \r
+       @Override\r
+       public IExpression rewrite(IFrame frame, Map<String, VariableBase> copies) {\r
+               throw new UnsupportedOperationException();\r
+       }\r
+       \r
 }\r
index 828459b90607028cee18749387b061e67bbf8edb..99bdaaee3a952db76e2ba27c2b69aa2fdb38d912 100644 (file)
@@ -189,9 +189,11 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
       case 34:\r
         jj_consume_token(34);\r
+                jjtn000.op = "class";\r
         break;\r
       case 7:\r
         jj_consume_token(7);\r
+                                                    jjtn000.op = "model";\r
         break;\r
       case 61:\r
         jj_consume_token(61);\r
@@ -293,21 +295,6 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         }\r
         comment();\r
       } else if (jj_2_3(3)) {\r
-        jj_consume_token(IDENT);\r
-        jj_consume_token(88);\r
-        jj_consume_token(40);\r
-        jj_consume_token(62);\r
-        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
-        case IDENT:\r
-          enum_list();\r
-          break;\r
-        default:\r
-          jj_la1[10] = jj_gen;\r
-          ;\r
-        }\r
-        jj_consume_token(63);\r
-        comment();\r
-      } else if (jj_2_4(3)) {\r
         jj_consume_token(IDENT);\r
         jj_consume_token(88);\r
         jj_consume_token(58);\r
@@ -322,7 +309,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
             ;\r
             break;\r
           default:\r
-            jj_la1[11] = jj_gen;\r
+            jj_la1[10] = jj_gen;\r
             break label_2;\r
           }\r
           jj_consume_token(71);\r
@@ -330,29 +317,24 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         }\r
         jj_consume_token(63);\r
         comment();\r
-      } else {\r
+      } else if (jj_2_4(3)) {\r
+        jj_consume_token(IDENT);\r
+        jj_consume_token(88);\r
+        jj_consume_token(40);\r
+        jj_consume_token(62);\r
         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
-        case 55:\r
-          jj_consume_token(55);\r
-          jj_consume_token(IDENT);\r
-          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
-          case 62:\r
-            class_modification();\r
-            break;\r
-          default:\r
-            jj_la1[12] = jj_gen;\r
-            ;\r
-          }\r
-          string_comment();\r
-          composition();\r
-          jj_consume_token(35);\r
-          jj_consume_token(IDENT);\r
+        case IDENT:\r
+          enum_list();\r
           break;\r
         default:\r
-          jj_la1[13] = jj_gen;\r
-          jj_consume_token(-1);\r
-          throw new ParseException();\r
+          jj_la1[11] = jj_gen;\r
+          ;\r
         }\r
+        jj_consume_token(63);\r
+        comment();\r
+      } else {\r
+        jj_consume_token(-1);\r
+        throw new ParseException();\r
       }\r
     } catch (Throwable jjte000) {\r
       if (jjtc000) {\r
@@ -417,7 +399,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[14] = jj_gen;\r
+          jj_la1[12] = jj_gen;\r
           break label_3;\r
         }\r
         jj_consume_token(71);\r
@@ -520,7 +502,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[15] = jj_gen;\r
+          jj_la1[13] = jj_gen;\r
           break label_4;\r
         }\r
         if (jj_2_5(2)) {\r
@@ -540,7 +522,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
             algorithm_section();\r
             break;\r
           default:\r
-            jj_la1[16] = jj_gen;\r
+            jj_la1[14] = jj_gen;\r
             jj_consume_token(-1);\r
             throw new ParseException();\r
           }\r
@@ -554,7 +536,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           language_specification();\r
           break;\r
         default:\r
-          jj_la1[17] = jj_gen;\r
+          jj_la1[15] = jj_gen;\r
           ;\r
         }\r
         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
@@ -563,7 +545,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           external_function_call();\r
           break;\r
         default:\r
-          jj_la1[18] = jj_gen;\r
+          jj_la1[16] = jj_gen;\r
           ;\r
         }\r
         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
@@ -571,13 +553,13 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           annotation();\r
           break;\r
         default:\r
-          jj_la1[19] = jj_gen;\r
+          jj_la1[17] = jj_gen;\r
           ;\r
         }\r
         jj_consume_token(70);\r
         break;\r
       default:\r
-        jj_la1[20] = jj_gen;\r
+        jj_la1[18] = jj_gen;\r
         ;\r
       }\r
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
@@ -586,7 +568,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         jj_consume_token(70);\r
         break;\r
       default:\r
-        jj_la1[21] = jj_gen;\r
+        jj_la1[19] = jj_gen;\r
         ;\r
       }\r
     } catch (Throwable jjte000) {\r
@@ -637,7 +619,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         jj_consume_token(88);\r
         break;\r
       default:\r
-        jj_la1[22] = jj_gen;\r
+        jj_la1[20] = jj_gen;\r
         ;\r
       }\r
       jj_consume_token(IDENT);\r
@@ -665,7 +647,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         expression_list();\r
         break;\r
       default:\r
-        jj_la1[23] = jj_gen;\r
+        jj_la1[21] = jj_gen;\r
         ;\r
       }\r
       jj_consume_token(63);\r
@@ -732,7 +714,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[24] = jj_gen;\r
+          jj_la1[22] = jj_gen;\r
           break label_5;\r
         }\r
         element();\r
@@ -768,9 +750,15 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
       case 36:\r
         import_clause();\r
+                      jjtree.closeNodeScope(jjtn000, true);\r
+                      jjtc000 = false;\r
+                      {if (true) return jjtn000;}\r
         break;\r
       case 55:\r
         extends_clause();\r
+                       jjtree.closeNodeScope(jjtn000, true);\r
+                       jjtc000 = false;\r
+                       {if (true) return jjtn000;}\r
         break;\r
       case 5:\r
       case 7:\r
@@ -805,7 +793,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           jj_consume_token(8);\r
           break;\r
         default:\r
-          jj_la1[25] = jj_gen;\r
+          jj_la1[23] = jj_gen;\r
           ;\r
         }\r
         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
@@ -813,23 +801,25 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           jj_consume_token(11);\r
           break;\r
         default:\r
-          jj_la1[26] = jj_gen;\r
+          jj_la1[24] = jj_gen;\r
           ;\r
         }\r
         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
         case 51:\r
           jj_consume_token(51);\r
+                jjtn000.op = "inner";\r
           break;\r
         default:\r
-          jj_la1[27] = jj_gen;\r
+          jj_la1[25] = jj_gen;\r
           ;\r
         }\r
         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
         case 27:\r
           jj_consume_token(27);\r
+                                                       jjtn000.op = "outer";\r
           break;\r
         default:\r
-          jj_la1[28] = jj_gen;\r
+          jj_la1[26] = jj_gen;\r
           ;\r
         }\r
         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
@@ -885,7 +875,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
             component_clause();\r
             break;\r
           default:\r
-            jj_la1[29] = jj_gen;\r
+            jj_la1[27] = jj_gen;\r
             jj_consume_token(-1);\r
             throw new ParseException();\r
           }\r
@@ -921,7 +911,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
             component_clause();\r
             break;\r
           default:\r
-            jj_la1[30] = jj_gen;\r
+            jj_la1[28] = jj_gen;\r
             jj_consume_token(-1);\r
             throw new ParseException();\r
           }\r
@@ -931,12 +921,12 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
             comment();\r
             break;\r
           default:\r
-            jj_la1[31] = jj_gen;\r
+            jj_la1[29] = jj_gen;\r
             ;\r
           }\r
           break;\r
         default:\r
-          jj_la1[32] = jj_gen;\r
+          jj_la1[30] = jj_gen;\r
           jj_consume_token(-1);\r
           throw new ParseException();\r
         }\r
@@ -945,7 +935,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
       {if (true) return jjtn000;}\r
         break;\r
       default:\r
-        jj_la1[33] = jj_gen;\r
+        jj_la1[31] = jj_gen;\r
         jj_consume_token(-1);\r
         throw new ParseException();\r
       }\r
@@ -993,12 +983,12 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
             jj_consume_token(82);\r
             break;\r
           default:\r
-            jj_la1[34] = jj_gen;\r
+            jj_la1[32] = jj_gen;\r
             ;\r
           }\r
           break;\r
         default:\r
-          jj_la1[35] = jj_gen;\r
+          jj_la1[33] = jj_gen;\r
           jj_consume_token(-1);\r
           throw new ParseException();\r
         }\r
@@ -1039,7 +1029,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         class_modification();\r
         break;\r
       default:\r
-        jj_la1[36] = jj_gen;\r
+        jj_la1[34] = jj_gen;\r
         ;\r
       }\r
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
@@ -1047,7 +1037,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         annotation();\r
         break;\r
       default:\r
-        jj_la1[37] = jj_gen;\r
+        jj_la1[35] = jj_gen;\r
         ;\r
       }\r
     } catch (Throwable jjte000) {\r
@@ -1084,7 +1074,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         class_modification();\r
         break;\r
       default:\r
-        jj_la1[38] = jj_gen;\r
+        jj_la1[36] = jj_gen;\r
         ;\r
       }\r
     } catch (Throwable jjte000) {\r
@@ -1125,7 +1115,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         array_subscripts();\r
         break;\r
       default:\r
-        jj_la1[39] = jj_gen;\r
+        jj_la1[37] = jj_gen;\r
         ;\r
       }\r
       componentList = component_list();\r
@@ -1180,13 +1170,13 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           jj_consume_token(23);\r
           break;\r
         default:\r
-          jj_la1[40] = jj_gen;\r
+          jj_la1[38] = jj_gen;\r
           jj_consume_token(-1);\r
           throw new ParseException();\r
         }\r
         break;\r
       default:\r
-        jj_la1[41] = jj_gen;\r
+        jj_la1[39] = jj_gen;\r
         ;\r
       }\r
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
@@ -1207,13 +1197,13 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
                                                                                                        jjtn000.op = "constant";\r
           break;\r
         default:\r
-          jj_la1[42] = jj_gen;\r
+          jj_la1[40] = jj_gen;\r
           jj_consume_token(-1);\r
           throw new ParseException();\r
         }\r
         break;\r
       default:\r
-        jj_la1[43] = jj_gen;\r
+        jj_la1[41] = jj_gen;\r
         ;\r
       }\r
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
@@ -1229,13 +1219,13 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
                     type = InterfaceVariableType.INPUT; jjtn000.op = "input";\r
           break;\r
         default:\r
-          jj_la1[44] = jj_gen;\r
+          jj_la1[42] = jj_gen;\r
           jj_consume_token(-1);\r
           throw new ParseException();\r
         }\r
         break;\r
       default:\r
-        jj_la1[45] = jj_gen;\r
+        jj_la1[43] = jj_gen;\r
         ;\r
       }\r
       jjtree.closeNodeScope(jjtn000, true);\r
@@ -1299,7 +1289,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[46] = jj_gen;\r
+          jj_la1[44] = jj_gen;\r
           break label_6;\r
         }\r
         jj_consume_token(71);\r
@@ -1345,7 +1335,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         conditional_attribute();\r
         break;\r
       default:\r
-        jj_la1[47] = jj_gen;\r
+        jj_la1[45] = jj_gen;\r
         ;\r
       }\r
       ret.description = comment();\r
@@ -1418,7 +1408,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         array_subscripts();\r
         break;\r
       default:\r
-        jj_la1[48] = jj_gen;\r
+        jj_la1[46] = jj_gen;\r
         ;\r
       }\r
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
@@ -1428,7 +1418,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         ret.optional = modification();\r
         break;\r
       default:\r
-        jj_la1[49] = jj_gen;\r
+        jj_la1[47] = jj_gen;\r
         ;\r
       }\r
           jjtree.closeNodeScope(jjtn000, true);\r
@@ -1472,7 +1462,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           expression();\r
           break;\r
         default:\r
-          jj_la1[50] = jj_gen;\r
+          jj_la1[48] = jj_gen;\r
           ;\r
         }\r
         break;\r
@@ -1487,7 +1477,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
                               optional = true;\r
         break;\r
       default:\r
-        jj_la1[51] = jj_gen;\r
+        jj_la1[49] = jj_gen;\r
         jj_consume_token(-1);\r
         throw new ParseException();\r
       }\r
@@ -1533,7 +1523,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         argument_list();\r
         break;\r
       default:\r
-        jj_la1[52] = jj_gen;\r
+        jj_la1[50] = jj_gen;\r
         ;\r
       }\r
       jj_consume_token(63);\r
@@ -1572,7 +1562,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[53] = jj_gen;\r
+          jj_la1[51] = jj_gen;\r
           break label_7;\r
         }\r
         jj_consume_token(71);\r
@@ -1617,7 +1607,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         element_redeclaration();\r
         break;\r
       default:\r
-        jj_la1[54] = jj_gen;\r
+        jj_la1[52] = jj_gen;\r
         jj_consume_token(-1);\r
         throw new ParseException();\r
       }\r
@@ -1653,7 +1643,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         jj_consume_token(10);\r
         break;\r
       default:\r
-        jj_la1[55] = jj_gen;\r
+        jj_la1[53] = jj_gen;\r
         ;\r
       }\r
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
@@ -1661,7 +1651,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         jj_consume_token(11);\r
         break;\r
       default:\r
-        jj_la1[56] = jj_gen;\r
+        jj_la1[54] = jj_gen;\r
         ;\r
       }\r
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
@@ -1673,7 +1663,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         element_replaceable();\r
         break;\r
       default:\r
-        jj_la1[57] = jj_gen;\r
+        jj_la1[55] = jj_gen;\r
         jj_consume_token(-1);\r
         throw new ParseException();\r
       }\r
@@ -1712,7 +1702,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         modification();\r
         break;\r
       default:\r
-        jj_la1[58] = jj_gen;\r
+        jj_la1[56] = jj_gen;\r
         ;\r
       }\r
       string_comment();\r
@@ -1749,7 +1739,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         jj_consume_token(10);\r
         break;\r
       default:\r
-        jj_la1[59] = jj_gen;\r
+        jj_la1[57] = jj_gen;\r
         ;\r
       }\r
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
@@ -1757,7 +1747,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         jj_consume_token(11);\r
         break;\r
       default:\r
-        jj_la1[60] = jj_gen;\r
+        jj_la1[58] = jj_gen;\r
         ;\r
       }\r
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
@@ -1813,7 +1803,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           component_clause1();\r
           break;\r
         default:\r
-          jj_la1[61] = jj_gen;\r
+          jj_la1[59] = jj_gen;\r
           jj_consume_token(-1);\r
           throw new ParseException();\r
         }\r
@@ -1822,7 +1812,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         element_replaceable();\r
         break;\r
       default:\r
-        jj_la1[62] = jj_gen;\r
+        jj_la1[60] = jj_gen;\r
         jj_consume_token(-1);\r
         throw new ParseException();\r
       }\r
@@ -1883,7 +1873,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         component_clause1();\r
         break;\r
       default:\r
-        jj_la1[63] = jj_gen;\r
+        jj_la1[61] = jj_gen;\r
         jj_consume_token(-1);\r
         throw new ParseException();\r
       }\r
@@ -1892,7 +1882,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         constraining_clause();\r
         break;\r
       default:\r
-        jj_la1[64] = jj_gen;\r
+        jj_la1[62] = jj_gen;\r
         ;\r
       }\r
     } catch (Throwable jjte000) {\r
@@ -1988,7 +1978,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
                       jjtn000.op = "initial";\r
         break;\r
       default:\r
-        jj_la1[65] = jj_gen;\r
+        jj_la1[63] = jj_gen;\r
         ;\r
       }\r
       jj_consume_token(45);\r
@@ -2034,7 +2024,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         jj_consume_token(46);\r
         break;\r
       default:\r
-        jj_la1[66] = jj_gen;\r
+        jj_la1[64] = jj_gen;\r
         ;\r
       }\r
       jj_consume_token(4);\r
@@ -2053,7 +2043,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[67] = jj_gen;\r
+          jj_la1[65] = jj_gen;\r
           break label_9;\r
         }\r
         statement();\r
@@ -2137,7 +2127,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           function_call_args();\r
           break;\r
         default:\r
-          jj_la1[68] = jj_gen;\r
+          jj_la1[66] = jj_gen;\r
           jj_consume_token(-1);\r
           throw new ParseException();\r
         }\r
@@ -2187,7 +2177,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           function_call_args();\r
           break;\r
         default:\r
-          jj_la1[69] = jj_gen;\r
+          jj_la1[67] = jj_gen;\r
           jj_consume_token(-1);\r
           throw new ParseException();\r
         }\r
@@ -2219,7 +2209,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         when_statement();\r
         break;\r
       default:\r
-        jj_la1[70] = jj_gen;\r
+        jj_la1[68] = jj_gen;\r
         jj_consume_token(-1);\r
         throw new ParseException();\r
       }\r
@@ -2282,7 +2272,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[71] = jj_gen;\r
+          jj_la1[69] = jj_gen;\r
           break label_10;\r
         }\r
         equation();\r
@@ -2295,7 +2285,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[72] = jj_gen;\r
+          jj_la1[70] = jj_gen;\r
           break label_11;\r
         }\r
         jj_consume_token(20);\r
@@ -2329,7 +2319,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
             ;\r
             break;\r
           default:\r
-            jj_la1[73] = jj_gen;\r
+            jj_la1[71] = jj_gen;\r
             break label_12;\r
           }\r
           equation();\r
@@ -2367,7 +2357,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
             ;\r
             break;\r
           default:\r
-            jj_la1[74] = jj_gen;\r
+            jj_la1[72] = jj_gen;\r
             break label_13;\r
           }\r
           equation();\r
@@ -2375,7 +2365,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         }\r
         break;\r
       default:\r
-        jj_la1[75] = jj_gen;\r
+        jj_la1[73] = jj_gen;\r
         ;\r
       }\r
       jj_consume_token(35);\r
@@ -2509,7 +2499,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[76] = jj_gen;\r
+          jj_la1[74] = jj_gen;\r
           break label_14;\r
         }\r
         then_statement();\r
@@ -2522,7 +2512,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[77] = jj_gen;\r
+          jj_la1[75] = jj_gen;\r
           break label_15;\r
         }\r
         jj_consume_token(20);\r
@@ -2543,7 +2533,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
             ;\r
             break;\r
           default:\r
-            jj_la1[78] = jj_gen;\r
+            jj_la1[76] = jj_gen;\r
             break label_16;\r
           }\r
           elseif_statement();\r
@@ -2568,7 +2558,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
             ;\r
             break;\r
           default:\r
-            jj_la1[79] = jj_gen;\r
+            jj_la1[77] = jj_gen;\r
             break label_17;\r
           }\r
           else_statement();\r
@@ -2576,7 +2566,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         }\r
         break;\r
       default:\r
-        jj_la1[80] = jj_gen;\r
+        jj_la1[78] = jj_gen;\r
         ;\r
       }\r
       jj_consume_token(35);\r
@@ -2639,7 +2629,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[81] = jj_gen;\r
+          jj_la1[79] = jj_gen;\r
           break label_18;\r
         }\r
         equation();\r
@@ -2692,7 +2682,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[82] = jj_gen;\r
+          jj_la1[80] = jj_gen;\r
           break label_19;\r
         }\r
         statement();\r
@@ -2735,7 +2725,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[83] = jj_gen;\r
+          jj_la1[81] = jj_gen;\r
           break label_20;\r
         }\r
         jj_consume_token(71);\r
@@ -2777,7 +2767,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         expression();\r
         break;\r
       default:\r
-        jj_la1[84] = jj_gen;\r
+        jj_la1[82] = jj_gen;\r
         ;\r
       }\r
     } catch (Throwable jjte000) {\r
@@ -2825,7 +2815,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[85] = jj_gen;\r
+          jj_la1[83] = jj_gen;\r
           break label_21;\r
         }\r
         statement();\r
@@ -2891,7 +2881,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[86] = jj_gen;\r
+          jj_la1[84] = jj_gen;\r
           break label_22;\r
         }\r
         equation();\r
@@ -2904,7 +2894,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[87] = jj_gen;\r
+          jj_la1[85] = jj_gen;\r
           break label_23;\r
         }\r
         jj_consume_token(25);\r
@@ -2938,7 +2928,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
             ;\r
             break;\r
           default:\r
-            jj_la1[88] = jj_gen;\r
+            jj_la1[86] = jj_gen;\r
             break label_24;\r
           }\r
           equation();\r
@@ -2992,7 +2982,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[89] = jj_gen;\r
+          jj_la1[87] = jj_gen;\r
           break label_25;\r
         }\r
         statement();\r
@@ -3005,7 +2995,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[90] = jj_gen;\r
+          jj_la1[88] = jj_gen;\r
           break label_26;\r
         }\r
         jj_consume_token(25);\r
@@ -3026,7 +3016,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
             ;\r
             break;\r
           default:\r
-            jj_la1[91] = jj_gen;\r
+            jj_la1[89] = jj_gen;\r
             break label_27;\r
           }\r
           statement();\r
@@ -3130,7 +3120,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
             ;\r
             break;\r
           default:\r
-            jj_la1[92] = jj_gen;\r
+            jj_la1[90] = jj_gen;\r
             break label_28;\r
           }\r
           jj_consume_token(20);\r
@@ -3143,7 +3133,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         jj_consume_token(0);\r
         break;\r
       default:\r
-        jj_la1[93] = jj_gen;\r
+        jj_la1[91] = jj_gen;\r
         jj_consume_token(-1);\r
         throw new ParseException();\r
       }\r
@@ -3185,7 +3175,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[94] = jj_gen;\r
+          jj_la1[92] = jj_gen;\r
           break label_29;\r
         }\r
         jj_consume_token(20);\r
@@ -3247,7 +3237,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         if_expression();\r
         break;\r
       default:\r
-        jj_la1[95] = jj_gen;\r
+        jj_la1[93] = jj_gen;\r
         jj_consume_token(-1);\r
         throw new ParseException();\r
       }\r
@@ -3289,12 +3279,12 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           logical_expression();\r
           break;\r
         default:\r
-          jj_la1[96] = jj_gen;\r
+          jj_la1[94] = jj_gen;\r
           ;\r
         }\r
         break;\r
       default:\r
-        jj_la1[97] = jj_gen;\r
+        jj_la1[95] = jj_gen;\r
         ;\r
       }\r
     } catch (Throwable jjte000) {\r
@@ -3332,7 +3322,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[98] = jj_gen;\r
+          jj_la1[96] = jj_gen;\r
           break label_30;\r
         }\r
         jj_consume_token(22);\r
@@ -3373,7 +3363,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[99] = jj_gen;\r
+          jj_la1[97] = jj_gen;\r
           break label_31;\r
         }\r
         jj_consume_token(9);\r
@@ -3411,7 +3401,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         jj_consume_token(12);\r
         break;\r
       default:\r
-        jj_la1[100] = jj_gen;\r
+        jj_la1[98] = jj_gen;\r
         ;\r
       }\r
       relation();\r
@@ -3454,7 +3444,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         arithmetic_expression();\r
         break;\r
       default:\r
-        jj_la1[101] = jj_gen;\r
+        jj_la1[99] = jj_gen;\r
         ;\r
       }\r
     } catch (Throwable jjte000) {\r
@@ -3522,7 +3512,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
                                                                                                                                                                jjtn000.op = "<>";\r
         break;\r
       default:\r
-        jj_la1[102] = jj_gen;\r
+        jj_la1[100] = jj_gen;\r
         jj_consume_token(-1);\r
         throw new ParseException();\r
       }\r
@@ -3547,7 +3537,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         add_op();\r
         break;\r
       default:\r
-        jj_la1[103] = jj_gen;\r
+        jj_la1[101] = jj_gen;\r
         ;\r
       }\r
       term();\r
@@ -3561,7 +3551,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[104] = jj_gen;\r
+          jj_la1[102] = jj_gen;\r
           break label_32;\r
         }\r
         add_op();\r
@@ -3614,7 +3604,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         jj_consume_token(81);\r
         break;\r
       default:\r
-        jj_la1[105] = jj_gen;\r
+        jj_la1[103] = jj_gen;\r
         jj_consume_token(-1);\r
         throw new ParseException();\r
       }\r
@@ -3642,7 +3632,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[106] = jj_gen;\r
+          jj_la1[104] = jj_gen;\r
           break label_33;\r
         }\r
         mul_op();\r
@@ -3690,12 +3680,15 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         break;\r
       case 84:\r
         jj_consume_token(84);\r
+                                                                 jjtree.closeNodeScope(jjtn000, true);\r
+                                                                 jjtc000 = false;\r
+                                                                 jjtn000.op = ".*";\r
         break;\r
       case 85:\r
         jj_consume_token(85);\r
         break;\r
       default:\r
-        jj_la1[107] = jj_gen;\r
+        jj_la1[105] = jj_gen;\r
         jj_consume_token(-1);\r
         throw new ParseException();\r
       }\r
@@ -3716,22 +3709,11 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
       case 86:\r
       case 87:\r
-        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
-        case 86:\r
-          jj_consume_token(86);\r
-          break;\r
-        case 87:\r
-          jj_consume_token(87);\r
-          primary();\r
-          break;\r
-        default:\r
-          jj_la1[108] = jj_gen;\r
-          jj_consume_token(-1);\r
-          throw new ParseException();\r
-        }\r
+        factor_op();\r
+        primary();\r
         break;\r
       default:\r
-        jj_la1[109] = jj_gen;\r
+        jj_la1[106] = jj_gen;\r
         ;\r
       }\r
     } catch (Throwable jjte000) {\r
@@ -3755,6 +3737,37 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     }\r
   }\r
 \r
+  final public void factor_op() throws ParseException {\r
+                    /*@bgen(jjtree) factor_op */\r
+  SimpleNode jjtn000 = new SimpleNode(JJTFACTOR_OP);\r
+  boolean jjtc000 = true;\r
+  jjtree.openNodeScope(jjtn000);\r
+    try {\r
+      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+      case 86:\r
+        jj_consume_token(86);\r
+          jjtree.closeNodeScope(jjtn000, true);\r
+          jjtc000 = false;\r
+          jjtn000.op = "^";\r
+        break;\r
+      case 87:\r
+        jj_consume_token(87);\r
+                                      jjtree.closeNodeScope(jjtn000, true);\r
+                                      jjtc000 = false;\r
+                                      jjtn000.op = ".^";\r
+        break;\r
+      default:\r
+        jj_la1[107] = jj_gen;\r
+        jj_consume_token(-1);\r
+        throw new ParseException();\r
+      }\r
+    } finally {\r
+      if (jjtc000) {\r
+        jjtree.closeNodeScope(jjtn000, true);\r
+      }\r
+    }\r
+  }\r
+\r
   final public void der_initial() throws ParseException {\r
                       /*@bgen(jjtree) der_initial */\r
   SimpleNode jjtn000 = new SimpleNode(JJTDER_INITIAL);\r
@@ -3776,7 +3789,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
                                                                                         jjtn000.op = "initial";\r
         break;\r
       default:\r
-        jj_la1[110] = jj_gen;\r
+        jj_la1[108] = jj_gen;\r
         jj_consume_token(-1);\r
         throw new ParseException();\r
       }\r
@@ -3816,7 +3829,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[111] = jj_gen;\r
+          jj_la1[109] = jj_gen;\r
           break label_34;\r
         }\r
         jj_consume_token(70);\r
@@ -3911,7 +3924,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
                jjtn000.op = token.image;\r
         break;\r
       default:\r
-        jj_la1[112] = jj_gen;\r
+        jj_la1[110] = jj_gen;\r
         if (jj_2_9(2147483647)) {\r
           der_initial();\r
         } else {\r
@@ -3937,7 +3950,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
             jj_consume_token(35);\r
             break;\r
           default:\r
-            jj_la1[113] = jj_gen;\r
+            jj_la1[111] = jj_gen;\r
             jj_consume_token(-1);\r
             throw new ParseException();\r
           }\r
@@ -3976,7 +3989,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
                 ret += ".";\r
         break;\r
       default:\r
-        jj_la1[114] = jj_gen;\r
+        jj_la1[112] = jj_gen;\r
         ;\r
       }\r
       jj_consume_token(IDENT);\r
@@ -3988,7 +4001,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[115] = jj_gen;\r
+          jj_la1[113] = jj_gen;\r
           break label_35;\r
         }\r
         jj_consume_token(68);\r
@@ -4018,7 +4031,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         jj_consume_token(68);\r
         break;\r
       default:\r
-        jj_la1[116] = jj_gen;\r
+        jj_la1[114] = jj_gen;\r
         ;\r
       }\r
       t = jj_consume_token(IDENT);\r
@@ -4028,7 +4041,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         array_subscripts();\r
         break;\r
       default:\r
-        jj_la1[117] = jj_gen;\r
+        jj_la1[115] = jj_gen;\r
         ;\r
       }\r
       label_36:\r
@@ -4038,7 +4051,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[118] = jj_gen;\r
+          jj_la1[116] = jj_gen;\r
           break label_36;\r
         }\r
         jj_consume_token(68);\r
@@ -4048,7 +4061,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           array_subscripts();\r
           break;\r
         default:\r
-          jj_la1[119] = jj_gen;\r
+          jj_la1[117] = jj_gen;\r
           ;\r
         }\r
       }\r
@@ -4103,7 +4116,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         function_arguments();\r
         break;\r
       default:\r
-        jj_la1[120] = jj_gen;\r
+        jj_la1[118] = jj_gen;\r
         ;\r
       }\r
       jj_consume_token(63);\r
@@ -4147,15 +4160,16 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           case 21:\r
             jj_consume_token(21);\r
             for_indices();\r
+                                                                                      jjtn000.op = "for";\r
             break;\r
           default:\r
-            jj_la1[121] = jj_gen;\r
+            jj_la1[119] = jj_gen;\r
             jj_consume_token(-1);\r
             throw new ParseException();\r
           }\r
           break;\r
         default:\r
-          jj_la1[122] = jj_gen;\r
+          jj_la1[120] = jj_gen;\r
           ;\r
         }\r
       } else {\r
@@ -4164,7 +4178,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           named_arguments();\r
           break;\r
         default:\r
-          jj_la1[123] = jj_gen;\r
+          jj_la1[121] = jj_gen;\r
           jj_consume_token(-1);\r
           throw new ParseException();\r
         }\r
@@ -4203,7 +4217,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         named_arguments();\r
         break;\r
       default:\r
-        jj_la1[124] = jj_gen;\r
+        jj_la1[122] = jj_gen;\r
         ;\r
       }\r
     } catch (Throwable jjte000) {\r
@@ -4286,7 +4300,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         expression();\r
         break;\r
       default:\r
-        jj_la1[125] = jj_gen;\r
+        jj_la1[123] = jj_gen;\r
         ;\r
       }\r
       label_37:\r
@@ -4296,7 +4310,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[126] = jj_gen;\r
+          jj_la1[124] = jj_gen;\r
           break label_37;\r
         }\r
         jj_consume_token(71);\r
@@ -4323,7 +4337,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           expression();\r
           break;\r
         default:\r
-          jj_la1[127] = jj_gen;\r
+          jj_la1[125] = jj_gen;\r
           ;\r
         }\r
       }\r
@@ -4362,7 +4376,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[128] = jj_gen;\r
+          jj_la1[126] = jj_gen;\r
           break label_38;\r
         }\r
         jj_consume_token(71);\r
@@ -4404,7 +4418,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[129] = jj_gen;\r
+          jj_la1[127] = jj_gen;\r
           break label_39;\r
         }\r
         jj_consume_token(71);\r
@@ -4467,7 +4481,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
         expression();\r
         break;\r
       default:\r
-        jj_la1[130] = jj_gen;\r
+        jj_la1[128] = jj_gen;\r
         jj_consume_token(-1);\r
         throw new ParseException();\r
       }\r
@@ -4501,7 +4515,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
       annotation();\r
       break;\r
     default:\r
-      jj_la1[131] = jj_gen;\r
+      jj_la1[129] = jj_gen;\r
       ;\r
     }\r
             {if (true) return ret;}\r
@@ -4521,7 +4535,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
           ;\r
           break;\r
         default:\r
-          jj_la1[132] = jj_gen;\r
+          jj_la1[130] = jj_gen;\r
           break label_40;\r
         }\r
         jj_consume_token(78);\r
@@ -4531,7 +4545,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
       }\r
       break;\r
     default:\r
-      jj_la1[133] = jj_gen;\r
+      jj_la1[131] = jj_gen;\r
       ;\r
     }\r
             {if (true) return ret;}\r
@@ -4637,50 +4651,41 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     finally { jj_save(9, xla); }\r
   }\r
 \r
-  private boolean jj_3_10() {\r
-    if (jj_3R_47()) return true;\r
-    Token xsp;\r
-    xsp = jj_scanpos;\r
-    if (jj_3R_48()) jj_scanpos = xsp;\r
-    return false;\r
-  }\r
-\r
-  private boolean jj_3R_158() {\r
-    if (jj_3R_157()) return true;\r
-    return false;\r
-  }\r
-\r
-  private boolean jj_3R_157() {\r
+  private boolean jj_3R_74() {\r
+    if (jj_scan_token(62)) return true;\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3_10()) {\r
-    jj_scanpos = xsp;\r
-    if (jj_3R_161()) return true;\r
-    }\r
+    if (jj_3R_165()) jj_scanpos = xsp;\r
+    if (jj_scan_token(63)) return true;\r
     return false;\r
   }\r
 \r
   private boolean jj_3R_85() {\r
-    if (jj_3R_93()) return true;\r
+    if (jj_3R_95()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_120() {\r
+  private boolean jj_3R_124() {\r
     if (jj_scan_token(75)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_125() {\r
+  private boolean jj_3R_129() {\r
     if (jj_scan_token(49)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_74() {\r
-    if (jj_scan_token(62)) return true;\r
+  private boolean jj_3R_152() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_158()) jj_scanpos = xsp;\r
-    if (jj_scan_token(63)) return true;\r
+    if (jj_scan_token(68)) jj_scanpos = xsp;\r
+    if (jj_scan_token(IDENT)) return true;\r
+    xsp = jj_scanpos;\r
+    if (jj_3R_160()) jj_scanpos = xsp;\r
+    while (true) {\r
+      xsp = jj_scanpos;\r
+      if (jj_3R_161()) { jj_scanpos = xsp; break; }\r
+    }\r
     return false;\r
   }\r
 \r
@@ -4698,42 +4703,24 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_103() {\r
-    Token xsp;\r
-    xsp = jj_scanpos;\r
-    if (jj_scan_token(50)) jj_scanpos = xsp;\r
-    if (jj_scan_token(44)) return true;\r
-    return false;\r
-  }\r
-\r
-  private boolean jj_3R_147() {\r
-    Token xsp;\r
-    xsp = jj_scanpos;\r
-    if (jj_scan_token(68)) jj_scanpos = xsp;\r
-    if (jj_scan_token(IDENT)) return true;\r
-    xsp = jj_scanpos;\r
-    if (jj_3R_153()) jj_scanpos = xsp;\r
-    while (true) {\r
-      xsp = jj_scanpos;\r
-      if (jj_3R_154()) { jj_scanpos = xsp; break; }\r
-    }\r
-    return false;\r
-  }\r
-\r
   private boolean jj_3R_78() {\r
     if (jj_scan_token(68)) return true;\r
     if (jj_scan_token(IDENT)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_151() {\r
+  private boolean jj_3R_158() {\r
     if (jj_scan_token(58)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_71() {\r
-    if (jj_scan_token(21)) return true;\r
-    if (jj_3R_85()) return true;\r
+  private boolean jj_3R_106() {\r
+    if (jj_scan_token(7)) return true;\r
+    return false;\r
+  }\r
+\r
+  private boolean jj_3R_150() {\r
+    if (jj_scan_token(84)) return true;\r
     return false;\r
   }\r
 \r
@@ -4754,6 +4741,12 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
+  private boolean jj_3R_71() {\r
+    if (jj_scan_token(21)) return true;\r
+    if (jj_3R_85()) return true;\r
+    return false;\r
+  }\r
+\r
   private boolean jj_3R_46() {\r
     if (jj_3R_60()) return true;\r
     return false;\r
@@ -4773,99 +4766,91 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_119() {\r
-    if (jj_scan_token(74)) return true;\r
+  private boolean jj_3R_163() {\r
+    if (jj_scan_token(70)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3_4() {\r
-    if (jj_scan_token(IDENT)) return true;\r
-    if (jj_scan_token(88)) return true;\r
-    if (jj_scan_token(58)) return true;\r
+  private boolean jj_3R_146() {\r
+    if (jj_3R_154()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3_3() {\r
+  private boolean jj_3R_123() {\r
+    if (jj_scan_token(74)) return true;\r
+    return false;\r
+  }\r
+\r
+  private boolean jj_3_4() {\r
     if (jj_scan_token(IDENT)) return true;\r
     if (jj_scan_token(88)) return true;\r
     if (jj_scan_token(40)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3_2() {\r
-    if (jj_scan_token(IDENT)) return true;\r
-    if (jj_scan_token(88)) return true;\r
+  private boolean jj_3R_145() {\r
+    if (jj_scan_token(66)) return true;\r
+    if (jj_3R_153()) return true;\r
+    if (jj_scan_token(67)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_156() {\r
-    if (jj_scan_token(70)) return true;\r
+  private boolean jj_3_3() {\r
+    if (jj_scan_token(IDENT)) return true;\r
+    if (jj_scan_token(88)) return true;\r
+    if (jj_scan_token(58)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_142() {\r
-    if (jj_3R_149()) return true;\r
+  private boolean jj_3R_144() {\r
+    if (jj_scan_token(62)) return true;\r
+    if (jj_3R_47()) return true;\r
+    if (jj_scan_token(63)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3_1() {\r
+  private boolean jj_3_2() {\r
     if (jj_scan_token(IDENT)) return true;\r
-    if (jj_3R_41()) return true;\r
-    if (jj_3R_42()) return true;\r
-    if (jj_scan_token(35)) return true;\r
-    return false;\r
-  }\r
-\r
-  private boolean jj_3R_141() {\r
-    if (jj_scan_token(66)) return true;\r
-    if (jj_3R_148()) return true;\r
-    if (jj_scan_token(67)) return true;\r
+    if (jj_scan_token(88)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_140() {\r
-    if (jj_scan_token(62)) return true;\r
-    if (jj_3R_47()) return true;\r
-    if (jj_scan_token(63)) return true;\r
+  private boolean jj_3R_156() {\r
+    if (jj_scan_token(87)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_138() {\r
-    if (jj_3R_146()) return true;\r
+  private boolean jj_3R_142() {\r
+    if (jj_3R_151()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_104() {\r
-    if (jj_scan_token(26)) return true;\r
+  private boolean jj_3R_143() {\r
+    if (jj_3R_152()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_139() {\r
-    if (jj_3R_147()) return true;\r
+  private boolean jj_3_1() {\r
+    if (jj_scan_token(IDENT)) return true;\r
+    if (jj_3R_41()) return true;\r
+    if (jj_3R_42()) return true;\r
+    if (jj_scan_token(35)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_137() {\r
+  private boolean jj_3R_141() {\r
     if (jj_scan_token(33)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_133() {\r
+  private boolean jj_3R_137() {\r
     if (jj_scan_token(UNSIGNED_NUMBER)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_130() {\r
+  private boolean jj_3R_134() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_133()) {\r
-    jj_scanpos = xsp;\r
-    if (jj_3R_134()) {\r
-    jj_scanpos = xsp;\r
-    if (jj_3R_135()) {\r
-    jj_scanpos = xsp;\r
-    if (jj_3R_136()) {\r
-    jj_scanpos = xsp;\r
     if (jj_3R_137()) {\r
     jj_scanpos = xsp;\r
     if (jj_3R_138()) {\r
@@ -4878,6 +4863,14 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     jj_scanpos = xsp;\r
     if (jj_3R_142()) {\r
     jj_scanpos = xsp;\r
+    if (jj_3R_143()) {\r
+    jj_scanpos = xsp;\r
+    if (jj_3R_144()) {\r
+    jj_scanpos = xsp;\r
+    if (jj_3R_145()) {\r
+    jj_scanpos = xsp;\r
+    if (jj_3R_146()) {\r
+    jj_scanpos = xsp;\r
     if (jj_scan_token(35)) return true;\r
     }\r
     }\r
@@ -4892,101 +4885,115 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_136() {\r
+  private boolean jj_3R_140() {\r
     if (jj_scan_token(6)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_145() {\r
-    if (jj_scan_token(83)) return true;\r
+  private boolean jj_3R_139() {\r
+    if (jj_scan_token(STRING)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_143() {\r
-    if (jj_scan_token(87)) return true;\r
-    if (jj_3R_130()) return true;\r
+  private boolean jj_3R_108() {\r
+    if (jj_scan_token(26)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_135() {\r
-    if (jj_scan_token(STRING)) return true;\r
+  private boolean jj_3R_138() {\r
+    if (jj_scan_token(UNSIGNED_INTEGER)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_134() {\r
-    if (jj_scan_token(UNSIGNED_INTEGER)) return true;\r
+  private boolean jj_3R_149() {\r
+    if (jj_scan_token(83)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_124() {\r
+  private boolean jj_3R_128() {\r
     if (jj_scan_token(42)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_131() {\r
-    Token xsp;\r
-    xsp = jj_scanpos;\r
-    if (jj_scan_token(86)) {\r
-    jj_scanpos = xsp;\r
-    if (jj_3R_143()) return true;\r
-    }\r
+  private boolean jj_3R_154() {\r
+    if (jj_scan_token(64)) return true;\r
+    if (jj_3R_164()) return true;\r
+    if (jj_scan_token(65)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_149() {\r
-    if (jj_scan_token(64)) return true;\r
-    if (jj_3R_157()) return true;\r
-    if (jj_scan_token(65)) return true;\r
+  private boolean jj_3R_135() {\r
+    if (jj_3R_147()) return true;\r
+    if (jj_3R_134()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_129() {\r
-    if (jj_scan_token(79)) return true;\r
+  private boolean jj_3R_105() {\r
+    if (jj_scan_token(34)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_148() {\r
-    if (jj_3R_155()) return true;\r
+  private boolean jj_3R_153() {\r
+    if (jj_3R_162()) return true;\r
     Token xsp;\r
     while (true) {\r
       xsp = jj_scanpos;\r
-      if (jj_3R_156()) { jj_scanpos = xsp; break; }\r
+      if (jj_3R_163()) { jj_scanpos = xsp; break; }\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_150() {\r
+  private boolean jj_3R_157() {\r
     if (jj_3R_60()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_118() {\r
+  private boolean jj_3R_133() {\r
+    if (jj_scan_token(79)) return true;\r
+    return false;\r
+  }\r
+\r
+  private boolean jj_3R_151() {\r
+    Token xsp;\r
+    xsp = jj_scanpos;\r
+    if (jj_3R_157()) {\r
+    jj_scanpos = xsp;\r
+    if (jj_3R_158()) {\r
+    jj_scanpos = xsp;\r
+    if (jj_3R_159()) return true;\r
+    }\r
+    }\r
+    if (jj_3R_74()) return true;\r
+    return false;\r
+  }\r
+\r
+  private boolean jj_3R_122() {\r
     if (jj_scan_token(73)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_99() {\r
+  private boolean jj_3R_101() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
     if (jj_scan_token(30)) jj_scanpos = xsp;\r
     xsp = jj_scanpos;\r
     if (jj_scan_token(47)) jj_scanpos = xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_scan_token(34)) {\r
+    if (jj_3R_105()) {\r
     jj_scanpos = xsp;\r
-    if (jj_scan_token(7)) {\r
+    if (jj_3R_106()) {\r
     jj_scanpos = xsp;\r
     if (jj_scan_token(61)) {\r
     jj_scanpos = xsp;\r
     if (jj_scan_token(24)) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_103()) {\r
+    if (jj_3R_107()) {\r
     jj_scanpos = xsp;\r
     if (jj_scan_token(38)) {\r
     jj_scanpos = xsp;\r
     if (jj_scan_token(37)) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_104()) {\r
+    if (jj_3R_108()) {\r
     jj_scanpos = xsp;\r
     if (jj_scan_token(17)) {\r
     jj_scanpos = xsp;\r
@@ -5006,59 +5013,60 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_115() {\r
-    if (jj_3R_130()) return true;\r
-    Token xsp;\r
-    xsp = jj_scanpos;\r
-    if (jj_3R_131()) jj_scanpos = xsp;\r
+  private boolean jj_3R_155() {\r
+    if (jj_scan_token(86)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_146() {\r
+  private boolean jj_3R_147() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_150()) {\r
-    jj_scanpos = xsp;\r
-    if (jj_3R_151()) {\r
+    if (jj_3R_155()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_152()) return true;\r
+    if (jj_3R_156()) return true;\r
     }\r
-    }\r
-    if (jj_3R_74()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_116() {\r
-    if (jj_3R_132()) return true;\r
-    if (jj_3R_115()) return true;\r
+  private boolean jj_3R_119() {\r
+    if (jj_3R_134()) return true;\r
+    Token xsp;\r
+    xsp = jj_scanpos;\r
+    if (jj_3R_135()) jj_scanpos = xsp;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_109() {\r
-    if (jj_3R_114()) return true;\r
-    if (jj_3R_108()) return true;\r
+  private boolean jj_3R_120() {\r
+    if (jj_3R_136()) return true;\r
+    if (jj_3R_119()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_102() {\r
-    if (jj_3R_110()) return true;\r
-    if (jj_3R_101()) return true;\r
+  private boolean jj_3R_113() {\r
+    if (jj_3R_118()) return true;\r
+    if (jj_3R_112()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_144() {\r
+  private boolean jj_3R_104() {\r
+    if (jj_3R_114()) return true;\r
+    if (jj_3R_103()) return true;\r
+    return false;\r
+  }\r
+\r
+  private boolean jj_3R_148() {\r
     if (jj_scan_token(82)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_132() {\r
+  private boolean jj_3R_136() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_144()) {\r
+    if (jj_3R_148()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_145()) {\r
+    if (jj_3R_149()) {\r
     jj_scanpos = xsp;\r
-    if (jj_scan_token(84)) {\r
+    if (jj_3R_150()) {\r
     jj_scanpos = xsp;\r
     if (jj_scan_token(85)) return true;\r
     }\r
@@ -5067,17 +5075,17 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_106() {\r
+  private boolean jj_3R_110() {\r
     if (jj_3R_60()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_108() {\r
-    if (jj_3R_115()) return true;\r
+  private boolean jj_3R_112() {\r
+    if (jj_3R_119()) return true;\r
     Token xsp;\r
     while (true) {\r
       xsp = jj_scanpos;\r
-      if (jj_3R_116()) { jj_scanpos = xsp; break; }\r
+      if (jj_3R_120()) { jj_scanpos = xsp; break; }\r
     }\r
     return false;\r
   }\r
@@ -5088,22 +5096,22 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_128() {\r
+  private boolean jj_3R_132() {\r
     if (jj_scan_token(78)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_127() {\r
+  private boolean jj_3R_131() {\r
     if (jj_scan_token(56)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_114() {\r
+  private boolean jj_3R_118() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_128()) {\r
+    if (jj_3R_132()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_129()) {\r
+    if (jj_3R_133()) {\r
     jj_scanpos = xsp;\r
     if (jj_scan_token(80)) {\r
     jj_scanpos = xsp;\r
@@ -5119,81 +5127,81 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_95() {\r
+  private boolean jj_3R_97() {\r
     if (jj_scan_token(9)) return true;\r
-    if (jj_3R_94()) return true;\r
+    if (jj_3R_96()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_107() {\r
-    if (jj_3R_114()) return true;\r
+  private boolean jj_3R_111() {\r
+    if (jj_3R_118()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_126() {\r
+  private boolean jj_3R_130() {\r
     if (jj_scan_token(32)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_113() {\r
+  private boolean jj_3R_117() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_126()) {\r
+    if (jj_3R_130()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_127()) return true;\r
+    if (jj_3R_131()) return true;\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_101() {\r
+  private boolean jj_3R_103() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_107()) jj_scanpos = xsp;\r
-    if (jj_3R_108()) return true;\r
+    if (jj_3R_111()) jj_scanpos = xsp;\r
+    if (jj_3R_112()) return true;\r
     while (true) {\r
       xsp = jj_scanpos;\r
-      if (jj_3R_109()) { jj_scanpos = xsp; break; }\r
+      if (jj_3R_113()) { jj_scanpos = xsp; break; }\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_123() {\r
+  private boolean jj_3R_127() {\r
     if (jj_scan_token(5)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_117() {\r
+  private boolean jj_3R_121() {\r
     if (jj_scan_token(72)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_112() {\r
+  private boolean jj_3R_116() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_123()) {\r
+    if (jj_3R_127()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_124()) {\r
+    if (jj_3R_128()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_125()) return true;\r
+    if (jj_3R_129()) return true;\r
     }\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_110() {\r
+  private boolean jj_3R_114() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_117()) {\r
+    if (jj_3R_121()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_118()) {\r
+    if (jj_3R_122()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_119()) {\r
+    if (jj_3R_123()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_120()) {\r
+    if (jj_3R_124()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_121()) {\r
+    if (jj_3R_125()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_122()) return true;\r
+    if (jj_3R_126()) return true;\r
     }\r
     }\r
     }\r
@@ -5202,7 +5210,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_111() {\r
+  private boolean jj_3R_115() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
     if (jj_scan_token(16)) {\r
@@ -5224,22 +5232,22 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_105() {\r
+  private boolean jj_3R_109() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_111()) jj_scanpos = xsp;\r
+    if (jj_3R_115()) jj_scanpos = xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_112()) jj_scanpos = xsp;\r
+    if (jj_3R_116()) jj_scanpos = xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_113()) jj_scanpos = xsp;\r
+    if (jj_3R_117()) jj_scanpos = xsp;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_98() {\r
-    if (jj_3R_101()) return true;\r
+  private boolean jj_3R_100() {\r
+    if (jj_3R_103()) return true;\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_102()) jj_scanpos = xsp;\r
+    if (jj_3R_104()) jj_scanpos = xsp;\r
     return false;\r
   }\r
 \r
@@ -5253,11 +5261,11 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_94() {\r
+  private boolean jj_3R_96() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
     if (jj_scan_token(12)) jj_scanpos = xsp;\r
-    if (jj_3R_98()) return true;\r
+    if (jj_3R_100()) return true;\r
     return false;\r
   }\r
 \r
@@ -5283,11 +5291,11 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
   }\r
 \r
   private boolean jj_3R_86() {\r
-    if (jj_3R_94()) return true;\r
+    if (jj_3R_96()) return true;\r
     Token xsp;\r
     while (true) {\r
       xsp = jj_scanpos;\r
-      if (jj_3R_95()) { jj_scanpos = xsp; break; }\r
+      if (jj_3R_97()) { jj_scanpos = xsp; break; }\r
     }\r
     return false;\r
   }\r
@@ -5307,6 +5315,11 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
+  private boolean jj_3R_92() {\r
+    if (jj_scan_token(27)) return true;\r
+    return false;\r
+  }\r
+\r
   private boolean jj_3_8() {\r
     if (jj_3R_45()) return true;\r
     return false;\r
@@ -5320,14 +5333,19 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_66() {\r
-    if (jj_3R_80()) return true;\r
+  private boolean jj_3R_172() {\r
+    if (jj_3R_47()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_100() {\r
-    if (jj_3R_105()) return true;\r
-    if (jj_3R_106()) return true;\r
+  private boolean jj_3R_102() {\r
+    if (jj_3R_109()) return true;\r
+    if (jj_3R_110()) return true;\r
+    return false;\r
+  }\r
+\r
+  private boolean jj_3R_66() {\r
+    if (jj_3R_80()) return true;\r
     return false;\r
   }\r
 \r
@@ -5346,8 +5364,8 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_165() {\r
-    if (jj_3R_47()) return true;\r
+  private boolean jj_3R_68() {\r
+    if (jj_scan_token(14)) return true;\r
     return false;\r
   }\r
 \r
@@ -5373,13 +5391,14 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_68() {\r
-    if (jj_scan_token(14)) return true;\r
+  private boolean jj_3R_161() {\r
+    if (jj_scan_token(68)) return true;\r
+    if (jj_scan_token(IDENT)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_97() {\r
-    if (jj_3R_100()) return true;\r
+  private boolean jj_3R_99() {\r
+    if (jj_3R_102()) return true;\r
     return false;\r
   }\r
 \r
@@ -5389,25 +5408,26 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_154() {\r
-    if (jj_scan_token(68)) return true;\r
-    if (jj_scan_token(IDENT)) return true;\r
+  private boolean jj_3R_64() {\r
+    if (jj_scan_token(21)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3_6() {\r
-    if (jj_scan_token(IDENT)) return true;\r
-    if (jj_scan_token(88)) return true;\r
+  private boolean jj_3R_49() {\r
+    if (jj_scan_token(STRING)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_64() {\r
-    if (jj_scan_token(21)) return true;\r
+  private boolean jj_3_6() {\r
+    if (jj_scan_token(IDENT)) return true;\r
+    if (jj_scan_token(88)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_49() {\r
-    if (jj_scan_token(STRING)) return true;\r
+  private boolean jj_3R_41() {\r
+    Token xsp;\r
+    xsp = jj_scanpos;\r
+    if (jj_3R_49()) jj_scanpos = xsp;\r
     return false;\r
   }\r
 \r
@@ -5416,7 +5436,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_122() {\r
+  private boolean jj_3R_126() {\r
     if (jj_scan_token(77)) return true;\r
     return false;\r
   }\r
@@ -5436,13 +5456,6 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_41() {\r
-    Token xsp;\r
-    xsp = jj_scanpos;\r
-    if (jj_3R_49()) jj_scanpos = xsp;\r
-    return false;\r
-  }\r
-\r
   private boolean jj_3R_88() {\r
     if (jj_scan_token(46)) return true;\r
     return false;\r
@@ -5467,7 +5480,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_92() {\r
+  private boolean jj_3R_94() {\r
     if (jj_scan_token(13)) return true;\r
     return false;\r
   }\r
@@ -5477,23 +5490,56 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_96() {\r
+  private boolean jj_3R_98() {\r
+    if (jj_3R_101()) return true;\r
+    return false;\r
+  }\r
+\r
+  private boolean jj_3R_171() {\r
+    if (jj_scan_token(69)) return true;\r
+    return false;\r
+  }\r
+\r
+  private boolean jj_3R_93() {\r
+    Token xsp;\r
+    xsp = jj_scanpos;\r
+    if (jj_3R_98()) {\r
+    jj_scanpos = xsp;\r
     if (jj_3R_99()) return true;\r
+    }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_91() {\r
+  private boolean jj_3R_169() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_96()) {\r
+    if (jj_3R_171()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_97()) return true;\r
+    if (jj_3R_172()) return true;\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_164() {\r
-    if (jj_scan_token(69)) return true;\r
+  private boolean jj_3R_167() {\r
+    if (jj_scan_token(71)) return true;\r
+    return false;\r
+  }\r
+\r
+  private boolean jj_3R_107() {\r
+    Token xsp;\r
+    xsp = jj_scanpos;\r
+    if (jj_scan_token(50)) jj_scanpos = xsp;\r
+    if (jj_scan_token(44)) return true;\r
+    return false;\r
+  }\r
+\r
+  private boolean jj_3R_91() {\r
+    if (jj_scan_token(51)) return true;\r
+    return false;\r
+  }\r
+\r
+  private boolean jj_3R_160() {\r
+    if (jj_3R_166()) return true;\r
     return false;\r
   }\r
 \r
@@ -5504,39 +5550,25 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     xsp = jj_scanpos;\r
     if (jj_scan_token(11)) jj_scanpos = xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_scan_token(51)) jj_scanpos = xsp;\r
-    xsp = jj_scanpos;\r
-    if (jj_scan_token(27)) jj_scanpos = xsp;\r
+    if (jj_3R_91()) jj_scanpos = xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_91()) {\r
-    jj_scanpos = xsp;\r
-    if (jj_3R_92()) return true;\r
-    }\r
-    return false;\r
-  }\r
-\r
-  private boolean jj_3R_162() {\r
-    Token xsp;\r
+    if (jj_3R_92()) jj_scanpos = xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_164()) {\r
+    if (jj_3R_93()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_165()) return true;\r
+    if (jj_3R_94()) return true;\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_160() {\r
-    if (jj_scan_token(71)) return true;\r
-    return false;\r
-  }\r
-\r
   private boolean jj_3R_83() {\r
     if (jj_3R_90()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_153() {\r
-    if (jj_3R_159()) return true;\r
+  private boolean jj_3R_166() {\r
+    if (jj_scan_token(66)) return true;\r
+    if (jj_3R_169()) return true;\r
     return false;\r
   }\r
 \r
@@ -5545,12 +5577,6 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_159() {\r
-    if (jj_scan_token(66)) return true;\r
-    if (jj_3R_162()) return true;\r
-    return false;\r
-  }\r
-\r
   private boolean jj_3R_63() {\r
     if (jj_scan_token(71)) return true;\r
     return false;\r
@@ -5579,7 +5605,17 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_121() {\r
+  private boolean jj_3R_162() {\r
+    if (jj_3R_47()) return true;\r
+    Token xsp;\r
+    while (true) {\r
+      xsp = jj_scanpos;\r
+      if (jj_3R_167()) { jj_scanpos = xsp; break; }\r
+    }\r
+    return false;\r
+  }\r
+\r
+  private boolean jj_3R_125() {\r
     if (jj_scan_token(76)) return true;\r
     return false;\r
   }\r
@@ -5598,35 +5634,38 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_155() {\r
-    if (jj_3R_47()) return true;\r
-    Token xsp;\r
-    while (true) {\r
-      xsp = jj_scanpos;\r
-      if (jj_3R_160()) { jj_scanpos = xsp; break; }\r
-    }\r
-    return false;\r
-  }\r
-\r
   private boolean jj_3R_73() {\r
     if (jj_scan_token(43)) return true;\r
     if (jj_3R_47()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_166() {\r
+  private boolean jj_3R_173() {\r
     if (jj_scan_token(IDENT)) return true;\r
     if (jj_scan_token(88)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_152() {\r
+  private boolean jj_3R_159() {\r
     if (jj_scan_token(46)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_163() {\r
-    if (jj_3R_166()) return true;\r
+  private boolean jj_3R_170() {\r
+    if (jj_3R_173()) return true;\r
+    return false;\r
+  }\r
+\r
+  private boolean jj_3R_168() {\r
+    if (jj_3R_170()) return true;\r
+    return false;\r
+  }\r
+\r
+  private boolean jj_3_10() {\r
+    if (jj_3R_47()) return true;\r
+    Token xsp;\r
+    xsp = jj_scanpos;\r
+    if (jj_3R_48()) jj_scanpos = xsp;\r
     return false;\r
   }\r
 \r
@@ -5635,13 +5674,23 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_51() {\r
-    if (jj_scan_token(59)) return true;\r
+  private boolean jj_3R_165() {\r
+    if (jj_3R_164()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_161() {\r
-    if (jj_3R_163()) return true;\r
+  private boolean jj_3R_164() {\r
+    Token xsp;\r
+    xsp = jj_scanpos;\r
+    if (jj_3_10()) {\r
+    jj_scanpos = xsp;\r
+    if (jj_3R_168()) return true;\r
+    }\r
+    return false;\r
+  }\r
+\r
+  private boolean jj_3R_51() {\r
+    if (jj_scan_token(59)) return true;\r
     return false;\r
   }\r
 \r
@@ -5667,7 +5716,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     return false;\r
   }\r
 \r
-  private boolean jj_3R_93() {\r
+  private boolean jj_3R_95() {\r
     if (jj_scan_token(IDENT)) return true;\r
     return false;\r
   }\r
@@ -5683,7 +5732,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
   private Token jj_scanpos, jj_lastpos;\r
   private int jj_la;\r
   private int jj_gen;\r
-  final private int[] jj_la1 = new int[134];\r
+  final private int[] jj_la1 = new int[132];\r
   static private int[] jj_la1_0;\r
   static private int[] jj_la1_1;\r
   static private int[] jj_la1_2;\r
@@ -5693,13 +5742,13 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
       jj_la1_init_2();\r
    }\r
    private static void jj_la1_init_0() {\r
-      jj_la1_0 = new int[] {0x0,0x0,0x45020880,0x800,0x40000000,0x0,0x0,0x5020080,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10,0x10,0x0,0x0,0x4000,0x0,0x4000,0x0,0x80001040,0x4d8329a0,0x100,0x800,0x0,0x8000000,0x458300a0,0x458300a0,0x0,0x458320a0,0x4d8329a0,0x0,0x0,0x0,0x4000,0x0,0x0,0x810000,0x810000,0x20,0x20,0x0,0x0,0x0,0x80000000,0x0,0x0,0x0,0x0,0x2d00,0x0,0x2d00,0x400,0x800,0x2000,0x0,0x400,0x800,0x458300a0,0x458320a0,0x458300a0,0x0,0x0,0x0,0xa0240000,0x80200000,0x0,0xa0240000,0x80201040,0x100000,0x80201040,0x80201040,0x8000,0xa0240000,0x100000,0xa0240000,0xa0240000,0x8000,0x80201040,0xa0240000,0x0,0x0,0xa0240000,0x80201040,0x2000000,0x80201040,0xa0240000,0x2000000,0xa0240000,0x100000,0x80001040,0x100000,0x80001040,0x0,0x0,0x400000,0x200,0x1000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80001040,0x200000,0x200000,0x0,0x0,0x80001040,0x0,0x80001040,0x0,0x0,0x80001040,0x4000,0x0,0x0,};\r
+      jj_la1_0 = new int[] {0x0,0x0,0x45020880,0x800,0x40000000,0x0,0x0,0x5020080,0x0,0x0,0x0,0x0,0x0,0x10,0x10,0x0,0x0,0x4000,0x0,0x4000,0x0,0x80001040,0x4d8329a0,0x100,0x800,0x0,0x8000000,0x458300a0,0x458300a0,0x0,0x458320a0,0x4d8329a0,0x0,0x0,0x0,0x4000,0x0,0x0,0x810000,0x810000,0x20,0x20,0x0,0x0,0x0,0x80000000,0x0,0x0,0x0,0x0,0x2d00,0x0,0x2d00,0x400,0x800,0x2000,0x0,0x400,0x800,0x458300a0,0x458320a0,0x458300a0,0x0,0x0,0x0,0xa0240000,0x80200000,0x0,0xa0240000,0x80201040,0x100000,0x80201040,0x80201040,0x8000,0xa0240000,0x100000,0xa0240000,0xa0240000,0x8000,0x80201040,0xa0240000,0x0,0x0,0xa0240000,0x80201040,0x2000000,0x80201040,0xa0240000,0x2000000,0xa0240000,0x100000,0x80001040,0x100000,0x80001040,0x0,0x0,0x400000,0x200,0x1000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80001040,0x200000,0x200000,0x0,0x0,0x80001040,0x0,0x80001040,0x0,0x0,0x80001040,0x4000,0x0,0x0,};\r
    }\r
    private static void jj_la1_init_1() {\r
-      jj_la1_1 = new int[] {0x0,0x200000,0x20049064,0x0,0x0,0x8000,0x40000,0x20041064,0x0,0x40000000,0x0,0x0,0x40000000,0x800000,0x0,0x2106000,0x106000,0x0,0x0,0x0,0x8000000,0x0,0x0,0x4400400a,0x218e9475,0x0,0x0,0x80000,0x0,0x21069465,0x21069465,0x400000,0x21069465,0x218e9475,0x0,0x0,0x40000000,0x0,0x40000000,0x0,0x0,0x0,0x20400,0x20400,0x1000001,0x1000001,0x0,0x0,0x0,0x40000000,0x0,0x40000000,0x0,0x0,0x0,0x0,0x0,0x0,0x40000000,0x0,0x0,0x21069465,0x21069465,0x21069465,0x400000,0x4000,0x4000,0x40010800,0x880,0x40000000,0x40010800,0x4400488a,0x0,0x4400488a,0x4400488a,0x0,0x40010800,0x0,0x40010800,0x40010800,0x0,0x4400488a,0x40010800,0x0,0x200,0x40010800,0x4400488a,0x0,0x4400488a,0x40010800,0x0,0x40010800,0x0,0x4400400a,0x0,0x4400400a,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4004000,0x0,0x2,0x40000008,0x0,0x0,0x0,0x0,0x0,0x0,0x4400400a,0x0,0x0,0x0,0x0,0x4400400a,0x0,0x4400400a,0x0,0x0,0x4400400a,0x0,0x0,0x0,};\r
+      jj_la1_1 = new int[] {0x0,0x200000,0x20049064,0x0,0x0,0x8000,0x40000,0x20041064,0x0,0x40000000,0x0,0x0,0x0,0x2106000,0x106000,0x0,0x0,0x0,0x8000000,0x0,0x0,0x4400400a,0x218e9475,0x0,0x0,0x80000,0x0,0x21069465,0x21069465,0x400000,0x21069465,0x218e9475,0x0,0x0,0x40000000,0x0,0x40000000,0x0,0x0,0x0,0x20400,0x20400,0x1000001,0x1000001,0x0,0x0,0x0,0x40000000,0x0,0x40000000,0x0,0x0,0x0,0x0,0x0,0x0,0x40000000,0x0,0x0,0x21069465,0x21069465,0x21069465,0x400000,0x4000,0x4000,0x40010800,0x880,0x40000000,0x40010800,0x4400488a,0x0,0x4400488a,0x4400488a,0x0,0x40010800,0x0,0x40010800,0x40010800,0x0,0x4400488a,0x40010800,0x0,0x200,0x40010800,0x4400488a,0x0,0x4400488a,0x40010800,0x0,0x40010800,0x0,0x4400400a,0x0,0x4400400a,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4004000,0x0,0x2,0x40000008,0x0,0x0,0x0,0x0,0x0,0x0,0x4400400a,0x0,0x0,0x0,0x0,0x4400400a,0x0,0x4400400a,0x0,0x0,0x4400400a,0x0,0x0,0x0,};\r
    }\r
    private static void jj_la1_init_2() {\r
-      jj_la1_2 = new int[] {0x4000010,0x0,0xc0000000,0x0,0x0,0x0,0x0,0xc0000000,0x4,0x0,0x4000000,0x80,0x0,0x0,0x80,0x0,0x0,0x8000000,0x4000010,0x0,0x0,0x0,0x4000010,0x3c03c015,0xc4000010,0x0,0x0,0x0,0x0,0xc4000010,0xc4000010,0x0,0xc4000010,0xc4000010,0x10,0x4000010,0x0,0x0,0x0,0x4,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x0,0x4,0x3000000,0x1000000,0x3000000,0x4000010,0x80,0x4000010,0x0,0x0,0x4000010,0x3000000,0x0,0x0,0xc4000010,0xc4000010,0xc4000010,0x0,0x0,0x0,0x4000010,0x4000000,0x2000000,0x4000010,0x3c03c015,0x0,0x3c03c015,0x3c03c015,0x0,0x4000010,0x0,0x4000010,0x4000010,0x0,0x3c03c015,0x4000010,0x80,0x0,0x4000010,0x3c03c015,0x0,0x3c03c015,0x4000010,0x0,0x4000010,0x0,0x3c03c015,0x0,0x3c03c015,0x20,0x20,0x0,0x0,0x0,0x3f00,0x3f00,0x3c000,0x3c000,0x3c000,0x3c0000,0x3c0000,0xc00000,0xc00000,0x4000010,0x40,0x38000000,0x4000015,0x10,0x10,0x10,0x4,0x10,0x4,0x3c03c015,0x80,0x80,0x4000000,0x80,0x3c03c015,0x80,0x3c03c015,0x80,0x80,0x3c03c035,0x0,0x4000,0x8000000,};\r
+      jj_la1_2 = new int[] {0x4000010,0x0,0xc0000000,0x0,0x0,0x0,0x0,0xc0000000,0x4,0x0,0x80,0x4000000,0x80,0x0,0x0,0x8000000,0x4000010,0x0,0x0,0x0,0x4000010,0x3c03c015,0xc4000010,0x0,0x0,0x0,0x0,0xc4000010,0xc4000010,0x0,0xc4000010,0xc4000010,0x10,0x4000010,0x0,0x0,0x0,0x4,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x0,0x4,0x3000000,0x1000000,0x3000000,0x4000010,0x80,0x4000010,0x0,0x0,0x4000010,0x3000000,0x0,0x0,0xc4000010,0xc4000010,0xc4000010,0x0,0x0,0x0,0x4000010,0x4000000,0x2000000,0x4000010,0x3c03c015,0x0,0x3c03c015,0x3c03c015,0x0,0x4000010,0x0,0x4000010,0x4000010,0x0,0x3c03c015,0x4000010,0x80,0x0,0x4000010,0x3c03c015,0x0,0x3c03c015,0x4000010,0x0,0x4000010,0x0,0x3c03c015,0x0,0x3c03c015,0x20,0x20,0x0,0x0,0x0,0x3f00,0x3f00,0x3c000,0x3c000,0x3c000,0x3c0000,0x3c0000,0xc00000,0xc00000,0x4000010,0x40,0x38000000,0x4000015,0x10,0x10,0x10,0x4,0x10,0x4,0x3c03c015,0x80,0x80,0x4000000,0x80,0x3c03c015,0x80,0x3c03c015,0x80,0x80,0x3c03c035,0x0,0x4000,0x8000000,};\r
    }\r
   final private JJCalls[] jj_2_rtns = new JJCalls[10];\r
   private boolean jj_rescan = false;\r
@@ -5716,7 +5765,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     token = new Token();\r
     jj_ntk = -1;\r
     jj_gen = 0;\r
-    for (int i = 0; i < 134; i++) jj_la1[i] = -1;\r
+    for (int i = 0; i < 132; i++) jj_la1[i] = -1;\r
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();\r
   }\r
 \r
@@ -5732,7 +5781,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     jj_ntk = -1;\r
     jjtree.reset();\r
     jj_gen = 0;\r
-    for (int i = 0; i < 134; i++) jj_la1[i] = -1;\r
+    for (int i = 0; i < 132; i++) jj_la1[i] = -1;\r
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();\r
   }\r
 \r
@@ -5743,7 +5792,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     token = new Token();\r
     jj_ntk = -1;\r
     jj_gen = 0;\r
-    for (int i = 0; i < 134; i++) jj_la1[i] = -1;\r
+    for (int i = 0; i < 132; i++) jj_la1[i] = -1;\r
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();\r
   }\r
 \r
@@ -5755,7 +5804,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     jj_ntk = -1;\r
     jjtree.reset();\r
     jj_gen = 0;\r
-    for (int i = 0; i < 134; i++) jj_la1[i] = -1;\r
+    for (int i = 0; i < 132; i++) jj_la1[i] = -1;\r
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();\r
   }\r
 \r
@@ -5765,7 +5814,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     token = new Token();\r
     jj_ntk = -1;\r
     jj_gen = 0;\r
-    for (int i = 0; i < 134; i++) jj_la1[i] = -1;\r
+    for (int i = 0; i < 132; i++) jj_la1[i] = -1;\r
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();\r
   }\r
 \r
@@ -5776,7 +5825,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
     jj_ntk = -1;\r
     jjtree.reset();\r
     jj_gen = 0;\r
-    for (int i = 0; i < 134; i++) jj_la1[i] = -1;\r
+    for (int i = 0; i < 132; i++) jj_la1[i] = -1;\r
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();\r
   }\r
 \r
@@ -5893,7 +5942,7 @@ public class ModelParser/*@bgen(jjtree)*/implements ModelParserTreeConstants, Mo
       la1tokens[jj_kind] = true;\r
       jj_kind = -1;\r
     }\r
-    for (int i = 0; i < 134; i++) {\r
+    for (int i = 0; i < 132; i++) {\r
       if (jj_la1[i] == jj_gen) {\r
         for (int j = 0; j < 32; j++) {\r
           if ((jj_la1_0[i] & (1<<j)) != 0) {\r
index 471f3ac8cd59ccb8649bc44bd7fbcdbbe5d22ccf..754f36e8fa3403579cc02a03dce08da9bbbd7c02 100644 (file)
@@ -15,21 +15,17 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1)
    switch (pos)
    {\r
       case 0:\r
-         if ((active1 & 0x80000L) != 0L)\r
-            return 15;\r
-         if ((active1 & 0x8000L) != 0L)\r
-            return 37;\r
-         if ((active1 & 0xb30010L) != 0L)\r
-            return 9;\r
          if ((active0 & 0x3ffffffffffffff0L) != 0L || (active1 & 0xc0000000L) != 0L)\r
          {\r
             jjmatchedKind = 90;\r
             return 2;\r
          }\r
+         if ((active1 & 0x80000L) != 0L)\r
+            return 13;\r
+         if ((active1 & 0xb30010L) != 0L)\r
+            return 9;\r
          return -1;\r
       case 1:\r
-         if ((active1 & 0x20000L) != 0L)\r
-            return 10;\r
          if ((active0 & 0x108420080400000L) != 0L)\r
             return 2;\r
          if ((active0 & 0x3ef7bdff7fbffff0L) != 0L || (active1 & 0xc0000000L) != 0L)\r
@@ -184,12 +180,12 @@ private int jjMoveStringLiteralDfa0_0()
       case 44:\r
          return jjStopAtPos(0, 71);\r
       case 45:\r
-         return jjStartNfaWithStates_0(0, 79, 37);\r
+         return jjStopAtPos(0, 79);\r
       case 46:\r
          jjmatchedKind = 68;\r
          return jjMoveStringLiteralDfa1_0(0x0L, 0xb30000L);\r
       case 47:\r
-         return jjStartNfaWithStates_0(0, 83, 15);\r
+         return jjStartNfaWithStates_0(0, 83, 13);\r
       case 58:\r
          jjmatchedKind = 69;\r
          return jjMoveStringLiteralDfa1_0(0x0L, 0x2000000L);\r
@@ -269,7 +265,7 @@ private int jjMoveStringLiteralDfa1_0(long active0, long active1)
          break;\r
       case 45:\r
          if ((active1 & 0x20000L) != 0L)\r
-            return jjStartNfaWithStates_0(1, 81, 10);\r
+            return jjStopAtPos(1, 81);\r
          break;\r
       case 47:\r
          if ((active1 & 0x200000L) != 0L)\r
@@ -940,7 +936,7 @@ static final long[] jjbitVec0 = {
 private int jjMoveNfa_0(int startState, int curPos)\r
 {\r
    int startsAt = 0;\r
-   jjnewStateCnt = 37;\r
+   jjnewStateCnt = 31;\r
    int i = 1;\r
    jjstateSet[0] = startState;\r
    int kind = 0x7fffffff;\r
@@ -955,59 +951,35 @@ private int jjMoveNfa_0(int startState, int curPos)
          {\r
             switch(jjstateSet[--i])\r
             {\r
-               case 9:\r
-                  if ((0x3ff000000000000L & l) != 0L)\r
-                  {\r
-                     if (kind > 93)\r
-                        kind = 93;\r
-                     jjCheckNAddTwoStates(10, 11);\r
-                  }\r
-                  else if (curChar == 45)\r
-                     jjCheckNAdd(10);\r
-                  break;\r
-               case 37:\r
-                  if ((0x3ff000000000000L & l) != 0L)\r
-                     jjCheckNAddTwoStates(32, 33);\r
-                  if ((0x3ff000000000000L & l) != 0L)\r
-                     jjCheckNAddTwoStates(25, 26);\r
-                  if ((0x3ff000000000000L & l) != 0L)\r
+               case 13:\r
+                  if (curChar == 47)\r
                   {\r
-                     if (kind > 92)\r
-                        kind = 92;\r
-                     jjCheckNAdd(24);\r
+                     if (kind > 3)\r
+                        kind = 3;\r
+                     jjCheckNAdd(20);\r
                   }\r
+                  else if (curChar == 42)\r
+                     jjCheckNAddStates(0, 2);\r
                   break;\r
                case 0:\r
                   if ((0x3ff000000000000L & l) != 0L)\r
                   {\r
                      if (kind > 92)\r
                         kind = 92;\r
-                     jjCheckNAddStates(0, 4);\r
+                     jjCheckNAddStates(3, 7);\r
                   }\r
                   else if ((0x100002600L & l) != 0L)\r
                   {\r
                      if (kind > 1)\r
                         kind = 1;\r
                   }\r
-                  else if (curChar == 45)\r
-                     jjCheckNAddStates(5, 7);\r
                   else if (curChar == 47)\r
                      jjAddStates(8, 9);\r
                   else if (curChar == 46)\r
-                     jjCheckNAddTwoStates(9, 10);\r
+                     jjCheckNAdd(9);\r
                   else if (curChar == 34)\r
                      jjCheckNAddStates(10, 12);\r
                   break;\r
-               case 15:\r
-                  if (curChar == 47)\r
-                  {\r
-                     if (kind > 3)\r
-                        kind = 3;\r
-                     jjCheckNAdd(22);\r
-                  }\r
-                  else if (curChar == 42)\r
-                     jjCheckNAddStates(13, 15);\r
-                  break;\r
                case 2:\r
                   if ((0x3ff400000000000L & l) == 0L)\r
                      break;\r
@@ -1033,129 +1005,109 @@ private int jjMoveNfa_0(int startState, int curPos)
                   break;\r
                case 8:\r
                   if (curChar == 46)\r
-                     jjCheckNAddTwoStates(9, 10);\r
+                     jjCheckNAdd(9);\r
                   break;\r
-               case 10:\r
+               case 9:\r
                   if ((0x3ff000000000000L & l) == 0L)\r
                      break;\r
                   if (kind > 93)\r
                      kind = 93;\r
-                  jjCheckNAddTwoStates(10, 11);\r
-                  break;\r
-               case 12:\r
-                  if (curChar == 45)\r
-                     jjCheckNAdd(13);\r
+                  jjCheckNAddTwoStates(9, 10);\r
                   break;\r
-               case 13:\r
+               case 11:\r
                   if ((0x3ff000000000000L & l) == 0L)\r
                      break;\r
                   if (kind > 93)\r
                      kind = 93;\r
-                  jjCheckNAdd(13);\r
+                  jjstateSet[jjnewStateCnt++] = 11;\r
                   break;\r
-               case 14:\r
+               case 12:\r
                   if (curChar == 47)\r
                      jjAddStates(8, 9);\r
                   break;\r
-               case 16:\r
+               case 14:\r
                   if ((0xfffffbffffffffffL & l) != 0L)\r
-                     jjCheckNAddStates(13, 15);\r
+                     jjCheckNAddStates(0, 2);\r
                   break;\r
-               case 17:\r
+               case 15:\r
                   if (curChar == 42)\r
-                     jjstateSet[jjnewStateCnt++] = 18;\r
+                     jjstateSet[jjnewStateCnt++] = 16;\r
                   break;\r
-               case 18:\r
+               case 16:\r
                   if ((0xffff7fffffffffffL & l) != 0L)\r
-                     jjCheckNAddStates(13, 15);\r
+                     jjCheckNAddStates(0, 2);\r
                   break;\r
-               case 19:\r
+               case 17:\r
                   if (curChar == 47 && kind > 2)\r
                      kind = 2;\r
                   break;\r
-               case 20:\r
+               case 18:\r
                   if (curChar == 42)\r
-                     jjstateSet[jjnewStateCnt++] = 19;\r
+                     jjstateSet[jjnewStateCnt++] = 17;\r
                   break;\r
-               case 21:\r
+               case 19:\r
                   if (curChar != 47)\r
                      break;\r
                   if (kind > 3)\r
                      kind = 3;\r
-                  jjCheckNAdd(22);\r
+                  jjCheckNAdd(20);\r
                   break;\r
-               case 22:\r
+               case 20:\r
                   if ((0xfffffffffffffbffL & l) == 0L)\r
                      break;\r
                   if (kind > 3)\r
                      kind = 3;\r
-                  jjCheckNAdd(22);\r
+                  jjCheckNAdd(20);\r
                   break;\r
-               case 23:\r
-                  if (curChar == 45)\r
-                     jjCheckNAddStates(5, 7);\r
+               case 21:\r
+                  if ((0x3ff000000000000L & l) == 0L)\r
+                     break;\r
+                  if (kind > 92)\r
+                     kind = 92;\r
+                  jjCheckNAddStates(3, 7);\r
                   break;\r
-               case 24:\r
+               case 22:\r
                   if ((0x3ff000000000000L & l) == 0L)\r
                      break;\r
                   if (kind > 92)\r
                      kind = 92;\r
-                  jjCheckNAdd(24);\r
+                  jjCheckNAdd(22);\r
                   break;\r
-               case 25:\r
+               case 23:\r
                   if ((0x3ff000000000000L & l) != 0L)\r
-                     jjCheckNAddTwoStates(25, 26);\r
+                     jjCheckNAddTwoStates(23, 24);\r
                   break;\r
-               case 26:\r
+               case 24:\r
                   if (curChar != 46)\r
                      break;\r
                   if (kind > 93)\r
                      kind = 93;\r
-                  jjCheckNAddStates(16, 18);\r
-                  break;\r
-               case 27:\r
-                  if (curChar == 45)\r
-                     jjCheckNAdd(28);\r
+                  jjCheckNAddTwoStates(25, 26);\r
                   break;\r
-               case 28:\r
+               case 25:\r
                   if ((0x3ff000000000000L & l) == 0L)\r
                      break;\r
                   if (kind > 93)\r
                      kind = 93;\r
-                  jjCheckNAddTwoStates(28, 29);\r
+                  jjCheckNAddTwoStates(25, 26);\r
                   break;\r
-               case 30:\r
-                  if (curChar == 45)\r
-                     jjCheckNAdd(31);\r
-                  break;\r
-               case 31:\r
+               case 27:\r
                   if ((0x3ff000000000000L & l) == 0L)\r
                      break;\r
                   if (kind > 93)\r
                      kind = 93;\r
-                  jjCheckNAdd(31);\r
+                  jjstateSet[jjnewStateCnt++] = 27;\r
                   break;\r
-               case 32:\r
+               case 28:\r
                   if ((0x3ff000000000000L & l) != 0L)\r
-                     jjCheckNAddTwoStates(32, 33);\r
+                     jjCheckNAddTwoStates(28, 29);\r
                   break;\r
-               case 34:\r
-                  if (curChar == 45)\r
-                     jjCheckNAdd(35);\r
-                  break;\r
-               case 35:\r
+               case 30:\r
                   if ((0x3ff000000000000L & l) == 0L)\r
                      break;\r
                   if (kind > 93)\r
                      kind = 93;\r
-                  jjCheckNAdd(35);\r
-                  break;\r
-               case 36:\r
-                  if ((0x3ff000000000000L & l) == 0L)\r
-                     break;\r
-                  if (kind > 92)\r
-                     kind = 92;\r
-                  jjCheckNAddStates(0, 4);\r
+                  jjstateSet[jjnewStateCnt++] = 30;\r
                   break;\r
                default : break;\r
             }\r
@@ -1187,26 +1139,26 @@ private int jjMoveNfa_0(int startState, int curPos)
                case 6:\r
                   jjCheckNAddStates(10, 12);\r
                   break;\r
-               case 11:\r
+               case 10:\r
                   if ((0x2000000020L & l) != 0L)\r
-                     jjAddStates(19, 20);\r
+                     jjstateSet[jjnewStateCnt++] = 11;\r
                   break;\r
+               case 14:\r
                case 16:\r
-               case 18:\r
-                  jjCheckNAddStates(13, 15);\r
+                  jjCheckNAddStates(0, 2);\r
                   break;\r
-               case 22:\r
+               case 20:\r
                   if (kind > 3)\r
                      kind = 3;\r
-                  jjstateSet[jjnewStateCnt++] = 22;\r
+                  jjstateSet[jjnewStateCnt++] = 20;\r
                   break;\r
-               case 29:\r
+               case 26:\r
                   if ((0x2000000020L & l) != 0L)\r
-                     jjAddStates(21, 22);\r
+                     jjstateSet[jjnewStateCnt++] = 27;\r
                   break;\r
-               case 33:\r
+               case 29:\r
                   if ((0x2000000020L & l) != 0L)\r
-                     jjAddStates(23, 24);\r
+                     jjstateSet[jjnewStateCnt++] = 30;\r
                   break;\r
                default : break;\r
             }\r
@@ -1225,17 +1177,17 @@ private int jjMoveNfa_0(int startState, int curPos)
                   if ((jjbitVec0[i2] & l2) != 0L)\r
                      jjCheckNAddStates(10, 12);\r
                   break;\r
+               case 14:\r
                case 16:\r
-               case 18:\r
                   if ((jjbitVec0[i2] & l2) != 0L)\r
-                     jjCheckNAddStates(13, 15);\r
+                     jjCheckNAddStates(0, 2);\r
                   break;\r
-               case 22:\r
+               case 20:\r
                   if ((jjbitVec0[i2] & l2) == 0L)\r
                      break;\r
                   if (kind > 3)\r
                      kind = 3;\r
-                  jjstateSet[jjnewStateCnt++] = 22;\r
+                  jjstateSet[jjnewStateCnt++] = 20;\r
                   break;\r
                default : break;\r
             }\r
@@ -1248,15 +1200,14 @@ private int jjMoveNfa_0(int startState, int curPos)
          kind = 0x7fffffff;\r
       }\r
       ++curPos;\r
-      if ((i = jjnewStateCnt) == (startsAt = 37 - (jjnewStateCnt = startsAt)))\r
+      if ((i = jjnewStateCnt) == (startsAt = 31 - (jjnewStateCnt = startsAt)))\r
          return curPos;\r
       try { curChar = input_stream.readChar(); }\r
       catch(java.io.IOException e) { return curPos; }\r
    }\r
 }\r
 static final int[] jjnextStates = {
-   24, 25, 26, 32, 33, 24, 25, 32, 15, 21, 4, 5, 7, 16, 17, 20, 
-   27, 28, 29, 12, 13, 30, 31, 34, 35, 
+   14, 15, 18, 22, 23, 24, 28, 29, 13, 19, 4, 5, 7, 
 };\r
 \r
 /** Token literal values. */\r
@@ -1295,8 +1246,8 @@ static final long[] jjtoSkip = {
    0xeL, 0x0L, 
 };\r
 protected SimpleCharStream input_stream;\r
-private final int[] jjrounds = new int[37];\r
-private final int[] jjstateSet = new int[74];\r
+private final int[] jjrounds = new int[31];\r
+private final int[] jjstateSet = new int[62];\r
 private final StringBuilder jjimage = new StringBuilder();\r
 private StringBuilder image = jjimage;\r
 private int jjimageLen;\r
@@ -1327,7 +1278,7 @@ private void ReInitRounds()
 {\r
    int i;\r
    jjround = 0x80000001;\r
-   for (i = 37; i-- > 0;)\r
+   for (i = 31; i-- > 0;)\r
       jjrounds[i] = 0x80000000;\r
 }\r
 \r
index 39cc66d46d1b05af4ae1c4d1475af43cbb6c80ac..8539a490f219f136551e775975277851f3e4edf1 100644 (file)
@@ -68,22 +68,23 @@ public interface ModelParserTreeConstants
   public int JJTTERM = 62;\r
   public int JJTMUL_OP = 63;\r
   public int JJTFACTOR = 64;\r
-  public int JJTDER_INITIAL = 65;\r
-  public int JJTSUBSCRIPT_2 = 66;\r
-  public int JJTARRAY = 67;\r
-  public int JJTPRIMARY = 68;\r
-  public int JJTNAME = 69;\r
-  public int JJTCOMPONENT_REFERENCE = 70;\r
-  public int JJTFUNCTION_CALL_ARGS = 71;\r
-  public int JJTFUNCTION_ARGUMENTS = 72;\r
-  public int JJTNAMED_ARGUMENTS = 73;\r
-  public int JJTNAMED_ARGUMENT = 74;\r
-  public int JJTOUTPUT_EXPRESSION_LIST = 75;\r
-  public int JJTEXPRESSION_LIST = 76;\r
-  public int JJTARRAY_SUBSCRIPTS = 77;\r
-  public int JJTSUBSCRIPT = 78;\r
-  public int JJTVOID = 79;\r
-  public int JJTANNOTATION = 80;\r
+  public int JJTFACTOR_OP = 65;\r
+  public int JJTDER_INITIAL = 66;\r
+  public int JJTSUBSCRIPT_2 = 67;\r
+  public int JJTARRAY = 68;\r
+  public int JJTPRIMARY = 69;\r
+  public int JJTNAME = 70;\r
+  public int JJTCOMPONENT_REFERENCE = 71;\r
+  public int JJTFUNCTION_CALL_ARGS = 72;\r
+  public int JJTFUNCTION_ARGUMENTS = 73;\r
+  public int JJTNAMED_ARGUMENTS = 74;\r
+  public int JJTNAMED_ARGUMENT = 75;\r
+  public int JJTOUTPUT_EXPRESSION_LIST = 76;\r
+  public int JJTEXPRESSION_LIST = 77;\r
+  public int JJTARRAY_SUBSCRIPTS = 78;\r
+  public int JJTSUBSCRIPT = 79;\r
+  public int JJTVOID = 80;\r
+  public int JJTANNOTATION = 81;\r
 \r
 \r
   public String[] jjtNodeName = {\r
@@ -152,6 +153,7 @@ public interface ModelParserTreeConstants
     "term",\r
     "mul_op",\r
     "factor",\r
+    "factor_op",\r
     "der_initial",\r
     "subscript_2",\r
     "array",\r
@@ -170,4 +172,4 @@ public interface ModelParserTreeConstants
     "annotation",\r
   };\r
 }\r
-/* JavaCC - OriginalChecksum=2406c3a5da0aa9cd9047b868bc6069b1 (do not edit this line) */\r
+/* JavaCC - OriginalChecksum=c86e9178ecd31c01eb2447d79ce33b0f (do not edit this line) */\r
index 990cfd104e6d918c008f53deb2db31a9c602c9ff..a6dceb85d65cdb79960463fe08f068fd53bc2f6e 100644 (file)
@@ -75,10 +75,10 @@ TOKEN:
 | "*" | "/" | ".*" | "./"\r
 | "^" | ".^"\r
 | "=" | ":=" \r
-| <IDENT: ["a"-"z","A"-"Z","_"] (["a"-"z","A"-"Z","_",".","0"-"9"])* >\r
+| <IDENT: ["a"-"z","A"-"Z","_"] (["a"-"z","A"-"Z","_",".", "0"-"9"])* >\r
 | <STRING: "\"" (~["\"", "\\", "\n"] | "\\" ~["\n"])* "\"">\r
     { matchedToken.image = matchedToken.image.substring(1,matchedToken.image.length()-1); }\r
-| <UNSIGNED_INTEGER: (["-"])? (["0"-"9"])+ >\r
+| <UNSIGNED_INTEGER: (["0"-"9"])+ >\r
 | <UNSIGNED_NUMBER:  \r
     ( <UNSIGNED_INTEGER> "." (<UNSIGNED_INTEGER>)? (["e","E"] <UNSIGNED_INTEGER>)?\r
     | "." <UNSIGNED_INTEGER> (["e","E"] <UNSIGNED_INTEGER>)?\r
@@ -191,7 +191,7 @@ void class_definition() : {/*@bgen(jjtree) class_definition */
 //  class_specifier\r
     ( "encapsulated" )?\r
     ( "partial" )?\r
-    ( "class" | "model" | "record" | "block" | ( "expandable" )? "connector" | "type" |\r
+    ( "class" { jjtn000.op = "class"; } | "model" { jjtn000.op = "model"; } | "record" | "block" | ( "expandable" )? "connector" | "type" |\r
     "package" | "function" { jjtn000.op = "function"; } | "operator" | "operator function" | "operator record" )\r
     class_specifier()/*@bgen(jjtree)*/\r
     } catch (Throwable jjte000) {\r
@@ -235,9 +235,8 @@ void class_specifier() : {/*@bgen(jjtree) class_specifier */
 //  end IDENT  \r
     LOOKAHEAD(2) t=<IDENT> { jjtn000.op = t.image; } string_comment() composition() "end" <IDENT>\r
     | LOOKAHEAD(2) <IDENT> "=" base_prefix() name() ( array_subscripts() )? ( class_modification() )? comment()\r
-    | LOOKAHEAD(3) <IDENT> "=" "enumeration" "(" ( ( enum_list() )? | ":" ) ")" comment()\r
-    |LOOKAHEAD(3)  <IDENT> "=" "der" "(" name() "," <IDENT> ( "," <IDENT> )* ")" comment()\r
-    | "extends" <IDENT> ( class_modification() )? string_comment() composition() "end" <IDENT>/*@bgen(jjtree)*/\r
+    | LOOKAHEAD(3)  <IDENT> "=" "der" "(" name() "," <IDENT> ( "," <IDENT> )* ")" comment()\r
+    | LOOKAHEAD(3) <IDENT> "=" "enumeration" "(" ( ( enum_list() )? | ":" ) ")" comment()/*@bgen(jjtree)*/\r
     } catch (Throwable jjte000) {\r
       if (jjtc000) {\r
         jjtree.clearNodeScope(jjtn000);\r
@@ -257,7 +256,8 @@ void class_specifier() : {/*@bgen(jjtree) class_specifier */
         jjtree.closeNodeScope(jjtn000, true);\r
       }\r
     }\r
-/*@egen*/ \r
+/*@egen*/\r
+    //| "extends" <IDENT> ( class_modification() )? string_comment() composition() "end" <IDENT> \r
 }\r
 \r
 void base_prefix() : {/*@bgen(jjtree) base_prefix */\r
@@ -526,11 +526,21 @@ Node element() : {/*@bgen(jjtree) element */
 //  ( ( class_definition | component_clause) |\r
 //  replaceable ( class_definition | component_clause)\r
 //  [constraining_clause comment])\r
-    import_clause() |\r
-    extends_clause() |\r
+    import_clause()/*@bgen(jjtree)*/\r
+                    {\r
+                      jjtree.closeNodeScope(jjtn000, true);\r
+                      jjtc000 = false;\r
+                    }\r
+/*@egen*/ { return jjtn000; } |\r
+    extends_clause()/*@bgen(jjtree)*/\r
+                     {\r
+                       jjtree.closeNodeScope(jjtn000, true);\r
+                       jjtc000 = false;\r
+                     }\r
+/*@egen*/ { return jjtn000; } |\r
     ( "redeclare" )?\r
     ( "final" )?\r
-    ( "inner" )? ( "outer" )?\r
+    ( "inner" { jjtn000.op = "inner"; } )? ( "outer" { jjtn000.op = "outer"; } )?\r
     ( (class_definition() | component_clause()) |\r
         "replaceable" (class_definition() | component_clause())\r
         (constraining_clause() comment())?)/*@bgen(jjtree)*/\r
@@ -2348,7 +2358,12 @@ void mul_op() : {/*@bgen(jjtree) mul_op */
                                      jjtree.closeNodeScope(jjtn000, true);\r
                                      jjtc000 = false;\r
                                    }\r
-/*@egen*/ { jjtn000.op = "/";} | ".*" | "./"/*@bgen(jjtree)*/\r
+/*@egen*/ { jjtn000.op = "/";} | ".*"/*@bgen(jjtree)*/\r
+                                                               {\r
+                                                                 jjtree.closeNodeScope(jjtn000, true);\r
+                                                                 jjtc000 = false;\r
+                                                               }\r
+/*@egen*/ { jjtn000.op = ".*";} | "./"/*@bgen(jjtree)*/\r
     } finally {\r
       if (jjtc000) {\r
         jjtree.closeNodeScope(jjtn000, true);\r
@@ -2365,7 +2380,7 @@ void factor() : {/*@bgen(jjtree) factor */
 } {/*@bgen(jjtree) factor */\r
         try {\r
 /*@egen*/\r
-       primary() ( "^" | ".^" primary() )?/*@bgen(jjtree)*/\r
+       primary() ( factor_op() primary() )?/*@bgen(jjtree)*/\r
         } catch (Throwable jjte000) {\r
           if (jjtc000) {\r
             jjtree.clearNodeScope(jjtn000);\r
@@ -2388,6 +2403,33 @@ void factor() : {/*@bgen(jjtree) factor */
 /*@egen*/\r
 }\r
 \r
+void factor_op() : {/*@bgen(jjtree) factor_op */\r
+  SimpleNode jjtn000 = new SimpleNode(JJTFACTOR_OP);\r
+  boolean jjtc000 = true;\r
+  jjtree.openNodeScope(jjtn000);\r
+/*@egen*/\r
+} {/*@bgen(jjtree) factor_op */\r
+    try {\r
+/*@egen*/\r
+    "^"/*@bgen(jjtree)*/\r
+        {\r
+          jjtree.closeNodeScope(jjtn000, true);\r
+          jjtc000 = false;\r
+        }\r
+/*@egen*/ { jjtn000.op = "^";} | ".^"/*@bgen(jjtree)*/\r
+                                    {\r
+                                      jjtree.closeNodeScope(jjtn000, true);\r
+                                      jjtc000 = false;\r
+                                    }\r
+/*@egen*/ { jjtn000.op = ".^";}/*@bgen(jjtree)*/\r
+    } finally {\r
+      if (jjtc000) {\r
+        jjtree.closeNodeScope(jjtn000, true);\r
+      }\r
+    }\r
+/*@egen*/\r
+}\r
+\r
 void der_initial() : {/*@bgen(jjtree) der_initial */\r
   SimpleNode jjtn000 = new SimpleNode(JJTDER_INITIAL);\r
   boolean jjtc000 = true;\r
@@ -2650,7 +2692,7 @@ void function_arguments() : {/*@bgen(jjtree) function_arguments */
 /*@egen*/\r
        //expression [ "," function_arguments | for for_indices ]\r
        //| named_arguments\r
-        LOOKAHEAD(2) expression() ( "," function_arguments() | "for" for_indices() )?\r
+        LOOKAHEAD(2) expression() ( "," function_arguments() | "for" for_indices() { jjtn000.op = "for"; } )?\r
        | named_arguments()/*@bgen(jjtree)*/\r
          } catch (Throwable jjte000) {\r
            if (jjtc000) {\r
index 793e0cfd48b297c90972d0c14f6775ff7b27f191..422e38fdb919627fb17737d09d5b9b1fc05eb3a9 100644 (file)
@@ -71,10 +71,10 @@ TOKEN:
 | "*" | "/" | ".*" | "./"\r
 | "^" | ".^"\r
 | "=" | ":=" \r
-| <IDENT: ["a"-"z","A"-"Z","_"] (["a"-"z","A"-"Z","_",".","0"-"9"])* >\r
+| <IDENT: ["a"-"z","A"-"Z","_"] (["a"-"z","A"-"Z","_",".", "0"-"9"])* >\r
 | <STRING: "\"" (~["\"", "\\", "\n"] | "\\" ~["\n"])* "\"">\r
     { matchedToken.image = matchedToken.image.substring(1,matchedToken.image.length()-1); }\r
-| <UNSIGNED_INTEGER: (["-"])? (["0"-"9"])+ >\r
+| <UNSIGNED_INTEGER: (["0"-"9"])+ >\r
 | <UNSIGNED_NUMBER:  \r
     ( <UNSIGNED_INTEGER> "." (<UNSIGNED_INTEGER>)? (["e","E"] <UNSIGNED_INTEGER>)?\r
     | "." <UNSIGNED_INTEGER> (["e","E"] <UNSIGNED_INTEGER>)?\r
@@ -119,7 +119,7 @@ void class_definition() : {
 //  class_specifier\r
     ( "encapsulated" )?\r
     ( "partial" )?\r
-    ( "class" | "model" | "record" | "block" | ( "expandable" )? "connector" | "type" |\r
+    ( "class" { jjtThis.op = "class"; } | "model" { jjtThis.op = "model"; } | "record" | "block" | ( "expandable" )? "connector" | "type" |\r
     "package" | "function" { jjtThis.op = "function"; } | "operator" | "operator function" | "operator record" )\r
     class_specifier()\r
 }\r
@@ -137,9 +137,9 @@ void class_specifier() : { Token t;
 //  end IDENT  \r
     LOOKAHEAD(2) t=<IDENT> { jjtThis.op = t.image; } string_comment() composition() "end" <IDENT>\r
     | LOOKAHEAD(2) <IDENT> "=" base_prefix() name() ( array_subscripts() )? ( class_modification() )? comment()\r
+    | LOOKAHEAD(3)  <IDENT> "=" "der" "(" name() "," <IDENT> ( "," <IDENT> )* ")" comment()\r
     | LOOKAHEAD(3) <IDENT> "=" "enumeration" "(" ( ( enum_list() )? | ":" ) ")" comment()\r
-    |LOOKAHEAD(3)  <IDENT> "=" "der" "(" name() "," <IDENT> ( "," <IDENT> )* ")" comment()\r
-    | "extends" <IDENT> ( class_modification() )? string_comment() composition() "end" <IDENT> \r
+    //| "extends" <IDENT> ( class_modification() )? string_comment() composition() "end" <IDENT> \r
 }\r
 \r
 void base_prefix() : {\r
@@ -208,11 +208,11 @@ Node element() : {
 //  ( ( class_definition | component_clause) |\r
 //  replaceable ( class_definition | component_clause)\r
 //  [constraining_clause comment])\r
-    import_clause() |\r
-    extends_clause() |\r
+    import_clause() { return jjtThis; } |\r
+    extends_clause() { return jjtThis; } |\r
     ( "redeclare" )?\r
     ( "final" )?\r
-    ( "inner" )? ( "outer" )?\r
+    ( "inner" { jjtThis.op = "inner"; } )? ( "outer" { jjtThis.op = "outer"; } )?\r
     ( (class_definition() | component_clause()) |\r
         "replaceable" (class_definition() | component_clause())\r
         (constraining_clause() comment())?)\r
@@ -651,12 +651,17 @@ void term() : {
 \r
 void mul_op() : {\r
 } {\r
-    "*" { jjtThis.op = "*";} | "/" { jjtThis.op = "/";} | ".*" | "./"\r
+    "*" { jjtThis.op = "*";} | "/" { jjtThis.op = "/";} | ".*" { jjtThis.op = ".*";} | "./"\r
 }\r
 \r
 void factor() : {\r
 } {\r
-       primary() ( "^" | ".^" primary() )?\r
+       primary() ( factor_op() primary() )?\r
+}\r
+\r
+void factor_op() : {\r
+} {\r
+    "^" { jjtThis.op = "^";} | ".^" { jjtThis.op = ".^";}\r
 }\r
 \r
 void der_initial() : { \r
@@ -717,7 +722,7 @@ void function_arguments() : {
 } {\r
        //expression [ "," function_arguments | for for_indices ]\r
        //| named_arguments\r
-        LOOKAHEAD(2) expression() ( "," function_arguments() | "for" for_indices() )?\r
+        LOOKAHEAD(2) expression() ( "," function_arguments() | "for" for_indices() { jjtThis.op = "for"; } )?\r
        | named_arguments()\r
 }\r
 \r
index da8f6ba4ac5cd28963ff2e9f8ba3280f337fc5cb..7908c7f93cf55d6e6a58048c9b78d65c436de913 100644 (file)
@@ -174,7 +174,7 @@ public class ModelicaManager {
         * \r
         * @return Open Modelica home directory\r
         */\r
-       private static File getOMHome() {\r
+       public static File getOMHome() {\r
                Preferences node = ConfigurationScope.INSTANCE.getNode(Activator.PLUGIN_ID);\r
                String omHomePath = node.get(OpenModelicaPreferences.OM_HOME, null);\r
                if (omHomePath != null) {\r
@@ -298,7 +298,7 @@ public class ModelicaManager {
                thread.run();\r
        }\r
 \r
-       public static SimulationLocation createSimulationLocation(File modelDir, String modelName, String modelContent) {               \r
+       public static SimulationLocation createSimulationLocation(File modelDir, String modelName, String modelContent, File omHome, boolean isOldOMVersion) {          \r
                if (!modelDir.isDirectory()) {\r
                        return null;\r
                }\r
@@ -323,7 +323,7 @@ public class ModelicaManager {
                }\r
                \r
                // full model files are (apparently) only needed for old parameter comparison routines\r
-               if (isOldOMVersion()) {\r
+               if (isOldOMVersion) {\r
                        location.fullModelDir = new File(location.getModelDir(), "fullModel");\r
                        if (!location.fullModelDir.isDirectory()) {\r
                                location.fullModelDir.mkdir();\r
@@ -332,7 +332,7 @@ public class ModelicaManager {
                        location.fullModelScriptFile = new File(location.fullModelDir, location.getModelName() + "_full.mos");\r
                }\r
                \r
-               location.omHome = getOMHome();\r
+               location.omHome = omHome;\r
                \r
                return location;\r
        }\r
index 315b1fc847a800ad6f4b3e98236356fe46893bf8..092ea62ab110939067f15424071ff272dbcb4bc9 100644 (file)
@@ -410,10 +410,10 @@ public class SimulationResult {
      */\r
     public DataSet getDataSet(String name) {\r
         for(DataSet set : variables)\r
-            if(set.name.equalsIgnoreCase(name))\r
+            if(set.name.equals(name)) // Why on earth had these been changed to equalsIgnoreCase???\r
                 return set;\r
         for(DataSet set : initials)\r
-            if(set.name.equalsIgnoreCase(name))\r
+            if(set.name.equals(name)) // Why on earth had these been changed to equalsIgnoreCase???\r
                 return set;\r
         return null;\r
     }\r
index cacb3605fa6ffc647516385fbe5b964dfd212cde..39b0dd707b0cfd397383cfbe5f841161b6d7714d 100644 (file)
Binary files a/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Bathtub.sysdyn and b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Bathtub.sysdyn differ
diff --git a/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Ceiling.sysdyn b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Ceiling.sysdyn
new file mode 100644 (file)
index 0000000..4a25312
Binary files /dev/null and b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Ceiling.sysdyn differ
index 334ca7e31143b4e31d8af6c4c7fe11297336afad..0244333a2c16b3aa928cffea6ffad2ab205f5864 100644 (file)
Binary files a/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Decay.sysdyn and b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Decay.sysdyn differ
diff --git a/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Extrapolation.sysdyn b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Extrapolation.sysdyn
new file mode 100644 (file)
index 0000000..beb195c
Binary files /dev/null and b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Extrapolation.sysdyn differ
diff --git a/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Extrapolation.sysdynModule b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Extrapolation.sysdynModule
new file mode 100644 (file)
index 0000000..37e1772
Binary files /dev/null and b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Extrapolation.sysdynModule differ
diff --git a/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Floor.sysdyn b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Floor.sysdyn
new file mode 100644 (file)
index 0000000..5e0ebb3
Binary files /dev/null and b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Floor.sysdyn differ
diff --git a/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/MoleculeFunctions.sysdynFunctions b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/MoleculeFunctions.sysdynFunctions
new file mode 100644 (file)
index 0000000..9cff2bc
Binary files /dev/null and b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/MoleculeFunctions.sysdynFunctions differ
diff --git a/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Multivariate Anchoring And Adjustment.sysdyn b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Multivariate Anchoring And Adjustment.sysdyn
new file mode 100644 (file)
index 0000000..3f021b0
Binary files /dev/null and b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Multivariate Anchoring And Adjustment.sysdyn differ
diff --git a/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Protected Sea Ancoring And Adjustment.sysdyn b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Protected Sea Ancoring And Adjustment.sysdyn
new file mode 100644 (file)
index 0000000..709a93a
Binary files /dev/null and b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Protected Sea Ancoring And Adjustment.sysdyn differ
diff --git a/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Sea Anchoring And Adjustment.sysdyn b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Sea Anchoring And Adjustment.sysdyn
new file mode 100644 (file)
index 0000000..0ea9942
Binary files /dev/null and b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Sea Anchoring And Adjustment.sysdyn differ
index 2abde7d687f5f80d26f17192ba24e1e8eef32ff3..14ff7532e7d299a85aae151120211dfcca47a0ee 100644 (file)
Binary files a/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Smooth.sysdyn and b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Smooth.sysdyn differ
index c4cfc408887ebc8ee6eba6881658cad483d59e80..450f52c2c9f0e68666485169001f649f1566c859 100644 (file)
Binary files a/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Smooth.sysdynModule and b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Smooth.sysdynModule differ
index caa66cee51485c704333e042b3773925d28055fe..bacab113566e303d78e414ba90b7ce9e590c5331 100644 (file)
Binary files a/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/SmoothThirdOrder.sysdyn and b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/SmoothThirdOrder.sysdyn differ
index 1186b743638bcfe9d7cf5525e1dc84abe11ee7cd..30c80f394d0aeae1ef62c1ec3928bbaa306fc46b 100644 (file)
Binary files a/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/SmoothThirdOrder.sysdynModule and b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/SmoothThirdOrder.sysdynModule differ
index 5a96a7e6b2c57dcdd8a83f737cb6d4b1c1f4488a..7c98f0413da0faa37ff4c72faaba04041b903425 100644 (file)
Binary files a/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Tester For Molecules.sysdyn and b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Tester For Molecules.sysdyn differ
diff --git a/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Trend.sysdyn b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Trend.sysdyn
new file mode 100644 (file)
index 0000000..79a1c5d
Binary files /dev/null and b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Trend.sysdyn differ
diff --git a/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Trend.sysdynModule b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Trend.sysdynModule
new file mode 100644 (file)
index 0000000..0a195ce
Binary files /dev/null and b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Trend.sysdynModule differ
diff --git a/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Univariate Anchoring And Adjustment.sysdyn b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Univariate Anchoring And Adjustment.sysdyn
new file mode 100644 (file)
index 0000000..70d58f1
Binary files /dev/null and b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/Univariate Anchoring And Adjustment.sysdyn differ
diff --git a/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/WeighedAverage.sysdyn b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/WeighedAverage.sysdyn
new file mode 100644 (file)
index 0000000..c69c7c0
Binary files /dev/null and b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/molecules/WeighedAverage.sysdyn differ
index bcbd16c29db79db92bb4931bf8f5f9f985515782..e90a36a480d59f7949bd1a9241728ff3e7542217 100644 (file)
Binary files a/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/sampleModels/Discovery And Exploitation Of Resources.sysdyn and b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/sampleModels/Discovery And Exploitation Of Resources.sysdyn differ
index 60edfdfa6b34efe0ec79d99065f8efd73cafbbf8..9afc06aeec806bbad8159bcf6b70a7bf92cc6d1a 100644 (file)
Binary files a/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/sampleModels/Global Carbon Cycle.sysdyn and b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/sampleModels/Global Carbon Cycle.sysdyn differ
index 2a8f549df8ed295af817bc820272292ccb38be5b..7d2d2fe2e7ebd5cfc68c50f5dc703b544e988dce 100644 (file)
Binary files a/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/sampleModels/Predator And Limited Prey.sysdyn and b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/sampleModels/Predator And Limited Prey.sysdyn differ
index 132c2fc7044d528b9d8b0b854381255be23b0544..33a8815c170b364b2ee0c42414a208b2e3f12a76 100644 (file)
Binary files a/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/sampleModels/Resource Exploitation Use Recycling.sysdyn and b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/sampleModels/Resource Exploitation Use Recycling.sysdyn differ
index d82832a45ed6d7e8445ba8c4c5aa7c1ef7eb7507..7af5e56704ca7fd21be45af9b8a565c716198412 100644 (file)
Binary files a/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/sampleModels/Tourists Environments And Hotel Facilities.sysdyn and b/dev-jkauttio/org.simantics.sysdyn.feature/rootfiles/sampleModels/Tourists Environments And Hotel Facilities.sysdyn differ
index 8f3e514e9f973f9c460afcf9f99032183af58a8b..37bbc783792c29bddb184129cd537704d14ed2a2 100644 (file)
Binary files a/dev-jkauttio/org.simantics.sysdyn.ontology/graph.tg and b/dev-jkauttio/org.simantics.sysdyn.ontology/graph.tg differ
index 4fc523d69f5eba066de40a5da247e3649e6e050d..1ad68f5d00c9ca77e2d59e2e7465d826e70adda1 100644 (file)
@@ -91,6 +91,7 @@ SYSDYN.HistoryRealization <T L0X.Realization
 SYSDYN.DefaultRealization <T L0X.Realization
 
 SYSDYN.ModulesSearchFunction : L0.Function
+  L0.HasLabel "Sysdyn Search" : L0.String
 
 SYSDYN.SearchContribution : WORKBENCH.SearchContribution
   WORKBENCH.hasSearchFunction SYSDYN.ModulesSearchFunction
@@ -262,6 +263,8 @@ SYSDYN.DelayExpression <T SYSDYN.Expression
     >-- SYSDYN.DelayExpression.order --> L0.Integer <R SYSDYN.Expression.equation : L0.FunctionalRelation
     >-- SYSDYN.DelayExpression.delayTime --> L0.String <R SYSDYN.Expression.equation : L0.FunctionalRelation
     >-- SYSDYN.DelayExpression.initialValue --> L0.String <R SYSDYN.HasEquationOrEmpty : L0.FunctionalRelation
+    >-- SYSDYN.DelayExpression.isInformationDelay --> SYSDYN.DelayExpression <R L0.IsRelatedTo : L0.Tag
+        @L0.symmetric
         
 SYSDYN.StockExpression <T SYSDYN.Expression
     >-- SYSDYN.StockExpression.useCustomIntegral --> SYSDYN.StockExpression <R L0.IsRelatedTo : L0.Tag
@@ -595,7 +598,7 @@ SYSDYN.DependencyConnection <T DIA.Connection <T DIA.FontProvider <T DIA.ColorPr
     >-- SYSDYN.DependencyConnection.strokeWidth --> L0.Float <R L0.HasProperty : L0.FunctionalRelation
     @L0.assert SYSDYN.DependencyConnection.strokeWidth 
         0.3 : L0.Float
-    @L0.assert SYSDYN.Dependency.angle 0.1
+    @L0.assert SYSDYN.Dependency.angle 0.3
     MOD.DiagramConnectionTypeToConnectionType
         SYSDYN.Dependency
     @L0.assert G2D.HasFont SYSDYN.DefaultFont
index 111bd73bc330f077c411ba749fc936de3b728ab5..6fdcc8966825d28e741b22ed1d9490333c1f0478 100644 (file)
@@ -195,4 +195,27 @@ algorithm
         else\r
             y := y1 + (y2 - y1)*(u - u1)/(u2 - u1);\r
         end if;\r
-    end if;"""
\ No newline at end of file
+    end if;"""\r
+    \r
+    \r
+    \r
+FL.unitCast : SYSDYN.SysdynModelicaFunction\r
+    L0.HasDescription """unitCast(u)\r
+\r
+Casts the expression to ANY unit."""\r
+    SYSDYN.SysdynModelicaFunction.inputs _ : L0.List\r
+        @L0.list\r
+            FL.unitCast.u : SYSDYN.SysdynModelicaFunction.Input\r
+                SYSDYN.Variable.type "Real"\r
+                SYSDYN.SysdynModelicaFunction.optional false\r
+                SYSDYN.SysdynModelicaFunction.unit "ANY"\r
+                SYSDYN.SysdynModelicaFunction.definition "the expression to be casted"\r
+    SYSDYN.SysdynModelicaFunction.outputs _ : L0.List\r
+        @L0.list\r
+            FL.unitCast.y : SYSDYN.SysdynModelicaFunction.Output\r
+                SYSDYN.Variable.type "Real"\r
+                SYSDYN.SysdynModelicaFunction.unit "ANY"\r
+    SYSDYN.SysdynModelicaFunction.modelicaFunctionCode """    input Real u "the expression to be casted";\r
+    output Real y "the expression with unit ANY";\r
+algorithm\r
+    y := u;"""\r
index 87c506f6b52034ffd1b6e5b69e0de8cd93e3a732..fdee797a5090bf5d70bbcd99354c12ad0a62b1f7 100644 (file)
@@ -511,4 +511,27 @@ In modelica log(x) is the natural logarighm and log10(x) is base 10 logarighm.""
     output Real z;\r
 algorithm\r
     z := log(x);"""  \r
-         
\ No newline at end of file
+         \r
+         \r
+         \r
+VF.GAME : SYSDYN.SysdynModelicaFunction\r
+    L0.HasDescription """GAME(x)\r
+\r
+Returns x during normal simulation with x being any expression.\r
+\r
+In Vensim, this function allows modifying the variable in game mode. However, this behavior is not implemented yet."""\r
+    SYSDYN.SysdynModelicaFunction.inputs _ : L0.List\r
+        @L0.list\r
+            VF.GAME.x : SYSDYN.SysdynModelicaFunction.Input\r
+                SYSDYN.Variable.type "Real"\r
+                SYSDYN.SysdynModelicaFunction.optional false\r
+                SYSDYN.SysdynModelicaFunction.unit "'p"\r
+    SYSDYN.SysdynModelicaFunction.outputs _ : L0.List\r
+        @L0.list\r
+            VF.GAME.z : SYSDYN.SysdynModelicaFunction.Output\r
+                SYSDYN.Variable.type "Real"\r
+                SYSDYN.SysdynModelicaFunction.unit "'p"\r
+    SYSDYN.SysdynModelicaFunction.modelicaFunctionCode """    input Real x;\r
+    output Real z;\r
+algorithm\r
+    z := x;""" 
\ No newline at end of file
index ef34edf7416250f2f2ef0860bbe077dfe08aa3e8..2f37ffee9082f961150e3d165e4022ec56999aca 100644 (file)
@@ -228,6 +228,9 @@ public class SysdynResource {
     public final Resource Built$in_Functions_Vensim_Functions_EXP;\r
     public final Resource Built$in_Functions_Vensim_Functions_EXP_x;\r
     public final Resource Built$in_Functions_Vensim_Functions_EXP_z;\r
+    public final Resource Built$in_Functions_Vensim_Functions_GAME;\r
+    public final Resource Built$in_Functions_Vensim_Functions_GAME_x;\r
+    public final Resource Built$in_Functions_Vensim_Functions_GAME_z;\r
     public final Resource Built$in_Functions_Vensim_Functions_IFTHENELSE;\r
     public final Resource Built$in_Functions_Vensim_Functions_IFTHENELSE_cond;\r
     public final Resource Built$in_Functions_Vensim_Functions_IFTHENELSE_onfalse;\r
@@ -299,6 +302,9 @@ public class SysdynResource {
     public final Resource Built$in_Functions_minmax_maximum;\r
     public final Resource Built$in_Functions_minmax_minimum;\r
     public final Resource Built$in_Functions_minmax_result;\r
+    public final Resource Built$in_Functions_unitCast;\r
+    public final Resource Built$in_Functions_unitCast_u;\r
+    public final Resource Built$in_Functions_unitCast_y;\r
     public final Resource Built$in_Functions_xidz;\r
     public final Resource Built$in_Functions_xidz_divident;\r
     public final Resource Built$in_Functions_xidz_divisor;\r
@@ -340,6 +346,7 @@ public class SysdynResource {
     public final Resource DelayExpression_expression_Inverse;\r
     public final Resource DelayExpression_initialValue;\r
     public final Resource DelayExpression_initialValue_Inverse;\r
+    public final Resource DelayExpression_isInformationDelay;\r
     public final Resource DelayExpression_order;\r
     public final Resource DelayExpression_order_Inverse;\r
     public final Resource Dependency;\r
@@ -996,6 +1003,9 @@ public class SysdynResource {
         public static final String Built$in_Functions_Vensim_Functions_EXP = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/Vensim%20Functions/EXP";\r
         public static final String Built$in_Functions_Vensim_Functions_EXP_x = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/Vensim%20Functions/EXP/x";\r
         public static final String Built$in_Functions_Vensim_Functions_EXP_z = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/Vensim%20Functions/EXP/z";\r
+        public static final String Built$in_Functions_Vensim_Functions_GAME = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/Vensim%20Functions/GAME";\r
+        public static final String Built$in_Functions_Vensim_Functions_GAME_x = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/Vensim%20Functions/GAME/x";\r
+        public static final String Built$in_Functions_Vensim_Functions_GAME_z = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/Vensim%20Functions/GAME/z";\r
         public static final String Built$in_Functions_Vensim_Functions_IFTHENELSE = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/Vensim%20Functions/IFTHENELSE";\r
         public static final String Built$in_Functions_Vensim_Functions_IFTHENELSE_cond = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/Vensim%20Functions/IFTHENELSE/cond";\r
         public static final String Built$in_Functions_Vensim_Functions_IFTHENELSE_onfalse = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/Vensim%20Functions/IFTHENELSE/onfalse";\r
@@ -1067,6 +1077,9 @@ public class SysdynResource {
         public static final String Built$in_Functions_minmax_maximum = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/minmax/maximum";\r
         public static final String Built$in_Functions_minmax_minimum = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/minmax/minimum";\r
         public static final String Built$in_Functions_minmax_result = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/minmax/result";\r
+        public static final String Built$in_Functions_unitCast = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/unitCast";\r
+        public static final String Built$in_Functions_unitCast_u = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/unitCast/u";\r
+        public static final String Built$in_Functions_unitCast_y = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/unitCast/y";\r
         public static final String Built$in_Functions_xidz = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/xidz";\r
         public static final String Built$in_Functions_xidz_divident = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/xidz/divident";\r
         public static final String Built$in_Functions_xidz_divisor = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/xidz/divisor";\r
@@ -1108,6 +1121,7 @@ public class SysdynResource {
         public static final String DelayExpression_expression_Inverse = "http://www.simantics.org/Sysdyn-1.1/DelayExpression/expression/Inverse";\r
         public static final String DelayExpression_initialValue = "http://www.simantics.org/Sysdyn-1.1/DelayExpression/initialValue";\r
         public static final String DelayExpression_initialValue_Inverse = "http://www.simantics.org/Sysdyn-1.1/DelayExpression/initialValue/Inverse";\r
+        public static final String DelayExpression_isInformationDelay = "http://www.simantics.org/Sysdyn-1.1/DelayExpression/isInformationDelay";\r
         public static final String DelayExpression_order = "http://www.simantics.org/Sysdyn-1.1/DelayExpression/order";\r
         public static final String DelayExpression_order_Inverse = "http://www.simantics.org/Sysdyn-1.1/DelayExpression/order/Inverse";\r
         public static final String Dependency = "http://www.simantics.org/Sysdyn-1.1/Dependency";\r
@@ -1774,6 +1788,9 @@ public class SysdynResource {
         Built$in_Functions_Vensim_Functions_EXP = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_EXP);\r
         Built$in_Functions_Vensim_Functions_EXP_x = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_EXP_x);\r
         Built$in_Functions_Vensim_Functions_EXP_z = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_EXP_z);\r
+        Built$in_Functions_Vensim_Functions_GAME = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_GAME);\r
+        Built$in_Functions_Vensim_Functions_GAME_x = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_GAME_x);\r
+        Built$in_Functions_Vensim_Functions_GAME_z = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_GAME_z);\r
         Built$in_Functions_Vensim_Functions_IFTHENELSE = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_IFTHENELSE);\r
         Built$in_Functions_Vensim_Functions_IFTHENELSE_cond = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_IFTHENELSE_cond);\r
         Built$in_Functions_Vensim_Functions_IFTHENELSE_onfalse = getResourceOrNull(graph, URIs.Built$in_Functions_Vensim_Functions_IFTHENELSE_onfalse);\r
@@ -1845,6 +1862,9 @@ public class SysdynResource {
         Built$in_Functions_minmax_maximum = getResourceOrNull(graph, URIs.Built$in_Functions_minmax_maximum);\r
         Built$in_Functions_minmax_minimum = getResourceOrNull(graph, URIs.Built$in_Functions_minmax_minimum);\r
         Built$in_Functions_minmax_result = getResourceOrNull(graph, URIs.Built$in_Functions_minmax_result);\r
+        Built$in_Functions_unitCast = getResourceOrNull(graph, URIs.Built$in_Functions_unitCast);\r
+        Built$in_Functions_unitCast_u = getResourceOrNull(graph, URIs.Built$in_Functions_unitCast_u);\r
+        Built$in_Functions_unitCast_y = getResourceOrNull(graph, URIs.Built$in_Functions_unitCast_y);\r
         Built$in_Functions_xidz = getResourceOrNull(graph, URIs.Built$in_Functions_xidz);\r
         Built$in_Functions_xidz_divident = getResourceOrNull(graph, URIs.Built$in_Functions_xidz_divident);\r
         Built$in_Functions_xidz_divisor = getResourceOrNull(graph, URIs.Built$in_Functions_xidz_divisor);\r
@@ -1886,6 +1906,7 @@ public class SysdynResource {
         DelayExpression_expression_Inverse = getResourceOrNull(graph, URIs.DelayExpression_expression_Inverse);\r
         DelayExpression_initialValue = getResourceOrNull(graph, URIs.DelayExpression_initialValue);\r
         DelayExpression_initialValue_Inverse = getResourceOrNull(graph, URIs.DelayExpression_initialValue_Inverse);\r
+        DelayExpression_isInformationDelay = getResourceOrNull(graph, URIs.DelayExpression_isInformationDelay);\r
         DelayExpression_order = getResourceOrNull(graph, URIs.DelayExpression_order);\r
         DelayExpression_order_Inverse = getResourceOrNull(graph, URIs.DelayExpression_order_Inverse);\r
         Dependency = getResourceOrNull(graph, URIs.Dependency);\r
diff --git a/dev-jkauttio/org.simantics.sysdyn.ui/icons/equalizer.png b/dev-jkauttio/org.simantics.sysdyn.ui/icons/equalizer.png
new file mode 100644 (file)
index 0000000..e496cf4
Binary files /dev/null and b/dev-jkauttio/org.simantics.sysdyn.ui/icons/equalizer.png differ
index dd1e065609b46fd1aeec16bc7865922ff71e072b..a6b3f78a614efb5d06fd4b61add692ba14a64cf1 100644 (file)
@@ -1,8 +1,8 @@
 about.text = Simantics System Dynamics\n\\r
 \n\\r
-Version 1.7.0\n\\r
+Version 1.8.0\n\\r
 \n\\r
-Copyright (c) 2013 Association for Decentralized Information Management in Industry THTH ry.\n\\r
+Copyright (c) 2014 Association for Decentralized Information Management in Industry THTH ry.\n\\r
 \n\\r
 Contributors:\n\\r
 VTT Technical Research Centre of Finland\n\\r
index c688debdbfce7e700f88d11b4d5b6bea51069209..2a977039ba2a16453e9b14a054bcffc2c7766f4c 100644 (file)
             targetID="org.simantics.sysdyn.ui.perspective">\r
          <view\r
                id="org.simantics.browsing.ui.graph.propertyView"\r
-               ratio="0.6f"\r
+               ratio="0.65f"\r
                relationship="bottom"\r
                relative="org.eclipse.ui.editorss">\r
          </view>\r
                id="org.simantics.workbench.search.browser"\r
                minimized="false"\r
                relationship="stack"\r
-               relative="org.simantics.browsing.ui.graph.propertyView">\r
+               relative="org.simantics.sysdyn.ui.browser">\r
          </view>\r
          <!--\r
          <view\r
                id="org.simantics.workbench.search.browser"\r
                minimized="false"\r
                relationship="stack"\r
-               relative="org.simantics.browsing.ui.graph.propertyView">\r
+               relative="org.simantics.sysdyn.ui.browser">\r
          </view>\r
       </perspectiveExtension>\r
       <perspectiveExtension\r
                id="org.simantics.workbench.search.browser"\r
                minimized="false"\r
                relationship="stack"\r
-               relative="org.simantics.browsing.ui.graph.propertyView">\r
+               relative="org.simantics.sysdyn.ui.browser">\r
          </view>\r
       </perspectiveExtension>\r
    </extension>\r
                   </with>\r
                </visibleWhen>\r
             </command>\r
+            <command\r
+                  commandId="org.simantics.sysdyn.ui.synthesisSimulation"\r
+                  hoverIcon="icons/equalizer.png"\r
+                  icon="icons/equalizer.png"\r
+                  label="Sliders and Trends"\r
+                  style="toggle"\r
+                  tooltip="Sliders and Trends">\r
+               <visibleWhen>\r
+                  <with\r
+                        variable="activeContexts">\r
+                     <iterate\r
+                           ifEmpty="false"\r
+                           operator="or">\r
+                        <equals\r
+                              value="org.simantics.sysdyn.ui.basicExperiment">\r
+                        </equals>\r
+                     </iterate>\r
+                     <and>\r
+                        <not>\r
+                           <count\r
+                                 value="0">\r
+                           </count>\r
+                        </not>\r
+                     </and>\r
+                  </with>\r
+               </visibleWhen>\r
+            </command>\r
          </toolbar>\r
          <toolbar\r
                id="org.simantics.sysdyn.ui.playbackControlToolbar">\r
                   </with>\r
                </visibleWhen>\r
             </command>\r
+            <command\r
+                  commandId="org.simantics.sysdyn.ui.newModel"\r
+                  icon="platform:/plugin/com.famfamfam.silk/icons/chart_organisation.png"\r
+                  id="org.simantics.sysdyn.ui.browser.newModel"\r
+                  label="Model"\r
+                  style="push">\r
+               <visibleWhen\r
+                     checkEnabled="true">\r
+               </visibleWhen>\r
+            </command>\r
             <!--\r
             <command\r
                   commandId="org.simantics.documentation.workbench.newDocumentation"\r
                label="Find"\r
                style="push">\r
          </command>\r
+         <command\r
+               commandId="org.simantics.sysdyn.ui.activateExperiment"\r
+               icon="platform:/plugin/com.famfamfam.silk/icons/control_play_blue.png"\r
+               id="org.simantics.sysdyn.ui.browser.activateExperiment"\r
+               label="Activate Experiment"\r
+               style="push">\r
+            <visibleWhen\r
+                  checkEnabled="true">\r
+               <with\r
+                     variable="selection">\r
+                  <test\r
+                        args="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode"\r
+                        property="org.simantics.sysdyn.ui.nodeClass">\r
+                  </test>\r
+               </with>\r
+            </visibleWhen>\r
+         </command>\r
       </menuContribution>\r
       <menuContribution\r
             locationURI="popup:#SysdynDiagramPopup?after=wbStart">\r
                id="org.simantics.sysdyn.ui.toggleSimulation.state">\r
          </state>\r
       </command>\r
+      <command\r
+            defaultHandler="org.simantics.sysdyn.ui.handlers.SynthesisSimulation"\r
+            id="org.simantics.sysdyn.ui.synthesisSimulation"\r
+            name="Slider and Trends">\r
+         <state\r
+               class="org.eclipse.jface.commands.ToggleState"\r
+               id="org.simantics.sysdyn.ui.synthesisSimulation.state">\r
+         </state>\r
+      </command>\r
       <command\r
             defaultHandler="org.simantics.sysdyn.ui.handlers.newComponents.NewModuleNodeHandler"\r
             id="org.simantics.sysdyn.ui.newModuleNode"\r
             class="org.simantics.sysdyn.ui.handlers.DiagramToolHandler"\r
             commandId="org.simantics.sysdyn.ui.diagramTool">\r
       </handler>\r
+      <handler\r
+            class="org.simantics.sysdyn.ui.handlers.SysdynExperimentActivator"\r
+            commandId="org.simantics.sysdyn.ui.activateExperiment">\r
+         <activeWhen>\r
+            <with\r
+                  variable="selection">\r
+               <or>\r
+                  <test\r
+                        args="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode"\r
+                        property="org.simantics.sysdyn.ui.nodeClass">\r
+                  </test>\r
+               </or>\r
+            </with>\r
+         </activeWhen>\r
+      </handler>\r
    </extension>\r
    <extension\r
          point="org.eclipse.ui.importWizards">\r
index 34f8fd71761f030702b4ccb76abc0ba4a64457c0..2cab67ead25c790d2452bb793227e738913237f9 100644 (file)
@@ -31,7 +31,7 @@ public class DependencyRouter implements IRouter2 {
         createArrowShape(shapes,\r
                        begin.parentObstacle,\r
                        end.parentObstacle,\r
-                       0.1,\r
+                       0.3,\r
                        null);\r
         \r
         Path2D path = new Path2D.Double();\r
index 3f757a08a7608122d17df99c1d51bb89e504338f..6316eec853e9d92adb0c47bb07a802d04efdcba3 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
- * Copyright (c) 2010, 2012 Association for Decentralized Information Management in\r
+ * Copyright (c) 2010, 2012, 2014 Association for Decentralized Information Management in\r
  * Industry THTH ry.\r
  * All rights reserved. This program and the accompanying materials\r
  * are made available under the terms of the Eclipse Public License v1.0\r
@@ -13,7 +13,10 @@ package org.simantics.sysdyn.ui.elements.connections;
 \r
 import java.awt.Color;\r
 import java.awt.Font;\r
+import java.io.StringReader;\r
 import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Set;\r
 import java.util.concurrent.ConcurrentSkipListMap;\r
 import java.util.concurrent.atomic.AtomicInteger;\r
 \r
@@ -26,6 +29,7 @@ import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.Statement;\r
+import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.procedure.AsyncMultiProcedure;\r
 import org.simantics.db.procedure.AsyncProcedure;\r
@@ -42,6 +46,9 @@ import org.simantics.g2d.element.ElementHints;
 import org.simantics.g2d.element.IElement;\r
 import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;\r
 import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.expressionParser.ExpressionParser;\r
 import org.simantics.sysdyn.ui.editor.routing.DependencyRouter;\r
 import org.simantics.sysdyn.ui.preferences.SysdynDiagramPreferences;\r
 import org.simantics.sysdyn.ui.preferences.SysdynDiagramPropertyExternalRead;\r
@@ -52,6 +59,7 @@ import org.simantics.utils.datastructures.Pair;
  * consists of connection edge segments and branch points as its children.\r
  * \r
  * @author Tuukka Lehtonen\r
+ * @author Tuomas Miettinen\r
  */\r
 public class DependencyConnectionFactory extends ElementFactoryAdapter {\r
 \r
@@ -123,8 +131,13 @@ public class DependencyConnectionFactory extends ElementFactoryAdapter {
                 if(result != null && !result.isAsserted(elementResource)) {\r
                     element.setHint(ElementHints.KEY_TEXT_COLOR, G2DUtils.getColor(graph, result.getObject()));\r
                 } else {\r
-                    String color = graph.syncRequest(new SysdynDiagramPropertyExternalRead(new Pair<Resource, String>(elementResource, SysdynDiagramPreferences.ARROW_COLOR)));\r
-                    if(color != null) {\r
+                       String color;\r
+                       if (isForStockInitialOnly(graph, elementResource)) {\r
+                               color = graph.syncRequest(new SysdynDiagramPropertyExternalRead(new Pair<Resource, String>(elementResource, SysdynDiagramPreferences.ARROW_STOCK_INITIAL_COLOR)));\r
+                       } else {\r
+                               color = graph.syncRequest(new SysdynDiagramPropertyExternalRead(new Pair<Resource, String>(elementResource, SysdynDiagramPreferences.ARROW_COLOR)));\r
+                       }\r
+                       if(color != null) {\r
                         RGB rgb = StringConverter.asRGB(color, null);\r
                         if(rgb != null) {\r
                             Color c = new Color(rgb.red, rgb.green, rgb.blue);\r
@@ -245,4 +258,62 @@ public class DependencyConnectionFactory extends ElementFactoryAdapter {
 \r
     }\r
 \r
+       protected static boolean isForStockInitialOnly(ReadGraph graph,\r
+                       Resource elementResource) throws DatabaseException {\r
+               SysdynResource SR = SysdynResource.getInstance(graph);\r
+       ModelingResources MO = ModelingResources.getInstance(graph);\r
+       Layer0 L0 = Layer0.getInstance(graph);\r
+       Resource connection = graph.getPossibleObject(elementResource, MO.DiagramConnectionToConnection);\r
+       Resource tail = graph.getPossibleObject(connection, SR.Variable_HasTail);\r
+       if (tail == null)\r
+               return false;\r
+       \r
+       if (graph.isInstanceOf(tail, SR.Shadow))\r
+               tail = graph.getPossibleObject(tail, SR.Shadow_original);\r
+               \r
+       Resource head = graph.getPossibleObject(connection, SR.Variable_HasHead);\r
+       if (head == null || !graph.isInstanceOf(head, SR.Stock) || tail == null)\r
+               return false;\r
+       \r
+       Resource expressionListResource = graph.getPossibleObject(head, SR.Variable_expressionList);\r
+       List<Resource> expressionList = ListUtils.toPossibleList(graph, expressionListResource);\r
+       \r
+       // Keep track on whether at least one initial equation contains the variable\r
+       boolean initialContainsVariable = false;\r
+       // Go through all expressions\r
+       for (Resource expression : expressionList) {\r
+               if (!graph.isInstanceOf(expression, SR.StockExpression))\r
+                       return false;\r
+               \r
+               String tailStr = graph.getPossibleRelatedValue(tail, L0.HasName, Bindings.STRING);\r
+               String integral = graph.getPossibleRelatedValue(expression, SR.StockExpression_integralEquation, Bindings.STRING);\r
+               if (equationContainsVariable(graph, integral, tailStr))\r
+                       // At least one integral equation contains the variable\r
+                       return false;\r
+               String initial = graph.getPossibleRelatedValue(expression, SR.StockExpression_initialEquation, Bindings.STRING);\r
+               if (!initialContainsVariable && equationContainsVariable(graph, initial, tailStr))\r
+                       // At least one initial equation contains the variable\r
+                       initialContainsVariable = true;\r
+       }\r
+       \r
+       // No integral equation contains the variable.\r
+               return initialContainsVariable;\r
+       }\r
+\r
+       private static boolean equationContainsVariable(ReadGraph graph,\r
+                       String equation, String variable) {\r
+               ExpressionParser parser = new ExpressionParser(new StringReader(equation));\r
+               try {\r
+                       parser.expr();\r
+               } catch (Throwable t) {\r
+                       return false;\r
+               }\r
+               \r
+               // Collect references\r
+        Set<String> references = parser.getReferences().keySet();\r
+        \r
+        // See if the equation contains variable\r
+        return references.contains(variable);\r
+       }\r
+\r
 }\r
index 96681fcb3219cc29307eb5d4efb0c2d9699559af..2bd3a51c15c0a6dd8ae32b671e0430758c7abdb4 100644 (file)
@@ -64,7 +64,7 @@ public class DependencyNode extends TextNode implements ISelectionPainterNode, I
     private Stroke stroke;\r
     private Shape beginBounds;\r
     private Shape endBounds;\r
-    private double angle = 0.1;\r
+    private double angle = 0.3;\r
     private String side;\r
     private boolean delayMark = false;\r
     private boolean arrowHead = true;\r
index 3caae72cec844972cf5635e0347207c191133503..bfed4278f9d367f7ec70cf1a815dcef0af44920b 100644 (file)
@@ -58,10 +58,21 @@ public class ModulesSearchFunction extends FunctionImpl5<IProgressMonitor, ReadG
     @Override\r
     public SearchResult apply(IProgressMonitor monitor, ReadGraph graph, Resource model, SearchQuery query, Integer maxResults) {\r
         try {\r
-               // Check whether only currently open diagram is searched\r
-               String filteredQuery = query.getQuery("Name","Types");\r
-               Collection<Map<String, Object>> results = Searching.performSearch(graph, Layer0X.getInstance(graph).Dependencies, model, filteredQuery, MAX_RESULTS);\r
+               String origQuery = query.getOriginalQuery();\r
+               SearchQuery wildcardedQuery;\r
+               if (!origQuery.isEmpty()) // Add asterisks for performSearch \r
+                       wildcardedQuery = query.withOriginalQuery("*" + origQuery + "*");\r
+               else\r
+                       wildcardedQuery = query.withOriginalQuery("*");\r
+               \r
+               String filteredQuery = wildcardedQuery.escaped(false).getQuery("Name","Types");\r
+               Collection<Map<String, Object>> results = Searching.performSearch(graph, \r
+                               Layer0X.getInstance(graph).Dependencies, \r
+                               model, \r
+                               filteredQuery, \r
+                               MAX_RESULTS);\r
 \r
+               // Check whether only currently open diagram is searched\r
                if (!query.getSearchParams().contains(FindSearchTrim.CURRENT_DIAGRAM_OPTION))\r
                return generateSearchResults(graph, results, Scope.ALL_MODELS);\r
                else\r
diff --git a/dev-jkauttio/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SynthesisSimulation.java b/dev-jkauttio/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SynthesisSimulation.java
new file mode 100644 (file)
index 0000000..00f12bb
--- /dev/null
@@ -0,0 +1,87 @@
+/*******************************************************************************\r
+ * Copyright (c) 2014 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+\r
+import java.util.Map;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.Command;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.core.commands.State;\r
+import org.eclipse.ui.PlatformUI;\r
+import org.eclipse.ui.commands.ICommandService;\r
+import org.eclipse.ui.commands.IElementUpdater;\r
+import org.eclipse.ui.menus.UIElement;\r
+import org.simantics.simulation.experiment.IExperiment;\r
+import org.simantics.simulation.project.IExperimentManager;\r
+import org.simantics.sysdyn.manager.SysdynExperiment;\r
+import org.simantics.sysdyn.ui.utils.HandlerUtils;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+/**\r
+ * @author Tuomas Miettinen\r
+ */\r
+public class SynthesisSimulation extends AbstractHandler implements IElementUpdater {\r
+\r
+       public static final String COMMAND = "org.simantics.sysdyn.ui.synthesisSimulation";\r
+    public static final String STATE = "org.simantics.sysdyn.ui.synthesisSimulation.state";\r
+\r
+    @Override\r
+    public Object execute(ExecutionEvent event) throws ExecutionException {\r
+        ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);\r
+        Command command = service.getCommand(COMMAND);\r
+        State state = command.getState(STATE);\r
+        Boolean value = (Boolean) state.getValue();\r
+        value = !value;\r
+        state.setValue(value);\r
+        service.refreshElements(RunBasicExperiment.COMMAND, null);\r
+        \r
+        Command toggleCommand = service.getCommand(ToggleSimulation.COMMAND);\r
+        State toggleState = toggleCommand.getState(ToggleSimulation.STATE);\r
+        toggleState.setValue(value);\r
+        service.refreshElements(RunBasicExperiment.COMMAND, null);\r
+        \r
+        IExperimentManager manager = \r
+            SimanticsUI.getProject().getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+        IExperiment experiment = manager.getActiveExperiment();\r
+        if(experiment instanceof SysdynExperiment) {\r
+            if(getState()) {\r
+                ((SysdynExperiment)experiment).toggleSimulation(true);\r
+            } else {\r
+                ((SysdynExperiment)experiment).toggleSimulation(false);\r
+            }\r
+        }\r
+            \r
+        HandlerUtils.saveBeforeExperimentRun(event);\r
+\r
+        return null;\r
+    }\r
+\r
+    public static Boolean getState() {\r
+        ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);\r
+        Command command = service.getCommand(COMMAND);\r
+        State state = command.getState(STATE);\r
+        return (Boolean)state.getValue();\r
+    }\r
+\r
+    @SuppressWarnings("rawtypes")\r
+       @Override\r
+    public void updateElement(UIElement element, Map parameters) {\r
+        ICommandService commandService =\r
+            (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);\r
+        Command command = commandService.getCommand(COMMAND);\r
+        boolean checked = (Boolean) command.getState(STATE).getValue();\r
+        element.setChecked(checked);\r
+    }\r
+}\r
index 7d6906019c6bf96ea8b3fcd2cef10fcdc07898ca..4b13c46c582ad79d63773cec51ecec6afbd20d86 100644 (file)
@@ -13,11 +13,16 @@ package org.simantics.sysdyn.ui.handlers;
 \r
 import java.util.concurrent.Semaphore;\r
 \r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
 import org.eclipse.core.runtime.IProgressMonitor;\r
 import org.eclipse.core.runtime.IStatus;\r
 import org.eclipse.core.runtime.Status;\r
 import org.eclipse.core.runtime.SubMonitor;\r
 import org.eclipse.core.runtime.jobs.Job;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.RequestProcessor;\r
 import org.simantics.db.Resource;\r
@@ -33,12 +38,14 @@ import org.simantics.simulation.model.ExperimentLoadingFailed;
 import org.simantics.simulation.project.IExperimentActivationListener;\r
 import org.simantics.simulation.project.IExperimentManager;\r
 import org.simantics.sysdyn.ui.listeners.SysdynExperimentManagerListener;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.ResourceAdaptionUtils;\r
 import org.simantics.utils.DataContainer;\r
 import org.simantics.utils.ui.ErrorLogger;\r
 import org.simantics.utils.ui.ExceptionUtils;\r
 import org.simantics.utils.ui.dialogs.ShowMessage;\r
 \r
-public class SysdynExperimentActivator {\r
+public class SysdynExperimentActivator extends AbstractHandler {\r
     /**\r
      * @param project\r
      * @param experimentManager\r
@@ -163,4 +170,25 @@ public class SysdynExperimentActivator {
         }\r
     }\r
 \r
+       @Override\r
+       public Object execute(ExecutionEvent event) throws ExecutionException {\r
+               ISelection selection = HandlerUtil.getCurrentSelection(event);\r
+        final Resource experiment = ResourceAdaptionUtils.toSingleResource(selection);\r
+        if (experiment == null)\r
+            return null;\r
+\r
+        final IProject project = SimanticsUI.getProject();\r
+        if (project == null)\r
+            return null;\r
+        \r
+        final IExperimentManager experimentManager = project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+        if (experimentManager == null) {\r
+            ErrorLogger.defaultLogWarning("Experiment manager not available.", new Exception());\r
+            return null;\r
+        }\r
+        \r
+        SysdynExperimentActivator.scheduleActivation(SimanticsUI.getSession(), project, experimentManager, experiment);\r
+               return null;\r
+       }\r
+\r
 }\r
index 79fa0ffd3e1ec8954bb3fe85f4600ecef1c55251..351f9c4ff9199796fc31a0ac4fe7ead14462f353 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
- * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Copyright (c) 2010, 2014 Association for Decentralized Information Management in\r
  * Industry THTH ry.\r
  * All rights reserved. This program and the accompanying materials\r
  * are made available under the terms of the Eclipse Public License v1.0\r
@@ -44,6 +44,11 @@ public class ToggleSimulation extends AbstractHandler implements IElementUpdater
         state.setValue(value);\r
         service.refreshElements(RunBasicExperiment.COMMAND, null);\r
         \r
+        Command synthesisCommand = service.getCommand(SynthesisSimulation.COMMAND);\r
+        State synthesisState = synthesisCommand.getState(SynthesisSimulation.STATE);\r
+        synthesisState.setValue(false);\r
+        service.refreshElements(RunBasicExperiment.COMMAND, null);\r
+        \r
         IExperimentManager manager = \r
             SimanticsUI.getProject().getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
         IExperiment experiment = manager.getActiveExperiment();\r
index 92a5ac8e2e73be774c7a64c71ee94ca2c5b6c263..1d7888409600755860bfbfc8ffa40706ef928f4a 100644 (file)
@@ -191,6 +191,10 @@ public class ExportModelHandler extends AbstractHandler {
                        // Use import default path.\r
                        path = Activator.getDefault().getPreferenceStore().getString(ImportUtilsUI.IMPORTMODELTPATH);\r
                }\r
+               if (saveAs == false && !(new File(path).exists())) {\r
+                       // Save == Save as... when the path doesn't exist. \r
+                       return getAbsolutePath(model, event, true);\r
+               }\r
                if(path.isEmpty() || !(new File(path).exists()))\r
                        path = Platform.getLocation().toOSString();\r
                                \r
index 87bccb75605b90e79f08a2a58a25ef8ea621dd55..caea744ab68bc578c4de0fa166062cbcf5684fe7 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
- * Copyright (c) 2010, 2012 Association for Decentralized Information Management in\r
+ * Copyright (c) 2010, 2012, 2014 Association for Decentralized Information Management in\r
  * Industry THTH ry.\r
  * All rights reserved. This program and the accompanying materials\r
  * are made available under the terms of the Eclipse Public License v1.0\r
@@ -19,6 +19,7 @@ import org.eclipse.ui.contexts.IContextActivation;
 import org.simantics.simulation.experiment.ExperimentState;\r
 import org.simantics.simulation.experiment.IExperimentListener;\r
 import org.simantics.sysdyn.ui.handlers.RunBasicExperiment;\r
+import org.simantics.sysdyn.ui.handlers.SynthesisSimulation;\r
 import org.simantics.sysdyn.ui.handlers.ToggleSimulation;\r
 import org.simantics.sysdyn.ui.handlers.game.ReloadGameExperimentHandler;\r
 import org.simantics.sysdyn.ui.handlers.game.StepHandler;\r
@@ -37,15 +38,21 @@ public class SysdynExperimentListener  implements IExperimentListener {
             public void run() {\r
                 ICommandService commandService =\r
                     (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);\r
-                Command command = commandService.getCommand(ToggleSimulation.COMMAND);\r
-                State buttonState = command.getState(ToggleSimulation.STATE);\r
+                Command toggleCommand = commandService.getCommand(ToggleSimulation.COMMAND);\r
+                State toggleButtonState = toggleCommand.getState(ToggleSimulation.STATE);\r
+                Command synhesisCommand = commandService.getCommand(SynthesisSimulation.COMMAND);\r
+                State synthesisButtonState = synhesisCommand.getState(SynthesisSimulation.STATE);\r
                                 \r
                 switch(state) {\r
                 case DISPOSED:\r
-                    buttonState.setValue(false); \r
+                       toggleButtonState.setValue(false); \r
+                       synthesisButtonState.setValue(false); \r
                     break;\r
+                               default:\r
+                                       break;\r
                 }\r
-                commandService.refreshElements(command.getId(), null); \r
+                commandService.refreshElements(toggleCommand.getId(), null); \r
+                commandService.refreshElements(synhesisCommand.getId(), null); \r
                 commandService.refreshElements(RunBasicExperiment.COMMAND, null);\r
                 commandService.refreshElements(PlaybackExperimentHandler.COMMAND, null);\r
                 commandService.refreshElements(PlaybackResetHandler.COMMAND, null);\r
index 4f9639da4895c1b6e335250bfd0c4910df31fa5b..a61ae6bd94a848a48b517789d2b782eb7ea4be51 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
- * Copyright (c) 2013 Association for Decentralized Information Management in\r
+ * Copyright (c) 2013, 2014 Association for Decentralized Information Management in\r
  * Industry THTH ry.\r
  * All rights reserved. This program and the accompanying materials\r
  * are made available under the terms of the Eclipse Public License v1.0\r
@@ -8,6 +8,7 @@
  *\r
  * Contributors:\r
  *     Semantum Oy\r
+ *     VTT Technical Research Centre of Finland\r
  *******************************************************************************/\r
 \r
 package org.simantics.sysdyn.ui.preferences;\r
@@ -33,6 +34,7 @@ import org.simantics.sysdyn.ui.Activator;
 /**\r
  * \r
  * @author Teemu Lempinen\r
+ * @author Tuomas Miettinen\r
  *\r
  */\r
 public class SysdynDiagramPreferencePage extends FieldEditorPreferencePage implements\r
@@ -82,6 +84,7 @@ IWorkbenchPreferencePage {
         GridDataFactory.fillDefaults().applyTo(label);\r
         \r
         addColorFieldEditor(SysdynDiagramPreferences.ARROW_COLOR, "&Dependency", SysdynDiagramPreferences.ARROW_USE_DEFAULT_COLOR);\r
+        addColorFieldEditor(SysdynDiagramPreferences.ARROW_STOCK_INITIAL_COLOR, "&Dependency to Stock Initial", SysdynDiagramPreferences.ARROW_STOCK_INITIAL_USE_DEFAULT_COLOR);\r
         addColorFieldEditor(SysdynDiagramPreferences.FLOW_COLOR, "&Flow", SysdynDiagramPreferences.FLOW_USE_DEFAULT_COLOR);\r
         addColorFieldEditor(SysdynDiagramPreferences.AUXILIARY_COLOR, "&Auxiliary", SysdynDiagramPreferences.AUXILIARY_USE_DEFAULT_COLOR);\r
         addColorFieldEditor(SysdynDiagramPreferences.STOCK_COLOR, "&Stock", SysdynDiagramPreferences.STOCK_USE_DEFAULT_COLOR);\r
index 94c4bcab2dd5dece40f7df50e5b1ceed06869225..1a8255fa87d4fed43c2e78328f245eded8314a26 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
- * Copyright (c) 2013 Association for Decentralized Information Management in\r
+ * Copyright (c) 2013, 2014 Association for Decentralized Information Management in\r
  * Industry THTH ry.\r
  * All rights reserved. This program and the accompanying materials\r
  * are made available under the terms of the Eclipse Public License v1.0\r
@@ -8,6 +8,7 @@
  *\r
  * Contributors:\r
  *     Semantum Oy\r
+ *     VTT Technical Research Centre of Finland\r
  *******************************************************************************/\r
 package org.simantics.sysdyn.ui.preferences;\r
 \r
@@ -24,6 +25,7 @@ import org.simantics.sysdyn.ui.Activator;
 /**\r
  * \r
  * @author Teemu Lempinen\r
+ * @author Tuomas Miettinen\r
  *\r
  */\r
 public class SysdynDiagramPreferences {\r
@@ -32,6 +34,7 @@ public class SysdynDiagramPreferences {
     public static String DEFAULT_FONT = "Default font";\r
     \r
     public static String ARROW_COLOR = "Arrow color";\r
+    public static String ARROW_STOCK_INITIAL_COLOR = "Arrow stock initial color";\r
     public static String FLOW_COLOR = "Flow color";\r
     public static String AUXILIARY_COLOR = "Auxiliary color";\r
     public static String CLOUD_COLOR = "Cloud color";\r
@@ -45,6 +48,7 @@ public class SysdynDiagramPreferences {
     static {\r
         colorPreferenceNames = new HashMap<String, String>();\r
         colorPreferenceNames.put(SysdynResource.URIs.DependencyConnection, ARROW_COLOR);\r
+        colorPreferenceNames.put(SysdynResource.URIs.DependencyConnection + "_stockInitial", ARROW_STOCK_INITIAL_COLOR);\r
         colorPreferenceNames.put(SysdynResource.URIs.FlowConnection, FLOW_COLOR);\r
         colorPreferenceNames.put(SysdynResource.URIs.AuxiliarySymbol, AUXILIARY_COLOR);\r
         colorPreferenceNames.put(SysdynResource.URIs.CloudSymbol, CLOUD_COLOR);\r
@@ -61,6 +65,7 @@ public class SysdynDiagramPreferences {
     }\r
     \r
     public static String ARROW_USE_DEFAULT_COLOR = "Arrow use default color";\r
+    public static String ARROW_STOCK_INITIAL_USE_DEFAULT_COLOR = "Arrow stock initial use default color";\r
     public static String FLOW_USE_DEFAULT_COLOR = "Flow use default color";\r
     public static String AUXILIARY_USE_DEFAULT_COLOR = "Auxiliary use default color";\r
     public static String CLOUD_USE_DEFAULT_COLOR = "Cloud use default color";\r
@@ -74,6 +79,7 @@ public class SysdynDiagramPreferences {
     static {\r
         colorDefaults = new HashMap<String, String>();\r
         colorDefaults.put(ARROW_COLOR, ARROW_USE_DEFAULT_COLOR);\r
+        colorDefaults.put(ARROW_STOCK_INITIAL_COLOR, ARROW_STOCK_INITIAL_USE_DEFAULT_COLOR);\r
         colorDefaults.put(FLOW_COLOR, FLOW_USE_DEFAULT_COLOR);\r
         colorDefaults.put(AUXILIARY_COLOR, AUXILIARY_USE_DEFAULT_COLOR);\r
         colorDefaults.put(CLOUD_COLOR, CLOUD_USE_DEFAULT_COLOR);\r
index cd5c8f506a3cead4ab560bf57187bd1c9ac7b0b3..1b1c4556971509d4c89a63e9273d94235523c268 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
- * Copyright (c) 2013 Association for Decentralized Information Management in\r
+ * Copyright (c) 2013, 2014 Association for Decentralized Information Management in\r
  * Industry THTH ry.\r
  * All rights reserved. This program and the accompanying materials\r
  * are made available under the terms of the Eclipse Public License v1.0\r
@@ -8,6 +8,7 @@
  *\r
  * Contributors:\r
  *     Semantum Oy\r
+ *     VTT Technical Research Centre of Finland\r
  *******************************************************************************/\r
 package org.simantics.sysdyn.ui.preferences;\r
 \r
@@ -23,6 +24,7 @@ import com.lowagie.text.Font;
 /**\r
  * \r
  * @author Teemu Lempinen\r
+ * @author Tuomas Miettinen\r
  *\r
  */\r
 public class SysdynDiagramPreferencesInitializer extends AbstractPreferenceInitializer {  \r
@@ -31,10 +33,12 @@ public class SysdynDiagramPreferencesInitializer extends AbstractPreferenceIniti
     public void initializeDefaultPreferences() {\r
         RGB black = new RGB(0, 0, 0);\r
         RGB arrow = new RGB(0,128,192);\r
+        RGB arrowToStockInitial = new RGB(128,128,128);\r
         \r
         IPreferenceStore store = Activator.getDefault().getPreferenceStore();\r
         \r
         PreferenceConverter.setDefault(store, SysdynDiagramPreferences.DEFAULT_COLOR, black);\r
+        PreferenceConverter.setDefault(store, SysdynDiagramPreferences.ARROW_STOCK_INITIAL_COLOR, arrowToStockInitial);\r
         PreferenceConverter.setDefault(store, SysdynDiagramPreferences.ARROW_COLOR, arrow);\r
         PreferenceConverter.setDefault(store, SysdynDiagramPreferences.FLOW_COLOR, black);\r
         PreferenceConverter.setDefault(store, SysdynDiagramPreferences.AUXILIARY_COLOR, black);\r
@@ -46,6 +50,7 @@ public class SysdynDiagramPreferencesInitializer extends AbstractPreferenceIniti
         \r
 \r
         store.setDefault(SysdynDiagramPreferences.ARROW_USE_DEFAULT_COLOR, false);\r
+        store.setDefault(SysdynDiagramPreferences.ARROW_STOCK_INITIAL_USE_DEFAULT_COLOR, false);\r
         store.setDefault(SysdynDiagramPreferences.FLOW_USE_DEFAULT_COLOR, true);\r
         store.setDefault(SysdynDiagramPreferences.AUXILIARY_USE_DEFAULT_COLOR, true);\r
         store.setDefault(SysdynDiagramPreferences.STOCK_USE_DEFAULT_COLOR, true);\r
index 41b8aaa6ba647975026d0a4f97ead2b87fda8f70..6756bb5ef99da7753b0ac1a32ddacce0347934db 100644 (file)
@@ -49,6 +49,7 @@ import org.simantics.sysdyn.SysdynResource;
 import org.simantics.sysdyn.ui.editor.SysdynEditorNamingService;\r
 import org.simantics.ui.workbench.IEditorNamingService;\r
 import org.simantics.utils.FileUtils;\r
+import org.simantics.utils.ui.BundleUtils;\r
 \r
 public class SysdynProject extends AbstractProjectFeature {\r
        private static final String DEFAULT_PERSPECTIVE = "org.simantics.sysdyn.ui.perspective";\r
@@ -58,6 +59,17 @@ public class SysdynProject extends AbstractProjectFeature {
                final IProject project = getProject();\r
                final Session session = getSession();\r
 \r
+               try {\r
+                       File base = BundleUtils.findFile("org.simantics.sysdyn.ui", "");\r
+                       File f = new File(base, "../org.simantics.sysdyn.tests/src/org/simantics/sysdyn/tests/scripts");\r
+                       if(f.exists()) {\r
+                               System.setProperty("scl.test.path", f.getAbsolutePath());\r
+                       }\r
+               } catch (Exception e) {\r
+                       \r
+               }\r
+               \r
+\r
                getProjectElement().setHint(ProjectKeys.DEFAULT_PERSPECTIVE, DEFAULT_PERSPECTIVE);\r
                \r
                // Multi for simupedia use\r
index 9250126c4d94070a4d9d860fb9096155b276b4de..afee67e9a9702edf8d032cd56b38b0bdb60d72c3 100644 (file)
@@ -236,6 +236,7 @@ public class ConfigurationTab extends AdjustableTab {
                 Map<String, Object> map = new HashMap<String, Object>();\r
                 map.put("year", "year");\r
                 map.put("month", "month");\r
+                map.put("week", "week");\r
                 map.put("day", "day");\r
                 map.put("hour", "hour");\r
                 map.put("min", "min");\r
index 3c1c1b1af882dc07b255a906e2e281340331573a..e7e5314cc6ea31123cc930c27fe69b23a0368b70 100644 (file)
@@ -25,10 +25,12 @@ import org.eclipse.swt.events.FocusAdapter;
 import org.eclipse.swt.events.FocusEvent;\r
 import org.eclipse.swt.events.FocusListener;\r
 import org.eclipse.swt.events.KeyListener;\r
+import org.eclipse.swt.events.ModifyEvent;\r
 import org.eclipse.swt.events.ModifyListener;\r
 import org.eclipse.swt.events.SelectionAdapter;\r
 import org.eclipse.swt.events.SelectionEvent;\r
 import org.eclipse.swt.graphics.Point;\r
+import org.eclipse.swt.widgets.Combo;\r
 import org.eclipse.swt.widgets.Composite;\r
 import org.eclipse.swt.widgets.Label;\r
 import org.eclipse.swt.widgets.Spinner;\r
@@ -60,6 +62,7 @@ public class DelayExpression implements IExpression {
     private Spinner order;\r
     private final ExpressionWidgetInput input;\r
     private Resource expression;\r
+       private Combo delayTypeCombo;\r
 \r
     /**\r
      * Creates a new DelayExpression\r
@@ -76,19 +79,19 @@ public class DelayExpression implements IExpression {
     @Override\r
     public void createExpressionFields(Composite parent, final Map<String, Object> data, Table allowedVariables) {\r
         // Get possible existing data\r
-        GridLayoutFactory.fillDefaults().numColumns(2).applyTo(parent);\r
+        GridLayoutFactory.fillDefaults().numColumns(5).applyTo(parent);\r
         String eq = data.get("equation") != null ? (String)data.get("equation") : "";\r
         String dt = data.get("delayTime") != null ? (String)data.get("delayTime") : "";\r
         String iv = data.get("initialValue") != null ? (String)data.get("initialValue") : "";\r
         int o = data.get("order") != null ? (Integer)data.get("order") : 3;\r
 \r
         Label l = new Label(parent, SWT.NONE);\r
-        l.setText("expression");\r
+        l.setText("Expression");\r
 \r
         // Equation that is delayed\r
         equation = new ExpressionField(parent, SWT.BORDER, allowedVariables, true, input);\r
         equation.setExpression(eq);\r
-        GridDataFactory.fillDefaults().grab(true, true).applyTo(equation);\r
+        GridDataFactory.fillDefaults().span(4, 1).grab(true, true).applyTo(equation);\r
         equation.getSourceViewer().getTextWidget().addFocusListener(new FocusAdapter() {\r
 \r
             @Override\r
@@ -98,12 +101,12 @@ public class DelayExpression implements IExpression {
         });\r
 \r
         l = new Label(parent, SWT.NONE);\r
-        l.setText("delay time");\r
+        l.setText("Delay time");\r
 \r
         // How much the equation is delayed\r
         delayTime = new ExpressionField(parent, SWT.BORDER, allowedVariables, true, input);\r
         delayTime.setExpression(dt);\r
-        GridDataFactory.fillDefaults().grab(true, true).applyTo(delayTime);\r
+        GridDataFactory.fillDefaults().span(4, 1).grab(true, true).applyTo(delayTime);\r
 \r
         delayTime.getSourceViewer().getTextWidget().addFocusListener(new FocusAdapter() {\r
 \r
@@ -114,12 +117,12 @@ public class DelayExpression implements IExpression {
         });\r
 \r
         l = new Label(parent, SWT.NONE);\r
-        l.setText("initial value");\r
+        l.setText("Initial value");\r
 \r
         // What is the initial value of the delay (empty == same as equation)\r
         initialValue = new ExpressionField(parent, SWT.BORDER, allowedVariables, true, input);\r
         initialValue.setExpression(iv);\r
-        GridDataFactory.fillDefaults().grab(true, true).applyTo(initialValue);\r
+        GridDataFactory.fillDefaults().span(4, 1).grab(true, true).applyTo(initialValue);\r
 \r
         initialValue.getSourceViewer().getTextWidget().addFocusListener(new FocusAdapter() {\r
 \r
@@ -131,7 +134,7 @@ public class DelayExpression implements IExpression {
 \r
 \r
         l = new Label(parent, SWT.NONE);\r
-        l.setText("order");\r
+        l.setText("Order");\r
 \r
         // The order of the delay (default == 3)\r
         order = new Spinner(parent, SWT.BORDER);\r
@@ -143,7 +146,42 @@ public class DelayExpression implements IExpression {
                 save(expression, data);\r
             }\r
         });\r
-        GridDataFactory.fillDefaults().applyTo(order);\r
+        GridDataFactory.fillDefaults().grab(false, false).applyTo(order);\r
+        \r
+        l = new Label(parent, SWT.NONE);\r
+        l.setText("Delay type");\r
+        GridDataFactory.fillDefaults().grab(true, false).align(SWT.END, SWT.CENTER).applyTo(l);\r
+        \r
+        // The type of the delay (material / information delay)\r
+        delayTypeCombo = new Combo(parent, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);\r
+        delayTypeCombo.add("Material");\r
+        delayTypeCombo.add("Information");\r
+        GridDataFactory.fillDefaults().applyTo(delayTypeCombo);\r
+        \r
+               // Initial selection to the combo\r
+        try {\r
+                       boolean isInformationDelay = SimanticsUI.getSession().syncRequest(new Read<Boolean>(){\r
+\r
+                               @Override\r
+                               public Boolean perform(ReadGraph graph) throws DatabaseException {\r
+                                       SysdynResource sr = SysdynResource.getInstance(graph);\r
+                                       return graph.hasStatement(expression, sr.DelayExpression_isInformationDelay, expression);\r
+                               }\r
+                       });\r
+                       delayTypeCombo.select(isInformationDelay ? 1 : 0);\r
+           } catch (DatabaseException e1) {\r
+                       delayTypeCombo.select(0);\r
+               e1.printStackTrace();\r
+               }\r
+        \r
+        // Modify listener for selecting the delay type\r
+        delayTypeCombo.addModifyListener(new ModifyListener() {\r
+\r
+                       @Override\r
+                       public void modifyText(ModifyEvent e) {\r
+                               save(expression, data);\r
+                       }\r
+               });\r
         \r
         lastSelectedText = equation;\r
     }\r
@@ -163,6 +201,7 @@ public class DelayExpression implements IExpression {
         class Auxiliary {\r
             String equation, delayTime, initialValue;\r
             Integer order;\r
+            Boolean isInformationDelay;\r
         }\r
 \r
         Auxiliary results = null;\r
@@ -179,10 +218,12 @@ public class DelayExpression implements IExpression {
                         results.delayTime = graph.getPossibleRelatedValue(expression, sr.DelayExpression_delayTime);\r
                         results.initialValue = graph.getPossibleRelatedValue(expression, sr.DelayExpression_initialValue);\r
                         results.order = graph.getPossibleRelatedValue(expression, sr.DelayExpression_order);\r
+                        results.isInformationDelay = graph.hasStatement(expression, sr.DelayExpression_isInformationDelay, expression);\r
                     } else {\r
                         results.equation = "";\r
                         results.delayTime = "";\r
                         results.order = 1;\r
+                        results.isInformationDelay = false;\r
                     }\r
                     return results;\r
                 }\r
@@ -198,6 +239,8 @@ public class DelayExpression implements IExpression {
             data.put("initialValue", results.initialValue);\r
         if(results.order != null)\r
             data.put("order", results.order);\r
+        if(results.isInformationDelay != null)\r
+            data.put("isInformationDelay", results.isInformationDelay);\r
     }\r
 \r
     @Override\r
@@ -221,15 +264,19 @@ public class DelayExpression implements IExpression {
         final String currentDelayTime =  this.delayTime.getExpression();\r
         final String currentInitialValue = this.initialValue.getExpression();\r
         final Integer currentOrder = this.order.getSelection();\r
+        final Boolean currentIsInformationDelay = (this.delayTypeCombo.getSelectionIndex() == 1);\r
 \r
         String oldEquation = (String)data.get("equation");\r
         String oldDelayTime = (String)data.get("delayTime");\r
         String oldInitialValue = (String)data.get("initialValue");\r
         Integer oldOrder = (Integer)data.get("order");\r
+        Boolean oldIsInformationDelay = (Boolean)data.get("isInformationDelay");\r
 \r
-        if((oldEquation == null || oldDelayTime == null || oldOrder == null || oldInitialValue == null) ||\r
-                !oldEquation.equals(currentEquation) || !oldDelayTime.equals(currentDelayTime) ||\r
-                !oldOrder.equals(currentOrder) || !oldInitialValue.equals(currentInitialValue)) {\r
+        if(oldEquation == null || oldDelayTime == null || oldOrder == null \r
+                       || oldInitialValue == null || oldIsInformationDelay == null \r
+                       || !oldEquation.equals(currentEquation) || !oldDelayTime.equals(currentDelayTime) \r
+                       || !oldOrder.equals(currentOrder) || !oldInitialValue.equals(currentInitialValue)\r
+                       || !oldIsInformationDelay.equals(currentIsInformationDelay)) {\r
             // old value was null or value has changed -> Do save\r
 \r
             data.putAll(data);\r
@@ -237,6 +284,7 @@ public class DelayExpression implements IExpression {
             data.put("delayTime", currentDelayTime);\r
             data.put("initialValue", currentInitialValue);\r
             data.put("order", currentOrder);\r
+            data.put("isInformationDelay", currentIsInformationDelay);\r
 \r
             SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
                 @Override\r
@@ -267,8 +315,7 @@ public class DelayExpression implements IExpression {
                                     graph.deny(variable, sr.IndependentVariable_activeExpression);\r
                                 graph.claim(variable, sr.IndependentVariable_activeExpression, newExpression);\r
                             }\r
-                        }\r
-                                );\r
+                        });\r
                         expression = newExpression;\r
                     }\r
                     \r
@@ -277,6 +324,10 @@ public class DelayExpression implements IExpression {
                     g.claimLiteral(expression, sr.DelayExpression_delayTime, currentDelayTime);\r
                     g.claimLiteral(expression, sr.DelayExpression_initialValue, currentInitialValue);\r
                     g.claimLiteral(expression, sr.DelayExpression_order, currentOrder);\r
+                    if (currentIsInformationDelay)\r
+                       g.claim(expression, sr.DelayExpression_isInformationDelay, expression);\r
+                    else\r
+                       g.deny(expression, sr.DelayExpression_isInformationDelay, expression);\r
                 }\r
             });\r
         }\r
@@ -293,6 +344,8 @@ public class DelayExpression implements IExpression {
             data.put("initialValue", this.initialValue.getExpression());   \r
         if(this.order != null)\r
             data.put("order", this.order.getSelection());   \r
+        if(this.delayTypeCombo != null)\r
+            data.put("isInformationDelay", (this.delayTypeCombo.getSelectionIndex() == 1));\r
     }\r
 \r
     @Override\r
index 928d8377c43cc5c9ed12e5eedcd5d84a03417363..ef13a4264384c305aee51ae2020b8b11f2074af8 100644 (file)
@@ -256,7 +256,8 @@ public class TrendView extends ViewPart {
                 }\r
                 frame.repaint();\r
                 frame.validate();\r
-                panel.requestFocus();\r
+                panel.requestFocusInWindow();\r
+                //panel.requestFocus();\r
             }\r
 \r
         });\r
index 21010c105d866967b7fb25c57a9948b5bfbc7a6a..b32a845a27caa419680124c6a7f9c06563e0bb97 100644 (file)
@@ -1,3 +1,4 @@
+include "UI/Progress"\r
 include "Simantics/DB"\r
 include "Simantics/Variables"\r
 \r
@@ -84,8 +85,15 @@ importJava "org.simantics.sysdyn.utils.DocumentationUtils" where
     formatDate :: Long -> <ReadGraph> String \r
     \r
     @JavaName importModel\r
-    importModel :: String -> <Proc> ()\r
+    importModel :: String -> <Proc> Resource\r
     \r
     @JavaName isParameter\r
     isParameter :: Variable -> <ReadGraph> Boolean\r
+\r
+    lastValue :: Resource -> String -> String -> Double\r
+\r
+importJava "org.simantics.sysdyn.manager.SysdynExperiments" where\r
+    \r
+    activateExperiment :: Resource -> String\r
+    run :: String -> ()\r
     
\ No newline at end of file
index 9834ff5db5c7bc42f04efe38cab661769a777eca..71ea423e1d9563618e40bd0160a5b5f5fb0144a1 100644 (file)
@@ -24,10 +24,12 @@ public class ValueIndexVariable extends IndexVariable<double[]> {
            super(graph, parent, indexes);\r
        }\r
 \r
+       public static double[] UNRESOLVED = new double[0];\r
+       \r
        @Override\r
        public double[] getValue() {\r
            if(experiment == null)\r
-               return new double[0];\r
+               return UNRESOLVED;\r
 \r
         Collection<SysdynResult> results = experiment.getActiveResults();\r
                ArrayList<String> variableNames = getVariableNamesWithIndexNumbers();\r
@@ -43,7 +45,7 @@ public class ValueIndexVariable extends IndexVariable<double[]> {
                            if(ds != null && ds.values != null && ds.values.length > 0) {\r
                                result[i] =  ds.values[ds.values.length-1];\r
                            } else {\r
-                               result[i] = 0;\r
+                               return UNRESOLVED;\r
                            }\r
                        }\r
                    }\r
index bcb3d09e804a66dec1a1a60615ed2fb3bf3c6419..08ecdcb477a21a81679cdad6a0578d6354392bd0 100644 (file)
@@ -369,17 +369,16 @@ public class ExpressionParser implements ExpressionParserConstants {
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
       case 84:\r
         jj_consume_token(84);\r
-        primary();\r
         break;\r
       case 85:\r
         jj_consume_token(85);\r
-        primary();\r
         break;\r
       default:\r
         jj_la1[15] = jj_gen;\r
         jj_consume_token(-1);\r
         throw new ParseException();\r
       }\r
+      primary();\r
       break;\r
     default:\r
       jj_la1[16] = jj_gen;\r
@@ -982,9 +981,9 @@ void named_arguments() : {
     return false;\r
   }\r
 \r
-  private boolean jj_3R_74() {\r
+  private boolean jj_3R_72() {\r
     if (jj_scan_token(67)) return true;\r
-    if (jj_3R_73()) return true;\r
+    if (jj_3R_71()) return true;\r
     return false;\r
   }\r
 \r
@@ -1003,7 +1002,7 @@ void named_arguments() : {
     return false;\r
   }\r
 \r
-  private boolean jj_3R_79() {\r
+  private boolean jj_3R_77() {\r
     if (jj_scan_token(41)) return true;\r
     if (jj_3R_16()) return true;\r
     return false;\r
@@ -1033,9 +1032,9 @@ void named_arguments() : {
     return false;\r
   }\r
 \r
-  private boolean jj_3R_76() {\r
+  private boolean jj_3R_74() {\r
     if (jj_scan_token(69)) return true;\r
-    if (jj_3R_75()) return true;\r
+    if (jj_3R_73()) return true;\r
     return false;\r
   }\r
 \r
@@ -1049,38 +1048,38 @@ void named_arguments() : {
     return false;\r
   }\r
 \r
-  private boolean jj_3R_67() {\r
+  private boolean jj_3R_65() {\r
     if (jj_scan_token(69)) return true;\r
-    if (jj_3R_55()) return true;\r
+    if (jj_3R_53()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_64() {\r
+  private boolean jj_3R_62() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_67()) {\r
+    if (jj_3R_65()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_68()) return true;\r
+    if (jj_3R_66()) return true;\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_58() {\r
+  private boolean jj_3R_56() {\r
     if (jj_scan_token(66)) return true;\r
-    if (jj_3R_52()) return true;\r
+    if (jj_3R_50()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_78() {\r
+  private boolean jj_3R_76() {\r
     if (jj_3R_14()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_75() {\r
+  private boolean jj_3R_73() {\r
     if (jj_3R_14()) return true;\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_79()) jj_scanpos = xsp;\r
+    if (jj_3R_77()) jj_scanpos = xsp;\r
     return false;\r
   }\r
 \r
@@ -1094,17 +1093,17 @@ void named_arguments() : {
     return false;\r
   }\r
 \r
-  private boolean jj_3R_77() {\r
+  private boolean jj_3R_75() {\r
     if (jj_scan_token(UNSIGNED_INTEGER)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_73() {\r
+  private boolean jj_3R_71() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_77()) {\r
+    if (jj_3R_75()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_78()) return true;\r
+    if (jj_3R_76()) return true;\r
     }\r
     return false;\r
   }\r
@@ -1127,19 +1126,19 @@ void named_arguments() : {
     return false;\r
   }\r
 \r
-  private boolean jj_3R_72() {\r
-    if (jj_3R_75()) return true;\r
+  private boolean jj_3R_70() {\r
+    if (jj_3R_73()) return true;\r
     Token xsp;\r
     while (true) {\r
       xsp = jj_scanpos;\r
-      if (jj_3R_76()) { jj_scanpos = xsp; break; }\r
+      if (jj_3R_74()) { jj_scanpos = xsp; break; }\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_54() {\r
+  private boolean jj_3R_52() {\r
     if (jj_scan_token(68)) return true;\r
-    if (jj_3R_53()) return true;\r
+    if (jj_3R_51()) return true;\r
     return false;\r
   }\r
 \r
@@ -1158,17 +1157,17 @@ void named_arguments() : {
     return false;\r
   }\r
 \r
-  private boolean jj_3R_61() {\r
+  private boolean jj_3R_59() {\r
     if (jj_3R_16()) return true;\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_64()) jj_scanpos = xsp;\r
+    if (jj_3R_62()) jj_scanpos = xsp;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_66() {\r
+  private boolean jj_3R_64() {\r
     if (jj_scan_token(69)) return true;\r
-    if (jj_3R_65()) return true;\r
+    if (jj_3R_63()) return true;\r
     return false;\r
   }\r
 \r
@@ -1193,34 +1192,34 @@ void named_arguments() : {
     return false;\r
   }\r
 \r
-  private boolean jj_3R_71() {\r
-    if (jj_3R_73()) return true;\r
+  private boolean jj_3R_69() {\r
+    if (jj_3R_71()) return true;\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_74()) jj_scanpos = xsp;\r
+    if (jj_3R_72()) jj_scanpos = xsp;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_60() {\r
+  private boolean jj_3R_58() {\r
     if (jj_3R_13()) return true;\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_63()) jj_scanpos = xsp;\r
+    if (jj_3R_61()) jj_scanpos = xsp;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_55() {\r
+  private boolean jj_3R_53() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_60()) {\r
+    if (jj_3R_58()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_61()) return true;\r
+    if (jj_3R_59()) return true;\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_56() {\r
-    if (jj_3R_55()) return true;\r
+  private boolean jj_3R_54() {\r
+    if (jj_3R_53()) return true;\r
     return false;\r
   }\r
 \r
@@ -1229,9 +1228,9 @@ void named_arguments() : {
     return false;\r
   }\r
 \r
-  private boolean jj_3R_70() {\r
+  private boolean jj_3R_68() {\r
     if (jj_3R_12()) return true;\r
-    if (jj_3R_51()) return true;\r
+    if (jj_3R_49()) return true;\r
     return false;\r
   }\r
 \r
@@ -1253,39 +1252,33 @@ void named_arguments() : {
     return false;\r
   }\r
 \r
-  private boolean jj_3R_51() {\r
+  private boolean jj_3R_49() {\r
     if (jj_scan_token(60)) return true;\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_56()) jj_scanpos = xsp;\r
+    if (jj_3R_54()) jj_scanpos = xsp;\r
     if (jj_scan_token(61)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_50() {\r
-    if (jj_scan_token(85)) return true;\r
-    if (jj_3R_41()) return true;\r
-    return false;\r
-  }\r
-\r
-  private boolean jj_3R_57() {\r
-    if (jj_3R_62()) return true;\r
+  private boolean jj_3R_55() {\r
+    if (jj_3R_60()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_69() {\r
+  private boolean jj_3R_67() {\r
     if (jj_scan_token(67)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_65() {\r
+  private boolean jj_3R_63() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_69()) {\r
+    if (jj_3R_67()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_70()) {\r
+    if (jj_3R_68()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_71()) return true;\r
+    if (jj_3R_69()) return true;\r
     }\r
     }\r
     return false;\r
@@ -1299,18 +1292,18 @@ void named_arguments() : {
 \r
   private boolean jj_3R_48() {\r
     if (jj_scan_token(62)) return true;\r
-    if (jj_3R_55()) return true;\r
+    if (jj_3R_53()) return true;\r
     if (jj_scan_token(63)) return true;\r
     return false;\r
   }\r
 \r
   private boolean jj_3R_47() {\r
     if (jj_scan_token(64)) return true;\r
-    if (jj_3R_53()) return true;\r
+    if (jj_3R_51()) return true;\r
     Token xsp;\r
     while (true) {\r
       xsp = jj_scanpos;\r
-      if (jj_3R_54()) { jj_scanpos = xsp; break; }\r
+      if (jj_3R_52()) { jj_scanpos = xsp; break; }\r
     }\r
     if (jj_scan_token(65)) return true;\r
     return false;\r
@@ -1324,23 +1317,23 @@ void named_arguments() : {
   }\r
 \r
   private boolean jj_3R_45() {\r
-    if (jj_3R_52()) return true;\r
+    if (jj_3R_50()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_59() {\r
+  private boolean jj_3R_57() {\r
     if (jj_scan_token(69)) return true;\r
     if (jj_3R_16()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_62() {\r
+  private boolean jj_3R_60() {\r
     if (jj_scan_token(64)) return true;\r
-    if (jj_3R_65()) return true;\r
+    if (jj_3R_63()) return true;\r
     Token xsp;\r
     while (true) {\r
       xsp = jj_scanpos;\r
-      if (jj_3R_66()) { jj_scanpos = xsp; break; }\r
+      if (jj_3R_64()) { jj_scanpos = xsp; break; }\r
     }\r
     if (jj_scan_token(65)) return true;\r
     return false;\r
@@ -1348,23 +1341,18 @@ void named_arguments() : {
 \r
   private boolean jj_3R_44() {\r
     if (jj_3R_12()) return true;\r
-    if (jj_3R_51()) return true;\r
-    return false;\r
-  }\r
-\r
-  private boolean jj_3R_49() {\r
-    if (jj_scan_token(84)) return true;\r
-    if (jj_3R_41()) return true;\r
+    if (jj_3R_49()) return true;\r
     return false;\r
   }\r
 \r
   private boolean jj_3R_42() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_49()) {\r
+    if (jj_scan_token(84)) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_50()) return true;\r
+    if (jj_scan_token(85)) return true;\r
     }\r
+    if (jj_3R_41()) return true;\r
     return false;\r
   }\r
 \r
@@ -1453,19 +1441,19 @@ void named_arguments() : {
     return false;\r
   }\r
 \r
-  private boolean jj_3R_53() {\r
+  private boolean jj_3R_51() {\r
     if (jj_3R_16()) return true;\r
     Token xsp;\r
     while (true) {\r
       xsp = jj_scanpos;\r
-      if (jj_3R_59()) { jj_scanpos = xsp; break; }\r
+      if (jj_3R_57()) { jj_scanpos = xsp; break; }\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_63() {\r
+  private boolean jj_3R_61() {\r
     if (jj_scan_token(69)) return true;\r
-    if (jj_3R_55()) return true;\r
+    if (jj_3R_53()) return true;\r
     return false;\r
   }\r
 \r
@@ -1476,9 +1464,9 @@ void named_arguments() : {
     return false;\r
   }\r
 \r
-  private boolean jj_3R_68() {\r
+  private boolean jj_3R_66() {\r
     if (jj_scan_token(21)) return true;\r
-    if (jj_3R_72()) return true;\r
+    if (jj_3R_70()) return true;\r
     return false;\r
   }\r
 \r
@@ -1516,13 +1504,13 @@ void named_arguments() : {
     return false;\r
   }\r
 \r
-  private boolean jj_3R_52() {\r
+  private boolean jj_3R_50() {\r
     if (jj_3R_14()) return true;\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_57()) jj_scanpos = xsp;\r
+    if (jj_3R_55()) jj_scanpos = xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_58()) jj_scanpos = xsp;\r
+    if (jj_3R_56()) jj_scanpos = xsp;\r
     return false;\r
   }\r
 \r
index ce3b612684e5278444e2415d1c3e0d07f1f4953f..e3884cf9580f0e0404b6892c2cec104dd51f7cf4 100644 (file)
@@ -191,7 +191,7 @@ void term() : {
 \r
 void factor() : {\r
 } {\r
-       primary() ( "^" primary() | ".^" primary() )?\r
+       primary() ( ( "^" | ".^" ) primary() )?\r
 }\r
 \r
 void mul_op() : {\r
index 87d62c8b3e63b09b0f4eb63a9f91591402899b10..5958ee17a9aba9de27b2162a405c2b35ff750d67 100644 (file)
@@ -382,7 +382,7 @@ public class OldSysdynExperiment extends SysdynExperiment {
         FunctionUtils.updateFunctionFilesForExperiment(this);\r
 \r
 \r
-        SimulationLocation location = ModelicaManager.createSimulationLocation(simulationDir, sysdynModel.getConfiguration().getLabel(), modelText);\r
+        SimulationLocation location = ModelicaManager.createSimulationLocation(simulationDir, sysdynModel.getConfiguration().getLabel(), modelText, ModelicaManager.getOMHome(), ModelicaManager.isOldOMVersion());\r
         if (fmu) {\r
                ModelicaManager.createFMUSimulationScripts(location, inits, additionalScript);\r
         }\r
diff --git a/dev-jkauttio/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiments.java b/dev-jkauttio/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiments.java
new file mode 100644 (file)
index 0000000..acbfdb5
--- /dev/null
@@ -0,0 +1,122 @@
+package org.simantics.sysdyn.manager;\r
+\r
+import java.util.concurrent.Semaphore;\r
+\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.eclipse.core.runtime.IStatus;\r
+import org.eclipse.core.runtime.NullProgressMonitor;\r
+import org.eclipse.core.runtime.SubMonitor;\r
+import org.simantics.Simantics;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.project.IProject;\r
+import org.simantics.simulation.experiment.ExperimentState;\r
+import org.simantics.simulation.experiment.IDynamicExperiment;\r
+import org.simantics.simulation.experiment.IExperiment;\r
+import org.simantics.simulation.model.ExperimentLoadingFailed;\r
+import org.simantics.simulation.project.IExperimentActivationListener;\r
+import org.simantics.simulation.project.IExperimentManager;\r
+import org.simantics.utils.DataContainer;\r
+\r
+public class SysdynExperiments {\r
+\r
+    public static String activateExperiment(IProgressMonitor monitor, final IProject project, final IExperimentManager manager, final Resource experimentResource) {\r
+       \r
+       if(monitor == null) monitor = new NullProgressMonitor();\r
+       \r
+        final SubMonitor mon = SubMonitor.convert(monitor, "Activating experiment", 100000);\r
+\r
+//        SysdynExperimentManagerListener.listenManager(manager);\r
+        IExperiment[] experiments = manager.getExperiments();\r
+        SubMonitor shutdownMon = mon.newChild(10000);\r
+        int workPerExperiment;\r
+        if (experiments.length > 0)\r
+               workPerExperiment = 10000 / experiments.length;\r
+        else\r
+               workPerExperiment = 10000;\r
+        for(IExperiment e : experiments)\r
+            if(e.getState() != ExperimentState.DISPOSED)\r
+                e.shutdown(shutdownMon.newChild(workPerExperiment));\r
+        mon.setWorkRemaining(90000);\r
+\r
+        final Semaphore activated = new Semaphore(0);\r
+        final DataContainer<Throwable> problem = new DataContainer<Throwable>();\r
+        final DataContainer<IExperiment> run = new DataContainer<IExperiment>();\r
+        manager.startExperiment(experimentResource, new IExperimentActivationListener() {\r
+\r
+            @Override\r
+            public void onExperimentActivated(final IExperiment experiment) {\r
+//                MessageService.defaultLog(new org.eclipse.core.runtime.Status(IStatus.INFO, "org.simantics.simulation.ui", 0, "Activated experiment " + experiment.getIdentifier() , null));\r
+                activated.release();\r
+                run.set(experiment);\r
+            }\r
+            @Override\r
+            public void onFailure(Throwable e) {\r
+                problem.set(e);\r
+                activated.release();\r
+            }\r
+            @Override\r
+            public void onMessage(IStatus message) {\r
+//                MessageService.getDefault().log(message);\r
+            }\r
+            @Override\r
+            public IProgressMonitor getProgressMonitor() {\r
+                return mon;\r
+            }\r
+        }, true);\r
+        try {\r
+            activated.acquire();\r
+            Throwable t = problem.get();\r
+            if (t != null) {\r
+                if (t instanceof ExperimentLoadingFailed) {\r
+//                    ErrorLogger.defaultLogError(t);\r
+//                    ShowMessage.showError("Experiment Activation Failed", t.getMessage());\r
+                } else {\r
+//                    ExceptionUtils.logAndShowError(t);\r
+                }\r
+            }\r
+\r
+            return run.get().getIdentifier();\r
+            //return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Experiment activation failed, see exception for details.", problem.get());\r
+        } catch (InterruptedException e) {\r
+            return null;\r
+        }\r
+    }\r
+       \r
+    \r
+    public static String activateExperiment(Resource experiment) throws DatabaseException {\r
+\r
+//     Resource experiment = Layer0Utils.getPossibleChild(graph, model, name);\r
+//     if( experiment == null) return false;\r
+\r
+//     SimulationResource SIMU = SimulationResource.getInstance(graph);\r
+//        if (!graph.isInstanceOf(experiment, SIMU.Experiment)) return false;\r
+        \r
+        final IProject project = Simantics.getProject();\r
+        if (project == null) return null;\r
\r
+        final IExperimentManager experimentManager = project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+        if(experimentManager == null) return null;\r
+        \r
+       return SysdynExperiments.activateExperiment(null, project, experimentManager, experiment);\r
+               \r
+       }\r
+    \r
+    public static void run(String experimentId) throws DatabaseException {\r
+\r
+        final IProject project = Simantics.getProject();\r
+        if (project == null) return;\r
\r
+        final IExperimentManager experimentManager = project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+        if(experimentManager == null) return;\r
+        \r
+        IExperiment experiment = experimentManager.getExperiment(experimentId);\r
+        if(experiment instanceof IDynamicExperiment)\r
+               ((IDynamicExperiment)experiment).simulate(true);\r
+        \r
+    }\r
+    \r
+\r
+    \r
+    \r
+}\r
index eb87c0d939c45040ad2996495739857f8906f646..5f89fce88f136ca1632d49a45e7f3f0c742a4670 100644 (file)
@@ -2170,13 +2170,13 @@ public class ModelParser implements ModelParserConstants {
         break;\r
       case 87:\r
         jj_consume_token(87);\r
-        primary();\r
         break;\r
       default:\r
         jj_la1[108] = jj_gen;\r
         jj_consume_token(-1);\r
         throw new ParseException();\r
       }\r
+      primary();\r
       break;\r
     default:\r
       jj_la1[109] = jj_gen;\r
@@ -2727,22 +2727,22 @@ public class ModelParser implements ModelParserConstants {
     return false;\r
   }\r
 \r
-  private boolean jj_3R_138() {\r
+  private boolean jj_3R_137() {\r
     if (jj_3R_46()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_136() {\r
+  private boolean jj_3R_135() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
     if (jj_scan_token(69)) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_138()) return true;\r
+    if (jj_3R_137()) return true;\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_132() {\r
+  private boolean jj_3R_131() {\r
     if (jj_scan_token(71)) return true;\r
     return false;\r
   }\r
@@ -2755,13 +2755,13 @@ public class ModelParser implements ModelParserConstants {
     return false;\r
   }\r
 \r
-  private boolean jj_3R_134() {\r
+  private boolean jj_3R_133() {\r
     if (jj_scan_token(66)) return true;\r
-    if (jj_3R_136()) return true;\r
+    if (jj_3R_135()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_131() {\r
+  private boolean jj_3R_130() {\r
     if (jj_scan_token(68)) return true;\r
     if (jj_scan_token(IDENT)) return true;\r
     return false;\r
@@ -2787,12 +2787,12 @@ public class ModelParser implements ModelParserConstants {
     return false;\r
   }\r
 \r
-  private boolean jj_3R_126() {\r
+  private boolean jj_3R_125() {\r
     if (jj_3R_46()) return true;\r
     Token xsp;\r
     while (true) {\r
       xsp = jj_scanpos;\r
-      if (jj_3R_132()) { jj_scanpos = xsp; break; }\r
+      if (jj_3R_131()) { jj_scanpos = xsp; break; }\r
     }\r
     return false;\r
   }\r
@@ -2802,7 +2802,7 @@ public class ModelParser implements ModelParserConstants {
     return false;\r
   }\r
 \r
-  private boolean jj_3R_137() {\r
+  private boolean jj_3R_136() {\r
     if (jj_scan_token(IDENT)) return true;\r
     if (jj_scan_token(88)) return true;\r
     return false;\r
@@ -2836,32 +2836,32 @@ public class ModelParser implements ModelParserConstants {
     return false;\r
   }\r
 \r
-  private boolean jj_3R_135() {\r
-    if (jj_3R_137()) return true;\r
+  private boolean jj_3R_134() {\r
+    if (jj_3R_136()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_130() {\r
-    if (jj_3R_134()) return true;\r
+  private boolean jj_3R_129() {\r
+    if (jj_3R_133()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_133() {\r
-    if (jj_3R_135()) return true;\r
+  private boolean jj_3R_132() {\r
+    if (jj_3R_134()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_124() {\r
+  private boolean jj_3R_123() {\r
     if (jj_3R_63()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_128() {\r
+  private boolean jj_3R_127() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
     if (jj_3_10()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_133()) return true;\r
+    if (jj_3R_132()) return true;\r
     }\r
     return false;\r
   }\r
@@ -2880,8 +2880,8 @@ public class ModelParser implements ModelParserConstants {
     return false;\r
   }\r
 \r
-  private boolean jj_3R_129() {\r
-    if (jj_3R_128()) return true;\r
+  private boolean jj_3R_128() {\r
+    if (jj_3R_127()) return true;\r
     return false;\r
   }\r
 \r
@@ -2889,7 +2889,7 @@ public class ModelParser implements ModelParserConstants {
     if (jj_scan_token(62)) return true;\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_129()) jj_scanpos = xsp;\r
+    if (jj_3R_128()) jj_scanpos = xsp;\r
     if (jj_scan_token(63)) return true;\r
     return false;\r
   }\r
@@ -2935,21 +2935,21 @@ public class ModelParser implements ModelParserConstants {
     return false;\r
   }\r
 \r
-  private boolean jj_3R_125() {\r
+  private boolean jj_3R_124() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
     if (jj_scan_token(68)) jj_scanpos = xsp;\r
     if (jj_scan_token(IDENT)) return true;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_130()) jj_scanpos = xsp;\r
+    if (jj_3R_129()) jj_scanpos = xsp;\r
     while (true) {\r
       xsp = jj_scanpos;\r
-      if (jj_3R_131()) { jj_scanpos = xsp; break; }\r
+      if (jj_3R_130()) { jj_scanpos = xsp; break; }\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_127() {\r
+  private boolean jj_3R_126() {\r
     if (jj_scan_token(70)) return true;\r
     return false;\r
   }\r
@@ -2996,12 +2996,6 @@ public class ModelParser implements ModelParserConstants {
     return false;\r
   }\r
 \r
-  private boolean jj_3R_123() {\r
-    if (jj_scan_token(87)) return true;\r
-    if (jj_3R_113()) return true;\r
-    return false;\r
-  }\r
-\r
   private boolean jj_3R_106() {\r
     if (jj_3R_63()) return true;\r
     return false;\r
@@ -3012,8 +3006,9 @@ public class ModelParser implements ModelParserConstants {
     xsp = jj_scanpos;\r
     if (jj_scan_token(86)) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_123()) return true;\r
+    if (jj_scan_token(87)) return true;\r
     }\r
+    if (jj_3R_113()) return true;\r
     return false;\r
   }\r
 \r
@@ -3025,18 +3020,18 @@ public class ModelParser implements ModelParserConstants {
 \r
   private boolean jj_3R_122() {\r
     if (jj_scan_token(64)) return true;\r
-    if (jj_3R_128()) return true;\r
+    if (jj_3R_127()) return true;\r
     if (jj_scan_token(65)) return true;\r
     return false;\r
   }\r
 \r
   private boolean jj_3R_121() {\r
     if (jj_scan_token(66)) return true;\r
-    if (jj_3R_126()) return true;\r
+    if (jj_3R_125()) return true;\r
     Token xsp;\r
     while (true) {\r
       xsp = jj_scanpos;\r
-      if (jj_3R_127()) { jj_scanpos = xsp; break; }\r
+      if (jj_3R_126()) { jj_scanpos = xsp; break; }\r
     }\r
     if (jj_scan_token(67)) return true;\r
     return false;\r
@@ -3057,7 +3052,7 @@ public class ModelParser implements ModelParserConstants {
   private boolean jj_3R_118() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_124()) {\r
+    if (jj_3R_123()) {\r
     jj_scanpos = xsp;\r
     if (jj_scan_token(58)) {\r
     jj_scanpos = xsp;\r
@@ -3069,7 +3064,7 @@ public class ModelParser implements ModelParserConstants {
   }\r
 \r
   private boolean jj_3R_119() {\r
-    if (jj_3R_125()) return true;\r
+    if (jj_3R_124()) return true;\r
     return false;\r
   }\r
 \r
index 04e39995d9fe22ca8264cc541f5cc80f242e00bc..e780b8a56ee219575bdf180cae69c3394c9b6cae 100644 (file)
@@ -628,7 +628,7 @@ void mul_op() : {
 \r
 void factor() : {\r
 } {\r
-       primary() ( "^" | ".^" primary() )?\r
+       primary() ( ( "^" | ".^" ) primary() )?\r
 }\r
 \r
 void primary() : {\r
index 186c92a5655a14fafdcc75775705137494601cb5..fc9415c7cc496a34973603fc321c8d91dfbe59f5 100644 (file)
@@ -14,6 +14,7 @@ package org.simantics.sysdyn.modelica;
 import java.util.ArrayList;\r
 import java.util.Collection;\r
 import java.util.Collections;\r
+import java.util.Comparator;\r
 import java.util.HashMap;\r
 import java.util.HashSet;\r
 import java.util.List;\r
@@ -47,7 +48,34 @@ public class ModelicaWriter {
      * @param Configurations Configurations, one main configuration and possible modules\r
      * @return Complete Modelica code of a model\r
      */\r
-    public static String write(Collection<Configuration> configurations, boolean isGame, String omVersion) {\r
+    public static String write(Collection<Configuration> _configurations, boolean isGame, String omVersion) {\r
+       \r
+       ArrayList<Configuration> configurations = new ArrayList<Configuration>(_configurations);\r
+       Collections.sort(configurations, new Comparator<Configuration>() {\r
+\r
+               boolean uses(Configuration o1, Configuration o2) {\r
+                       ModuleType type = o2.getModuleType();\r
+                       if(type == null) return false;\r
+                       for(IElement e : o1.getElements()) {\r
+                               if(e instanceof Module) {\r
+                                       Module m = (Module)e;\r
+                                       if(m.getType().equals(type)) {\r
+                                               return true;\r
+                                       }\r
+                               }\r
+                       }\r
+                       return false;\r
+               }\r
+               \r
+                       @Override\r
+                       public int compare(Configuration o1, Configuration o2) {\r
+                       if(uses(o1, o2)) return 1;\r
+                       else if(uses(o2, o1)) return -1;\r
+                       else return 0;\r
+                       }\r
+                       \r
+               });\r
+       \r
         Configuration modelConf = null;\r
         for(Configuration conf : configurations) {\r
             if(conf.getModel() != null) {\r
@@ -209,6 +237,14 @@ public class ModelicaWriter {
         \r
         b.append("\n");\r
 \r
+\r
+        if(!enumerations.isEmpty()) {\r
+            b.append("// Enumeration definitions\n");\r
+            for(Enumeration e : enumerations) {\r
+                b.append(e.getDeclaration());\r
+            }\r
+        }\r
+\r
         b.append("// Variable definitions\n");\r
         for(IndependentVariable variable : variables) {\r
             app = variable.getDeclaration();\r
@@ -239,13 +275,6 @@ public class ModelicaWriter {
         // Input definitions\r
         inputDefinitions(b, configuration, inputs, inputReferences);\r
 \r
-        if(!enumerations.isEmpty()) {\r
-            b.append("// Enumeration definitions\n");\r
-            for(Enumeration e : enumerations) {\r
-                b.append(e.getDeclaration());\r
-            }\r
-        }\r
-\r
         boolean initialEquations = false;\r
         for(Stock stock : stocks) {\r
             app = stock.getInitialEquation();\r
index 91358b71c093d8dddc72b5826e573800ea61563d..3842234c2c1f62549ae69e66494f0af896e6544c 100644 (file)
@@ -89,5 +89,14 @@ public class Shadow extends Variable {
     public String getDocumentationDefinition(ReadGraph graph) throws DatabaseException {\r
         return null;\r
     }\r
+    \r
+    @Override\r
+    public String getModelicaName() {\r
+        if(getOriginal() != null)\r
+            return getOriginal().getModelicaName();\r
+        else\r
+            return super.getModelicaName();\r
+    }\r
+    \r
 }\r
 \r
index 4c00a72e0115f14d02e47945516bb0a2dc2fb88d..7144a00c3a7b4db0718882145a91f72ab3d7e76c 100644 (file)
@@ -1,5 +1,6 @@
 package org.simantics.sysdyn.solver;\r
 \r
+import java.io.File;\r
 import java.util.HashMap;\r
 \r
 import org.simantics.modelica.ModelicaManager;\r
@@ -11,11 +12,14 @@ import org.simantics.sysdyn.manager.SysdynModel;
 import org.simantics.sysdyn.modelica.ModelicaWriter;\r
 import org.simantics.sysdyn.representation.Model;\r
 import org.simantics.sysdyn.solver.SolverSettings.SolverType;\r
+import org.simantics.utils.FileUtils;\r
 \r
 import fi.semantum.sysdyn.solver.Solver;\r
 \r
 public class InternalSolver implements ISolver {\r
 \r
+       public static final boolean PRINT_CODE = false;\r
+       \r
        private SysdynExperiment experiment;\r
        private SysdynModel model;\r
        private ISolverMonitor monitor;\r
@@ -46,14 +50,14 @@ public class InternalSolver implements ISolver {
 \r
        @Override\r
        public void initialize() throws Exception {\r
-               String omVersion = ModelicaManager.getDefaultOMVersion();\r
-               String modelContent = ModelicaWriter.write(model.getModules(), false, omVersion);\r
+//             String omVersion = ModelicaManager.getDefaultOMVersion();\r
+               String modelContent = ModelicaWriter.write(model.getModules(), false, "1.9");\r
 \r
                // update some stuff\r
                FunctionUtils.updateFunctionFilesForExperiment(experiment);\r
 \r
                location = ModelicaManager.createSimulationLocation(experiment.getExperimentDir(), \r
-                               model.getConfiguration().getLabel(), modelContent);\r
+                               model.getConfiguration().getLabel(), modelContent, null, false);\r
                \r
                // set solver parameters\r
                Model representation = model.getConfiguration().getModel();\r
@@ -80,12 +84,34 @@ public class InternalSolver implements ISolver {
 \r
        @Override\r
        public void buildModel() throws Exception {\r
-               String flat = ModelicaManager.getFlatModelText(location, monitor, FunctionUtils.getLibraryPathsForModelica(experiment));\r
-               solver.prepare(flat);\r
+               \r
+//             String flat = ModelicaManager.getFlatModelText(location, monitor, FunctionUtils.getLibraryPathsForModelica(experiment));\r
+//             System.err.println("=== FLAT ===");\r
+//             System.err.println(flat);\r
+//             System.err.println("=== FLAT ENDS ===");\r
+               \r
+               StringBuilder code = new StringBuilder();\r
+               for(String path : FunctionUtils.getLibraryPathsForModelica(experiment)) {\r
+                       File f = new File(location.modelFile.getParentFile(), path);\r
+                       code.append(FileUtils.getContents(f));\r
+               }\r
+               code.append(FileUtils.getContents(location.modelFile));\r
+               \r
+               if(PRINT_CODE) {\r
+                       System.err.println("=== CODE === ");\r
+                       System.err.println(code.toString());\r
+                       System.err.println("=== CODE ENDS ===");\r
+               }\r
+\r
+               solver.prepare(code.toString());\r
+               \r
        }\r
 \r
        @Override\r
        public void runSolver() throws Exception {\r
+               \r
+               long startTime = System.nanoTime();\r
+               \r
                // the number of result intervals in the simulation (account for initial values)\r
                int count = (int)((stop - start) / interval) + 1;\r
                // the number of steps in one result interval\r
@@ -94,13 +120,22 @@ public class InternalSolver implements ISolver {
                // an array containing an accurate time stamp for each interval\r
                double[] times = new double[count];\r
                // a map containing values of all variables for each interval\r
-               HashMap<String, double[]> values = new HashMap<String, double[]>();\r
+\r
+               String[] keys = solver.keys();\r
+\r
+               double[][] values = new double[keys.length][];\r
+               \r
+//             HashMap<String, double[]> values = new HashMap<String, double[]>();\r
                // initialize the temporary data structures\r
                times[0] = start;\r
-               HashMap<String, Double> tmp = solver.values();\r
-               for (String key : tmp.keySet()) {\r
-                       values.put(key, new double[count]);\r
-                       values.get(key)[0] = tmp.get(key);\r
+               \r
+               double[] valueArray = solver.values();\r
+//             HashMap<String, Double> tmp = solver.values();\r
+//             String[] keys = new ArrayList<String>(tmp.keySet()).toArray(new String[tmp.size()]);\r
+\r
+               for(int i=0;i<keys.length;i++) {\r
+                       values[i] = new double[count];\r
+                       values[i][0] = valueArray[i];\r
                }\r
                \r
                // run the simulation\r
@@ -109,16 +144,29 @@ public class InternalSolver implements ISolver {
                                solver.step();\r
                        }\r
                        times[interval] = times[interval-1] + steps * step;\r
-                       tmp = solver.values();\r
-                       for (String key : tmp.keySet()) {\r
-                               values.get(key)[interval] = tmp.get(key);\r
+\r
+                       valueArray = solver.values();\r
+                       for(int i=0;i<keys.length;i++) {\r
+                               values[i][interval] = valueArray[i];\r
                        }\r
+                       \r
                }\r
 \r
                results = new HashMap<String, SysdynDataSet>();\r
-               for (String name : values.keySet()) {\r
-                       results.put(name, new SysdynDataSet(name, null, times, values.get(name)));\r
+               for(int i=0;i<keys.length;i++) {\r
+                       String name = keys[i];\r
+                       double[] arr = values[i];\r
+                       results.put(name, new SysdynDataSet(name, null, times, arr));\r
                }\r
+\r
+//             for (String name : values.keySet()) {\r
+//                     results.put(name, new SysdynDataSet(name, null, times, values.get(name)));\r
+//             }\r
+               \r
+               long endTime = System.nanoTime();\r
+               \r
+               System.err.println("ran simulation in " + 1e-6*(endTime-startTime) + "ms.");\r
+               \r
        }\r
 \r
        @Override\r
index 9c80432225862ad319dcfb7ff6c9e42c1b38f3b7..e12c6e3d97d019adb7b59331e35240e5bfbc72c0 100644 (file)
@@ -21,12 +21,14 @@ public class SysdynSimulationJob extends Job {
        protected String name;\r
        protected SysdynExperiment experiment;\r
        protected ISolver solver;\r
+       protected ISolverMonitor solverMonitor;\r
 \r
        public SysdynSimulationJob(String name, SysdynExperiment experiment) {\r
                super(name);\r
                this.name = name;\r
                this.experiment = experiment;\r
                this.solver = null;\r
+               this.solverMonitor = SysdynConsole.INSTANCE;\r
        }\r
 \r
        @Override\r
@@ -60,7 +62,7 @@ public class SysdynSimulationJob extends Job {
                // has changed, a new solver must be created\r
                if (solver == null || !solver.getType().equals(type)) {\r
                        if (SolverType.INTERNAL.equals(type)) {\r
-                               solver = new InternalSolver(experiment, experiment.sysdynModel, SysdynConsole.INSTANCE);\r
+                               solver = new InternalSolver(experiment, experiment.sysdynModel, solverMonitor);\r
                        }\r
                        else if (SolverType.OPENMODELICA.equals(type)) {\r
                                return new Status(Status.ERROR, pluginId, "The experiment should be reloaded");\r
index 296c0ddd62e31401d45b06374d956a947711a365..b3e3960975acb0bd587829d36c53fa6bdf3cb2b8 100644 (file)
@@ -6,21 +6,30 @@ import java.util.Collections;
 import java.util.Comparator;\r
 import java.util.Date;\r
 import java.util.List;\r
+import java.util.concurrent.TimeUnit;\r
 \r
 import org.eclipse.core.runtime.NullProgressMonitor;\r
+import org.simantics.Simantics;\r
 import org.simantics.databoard.Bindings;\r
 import org.simantics.databoard.util.Base64;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.common.request.ObjectsWithSupertype;\r
+import org.simantics.db.common.request.UniqueRead;\r
+import org.simantics.db.common.request.WriteRequest;\r
 import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.EvaluatingListener;\r
+import org.simantics.db.layer0.util.EvaluatingListener.Criterion;\r
+import org.simantics.db.layer0.util.EvaluatingListener.Evaluation;\r
 import org.simantics.db.layer0.variable.Variables;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.modeling.ModelingResources;\r
+import org.simantics.scl.runtime.function.FunctionImpl1;\r
 import org.simantics.simulation.ontology.SimulationResource;\r
 import org.simantics.structural.stubs.StructuralResource2;\r
 import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.adapter.ValueIndexVariable;\r
 import org.simantics.sysdyn.manager.SysdynModel;\r
 import org.simantics.sysdyn.manager.SysdynModelManager;\r
 import org.simantics.sysdyn.representation.Book;\r
@@ -33,6 +42,7 @@ import org.simantics.sysdyn.representation.Stock;
 import org.simantics.sysdyn.representation.Variability;\r
 import org.simantics.sysdyn.representation.Variable;\r
 import org.simantics.sysdyn.utils.imports.ImportUtils;\r
+import org.simantics.utils.DataContainer;\r
 \r
 public class DocumentationUtils {\r
     \r
@@ -469,8 +479,18 @@ public class DocumentationUtils {
      * \r
      * @param path\r
      */\r
-    public static void importModel(String path) {\r
-        ImportUtils.importModelFile(path, new NullProgressMonitor());\r
+    public static Resource importModel(String path) {\r
+       final DataContainer<Resource> m = new DataContainer<Resource>();\r
+        ImportUtils.importModelFile(path, new NullProgressMonitor(), new FunctionImpl1<Resource,WriteRequest>() {\r
+\r
+               @Override\r
+               public WriteRequest apply(Resource model) {\r
+                       m.set(model);\r
+                       return null;\r
+               }\r
+               \r
+        });\r
+        return m.get();\r
     }\r
 \r
     public static boolean isParameter(ReadGraph graph, org.simantics.db.layer0.variable.Variable variable) throws DatabaseException {\r
@@ -492,4 +512,43 @@ public class DocumentationUtils {
         Resource expression = expressions.get(0);\r
         return graph.isInstanceOf(expression, SR.ParameterExpression);\r
     }\r
+    \r
+    public static double lastValue(final Resource experiment, final String runId, final String path) throws DatabaseException {\r
+       \r
+               try {\r
+                       double[] values = EvaluatingListener.<double[]>trySyncRequest(Simantics.getSession(),\r
+                                       \r
+                                       new UniqueRead<double[]>(){\r
+                                               @SuppressWarnings("unchecked")\r
+                                               @Override\r
+                                               public double[] perform(ReadGraph graph) throws DatabaseException{\r
+                                                       \r
+                                               org.simantics.db.layer0.variable.Variable var = Variables.getVariable(graph, experiment);\r
+                                               if(var == null) return null;\r
+                                               org.simantics.db.layer0.variable.Variable run = var.getPossibleChild(graph, runId);\r
+                                               if(run == null) return null;\r
+                                               org.simantics.db.layer0.variable.Variable v = run.browsePossible(graph, path + "#value#");\r
+                                               if(v == null) return null;\r
+                                               return  v.getPossibleValue(graph);\r
+                                                       \r
+                                               }               \r
+                                       }, \r
+                                       new Criterion<double[]>() {\r
+\r
+                                               @Override\r
+                                               public Evaluation evaluate(double[] result) {\r
+                                                       if(result == null) return Evaluation.DISCARD;\r
+                                                       return (result != ValueIndexVariable.UNRESOLVED) ? Evaluation.ACCEPT : Evaluation.IGNORE;\r
+                                               }\r
+                                               \r
+                                       },\r
+                                       15, TimeUnit.SECONDS);\r
+                       return values[0];\r
+               } catch (InterruptedException e) {\r
+                       e.printStackTrace();\r
+                       return Double.NaN;\r
+               }\r
+       \r
+    }\r
+    \r
 }\r
index bedd3247a46ce04f6e8409acadc91bd75ce4b102..21fce962f991ab0d4a7f7eb5a3889567efb4de6a 100644 (file)
@@ -72,7 +72,6 @@ public class Function implements Comparable<Function>{
                                output = (UnitCheckingNode) outputParser.expr();\r
                                outputReader.close();\r
                    result.appendResult(output.getUnits(null, functions, allowEquivalents));\r
-                               result.setUnitType(UnitType.NORMAL);\r
                        } catch (UnitCheckingException e) {\r
                                e.printStackTrace();\r
                        } catch (ParseException e) {\r
@@ -91,7 +90,7 @@ public class Function implements Comparable<Function>{
                while ((index = ret.indexOf('\'')) >= 0) {\r
                        String replaced = ret.substring(index, index + 2); // The replaced units are always of length 2.\r
                        try {\r
-                               ret = ret.replace(replaced, correspondences.get(replaced));\r
+                               ret = ret.replace(replaced, "(" + correspondences.get(replaced) + ")");\r
                        } catch (NullPointerException npe) {\r
                                throw new UnitCheckingException("Function " + f.getName() + " output unit could not be determined. Replacement unit " \r
                                                + replaced + " not found in input unit definitions.");\r
diff --git a/dev-jkauttio/org.simantics.sysdyn/testModels/MaintenanceModel_2012-12-03.tg b/dev-jkauttio/org.simantics.sysdyn/testModels/MaintenanceModel_2012-12-03.tg
new file mode 100644 (file)
index 0000000..e869a12
Binary files /dev/null and b/dev-jkauttio/org.simantics.sysdyn/testModels/MaintenanceModel_2012-12-03.tg differ
diff --git a/dev-jkauttio/org.simantics.sysdyn/testModels/Model1412Health.tg b/dev-jkauttio/org.simantics.sysdyn/testModels/Model1412Health.tg
new file mode 100644 (file)
index 0000000..8635b39
Binary files /dev/null and b/dev-jkauttio/org.simantics.sysdyn/testModels/Model1412Health.tg differ
diff --git a/dev-jkauttio/org.simantics.sysdyn/testModels/WorkModel_2012-12-03.tg b/dev-jkauttio/org.simantics.sysdyn/testModels/WorkModel_2012-12-03.tg
new file mode 100644 (file)
index 0000000..781a161
Binary files /dev/null and b/dev-jkauttio/org.simantics.sysdyn/testModels/WorkModel_2012-12-03.tg differ
diff --git a/dev-jkauttio/org.simantics.sysdyn/testModels/openprod_demo_2012-12-03.tg b/dev-jkauttio/org.simantics.sysdyn/testModels/openprod_demo_2012-12-03.tg
new file mode 100644 (file)
index 0000000..bf98e97
Binary files /dev/null and b/dev-jkauttio/org.simantics.sysdyn/testModels/openprod_demo_2012-12-03.tg differ
diff --git a/dev-jkauttio/org.simantics.sysdyn/testModels/references.txt b/dev-jkauttio/org.simantics.sysdyn/testModels/references.txt
new file mode 100644 (file)
index 0000000..b35e14b
--- /dev/null
@@ -0,0 +1,5 @@
+The models in this folder are made by Sampsa Ruutu (openprod_demo), \r
+Tero Jokinen (MaintenanceModel, WorkModel), and Ossi Koivula \r
+(HealthModel). Health model and openprod_demo seem to be broken in \r
+newer versions of the tool. The models are not distributed with the \r
+installer, even though they're probably public. 
\ No newline at end of file