From 251d4240dcd618088ad6ff58e83b0aaed78726dc Mon Sep 17 00:00:00 2001 From: villberg Date: Tue, 9 Dec 2014 09:49:59 +0000 Subject: [PATCH] (refs #5538) Initial equations are evaluated during experiment run in Simupedia git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@30665 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../src/fi/semantum/sysdyn/solver/Solver.java | 16 +++++++++------- .../src/fi/semantum/sysdyn/solver/Variable.java | 16 +++++++++++++++- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Solver.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Solver.java index 591ba337..fd5e1245 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Solver.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Solver.java @@ -252,14 +252,14 @@ public class Solver { // Object value = assignments[i].expression.evaluate(env); // assignments[i].target.assign(env, assignments[i].subscripts, value); } - for(Assignment ass : model.initials) { - if(ass.isConstant) continue; - ass.assign(env); -// Object value = ass.expression.evaluate(env); -// ass.target.assign(env, ass.subscripts, value); - } - + if (!started) { + + for(Assignment ass : model.initials) { + if(ass.isConstant) continue; + ass.assign(env); + } + for(VariableDeclaration vd : model.variables) { try { for(Argument arg : vd.modification.args) { @@ -300,6 +300,8 @@ public class Solver { public void step() { + System.err.println("step @ " + getTime()); + // printEnvironment(); // // new Exception().printStackTrace(); diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Variable.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Variable.java index 581ccecb..abc6700e 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Variable.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Variable.java @@ -20,6 +20,7 @@ public class Variable implements IExpression { public VariableBase base; public IExpression[] subscripts = null; public int line = -1; + public VariableDeclaration decl = null; public Variable(IFrame frame, String name, IExpression[] subscripts, int line) { base = frame.getBase(name); @@ -43,7 +44,20 @@ public class Variable implements IExpression { this.base = base; this.subscripts = subscripts; } - + + public VariableDeclaration getDeclaration(Model model) { + if(decl == null) { + for(VariableDeclaration d : model.variables) { + if(d.variable.base.name.equals(base.name)) { + decl = d; + break; + } + } + } + return decl; + + } + @Override public String toString() { // updated to print the double value as an integer value in subscripts -- 2.47.1