neic-glass3  1.4.6
HypoList.h
Go to the documentation of this file.
1 /*****************************************
2  * This file is documented for Doxygen.
3  * If you modify this file please update
4  * the comments so that Doxygen will still
5  * be able to work.
6  ****************************************/
7 #ifndef HYPOLIST_H
8 #define HYPOLIST_H
9 
10 #include <json.h>
11 #include <threadbaseclass.h>
12 #include <vector>
13 #include <list>
14 #include <queue>
15 #include <map>
16 #include <set>
17 #include <memory>
18 #include <utility>
19 #include <string>
20 #include <mutex>
21 #include <thread>
22 #include <random>
23 #include "Glass.h"
24 #include "Hypo.h"
25 
26 namespace glasscore {
27 
28 // forward declarations
29 class CSite;
30 class CPick;
31 class CCorrelation;
32 
39 struct HypoCompare {
40  bool operator()(const std::shared_ptr<CHypo> &lhs,
41  const std::shared_ptr<CHypo> &rhs) const {
42  // sort by tSort
43  if (lhs->getTSort() < rhs->getTSort()) {
44  return (true);
45  }
46  return (false);
47  }
48 };
49 
68  public:
80  explicit CHypoList(int numThreads = 1, int sleepTime = 50,
81  int checkInterval = 300);
82 
88  ~CHypoList();
89 
109  bool addHypo(std::shared_ptr<CHypo> hypo, bool scheduleProcessing = true,
110  CPickList* parentThread = NULL);
111 
122  bool associateData(std::shared_ptr<CPick> pk);
123 
133  bool fitData(std::shared_ptr<CPick> pk);
134 
147  bool associateData(std::shared_ptr<CCorrelation> corr);
148 
152  void clear() override;
153 
168  bool receiveExternalMessage(std::shared_ptr<json::Object> com);
169 
182  bool processHypo(std::shared_ptr<CHypo> hyp);
183 
189  int getHypoProcessingQueueLength();
190 
201  std::vector<std::weak_ptr<CHypo>> getHypos(double t1, double t2);
202 
208  int getMaxAllowableHypoCount() const;
209 
215  int getCountOfTotalHyposProcessed() const;
216 
222  int length() const;
223 
237  bool findAndMergeMatchingHypos(std::shared_ptr<CHypo> hyp);
238 
248  int appendToHypoProcessingQueue(std::shared_ptr<CHypo> hyp);
249 
258  std::shared_ptr<CHypo> getNextHypoFromProcessingQueue();
259 
270  void removeHypo(std::shared_ptr<CHypo> hypo, bool reportCancel = true);
271 
283  bool requestHypo(std::shared_ptr<json::Object> com);
284 
300  bool resolveData(std::shared_ptr<CHypo> hypo, bool allowStealing = true);
301 
307  void setMaxAllowableHypoCount(int hypoMax);
308 
325  glass3::util::WorkState work() override;
326 
327  // constants
332  static constexpr double k_nHypoSearchPastDurationForPick = 3600;
333 
334  private:
340  void updatePosition(std::shared_ptr<CHypo> hyp);
341 
346  void eraseFromMultiset(std::shared_ptr<CHypo> hyp);
347 
352  std::atomic<int> m_iMaxAllowableHypoCount;
353 
358  std::atomic<int> m_iCountOfTotalHyposProcessed;
359 
365  std::list<std::weak_ptr<CHypo>> m_lHypoProcessingQueue;
366 
370  std::mutex m_HypoProcessingQueueMutex;
371 
376  std::multiset<std::shared_ptr<CHypo>, HypoCompare> m_msHypoList;
377 
382  std::map<std::string, std::shared_ptr<CHypo>> m_mHypo;
383 
391  mutable std::recursive_mutex m_HypoListMutex;
392 
393  // constants
397  static const int k_nMaxAllowableHypoCountDefault = 100;
398 
402  static const unsigned int k_nNumberOfMergeAnnealIterations = 2000;
403 
407  static constexpr double k_dFinalMergeAnnealTimeStepSize = 0.01;
408 
413  static constexpr double k_dMergeStackImprovementRatio = 0.1;
414 
418  static constexpr double k_dMinimumRoundingProtectionRatio = 0.99;
419 
423  static constexpr double k_dExistingTimeTolerance = 5.0;
424 
428  static constexpr double k_dExistingDistanceTolerance = 0.5;
429 };
430 } // namespace glasscore
431 #endif // HYPOLIST_H
CHypoList comparison function.
Definition: HypoList.h:39
glasscore pick list class
Definition: PickList.h:62
WorkState
glass3::util::WorkState enumeration
Definition: workstate.h:25
glasscore hypocenter list class
Definition: HypoList.h:67
bool operator()(const std::shared_ptr< CHypo > &lhs, const std::shared_ptr< CHypo > &rhs) const
Definition: HypoList.h:40
The namespace containing the core algorithm.
Definition: Correlation.h:17
glass3::util::ThreadBaseClass class
Definition: threadbaseclass.h:34