List of usage examples for org.apache.commons.math3.distribution AbstractIntegerDistribution probability
double probability(int x);
From source file:edu.oregonstate.eecs.mcplan.domains.fuelworld.FuelWorldMDP.java
@Override public Pair<ArrayList<FuelWorldState>, ArrayList<Double>> sparseP(final FuelWorldState s, final FuelWorldAction a) { final ArrayList<FuelWorldState> succ = new ArrayList<FuelWorldState>(); final ArrayList<Double> p = new ArrayList<Double>(); if (a instanceof MoveAction) { // Add expected running out of fuel cost final MoveAction move = (MoveAction) a; final AbstractIntegerDistribution f = move.getFuelConsumption(s); for (int i = 0; i <= s.fuel; ++i) { final double pi = f.probability(i); if (pi > 0) { final FuelWorldState si = new FuelWorldState(s.rng, s.adjacency, s.goal, s.fuel_depots); si.location = move.dest; si.fuel = s.fuel - i;/*from www . ja v a 2s . c o m*/ succ.add(si); p.add(pi); } } // 1.0 - P(consumption <= fuel) final double p_empty = 1.0 - f.cumulativeProbability(s.fuel); final FuelWorldState empty = new FuelWorldState(s.rng, s.adjacency, s.goal, s.fuel_depots); empty.fuel = 0; empty.location = s.goal; succ.add(empty); p.add(p_empty); } else if (a instanceof RefuelAction) { assert (s.fuel_depots.contains(s.location)); final FuelWorldState sprime = new FuelWorldState(s.rng, s.adjacency, s.goal, s.fuel_depots); sprime.fuel = s.fuel_capacity; sprime.location = s.location; succ.add(sprime); p.add(1.0); } return Pair.makePair(succ, p); }