import gnu.trove.map.hash.TObjectIntHashMap;\r
\r
import java.util.ArrayList;\r
-import java.util.Arrays;\r
import java.util.Collection;\r
import java.util.HashMap;\r
import java.util.HashSet;\r
Double d = (Double)environment.getValue(i);\r
dims[i] = d.intValue();\r
}\r
- System.err.println("zeros " + Arrays.toString(dims));\r
return make(dims, 0);\r
}\r
\r
\r
public class Solver {\r
\r
+ private static final boolean VALIDATE = false; \r
private static final boolean PRINT_EXCEPTIONS = false; \r
private static final int STACK_SIZE = 1000;\r
private static final int MAX_LOOPS = 50;\r
private String codeCache = null;\r
\r
private void validate(Variable var, Object value) {\r
- if(value instanceof Double) {\r
- if(Double.isNaN((Double)value)) {\r
- throw new IllegalStateException("value is invalid (NaN)");\r
+ if(VALIDATE) {\r
+ if(value instanceof Double) {\r
+ if(Double.isNaN((Double)value)) {\r
+ throw new IllegalStateException("value is invalid (NaN)");\r
+ }\r
+ }\r
+ if(value instanceof Array) {\r
+ for(Object o : ((Array)value).elements()) validate(var, o);\r
}\r
- }\r
- if(value instanceof Array) {\r
- for(Object o : ((Array)value).elements()) validate(var, o);\r
}\r
}\r
\r
ass.target.assign(env, ass.subscripts, value);\r
}\r
\r
- // Solve initial values\r
for(VariableDeclaration vd : model.variables) {\r
try {\r
for(Argument arg : vd.modification.args) {\r
if(arg.name.endsWith("start")) {\r
Object value = arg.modification.evaluate(env);\r
if(vd.variable.base.dimension() == 1) {\r
+ validate(vd.variable, value);\r
vd.variable.assign(env, null, value);\r
} else {\r
+ validate(vd.variable, value);\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 if (value instanceof Array) {\r
+ vd.variable.assign(env, null, value);\r
} else {\r
throw new IllegalStateException();\r
}\r