Class PredictionParser

java.lang.Object
  extended by se.sics.tasim.tac05.Parser
      extended by PredictionParser
All Implemented Interfaces:
se.sics.tasim.tac05.TAC05Constants

public class PredictionParser
extends se.sics.tasim.tac05.Parser

Parses a single game log. All incoming and outgoing messages for the specified agent are stored, along with all prices for which predictions are needed. The predictor is then called with each day's information, and the predictions are evaluated.


Field Summary
private  java.lang.String agentName
           
(package private)  se.sics.tasim.props.BOMBundle bom
           
(package private)  se.sics.tasim.props.ComponentCatalog catalog
           
(package private)  int[] componentBasePrices
           
(package private)  int[] componentIDs
           
(package private)  int[][] componentIndexList
           
(package private)  int componentPredictionCount
           
(package private)  double componentPredictionSquaredError
           
(package private)  int[] computerBasePrices
           
(package private)  int[] computerIDs
           
(package private)  int computerPredictionCount
           
(package private)  double computerPredictionSquaredError
           
(package private)  java.util.Hashtable customerOffers
           
(package private)  java.util.Vector[] customerOrders
           
(package private)  java.util.Hashtable customerRFQs
           
(package private)  int date
           
(package private)  int futureComponentPredictionCount
           
(package private)  double futureComponentPredictionSquaredError
           
(package private)  int futureComputerPredictionCount
           
(package private)  double futureComputerPredictionSquaredError
           
private  java.util.Vector[] futureRFQs
           
(package private)  double[][] medianPrice
           
private  java.util.Vector[] messagesIn
           
private  java.util.Vector[] messagesOut
           
(package private) static int N_COMPONENT
           
(package private) static int N_COMPUTER
           
(package private) static int numComponents
           
(package private) static int numComputers
           
(package private) static int numDays
           
(package private)  se.sics.tasim.logtool.ParticipantInfo[] participants
           
private  SCMPredictor predictor
           
(package private)  double[] results
           
(package private)  java.util.Vector[] supplierOffers
           
(package private)  java.util.Hashtable supplierOrders
           
(package private)  java.util.Hashtable supplierRFQs
           
(package private)  java.util.Vector[] todaysPrices
           
private  boolean verbose
           
 
Fields inherited from interface se.sics.tasim.tac05.TAC05Constants
CUSTOMER, DU_BANK_ACCOUNT, DU_CAPACITY_FLAG, DU_COMPONENT_ID_FLAG, DU_COMPONENT_PRICE_FLAG, DU_CUSTOMER_DEMAND, DU_CUSTOMER_ORDERED, DU_INVENTORY_FLAG, DU_NOMINAL_CAPACITY_FLAG, DU_PRODUCTION_FLAG, FACTORY, MANUFACTURER, ROLE_NAME, SIMULATION_TYPE, SUPPLIER, TYPE_DELIVERY, TYPE_MESSAGE, TYPE_NEGOTIATION, TYPE_NONE, TYPE_ORDER, TYPE_WARNING
 
Constructor Summary
PredictionParser(se.sics.tasim.logtool.LogReader reader, java.lang.String agentName, SCMPredictor predictor, boolean verbose, double[] results)
          Called by the main class for each game.
 
Method Summary
protected  void dataUpdated(int type, se.sics.isl.transport.Transportable content)
          BOMBundle, ComponentCatalog, and StartInfo are given here, instead of with the messages
private  int getComponentIndex(int productID)
          Returns the index for the productID.
private  int getComputerIndex(int productID)
          Returns the index for the productID.
private  void getMedianPrices()
          Calculates the median prices for each computer type each day.
private  void getPredictions()
          After the game is parsed, this will get the daily predictions from the predictor.
private  void handleCOffer(int sender, int receiver, se.sics.tasim.props.OfferBundle content)
          Stores offers from customers.
private  void handleCOrder(int sender, int receiver, se.sics.tasim.props.OrderBundle content)
          Stores orders from customers.
private  void handleCRFQ(int sender, int receiver, se.sics.tasim.props.RFQBundle content)
           
private  void handleSOffer(int sender, int receiver, se.sics.tasim.props.OfferBundle content)
          Stores offers from suppliers.
private  void handleSRFQ(int sender, int receiver, se.sics.tasim.props.RFQBundle content)
          Stores RFQs to suppliers.
protected  void message(int sender, int receiver, se.sics.isl.transport.Transportable content)
          Called each time a message is read from the game log.
protected  void nextDay(int somedate, long serverTime)
          Called each time a new day is reached in the game log
private  java.lang.String pad(double d)
          Used for formatting output.
protected  void parseStopped()
          Called at the end of the game.
private  void setup()
          Sets up information using the catalog and BOM.
 
Methods inherited from class se.sics.tasim.tac05.Parser
data, dataUpdated, dataUpdated, dataUpdated, dataUpdated, dataUpdated, getReader, interest, messageToRole, parseStarted, penalty, reputation, start, stop, storageCost, transaction, unhandledNode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

N_COMPUTER

static final int N_COMPUTER
See Also:
Constant Field Values

N_COMPONENT

static final int N_COMPONENT
See Also:
Constant Field Values

numDays

static final int numDays
See Also:
Constant Field Values

numComputers

static final int numComputers
See Also:
Constant Field Values

numComponents

static final int numComponents
See Also:
Constant Field Values

agentName

private java.lang.String agentName

verbose

private boolean verbose

messagesIn

private java.util.Vector[] messagesIn

messagesOut

private java.util.Vector[] messagesOut

futureRFQs

private java.util.Vector[] futureRFQs

predictor

private SCMPredictor predictor

date

int date

participants

se.sics.tasim.logtool.ParticipantInfo[] participants

bom

se.sics.tasim.props.BOMBundle bom

catalog

se.sics.tasim.props.ComponentCatalog catalog

computerIDs

int[] computerIDs

componentIDs

int[] componentIDs

componentIndexList

int[][] componentIndexList

computerBasePrices

int[] computerBasePrices

componentBasePrices

int[] componentBasePrices

medianPrice

double[][] medianPrice

todaysPrices

java.util.Vector[] todaysPrices

supplierOffers

java.util.Vector[] supplierOffers

supplierOrders

java.util.Hashtable supplierOrders

supplierRFQs

java.util.Hashtable supplierRFQs

customerOffers

java.util.Hashtable customerOffers

customerOrders

java.util.Vector[] customerOrders

customerRFQs

java.util.Hashtable customerRFQs

futureComputerPredictionCount

int futureComputerPredictionCount

futureComputerPredictionSquaredError

double futureComputerPredictionSquaredError

computerPredictionCount

int computerPredictionCount

computerPredictionSquaredError

double computerPredictionSquaredError

futureComponentPredictionCount

int futureComponentPredictionCount

futureComponentPredictionSquaredError

double futureComponentPredictionSquaredError

componentPredictionCount

int componentPredictionCount

componentPredictionSquaredError

double componentPredictionSquaredError

results

double[] results
Constructor Detail

PredictionParser

public PredictionParser(se.sics.tasim.logtool.LogReader reader,
                        java.lang.String agentName,
                        SCMPredictor predictor,
                        boolean verbose,
                        double[] results)
Called by the main class for each game.

Parameters:
reader - reads the game log
agentName - the agent for which predictions are made
predictor - makes predictions
verbose - whether to output all predictions
results - accuracy results to be returned
Method Detail

message

protected void message(int sender,
                       int receiver,
                       se.sics.isl.transport.Transportable content)
Called each time a message is read from the game log.

Specified by:
message in class se.sics.tasim.tac05.Parser

dataUpdated

protected void dataUpdated(int type,
                           se.sics.isl.transport.Transportable content)
BOMBundle, ComponentCatalog, and StartInfo are given here, instead of with the messages

Overrides:
dataUpdated in class se.sics.tasim.tac05.Parser

nextDay

protected void nextDay(int somedate,
                       long serverTime)
Called each time a new day is reached in the game log

Overrides:
nextDay in class se.sics.tasim.tac05.Parser

parseStopped

protected void parseStopped()
Called at the end of the game.

Overrides:
parseStopped in class se.sics.tasim.tac05.Parser

getPredictions

private void getPredictions()
After the game is parsed, this will get the daily predictions from the predictor.


setup

private void setup()
Sets up information using the catalog and BOM.


handleCRFQ

private void handleCRFQ(int sender,
                        int receiver,
                        se.sics.tasim.props.RFQBundle content)

handleCOffer

private void handleCOffer(int sender,
                          int receiver,
                          se.sics.tasim.props.OfferBundle content)
Stores offers from customers.


handleCOrder

private void handleCOrder(int sender,
                          int receiver,
                          se.sics.tasim.props.OrderBundle content)
Stores orders from customers.


handleSRFQ

private void handleSRFQ(int sender,
                        int receiver,
                        se.sics.tasim.props.RFQBundle content)
Stores RFQs to suppliers.


handleSOffer

private void handleSOffer(int sender,
                          int receiver,
                          se.sics.tasim.props.OfferBundle content)
Stores offers from suppliers.


getMedianPrices

private void getMedianPrices()
Calculates the median prices for each computer type each day.


getComponentIndex

private int getComponentIndex(int productID)
Returns the index for the productID.


getComputerIndex

private int getComputerIndex(int productID)
Returns the index for the productID.


pad

private java.lang.String pad(double d)
Used for formatting output.