package main; import java.io.*; import parameters.ParameterSetArray; import java.util.Random; /** Contains all the global parameters of our model which */ public class Globals extends Object { // Note - mostly, the numbers here are defaults that should be overridden in the input file /** The maximum number of parameters for all the affectors */ static public int maxNumParams = 1000; // Note - we should clean up the code eventually so this is no longer neccesary /** The number of sides that each cell has */ static public int cellNumSides = 6; /** Something for the integrator (?) */ static public int numIntegratorSteps = 6; /** The current time in the integration */ static public float time = 0.0f; /** Some scaling adjustment, sort of like a partial non-dimensionalization for some affectors */ static public float characteristicTime = 1.0f; /** The maximum number of nodes - like maxNumParams, we should clean this out of the code eventually */ static public int maxNumNodes = 1000; /** The integration algorithm to use in running models. This can be overridden by an iterator. */ static public String integrationAlgorithm = "CashKarp"; /** The amount of time to run a model when the user selects Run from the menu. */ static public float runTime = 1000f; /** The name of the currently loaded model file */ static public String modelFilename = ""; /** The lastModified time for current model file */ static public long modelChangeTime = 0; /** The currently selected cam object - put here so it can be used in other places in program, like in iterators */ static ParameterSetArray curParamSetArray = null; /** A secondarily selected cam object, used by some statistics. */ static ParameterSetArray compareParamSetArray = null; static ParameterSetArray [] paramSetArrays = null; /** Set to true if GeneNet is being run with gui, false otherwise */ static public boolean usingGUI = true; static public int flag = 0; // For debugging static public Random rng = new Random(); static public GeneNet mainProgram = null; // Kind of a kludge - used currently by NodeListModel to find out when network changes /** True when a script is running. */ static public boolean scriptRunning = false; static public void setModelFile(String str, long t) { modelFilename = str; modelChangeTime = t; } static public String getModelFile() { return new String(modelFilename + "\t" + (new Long(modelChangeTime)).toString()); } static public String getModelName() { return new String(modelFilename); } static public void addParamSetArray(ParameterSetArray a) { if(paramSetArrays == null) paramSetArrays = new ParameterSetArray[1]; else { ParameterSetArray [] temp = new ParameterSetArray[paramSetArrays.length + 1]; System.arraycopy(paramSetArrays, 0, temp, 0, paramSetArrays.length); paramSetArrays = temp; } paramSetArrays[paramSetArrays.length - 1] = a; } static public int getNumParamSetArrays() { return paramSetArrays.length; } static public ParameterSetArray getParamSetArray(int pos) { return paramSetArrays[pos]; } static public ParameterSetArray getParamSetArray(String name) { int i = 0; while(i < getNumParamSetArrays() && !getParamSetArray(i).getFilename().equals(name)) i++; if(i == Globals.getNumParamSetArrays()) return null; else return getParamSetArray(i); } static public void setCurParamSetArray(ParameterSetArray a) { curParamSetArray = a; } static public void setCurParamSetArray(String name) { curParamSetArray = getParamSetArray(name); } static public ParameterSetArray getCurParamSetArray() { return curParamSetArray; } static public void setCompareParamSetArray(ParameterSetArray a) { compareParamSetArray = a; } static public void setCompareParamSetArray(String name) { compareParamSetArray = getParamSetArray(name); } static public ParameterSetArray getCompareParamSetArray() { return compareParamSetArray; } static public void removeParamSetArray(ParameterSetArray a) { int i = 0; while(i < getNumParamSetArrays() && getParamSetArray(i) != a) i++; if(i < Globals.getNumParamSetArrays()) { getParamSetArray(i).deleting(); // Tell it that its going ParameterSetArray [] temp = new ParameterSetArray[paramSetArrays.length - 1]; System.arraycopy(paramSetArrays, 0, temp, 0, i); System.arraycopy(paramSetArrays, i + 1, temp, i, paramSetArrays.length - i - 1); paramSetArrays = temp; } } static public void setUsingGUI(boolean b) { usingGUI = b; } static public boolean getUsingGUI() { return usingGUI; } static public void setMainProgram(GeneNet gn) { mainProgram = gn; } static public GeneNet getMainProgram() { return mainProgram; } static public String getIntegrationAlgorithm() { return integrationAlgorithm; } static public void setIntegrationAlgorithm(String str) { integrationAlgorithm = str; } static public float getRunTime() { return runTime; } static public void setRunTime(float t) { runTime = t; } static public boolean isScriptRunning() { return scriptRunning; } static public void setScriptRunning(boolean running) { scriptRunning = running; } public void finalize() throws Throwable { super.finalize(); } }