Esempio n. 1
0
 @Override
 public void recordAfterEvent(Sim sim, Event event) {
   if (trace) {
     logger.trace("Recording state of machine at time " + sim.getTime());
   }
   for (Item item : sim.getMachine()) {
     Object[] row = getRow(item, sim);
     record(row);
   }
 }
Esempio n. 2
0
  private Object[] getRow(Item item, Sim sim) {

    Object[] row = new Object[7];
    row[0] = sim.getId();
    row[1] = sim.getTime();
    row[2] = sim.getMachine().getSetup().getId();
    row[3] = item.getId();
    row[4] = item.getSurplus();
    row[5] = item.getCumulativeProduction();
    row[6] = item.getCumulativeDemand();

    return row;
  }
Esempio n. 3
0
 @Override
 public void recordEndOfSim(Sim sim) {
   // If highFreq is turned off, record the last N points stored for that sim instance
   if (!sim.getParams().isRecordHighFreq()) {
     for (int i = 0; i < MIN_NUM_POINTS_PER_ITEM; i++) {
       for (Item item : sim.getMachine()) {
         Map<Item, Queue<Object[]>> lastNRowsForSim = lastNRows.get(sim);
         Queue<Object[]> queue = lastNRowsForSim.get(item);
         Object[] row = queue.poll();
         record(row);
       }
     }
   }
   // Remove the sim instance from the map to preserve memory
   lastNRows.remove(sim);
 }
Esempio n. 4
0
 @Override
 public void updateAfterEvent(Sim sim, Event event) {
   for (Item item : sim.getMachine()) {
     Object[] row = getRow(item, sim);
     // Use an evicting queue so that we maintain a fixed number of
     // points per item
     if (!lastNRows.containsKey(sim)) {
       lastNRows.put(sim, new HashMap<Item, Queue<Object[]>>());
     }
     Map<Item, Queue<Object[]>> lastNRowsForSim = lastNRows.get(sim);
     if (!lastNRowsForSim.containsKey(item)) {
       lastNRowsForSim.put(item, EvictingQueue.<Object[]>create(MIN_NUM_POINTS_PER_ITEM));
     }
     lastNRowsForSim.get(item).add(row);
   }
 }