001: /*--------------------------------------------------------------------------
002: * <copyright>
003: *
004: * Copyright 1999-2004 BBNT Solutions, LLC
005: * under sponsorship of the Defense Advanced Research Projects
006: * Agency (DARPA).
007: *
008: * You can redistribute this software and/or modify it under the
009: * terms of the Cougaar Open Source License as published on the
010: * Cougaar Open Source Website (www.cougaar.org).
011: *
012: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023: *
024: * </copyright>
025: * --------------------------------------------------------------------------*/
026: package org.cougaar.glm.plugins.inventory;
027:
028: import org.cougaar.planning.ldm.policy.DoubleRuleParameter;
029: import org.cougaar.planning.ldm.policy.IntegerRuleParameter;
030: import org.cougaar.planning.ldm.policy.Policy;
031: import org.cougaar.planning.ldm.policy.RuleParameterIllegalValueException;
032: import org.cougaar.planning.ldm.policy.StringRuleParameter;
033:
034: /**
035: * The PolicyPlugin
036: *
037: *
038: */
039:
040: public class DaysOnHandPolicy extends Policy {
041: public static final String ResourceType = "ResourceType";
042: public static final String DaysOnHand = "DaysOnHand";
043: public static final String DaysForward = "DaysForward";
044: public static final String DaysBackward = "DaysBackward";
045: public static final String GoalLevelMultiplier = "GoalLevelMultiplier";
046:
047: public DaysOnHandPolicy() {
048: super ("DaysOnHandPolicy");
049: StringRuleParameter ic = new StringRuleParameter(ResourceType);
050: try {
051: ic.setValue(new String());
052: } catch (RuleParameterIllegalValueException ex) {
053: System.out.println(ex);
054: }
055: Add(ic);
056:
057: IntegerRuleParameter dbd = new IntegerRuleParameter(DaysOnHand,
058: 0, 40);
059: try {
060: dbd.setValue(new Integer(1));
061: } catch (RuleParameterIllegalValueException ex) {
062: System.out.println(ex);
063: }
064: Add(dbd);
065:
066: IntegerRuleParameter frp = new IntegerRuleParameter(
067: DaysForward, 0, 40);
068: try {
069: frp.setValue(new Integer(15));
070: } catch (RuleParameterIllegalValueException ex) {
071: System.out.println(ex);
072: }
073: Add(frp);
074:
075: IntegerRuleParameter brp = new IntegerRuleParameter(
076: DaysBackward, 0, 40);
077: try {
078: brp.setValue(new Integer(15));
079: } catch (RuleParameterIllegalValueException ex) {
080: System.out.println(ex);
081: }
082: Add(brp);
083:
084: DoubleRuleParameter drp = new DoubleRuleParameter(
085: GoalLevelMultiplier, 1.0, 30.0);
086: try {
087: drp.setValue(new Double(2.0));
088: } catch (RuleParameterIllegalValueException ex) {
089: System.out.println(ex);
090: }
091: Add(drp);
092: }
093:
094: public String getResourceType() {
095: StringRuleParameter param = (StringRuleParameter) Lookup(ResourceType);
096: return (String) param.getValue();
097: }
098:
099: public void setResourceType(String name) {
100: StringRuleParameter param = (StringRuleParameter) Lookup(ResourceType);
101: try {
102: param.setValue(name);
103: } catch (RuleParameterIllegalValueException ex) {
104: System.out.println(ex);
105: }
106: }
107:
108: public int getDaysOnHand() {
109: IntegerRuleParameter param = (IntegerRuleParameter) Lookup(DaysOnHand);
110: return ((Integer) (param.getValue())).intValue();
111: }
112:
113: public void setDaysBetweenDemand(int days) {
114: IntegerRuleParameter param = (IntegerRuleParameter) Lookup(DaysOnHand);
115: try {
116: param.setValue(new Integer(days));
117: } catch (RuleParameterIllegalValueException ex) {
118: System.out.println(ex);
119: }
120: }
121:
122: public int getDaysForward() {
123: IntegerRuleParameter param = (IntegerRuleParameter) Lookup(DaysForward);
124: return ((Integer) (param.getValue())).intValue();
125: }
126:
127: public void setDaysForward(int days) {
128: IntegerRuleParameter param = (IntegerRuleParameter) Lookup(DaysForward);
129: try {
130: param.setValue(new Integer(days));
131: } catch (RuleParameterIllegalValueException ex) {
132: System.out.println(ex);
133: }
134: }
135:
136: public int getDaysBackward() {
137: IntegerRuleParameter param = (IntegerRuleParameter) Lookup(DaysBackward);
138: return ((Integer) (param.getValue())).intValue();
139: }
140:
141: public void setDaysBackward(int days) {
142: IntegerRuleParameter param = (IntegerRuleParameter) Lookup(DaysBackward);
143: try {
144: param.setValue(new Integer(days));
145: } catch (RuleParameterIllegalValueException ex) {
146: System.out.println(ex);
147: }
148: }
149:
150: public int getWindowSize() {
151: IntegerRuleParameter param = (IntegerRuleParameter) Lookup(DaysForward);
152: int forward = ((Integer) (param.getValue())).intValue();
153: param = (IntegerRuleParameter) Lookup(DaysBackward);
154: int backward = ((Integer) (param.getValue())).intValue();
155: return forward + backward;
156: }
157:
158: public double getGoalLevelMultiplier() {
159: DoubleRuleParameter param = (DoubleRuleParameter) Lookup(GoalLevelMultiplier);
160: return ((Double) (param.getValue())).doubleValue();
161: }
162:
163: public void setGoalLevelMultiplier(double multiplier) {
164: DoubleRuleParameter param = (DoubleRuleParameter) Lookup(GoalLevelMultiplier);
165: try {
166: param.setValue(new Double(multiplier));
167: } catch (RuleParameterIllegalValueException ex) {
168: System.out.println(ex);
169: }
170: }
171: }
|