root/trunk/Search.java

Revision 3, 1.8 kB (checked in by dpaola2, 1 week ago)

old pathways project added

Line 
1 // Search - copyright Tom Felker, <tfelker2@uiuc.edu>, December 2004
2 //
3 // stores information specific to a search, especially information
4 // that will be needed in computing heuristics
5
6 // everything here is added on an as-needed basis so it can be minimal
7 public abstract class Search {
8         public Node getOrigin() { return origin; }
9         public Node getDestination() { return destination; }
10         public double getWalkingSpeed() { return walkingSpeed; }
11         public boolean getBusEnable() { return busEnable; }
12
13         // these two methods must be called before performing a search
14         public void setOrigin(PhysicalNode o) { origin = o; }
15         public void setDestination(PhysicalNode d ) { destination = d; }
16
17         public void setWalkingSpeed(double s) { walkingSpeed = s; fastestTransportationSpeed = s; }
18         public void setBusEnable(boolean e) {
19                 busEnable = e;
20                 if(busEnable)
21                         fastestTransportationSpeed = 10;
22                 else
23                         fastestTransportationSpeed = walkingSpeed;
24         }
25
26         Search() {
27                 // see the above changes in busenable
28                 // this is so that the heuristic is tighter
29                 // if we disable busses.
30                 fastestTransportationSpeed = 1.4;
31                 this.walkingSpeed = 1.4;
32         }
33
34         Search(PhysicalNode origin, PhysicalNode destination, double walkingSpeed) {
35                 this.origin = origin;
36                 this.destination = destination;
37                 fastestTransportationSpeed = walkingSpeed;
38                 this.walkingSpeed = walkingSpeed;
39         }
40
41         // various types of search must override this
42         // this is called computeBestPath because the path it returns can be
43         // changed, and to emphasize that is actually doing significant work,
44         // as opposed to get* functions, which quickly return an object
45         // we shouldn't change.
46         public abstract Path computeBestPath();
47
48         protected PhysicalNode origin, destination;
49
50         protected double fastestTransportationSpeed;
51         protected double walkingSpeed;
52         protected boolean busEnable;
53 }
54
Note: See TracBrowser for help on using the browser.