/*******************************************************************************\r
- * Copyright (c) 2007, 2012 Association for Decentralized Information Management in\r
+ * Copyright (c) 2007, 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
* Variability of a variable in system dynamics models. \r
* \r
* @author Teemu Lempinen\r
+ * @author Tuomas Miettinen\r
*\r
*/\r
public enum Variability {\r
* @return Variabilty of a variable\r
*/\r
static public Variability getVariability(IndependentVariable variable) {\r
- if(RepresentationUtils.isPartOfGameExperiment(variable) && !(variable instanceof Stock)) {\r
- \r
- /* \r
- * Game experiments cannot use as many parameter variables as normal experiments.\r
- * If a parameter variable is changed, other parameter values depending on that \r
- * parameter value are not automatically changed.\r
- * \r
- * Something of a hack: \r
- * Allow variable references, if there are not incoming dependencies to the variable.\r
- * This enables the use of derived variables for initial values of stocks.\r
- */\r
- if(variable.getIncomingDependencies() == null || variable.getIncomingDependencies().isEmpty())\r
- return getVariability(variable, true, null);\r
- else\r
- return getVariability(variable, false, null);\r
- } else {\r
- return getVariability(variable, true, null);\r
+ try {\r
+ if(RepresentationUtils.isPartOfGameExperiment(variable) && !(variable instanceof Stock)) {\r
+ \r
+ /* \r
+ * Game experiments cannot use as many parameter variables as normal experiments.\r
+ * If a parameter variable is changed, other parameter values depending on that \r
+ * parameter value are not automatically changed.\r
+ * \r
+ * Something of a hack: \r
+ * Allow variable references, if there are not incoming dependencies to the variable.\r
+ * This enables the use of derived variables for initial values of stocks.\r
+ */\r
+ if(variable.getIncomingDependencies() == null || variable.getIncomingDependencies().isEmpty())\r
+ return getVariability(variable, true, null);\r
+ else\r
+ return getVariability(variable, false, null);\r
+ } else {\r
+ return getVariability(variable, true, null);\r
+ }\r
+ } catch (StackOverflowError e) {\r
+ // For circular dependencies; selecting continuous for a good guess.\r
+ return Variability.CONTINUOUS;\r
}\r
}\r
\r