01: /*
02: * <copyright>
03: *
04: * Copyright 1997-2004 BBNT Solutions, LLC
05: * under sponsorship of the Defense Advanced Research Projects
06: * Agency (DARPA).
07: *
08: * You can redistribute this software and/or modify it under the
09: * terms of the Cougaar Open Source License as published on the
10: * Cougaar Open Source Website (www.cougaar.org).
11: *
12: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
14: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
15: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
16: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
17: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
18: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23: *
24: * </copyright>
25: */
26: package org.cougaar.glm.ldm.policy;
27:
28: import org.cougaar.planning.ldm.policy.DoubleRuleParameter;
29: import org.cougaar.planning.ldm.policy.Policy;
30: import org.cougaar.planning.ldm.policy.RuleParameter;
31: import org.cougaar.planning.ldm.policy.RuleParameterIllegalValueException;
32: import org.cougaar.planning.ldm.policy.StringRuleParameter;
33:
34: /**
35: * Answers the question, "What should our policy be for interpreting acr factors?" In the absence of an explicit policy, the answer is to multiply the factor by 1.0.
36: **/
37: public class ACRPolicy extends Policy {
38: private static final String CONSUMER = "consumer";
39: private static final String CONSUMED = "consumed";
40: private static final String ADJUSTMENT_FACTOR = "adjustmentFactor";
41:
42: public ACRPolicy() {
43: super ("ACRPolicy");
44: }
45:
46: public void setConsumerTypeIdentification(
47: String newConsumerTypeIdentification)
48: throws RuleParameterIllegalValueException {
49: RuleParameter p = new StringRuleParameter(CONSUMER);
50: p.setValue(newConsumerTypeIdentification);
51: Add(p);
52: }
53:
54: public String getConsumerTypeIdentification() {
55: return (String) Lookup(CONSUMER).getValue();
56: }
57:
58: public void setConsumedTypeIdentification(
59: String newConsumedTypeIdentification)
60: throws RuleParameterIllegalValueException {
61: RuleParameter p = new StringRuleParameter(CONSUMED);
62: p.setValue(newConsumedTypeIdentification);
63: Add(p);
64: }
65:
66: public String getConsumedTypeIdentification() {
67: return (String) Lookup(CONSUMED).getValue();
68: }
69:
70: public void setAdjustmentFactor(double newAdjustmentFactor)
71: throws RuleParameterIllegalValueException {
72: RuleParameter p = new DoubleRuleParameter(ADJUSTMENT_FACTOR,
73: 0.0, Double.MAX_VALUE);
74: p.setValue(new Double(newAdjustmentFactor));
75: Add(p);
76: }
77:
78: public double getAdjustmentFactor() {
79: return ((Double) Lookup(ADJUSTMENT_FACTOR).getValue())
80: .doubleValue();
81: }
82:
83: public String toString() {
84: return "ACRPolicy[consumer=" + getConsumerTypeIdentification()
85: + ",consumed=" + getConsumedTypeIdentification()
86: + ",factor=" + getAdjustmentFactor() + "]";
87: }
88: }
|