001: /*
002: * <copyright>
003: *
004: * Copyright 1997-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:
027: package org.cougaar.lib.util;
028:
029: import java.util.Date;
030:
031: import org.cougaar.planning.ldm.plan.AspectType;
032: import org.cougaar.planning.ldm.plan.AspectValue;
033: import org.cougaar.planning.ldm.plan.ScoringFunction;
034: import org.cougaar.util.log.Logger;
035: import org.cougaar.util.log.LoggerFactory;
036:
037: /**
038: * Represents an <early, best, late> end date scoring function
039: *
040: */
041:
042: public class UTILEndDateScoringFunction extends
043: ScoringFunction.VScoringFunction {
044: /* only used for isolated main ()-style testing */
045: private static Logger logger = LoggerFactory.getInstance()
046: .createLogger("UTILEndDateScoringFunction");
047:
048: public UTILEndDateScoringFunction(Date early, Date best, Date late,
049: double boundaryScore) {
050: super (AspectValue.newAspectValue(AspectType.END_TIME,
051: (double) early.getTime()), AspectValue.newAspectValue(
052: AspectType.END_TIME, (double) best.getTime()),
053: AspectValue.newAspectValue(AspectType.END_TIME,
054: (double) late.getTime()), boundaryScore);
055: }
056:
057: public Date getEarlyDate() {
058: return new Date((long) point1.getValue());
059: }
060:
061: public Date getBestDate() {
062: return new Date((long) best.getValue());
063: }
064:
065: public Date getLateDate() {
066: return new Date((long) point2.getValue());
067: }
068:
069: public Object clone() {
070: return new UTILEndDateScoringFunction(new Date(point1
071: .longValue()), new Date(best.longValue()), new Date(
072: point2.longValue()), ok);
073: }
074:
075: /*
076: public void main (String [] args) {
077: Calendar cal = Calendar.getInstance ();
078: cal.set (1999, 6, 1, 11, 59, 59);
079: Date beforeearly = cal.getTime ();
080: cal.set (1999, 6, 1, 12, 0, 0);
081: Date early = cal.getTime ();
082:
083: cal.set (1999, 6, 1, 13, 0, 0);
084: Date best = cal.getTime ();
085: cal.set (1999, 6, 1, 14, 0, 0);
086: Date late = cal.getTime ();
087: cal.set (1999, 6, 1, 14, 0, 1);
088: Date afterlate = cal.getTime ();
089: ScoringFunction sf = new UTILEndDateScoringFunction (early,
090: best,
091: late, 0.9);
092: AspectValue av = AspectValue.newAspectValue (AspectType.END_TIME,
093: (double) beforeearly.getTime ());
094: logger.debug ("Score for before early " + sf.getScore (av));
095:
096: av = AspectValue.newAspectValue (AspectType.END_TIME, (double) early.getTime ());
097: logger.debug ("Score for early " + sf.getScore (av));
098:
099: av = AspectValue.newAspectValue (AspectType.END_TIME, (double) best.getTime ());
100: logger.debug ("Score for best " + sf.getScore (av));
101:
102: av = AspectValue.newAspectValue (AspectType.END_TIME, (double) late.getTime ());
103: logger.debug ("Score for late " + sf.getScore (av));
104:
105: av = AspectValue.newAspectValue (AspectType.END_TIME, (double) afterlate.getTime ());
106: logger.debug ("Score for after late " + sf.getScore (av));
107: }
108: */
109: }
|