package initialconditions; import java.lang.*; import java.io.*; import main.BetterTokenizer; import main.Cell; import main.GeneralInput; /**
Input Parameters:
Node
Value
LowToHighDifference
StartLowCell
StepSize
NumRows

*/ public class NeuroNoiseIC extends InitialCondition { float lowToHighDifference = 2f; float startLowCell = 0.05f, stepSize = 0.05f; int numRows = 5, rowWidth = 6; String [] nodes = new String[4]; int numNodes = 0; public NeuroNoiseIC() { super(); } public void setModel(Cell [] cells) { // Note that in this code I am assuming rowWidth cells wide and two cell rows per active // row, with the second row the active one. int row, n; Cell cell; try { float low_value = startLowCell; for(row = 0; row < numRows; row++) { // The low column cell = cells[(row * 2 + 1) * rowWidth + 1]; for(n = 0; n < numNodes; n++) { cell.setInitialValue(cells[0].getNodeNum(nodes[n]), low_value); } // The control column cell = cells[(row * 2 + 1) * rowWidth + 4]; for(n = 0; n < numNodes; n++) { cell.setInitialValue(cells[0].getNodeNum(nodes[n]), low_value); } // The high column cell = cells[(row * 2 + 1) * rowWidth + 2]; for(n = 0; n < numNodes; n++) { cell.setInitialValue(cells[0].getNodeNum(nodes[n]), low_value * lowToHighDifference); } low_value += stepSize; } } catch(Exception e) { System.out.println(e.toString()); return; } } protected void loadParameter(String info, BetterTokenizer tokenizer) throws Exception { if(info.equals("Node")) { if(numNodes == nodes.length) { // If too many nodes, expand arrays String [] temp_nodes = new String[numNodes + 4]; System.arraycopy(nodes, 0, temp_nodes, 0, numNodes); nodes = temp_nodes; } GeneralInput.nextToken(tokenizer); nodes[numNodes] = tokenizer.sval; numNodes++; } else if(info.equals("LowToHighDifference")) { GeneralInput.nextToken(tokenizer); lowToHighDifference = (float)tokenizer.nval; } else if(info.equals("StartLowCell")) { GeneralInput.nextToken(tokenizer); startLowCell = (float)tokenizer.nval; } else if(info.equals("StepSize")) { GeneralInput.nextToken(tokenizer); stepSize = (float)tokenizer.nval; } else if(info.equals("NumRows")) { GeneralInput.nextToken(tokenizer); numRows = (int)tokenizer.nval; } else super.loadParameter(info, tokenizer); } public void toString(PrintWriter pw, String indent) { // Don't want in this IC super.toString(pw, indent); for(int i = 0; i < numNodes; i++) pw.println(indent + "&Node\t" + nodes[i]); pw.println(indent + "&LowToHighDifference\t" + lowToHighDifference); pw.println(indent + "&StartLowCell\t" + startLowCell); pw.println(indent + "&StepSize\t" + stepSize); pw.println(indent + "&NumRows\t" + numRows); } }