Source Code Cross Referenced for GLMLocationScoringFunction.java in  » Science » Cougaar12_4 » org » cougaar » glm » util » 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.glm.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*  */
002:        /*
003:         * <copyright>
004:         *  
005:         *  Copyright 1997-2004 BBNT Solutions, LLC
006:         *  under sponsorship of the Defense Advanced Research Projects
007:         *  Agency (DARPA).
008:         * 
009:         *  You can redistribute this software and/or modify it under the
010:         *  terms of the Cougaar Open Source License as published on the
011:         *  Cougaar Open Source Website (www.cougaar.org).
012:         * 
013:         *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
014:         *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
015:         *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
016:         *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
017:         *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
018:         *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
019:         *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
020:         *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
021:         *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
022:         *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
023:         *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
024:         *  
025:         * </copyright>
026:         */
027:
028:        package org.cougaar.glm.util;
029:
030:        import java.util.Enumeration;
031:
032:        import org.cougaar.glm.ldm.plan.GeolocLocation;
033:        import org.cougaar.planning.ldm.plan.AspectLocation;
034:        import org.cougaar.planning.ldm.plan.AspectScorePoint;
035:        import org.cougaar.planning.ldm.plan.AspectType;
036:        import org.cougaar.planning.ldm.plan.AspectValue;
037:        import org.cougaar.planning.ldm.plan.ScoringFunction;
038:        import org.cougaar.util.Empty;
039:        import org.cougaar.util.log.Logger;
040:
041:        /** 
042:         * Represents a location scoring function - score gets worse (higher or lower?)
043:         * as straight-line distance from Lat, Lon increases.
044:         * ?We'd like this to be part of the COUGAAR baseline...?
045:         */
046:
047:        public class GLMLocationScoringFunction extends
048:                ScoringFunction.PreferredValueScoringFunction {
049:            public static double EPSILON = 1.0d;
050:
051:            /**
052:             * Makes an AspectLocation, which I assume to have type AspectType.POD.
053:             * (It's not clear anywhere that it should be anything else...)
054:             *
055:             * @see org.cougaar.planning.ldm.plan.AspectLocation
056:             * @see org.cougaar.planning.ldm.plan.AspectType
057:             */
058:            public GLMLocationScoringFunction(GeolocLocation loc, Logger logger) {
059:                super (AspectValue.newAspectValue(AspectType.POD, loc), 0);
060:                //    my_loc = loc;
061:                measureHelper = new GLMMeasure(logger);
062:            }
063:
064:            /** 
065:             * This doesn't make any sense --- there is no way to represent this.
066:             * Geolocs are two-tuples, and so don't map onto AspectValues, which
067:             * are doubles.
068:             *
069:             * @param lowerbound (ignored)
070:             * @param upperbound (ignored)
071:             * @return Enumeration
072:             */
073:            public Enumeration getValidRanges(AspectValue lowerbound,
074:                    AspectValue upperbound) {
075:                return Empty.enumeration;
076:            }
077:
078:            /** 
079:             * This doesn't make any sense --- there is no way to represent this.
080:             * Geolocs are two-tuples, and so don't map onto AspectValues, which
081:             * are doubles.
082:             *
083:             * @param lowerbound (ignored)
084:             * @param upperbound (ignored)
085:             * @return null
086:             */
087:            public AspectScorePoint getMinInRange(AspectValue lowerbound,
088:                    AspectValue upperbound) {
089:                AspectScorePoint asp = null;
090:                return asp;
091:            }
092:
093:            /** 
094:             * This doesn't make any sense --- there is no way to represent this.
095:             * Geolocs are two-tuples, and so don't map onto AspectValues, which
096:             * are doubles.
097:             *
098:             * @param lowerbound (ignored)
099:             * @param upperbound (ignored)
100:             * @return null
101:             */
102:            public AspectScorePoint getMaxInRange(AspectValue lowerbound,
103:                    AspectValue upperbound) {
104:                AspectScorePoint asp = null;
105:                return asp;
106:            }
107:
108:            /**
109:             * The score is based on the distance between the two points in furlongs.
110:             * There are many better measures, but this works for now.
111:             * 
112:             * @return WORST if bad data only, though we should probably throw an exception
113:             */
114:            public double getScore(AspectValue av) {
115:                if (!(av instanceof  AspectLocation))
116:                    return ScoringFunction.WORST;
117:
118:                AspectLocation av_loc = (AspectLocation) av;
119:                GeolocLocation loc = (GeolocLocation) av_loc.getLocationValue();
120:                GeolocLocation my_loc = getLocation();
121:
122:                if (loc != null) {
123:                    if (loc.getLongitude() != null && loc.getLatitude() != null
124:                            && my_loc.getLongitude() != null
125:                            && my_loc.getLatitude() != null) {
126:
127:                        double score_as_distance = measureHelper
128:                                .distanceBetween(loc, my_loc).getFurlongs();
129:                        return score_as_distance;
130:                    }
131:                }
132:
133:                // drop through - WORST after last point.
134:                return ScoringFunction.WORST;
135:            }
136:
137:            // Do we want to return a copy?  i.e. a new instance?
138:            //  The dates used to be new instances of dates...
139:            public GeolocLocation getLocation() {
140:                AspectLocation al = (AspectLocation) getBest().getAspectValue();
141:                return (GeolocLocation) al.getLocationValue();
142:            }
143:
144:            public static void main(String[] args) {
145:                //    PlanningFactory ldmf = getLDM().getFactory();
146:
147:                //    NewGeolocLocation new_gl = ldmf.newGeolocLocation();
148:                //    new_gl.setName("Ad Dammam, SA");
149:                //    new_gl.setGeolocCode("ABFL");
150:                //    new_gl.setLatitude(Latitude.newDegrees("26.43"));
151:                //    new_gl.setLongitude(Longitude.newDegrees("50.1"));
152:
153:                //    ScoringFunction sf = new GLMLocationScoringFunction (new_gl);
154:                //    setDebug (true);
155:
156:                //    AspectLocation a_loc = new AspectLocation (AspectType.POD, 
157:                //					    (double) beforeearly.getTime ());
158:                //    logger.isDebugEnabled() ("Score for before early " + sf.getScore (a_loc));
159:
160:                //     a_loc = new AspectLocation (AspectType.POD, (double) early.getTime ());
161:                //     logger.isDebugEnabled() ("Score for early " + sf.getScore (a_loc));
162:
163:                //USE THIS ONE FIRST    a_loc = new AspectLocation (AspectType.POD, new_gl);
164:                //    logger.isDebugEnabled() ("Score for best " + sf.getScore (a_loc));
165:
166:                //     a_loc = new AspectLocation (AspectType.POD, (double) late.getTime ());
167:                //     logger.isDebugEnabled() ("Score for late " + sf.getScore (a_loc));
168:
169:                //     a_loc = new AspectLocation (AspectType.POD, (double) afterlate.getTime ());
170:                //     logger.isDebugEnabled() ("Score for after late " + sf.getScore (a_loc));
171:            }
172:
173:            protected GLMMeasure measureHelper;
174:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.