1
2
3
4
5
6
7
8
9
10 package nl.tudelft.simulation.dsol.tutorial.section42.policies;
11
12 import java.rmi.RemoteException;
13 import java.util.Properties;
14
15 import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;
16
17 /***
18 * A StationaryPolicy <br>
19 * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
20 * University of Technology </a>, the Netherlands. <br>
21 * See for project information <a
22 * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
23 * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
24 * License (GPL) </a>, no warranty <br>
25 *
26 * @version 1.0 Dec 8, 2003 <br>
27 * @author <a href="http://www.simulation.tudelft.nl/people/jacobs.html">Peter
28 * Jacobs </a>
29 */
30 public class StationaryPolicy implements OrderingPolicy
31 {
32 /*** the lower bound of the policy */
33 private long lowerBound;
34
35 /*** the upper bound of the policy */
36 private long upperBound;
37
38 /***
39 * constructs a new StationaryPolicy
40 *
41 * @param simulator the simulator which is executing the experiment
42 * @throws RemoteException on network failure
43 */
44 public StationaryPolicy(final SimulatorInterface simulator)
45 throws RemoteException
46 {
47 super();
48 Properties properties = simulator.getReplication().getRunControl()
49 .getTreatment().getProperties();
50
51 this.lowerBound = new Long(properties.getProperty("policy.lowerBound"))
52 .longValue();
53 this.upperBound = new Long(properties.getProperty("policy.upperBound"))
54 .longValue();
55 }
56
57 /***
58 * @see nl.tudelft.simulation.dsol.tutorial.section42.policies.OrderingPolicy
59 * #computeAmountToOrder(long)
60 */
61 public long computeAmountToOrder(final long inventory)
62 {
63 if (inventory <= this.lowerBound)
64 {
65 return this.upperBound - inventory;
66 }
67 return 0;
68 }
69 }