Source Code Cross Referenced for TransportAggregatorPlugin.java in  » Science » Cougaar12_4 » org » cougaar » logistics » plugin » trans » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Science » Cougaar12_4 » org.cougaar.logistics.plugin.trans 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * <copyright>
003:         *  
004:         *  Copyright 2001-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.logistics.plugin.trans;
027:
028:        import org.cougaar.planning.ldm.asset.AggregateAsset;
029:        import org.cougaar.planning.ldm.asset.Asset;
030:        import org.cougaar.planning.ldm.plan.Task;
031:        import org.cougaar.planning.ldm.plan.MPTask;
032:
033:        import org.cougaar.lib.vishnu.client.VishnuAggregatorPlugin;
034:
035:        import org.cougaar.logistics.ldm.Constants;
036:        import org.cougaar.glm.ldm.asset.GLMAsset;
037:        import org.cougaar.glm.ldm.asset.MovabilityPG;
038:        import org.cougaar.glm.ldm.plan.GeolocLocation;
039:        import org.cougaar.util.log.Logger;
040:
041:        import java.util.Calendar;
042:        import java.util.Date;
043:        import java.util.Enumeration;
044:        import java.util.HashMap;
045:        import java.util.Map;
046:
047:        import org.cougaar.planning.ldm.plan.AspectScorePoint;
048:        import org.cougaar.planning.ldm.plan.AspectScoreRange;
049:        import org.cougaar.planning.ldm.plan.AspectType;
050:        import org.cougaar.planning.ldm.plan.AspectValue;
051:        import org.cougaar.planning.ldm.plan.Preference;
052:        import org.cougaar.planning.ldm.plan.ScoringFunction;
053:
054:        import org.cougaar.lib.callback.UTILExpandableTaskCallback;
055:        import org.cougaar.lib.callback.UTILFilterCallback;
056:        import org.cougaar.lib.callback.UTILGenericListener;
057:
058:        /**
059:         * Note that although this is an aggregator, an expansion is made and subtasks created. <p>
060:         *
061:         * This is because after the aggregation, the setup and wrapup times must be represented. <br>
062:         * They are represented as separate tasks with verb "Transit".  They represent the time   <br>
063:         * taken to travel from the supply point and to return.  They should not be figured into  <br>
064:         * the time that the task takes to perform, since they are only indirectly related to it. <p>
065:         * 
066:         * If the specs were altered, and no setup and wrapup duration were included, only aggregations <br>
067:         * would be made, and therefore only MPTask would be produced.  The allocator downstream        <br>
068:         * would have to be sensitive to this change.
069:         */
070:        public class TransportAggregatorPlugin extends VishnuAggregatorPlugin {
071:            boolean debugPrefs = false;
072:
073:            /** 
074:             * Only tasks with transport verbs are given to Vishnu   <p>
075:             * If a task has no FROM prep, it is not handled.         <p>
076:             * If a task has a FROM prep that is in CONUS, it is not handled. <p>
077:             * If a task is an MPTask (and possibly an output of the plugin), it is not handled.
078:             */
079:            public boolean interestingTask(Task t) {
080:                if (debugPrefs) {
081:                    for (Enumeration prefs = t.getPreferences(); prefs
082:                            .hasMoreElements();) {
083:                        Preference pref = (Preference) prefs.nextElement();
084:                        int aspectType = pref.getAspectType();
085:
086:                        AspectValue lower = AspectValue.newAspectValue(
087:                                aspectType, 0.0d);
088:
089:                        Calendar cal = java.util.Calendar.getInstance();
090:                        cal.set(2200, 0, 0, 0, 0, 0);
091:                        cal.set(Calendar.MILLISECOND, 0);
092:                        double endOfRange = (double) ((Date) cal.getTime())
093:                                .getTime();
094:                        AspectValue upper = AspectValue.newAspectValue(
095:                                aspectType, endOfRange);
096:
097:                        print(pref,
098:                                pref.getScoringFunction().getDefinedRange(),
099:                                pref.getScoringFunction().getValidRanges(lower,
100:                                        upper), logger);
101:                    }
102:                }
103:
104:                boolean hasTransport = t.getVerb().equals(
105:                        Constants.Verb.TRANSPORT)
106:                        || t.getVerb().equals(Constants.Verb.TRANSIT);
107:
108:                if (!hasTransport)
109:                    return false;
110:                if (!prepHelper.hasPrepNamed(t, Constants.Preposition.FROM)) {
111:                    if (isInfoEnabled())
112:                        info(getName()
113:                                + ".interestingTask - ignoring TRANSPORT task "
114:                                + t.getUID()
115:                                + " that doesn't have a FROM prep.");
116:                    return false;
117:                }
118:                /*
119:                  GeolocLocation geoloc = 
120:                  (GeolocLocation) UTILPrepPhrase.getIndirectObject (t, Constants.Preposition.FROM);
121:                  if (geoloc.getLongitude().getDegrees () < 0) {
122:                  if (isInfoEnabled())
123:                  info (getName () + ".interestingTask - ignoring task " + t.getUID() + " with FROM of " + geoloc + " - it's not in theater.");
124:                  return false;
125:                  }
126:                  geoloc = 
127:                  (GeolocLocation) UTILPrepPhrase.getIndirectObject (t, Constants.Preposition.TO);
128:                  if (geoloc.getLongitude().getDegrees () < 0) {
129:                  if (isInfoEnabled())
130:                  info (getName () + ".interestingTask - ignoring task " + t.getUID() + " with TO of " + geoloc + " - it's not in theater.");
131:                  return false;
132:                  }
133:                 */
134:
135:                /*
136:                  boolean hasPrepo = UTILPrepPhrase.hasPrepNamed (t, "PREPO");
137:                  boolean hasStratTrans = false;
138:
139:                  if (UTILPrepPhrase.hasPrepNamed (t, "OFTYPE")) {
140:                  Asset oftype = (Asset) UTILPrepPhrase.getIndirectObject (t, "OFTYPE");
141:                  String typeid = oftype.getTypeIdentificationPG().getTypeIdentification ();
142:                  hasStratTrans = typeid.equals ("StrategicTransportation");
143:                  }
144:                 */
145:
146:                boolean val = !(t instanceof  MPTask)
147:                        && super .interestingTask(t);
148:                //  !hasPrepo && !hasStratTrans; 
149:
150:                if (isDebugEnabled() && val)
151:                    debug(getName() + ".interestingTask - interested in "
152:                            + t.getUID());
153:
154:                return val;
155:            }
156:
157:            protected void print(Preference pref,
158:                    AspectScoreRange definedRange, Enumeration validRanges,
159:                    Logger logger) {
160:                double prefval = pref.getScoringFunction().getBest().getValue();
161:                String prefstr = "" + prefval;
162:                String type = "" + pref.getAspectType();
163:                boolean isDate = false;
164:                switch (pref.getAspectType()) {
165:                case AspectType.START_TIME:
166:                    type = "START_TIME";
167:                    prefstr = "" + new Date((long) prefval);
168:                    isDate = true;
169:                    break;
170:                case AspectType.END_TIME:
171:                    type = "END_TIME";
172:                    prefstr = "" + new Date((long) prefval);
173:                    isDate = true;
174:                    break;
175:                case AspectType.COST:
176:                    type = "COST";
177:                    prefstr = "$" + (long) prefval;
178:                    break;
179:                }
180:
181:                logger.info("pref type " + type + " value " + prefstr + " sf "
182:                        + pref.getScoringFunction());
183:
184:                for (; validRanges.hasMoreElements();) {
185:                    AspectScoreRange range = (AspectScoreRange) validRanges
186:                            .nextElement();
187:                    AspectScorePoint start = range.getRangeStartPoint();
188:                    AspectScorePoint end = range.getRangeEndPoint();
189:                    double startValue = start.getValue();
190:                    double endValue = end.getValue();
191:
192:                    if (isDate) {
193:                        logger.info("<" + new Date((long) (startValue)) + "-"
194:                                + new Date((long) (endValue)) + "> ");
195:                    } else {
196:                        logger.info("<" + startValue + "-" + endValue + "> ");
197:                    }
198:                }
199:                logger.info("");
200:            }
201:
202:            /** only trucks, which have contain pgs, are given to Vishnu */
203:            public boolean interestingAsset(Asset a) {
204:                if (!(a instanceof  GLMAsset)) {
205:                    if (isInfoEnabled())
206:                        info(getName() + ".interestingAsset - ignoring asset "
207:                                + a + " because it's not an GLMAsset.");
208:                    return false;
209:                }
210:
211:                boolean val = ((GLMAsset) a).hasContainPG();
212:                if (isInfoEnabled() && !val)
213:                    info(getName() + ".interestingAsset - ignoring GLMAsset "
214:                            + a + " because it's missing a Contain PG.");
215:                return val;
216:            }
217:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.