List of usage examples for org.apache.commons.math3.distribution GeometricDistribution sample
public int sample()
From source file:edu.oregonstate.eecs.mcplan.domains.inventory.InventoryProblem.java
/** * Demand follows a bounded random walk with uniform increments of bounded * size. Delivery probability is fairly high, and warehouse costs are * small in proportion to prices.//from w w w . j a v a 2s . c om * @return */ public static InventoryProblem Geometric() { final int Nproducts = 2; final int max_inventory = 30; final double warehouse_cost = 1; final int min_order = 2; final int max_order = 5; final int cost[] = { 1, 2 }; final double delivery_probability = 0.7; final int max_demand = 20; final int[] price = new int[] { 9, 15 }; final InventoryProblem problem = new InventoryProblem(Nproducts, price, max_inventory, warehouse_cost, min_order, max_order, cost, delivery_probability, max_demand) { @Override public int[] sampleNextDemand(final InventoryState s) { final GeometricDistribution f = new GeometricDistribution(s.rng, 0.4); final int[] dprime = new int[s.problem.Nproducts]; for (int i = 0; i < s.problem.Nproducts; ++i) { dprime[i] = Math.min(f.sample(), max_demand); } return dprime; } }; return problem; }
From source file:edu.oregonstate.eecs.mcplan.domains.inventory.InventoryProblem.java
/** * Almost the same as 'Geometric', but with a small warehouse capacity and * higher delivery probability./*w ww. j a v a 2 s.c o m*/ * We hope that this will make lookahead more useful. * @return */ public static InventoryProblem Geometric2() { final int Nproducts = 2; final int max_inventory = 4; final double warehouse_cost = 1; final int min_order = 2; final int max_order = 5; final int cost[] = { 1, 2 }; final double delivery_probability = 0.8; final int max_demand = 20; final double demand_p = 0.4; final int[] price = new int[] { 9, 15 }; final InventoryProblem problem = new InventoryProblem(Nproducts, price, max_inventory, warehouse_cost, min_order, max_order, cost, delivery_probability, max_demand) { @Override public int[] sampleNextDemand(final InventoryState s) { final GeometricDistribution f = new GeometricDistribution(s.rng, demand_p); final int[] dprime = new int[s.problem.Nproducts]; for (int i = 0; i < s.problem.Nproducts; ++i) { dprime[i] = Math.min(f.sample(), max_demand); } return dprime; } }; return problem; }