00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef ESTAR_ALGORITHM_HPP
00022 #define ESTAR_ALGORITHM_HPP
00023
00024
00025 #include <estar/CSpace.hpp>
00026 #include <estar/Queue.hpp>
00027 #include <estar/Upwind.hpp>
00028 #include <estar/PropagatorFactory.hpp>
00029 #include <boost/shared_ptr.hpp>
00030 #include <boost/scoped_ptr.hpp>
00031 #include <map>
00032
00033
00034 namespace estar {
00035
00036
00037 class Kernel;
00038
00039
00045 class Algorithm {
00046 public:
00047 Algorithm(
00048 boost::shared_ptr<BaseCSpace> cspace,
00052 bool check_upwind,
00056 bool check_local_consistency,
00060 bool check_queue_key,
00064 bool auto_reset,
00069 bool auto_flush);
00070
00088 void AddVertex(vertex_t vertex, const Kernel & kernel);
00089
00103 void AddGoal(vertex_t vertex, double value);
00104
00111 void RemoveGoal(vertex_t vertex);
00112
00119 void RemoveAllGoals();
00120
00134 void Reset();
00135
00139 bool IsGoal(vertex_t vertex) const;
00140
00159 void SetMeta(vertex_t vertex, double meta, const Kernel & kernel);
00160
00189 void ComputeOne(const Kernel & kernel,
00197 double slack);
00198
00203 bool HaveWork() const;
00204
00206 boost::shared_ptr<BaseCSpace const> GetCSpace() const { return m_cspace; }
00207
00209 const cspace_t & GetCSpaceGraph() const { return m_cspace_graph; }
00210
00212 const value_map_t & GetValueMap() const { return m_value; }
00213
00215 const meta_map_t & GetMetaMap() const { return m_meta; }
00216
00218 const rhs_map_t & GetRhsMap() const { return m_rhs; }
00219
00221 const flag_map_t & GetFlagMap() const { return m_flag; }
00222
00229 const vertexid_map_t & GetVertexIdMap() const
00230 { return m_cspace->GetVertexIdMap(); }
00231
00233 const Queue & GetQueue() const { return m_queue; }
00234
00237 const Upwind & GetUpwind() const { return m_upwind; }
00238
00243 Queue & GetQueue() { return m_queue; }
00244
00247 size_t GetStep() const { return m_step; }
00248
00250 double GetLastComputedValue() const { return m_last_computed_value; }
00251
00253 vertex_t GetLastComputedVertex() const { return m_last_computed_vertex; }
00254
00257 double GetLastPoppedKey() const { return m_last_popped_key; }
00258
00259
00260 private:
00261 typedef std::set<vertex_t> goalset_t;
00262
00263
00264 void UpdateVertex(vertex_t vertex, const Kernel & kernel);
00265 void DoComputeOne(const Kernel & kernel, double slack);
00266
00267 boost::shared_ptr<BaseCSpace> m_cspace;
00268 Queue m_queue;
00269 Upwind m_upwind;
00270
00271 goalset_t m_goalset;
00272
00273 size_t m_step;
00274 double m_last_computed_value;
00275 vertex_t m_last_computed_vertex;
00276 double m_last_popped_key;
00277
00278 bool m_pending_reset;
00279 bool m_auto_reset;
00280 bool m_auto_flush;
00281
00282 cspace_t & m_cspace_graph;
00283 value_map_t & m_value;
00284 meta_map_t & m_meta;
00285 rhs_map_t & m_rhs;
00286 flag_map_t & m_flag;
00287
00288 boost::scoped_ptr<PropagatorFactory> m_propfactory;
00289 };
00290
00291
00292 }
00293
00294 #endif // ESTAR_ALGORITHM_HPP