7.1 Tools/ FileIO

An essential piece of the framework, the FileIO class facilitates easily writing to and reading from files. this is important for collecting data from your models as well as systematically paramaterizing them. the API for the FileIO object is discussed.

FileIO(filename,mode):
the FileIO constructor expects a filename or path as a string, and a mode string, of which there are 6 options:
  • “r” creates a FileIO in read mode, this FileIO is able to read text files
  • “w” creats a FileIO in write mode, this FileIO is able to write to a new text file
  • “a” creates a FileIO in append mode, this FileIO is able to append to an existing text file or write to a new file.
  • “rb” creates a FileIO in read binary mode, this FileIO is able to read binary files
  • “wb” creates a FileIO in write binary mode, this FileIO is able to write to binary files.
  • “ab” creates a FileIO in append binary mode, this FileIO is able to append to an existing binary file or write to a new file.

The functions in the next sections are split up based on which mode was used to open the FileIO

Close():
make sure to call this function when finished with the FileIO. the FileIO uses buffers internally to make writing more efficient. without calling close the buffers may never be fully written out.

Read Mode Functions

Read():
returns an arraylist of Strings. each string is one line from the file
ReadLine():
returns the next line from the file as a string
ReadLineDelimit(delimeter),ReadLineIntDelimit(delimeter),etc:
returns an array of strings,ints,or doubles, etc. each entry is parsed using the delimeter.
ReadDelimit(delimeter),ReadIntDelimit(delimeter),etc:
returns an arraylist of arrays of strings,ints,or doubles, etc. each entry is parsed using the delimeter. each array is a line.

Write Mode Functions

Write(string):
writes the string argument to a file
WriteDelimit(arr,delimit):
writes the contents of the provided array to a file, entries are separated using the delimeter.

ReadBinary Mode Functions

ReadBinBool(bool),ReadBinInt(int),ReadBinDouble(double),etc:
read the next single value from the binary file.
ReadBinBools(bool[]),ReadBinInts(int[]),ReadBinDoubles(double[]),etc:
fills the array arugment with values read from the binary file.

WriteBinary Mode Functions

WriteBinBool(bool),WriteBinInt(int),WriteBinDouble(double),etc:
writes a single value to the binary file.
WriteBinBools(bool[]),WriteBinInts(int[]),WriteBinDouble(double[]),etc:
writes every entry in the array to the binary file.

7.2 Tools/ MultiWellExperiment

the multiwell experiment class will visualize many models simultaneously on a single GridWindow. It can also run the models in parallel for better throughput.

MultiWellExperiment(numWellsX,numWellsY,models[],visXdim,visYdim,borderColor,scaleFactor,StepFn,ColorFn):
the constructor for the MultiWellExperiment class. numWellsX, numWellsY define the number of well (model) rows, models[] is an array of the starting conditions of the models. visXdim, visYdim, scaleFactor define the x pixels, y pixels, and scaling of the visualization of each mdoel. borderColor defines the color of the separator between models, StepFn is a function argument. it takes a model, a well index, and a timestep as argument, and should update the model argument for one timestep. ColorFn is a function argument that takes a model, x, and y, and is used to set one pixel of the visualization.
Run(numTicks,multiThread?,tickPause):
runs a multiwell experiment for a numTicks duration. if the multiThread boolean is set to true, the model execution will be multithreaded.
Step(tick):
runs a single timestep