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:
27: package org.cougaar.mlm.construction;
28:
29: import java.io.Serializable;
30:
31: import org.cougaar.glm.ldm.Constants;
32: import org.cougaar.glm.ldm.asset.ProjectionWeight;
33: import org.cougaar.planning.ldm.plan.Task;
34: import org.cougaar.planning.ldm.plan.Verb;
35:
36: public class ConstructionProjectionWeight implements ProjectionWeight,
37: Serializable {
38:
39: protected int switchOverDay_ = 0;
40:
41: public ConstructionProjectionWeight(int day) {
42: switchOverDay_ = day;
43: }
44:
45: public ConstructionProjectionWeight() {
46: }
47:
48: public void setSwitchOverDay(int day) {
49: switchOverDay_ = day;
50: }
51:
52: public double getProjectionWeight(Task task, int imputedDay) {
53: // because ProjectSupply tasks span a long time period, their start time is not
54: // useful for deteriming when to credit them -- for withdrawals, we have created
55: // ProjectWithdraw tasks, but for refill tasks we are passing in the raw ProjectSupply
56: // tasks (this is a lonnng story)
57: Verb task_verb = task.getVerb();
58: int day = imputedDay;
59: double weight = 0.0;
60:
61: if (task_verb.equals(Constants.Verb.SUPPLY)) {
62: if (day > getRefillSwitchoverDay()) {
63: weight = 0.0;
64: } else {
65: weight = 1.0;
66: }
67: } else if (task_verb.equals(Constants.Verb.PROJECTSUPPLY)) {
68: if (day > getRefillSwitchoverDay()) {
69: weight = 1.0;
70: } else {
71: weight = 0.0;
72: }
73: } else if (task_verb.equals(Constants.Verb.PROJECTWITHDRAW)) {
74: if (day > getRefillSwitchoverDay()) {
75: weight = 1.0;
76: } else {
77: weight = 0.0;
78: }
79: } else if (task_verb.equals(Constants.Verb.WITHDRAW)) {
80: if (day > getRefillSwitchoverDay()) {
81: weight = 0.0;
82: } else {
83: weight = 1.0;
84: }
85: }
86: return weight;
87: }
88:
89: public int getRefillSwitchoverDay() {
90: // eventually should be the lead-time from the allocation result for projections
91: return 100;
92: //switchoverDay*5;
93: }
94:
95: }
|