RLPark 1.0.0
Reinforcement Learning Framework in Java

LTUUpdated.java

Go to the documentation of this file.
00001 package rlpark.plugin.rltoys.algorithms.representations.ltu.internal;
00002 
00003 import java.io.Serializable;
00004 import java.util.Arrays;
00005 
00006 import rlpark.plugin.rltoys.algorithms.representations.ltu.units.LTU;
00007 
00008 public class LTUUpdated implements Serializable {
00009   private static final long serialVersionUID = -8496340357389642735L;
00010   public final boolean[] updated;
00011   private int nbUnitUpdated;
00012 
00013   public LTUUpdated(int nbLTU) {
00014     updated = new boolean[nbLTU];
00015   }
00016 
00017   final public void updateLTUSum(int index, LTU ltu, double[] denseInputVector) {
00018     if (markLTU(index))
00019       ltu.updateSum(denseInputVector);
00020   }
00021 
00022   synchronized private boolean markLTU(int index) {
00023     if (updated[index])
00024       return false;
00025     nbUnitUpdated++;
00026     updated[index] = true;
00027     return true;
00028   }
00029 
00030   synchronized public void clean() {
00031     Arrays.fill(updated, false);
00032     nbUnitUpdated = 0;
00033   }
00034 
00035   public int nbUnitUpdated() {
00036     return nbUnitUpdated;
00037   }
00038 }
 All Classes Namespaces Files Functions Variables Enumerations
Zephyr
RLPark