00001 /* PathSearchAI.h 00002 ===BIKEQUEST=== 00003 Author: Bill Cabral 00004 */ 00005 00006 #ifndef PathSearchAI_h 00007 #define PathSearchAI_h 00008 00009 #include <iostream> 00010 #include <string> 00011 #include "BQStructs.H" 00012 00013 class DBInterface; 00014 00015 /* 00016 * AIStreetSeg: A custom data structure designed to hold a street segment and the segment's parent 00017 * Needed to construct the final linked list of intersections 00018 */ 00020 typedef struct AIStreetSeg{ 00021 seg_t* seg; 00022 seg_t* parent; 00023 }AIseg_t; 00024 00025 using namespace std; 00026 00027 /* This class provides the functionality necessary to find an optimal path from A to B. 00028 * The types of data being passed around are basically set: 00029 * streetSeg and userPrefs are structs that will be defined elsewhere in our project 00030 */ 00031 00033 class PathSearchAI 00034 { 00035 public: 00036 00037 /* 00038 * Default Constructor 00039 */ 00041 PathSearchAI( DBInterface* db ); 00042 //default destructor 00044 ~PathSearchAI(); 00045 /* 00046 * findAtoBPath: seg_t*, seg_t*, userPrefs_t => path_t 00047 * This will return a path from seg_t to seg_t given user preferences (and unique seg_t's) 00048 */ 00050 path_t* findAtoBPath(seg_t*, seg_t*, userPrefs_t); 00051 00052 /* 00053 * findAtoAPath: seg_t*, seg_t*, double, userPrefs_t => path_t 00054 * This will return a path from seg_t to itself in a loop route of the given distance 00055 */ 00057 path_t* findAtoAPath(seg_t*, double, userPrefs_t); 00058 00059 protected: 00060 00061 private: 00062 00064 DBInterface *m_db; 00065 00066 /* 00067 * heuristic: seg_t*, seg_t*, seg_t*, userPrefs_t => double 00068 * This function will set and return the heuristic value for a street segment 00069 * It relies on user preferences that are passed in, and street data from the database 00070 * The values returned will determine which neighbor is the best 00071 */ 00072 00074 double heuristic(seg_t*, seg_t*, seg_t*, userPrefs_t); 00075 00076 /* 00077 * heuristicAtoA: seg_t*, seg_t*, double, double, userPrefs_t => double 00078 * Same as heuristic above, but modified to create a loop route 00079 */ 00080 00082 double heuristicAtoA(seg_t*, seg_t*, double, double, userPrefs_t); 00083 00084 /* 00085 * insertInOpenList 00086 * uses an iterator to insert an element into the open list 00087 */ 00089 void insertInOpenList(vector<AIseg_t>& list, seg_t* goal, AIseg_t curr, double heurVal, userPrefs_t prefs); 00090 00091 /* 00092 * inList 00093 * returns a boolean saying if the element was in the given list 00094 */ 00096 bool inList(vector<AIseg_t> list, AIseg_t segment); 00097 00098 /* 00099 * findParent 00100 * searches the given list for the parent of the given child 00101 */ 00103 AIseg_t findParent(vector<AIseg_t> list, seg_t* child); 00104 00105 00106 }; 00107 #endif 00108