eos.io.printer
Class LaborersPrinter

Object
  extended by eos.io.printer.Printer
      extended by eos.io.printer.LaborersPrinter

public class LaborersPrinter
extends Printer

This printer tracks statistics of a group of laborers. To use it:

1. Create a new LaborersPrinter. See LaborersPrinter(String fileName, int period, int start, int end, Laborer[] laborers).

2. Call printTitles() to print column titles.

3. Add the printer to the Economy by calling Economy.addPrinter().

4. Call print() of this printer in Economy.step() to print data.

5. Include cleanup() of this printer in Economy.cleanUpPrinters(), and call that method to clean up the printers.

The output of the printer is a CSV file. If you have closely followed the above steps, the first line of the file should be the column titles, and the first column is the time step. All entries are comma-delimited (without space). The file could be directly used as an input file for Grapher and MultiAxisGrapher. You could also open the file with most spreadsheet softwares like Microsoft Excel and OpenOffice Spreadsheet, and perform any data processing you wish.

If you omit the file name or provide a simple file name in the constructor, the output file will be saved in a folder called "output". If on the other hand, you specify a directory in the file name, the output file will be saved in your specified directory.

The default columns to be printed are:
Col0: average wage
Col1: average income
Col2: average consumption
Col3: average savings
Col4: total savings
Col5: average savings rate
Col6: average necessity stock
Col7: average enjoyment stock
Col8: average necessity consumption
Col9: average enjoyment consumption


Field Summary
 
Fields inherited from class eos.io.printer.Printer
end, period, start
 
Constructor Summary
LaborersPrinter(int period, int start, int end, Laborer[] laborers)
          Create a new LaborersPrinter.
LaborersPrinter(int period, int start, Laborer[] laborers)
          Create a new LaborersPrinter.
LaborersPrinter(int period, Laborer[] laborers)
          Create a new LaborersPrinter.
LaborersPrinter(String fileName, int period, int start, int end, Laborer[] laborers)
          Create a new LaborersPrinter.
LaborersPrinter(String fileName, int period, int start, Laborer[] laborers)
          Create a new LaborersPrinter.
LaborersPrinter(String fileName, int period, Laborer[] laborers)
          Create a new LaborersPrinter.
 
Method Summary
 void cleanup()
          Clean up the printer
 String getFileName()
          Return the name of the output file.
 void print()
          Print data, called by Economy at each time step
 void printTitles()
          Print column titles
 
Methods inherited from class eos.io.printer.Printer
getEnd, getPeriod, getStart
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LaborersPrinter

public LaborersPrinter(String fileName,
                       int period,
                       int start,
                       int end,
                       Laborer[] laborers)
Create a new LaborersPrinter.

Parameters:
fileName - name of the CSV output file. A default name will be used if it is omitted

period - number of steps between two printing. e.g. if period = 5, data will be printed every 5 time steps.

start - starting time step, no data will be printed before this

end - ending step, no data will be printed after this. If end is omitted, it will be taken to be the last step of the simulation. If both start and end are omitted, they will be taken to be the first and last step of the simulation respectively.

laborers - laborers to be tracked


LaborersPrinter

public LaborersPrinter(String fileName,
                       int period,
                       int start,
                       Laborer[] laborers)
Create a new LaborersPrinter. See LaborersPrinter(String fileName, int period, int start, int end, Laborer[] laborers) . end is set to the end of the simulation.

Parameters:
fileName - name of the CSV output file. A default name will be used if it is omitted

period - number of steps between two prints. e.g. if period = 5, data will be printed every 5 time steps.

start - starting time step, no data will be printed before this

laborers - laborers to be tracked


LaborersPrinter

public LaborersPrinter(String fileName,
                       int period,
                       Laborer[] laborers)
Create a new LaborersPrinter. See LaborersPrinter(String fileName, int period, int start, int end, Laborer[] laborers) . start is set to 0. end is set to the end of the simulation.

Parameters:
fileName - name of the CSV output file. A default name will be used if it is omitted

period - number of steps between two prints. e.g. if period = 5, data will be printed every 5 time steps.

laborers - laborers to be tracked


LaborersPrinter

public LaborersPrinter(int period,
                       int start,
                       int end,
                       Laborer[] laborers)
Create a new LaborersPrinter. See LaborersPrinter(String fileName, int period, int start, int end, Laborer[] laborers) . A default fileName is used.

Parameters:
period - number of steps between two prints. e.g. if period = 5, data will be printed every 5 time steps.

start - starting time step, no data will be printed before this

end - ending step, no data will be printed after this. If end is omitted, it will be taken to be the last step of the simulation. If both start and end are omitted, they will be taken to be the first and last step of the simulation respectively.

laborers - laborers to be tracked


LaborersPrinter

public LaborersPrinter(int period,
                       int start,
                       Laborer[] laborers)
Create a new LaborersPrinter. See LaborersPrinter(String fileName, int period, int start, int end, Laborer[] laborers) . A default fileName is used. end is set to the end of the simulation.

Parameters:
period - number of steps between two prints. e.g. if period = 5, data will be printed every 5 time steps.

start - starting time step, no data will be printed before this

laborers - laborers to be tracked


LaborersPrinter

public LaborersPrinter(int period,
                       Laborer[] laborers)
Create a new LaborersPrinter. See LaborersPrinter(String fileName, int period, int start, int end, Laborer[] laborers) . A default fileName is used. start is set to 0. end is set to the end of the simulation.

Parameters:
period - number of steps between two prints. e.g. if period = 5, data will be printed every 5 time steps.

laborers - laborers to be tracked

Method Detail

print

public void print()
Print data, called by Economy at each time step

Specified by:
print in class Printer

printTitles

public void printTitles()
Print column titles

Specified by:
printTitles in class Printer

cleanup

public void cleanup()
Clean up the printer

Specified by:
cleanup in class Printer

getFileName

public String getFileName()
Return the name of the output file.

Specified by:
getFileName in class Printer
Returns:
the name of the output file