Beispiel #1
0
 public int calculateStepToPerformSwap() {
   double pedestrianDensity = calculatePerceivedDensity();
   double delay_seconds =
       Math.pow(pedestrianDensity * .61, 1.45) * 0.4; // Math.pow(pedestrianDensity*.61,1.43)*0.39;
   double delay = delay_seconds / Constants.STEP_DURATION;
   int result = (int) delay; // Constants.STEP_FOR_BIDIRECTIONAL_SWAPPING;
   double probability = delay - result;
   if (Lottery.simpleExtraction(probability)) result++;
   return result;
 }
Beispiel #2
0
  protected ArrayList<WeightedCell> evaluate() {
    double myPositionValue = getStaticFFValue(position);
    double neighbourValue;
    double occupation = 0.0;
    double probabilitySum = 0.0;

    Neighbourhood neighbourhood = getNeighbourhood();
    ArrayList<WeightedCell> probabilityValues = new ArrayList<WeightedCell>();

    for (int index = 0; index < neighbourhood.size(); index++) {
      GridPoint neighbour = neighbourhood.get(index);
      neighbourValue = getStaticFFValue(neighbour);

      occupation = 0.0;
      if ((!neighbour.equals(position)) && checkOccupancy(neighbour)) occupation = 1.0;

      double p = utilityFunction(myPositionValue, neighbourValue, occupation);

      probabilitySum += p;
      probabilityValues.add(new WeightedCell(neighbour, p));
    }
    Lottery.normalizeProbabilities(probabilityValues, probabilitySum);
    return probabilityValues;
  }
Beispiel #3
0
 protected void choose(ArrayList<WeightedCell> probabilityValues) {
   WeightedCell winningCell = Lottery.pickWinner(probabilityValues);
   if (winningCell == null) nextpos = position;
   else nextpos = new GridPoint(winningCell.x, winningCell.y);
 }