Xin_Wang.cpp
Go to the documentation of this file.
1 // ICHWithFurtherPriorityQueue.cpp: implementation of the CXin_Wang class.
2 //
4 
5 #include "Xin_Wang.h"
6 #include <iostream>
7 using namespace std;
8 
9 // dsy
10 int64_t max(int64_t a, const int b)
11 {
12  if (a>b)
13  return a;
14  return (int64_t)b;
15 }
16 
17 CXin_Wang::CXin_Wang(const CRichModel& model, int source) : CICH_WindowFiltering(model, source)
18 {
19  m_nameOfAlgorithm = "ICH2";
20 }
21 CXin_Wang::CXin_Wang(const CRichModel& model, int source, int destination) : CICH_WindowFiltering(model, source, destination)
22 {
23  m_nameOfAlgorithm = "ICH2";
24 }
25 
26 CXin_Wang::CXin_Wang(const CRichModel& model, int source, double R)
27  : CICH_WindowFiltering(model, source, R)
28 {
29  m_nameOfAlgorithm = "ICH2";
30 }
31 
32 CXin_Wang::CXin_Wang(const CRichModel& model, const map<int, double>& sources) : CICH_WindowFiltering(model, sources)
33 {
34  m_nameOfAlgorithm = "ICH2";
35 }
36 
37 CXin_Wang::CXin_Wang(const CRichModel& model, const map<int, double>& sources, const set<int> &destinations) : CICH_WindowFiltering(model, sources, destinations)
38 {
39  m_nameOfAlgorithm = "ICH2";
40 }
41 
42 CXin_Wang::CXin_Wang(const CRichModel& model, const set<int>& sources) : CICH_WindowFiltering(model, sources)
43 {
44  m_nameOfAlgorithm = "ICH2";
45 }
46 
47 CXin_Wang::CXin_Wang(const CRichModel& model, const set<int>& sources, double R)
48  : CICH_WindowFiltering(model, sources, R)
49 {
50  m_nameOfAlgorithm = "ICH2";
51 }
52 
53 CXin_Wang::CXin_Wang(const CRichModel& model, const set<int>& sources, const set<int>& destinations) : CICH_WindowFiltering(model, sources, destinations)
54 {
55  m_nameOfAlgorithm = "ICH2";
56 }
57 
58 
60 {
61  while (!m_QueueForWindows.empty())
62  {
63  delete m_QueueForWindows.top().pWindow;
64  m_QueueForWindows.pop();
65  }
66  m_QueueForPseudoSources = priority_queue<QuoteInfoAtVertex>();
67 }
68 
70 {
71  set<int> tmpDestinations(m_destinations);
72  for (map<int, double>::const_iterator it = m_sources.begin();
73  it != m_sources.end(); ++it)
74  {
75  tmpDestinations.erase(it->first);
76  m_fixedSequence.push_back(it->first);
77  }
79  bool fFromQueueOfPseudoSources = UpdateTreeDepthBackWithChoice();
80 
81  while (!m_QueueForPseudoSources.empty() || !m_QueueForWindows.empty())
82  {
89  if (fFromQueueOfPseudoSources) //pseudosource
90  {
91  int indexOfVert = m_QueueForPseudoSources.top().indexOfVert;
92  //cout << "Vert = " << indexOfVert << endl;
94  if (m_InfoAtVertices[indexOfVert].disUptodate > m_radius)
95  break;
96  tmpDestinations.erase(indexOfVert);
97  m_fixedSequence.push_back(indexOfVert);
98  if (!m_destinations.empty() && tmpDestinations.empty())
99  return;
100  if (!model.IsStronglyConvexVert(indexOfVert))
101  ComputeChildrenOfPseudoSource(indexOfVert);
102  }
103  else
104  {
105  QuoteWindow quoteW = m_QueueForWindows.top();
106  m_QueueForWindows.pop();
107  if (quoteW.disUptodate > m_radius)
108  break;
109  ComputeChildrenOfWindow(quoteW);
110  delete quoteW.pWindow;
111  }
112  fFromQueueOfPseudoSources = UpdateTreeDepthBackWithChoice();
113  }
114 }
115 
116 
117 double CXin_Wang::GetMinDisOfWindow(const Window& w) const
118 {
119  double projProp = w.coordOfPseudoSource.first / model.Edge(w.indexOfCurEdge).length;
120  if (projProp <= w.proportions[0])
121  {
122  double detaX = w.coordOfPseudoSource.first - w.proportions[0] * model.Edge(w.indexOfCurEdge).length;
123  return w.disToRoot + sqrt(detaX * detaX + w.coordOfPseudoSource.second * w.coordOfPseudoSource.second);
124  }
125  if (projProp >= w.proportions[1])
126  {
127  double detaX = w.coordOfPseudoSource.first - w.proportions[1] * model.Edge(w.indexOfCurEdge).length;
128  return w.disToRoot + sqrt(detaX * detaX + w.coordOfPseudoSource.second * w.coordOfPseudoSource.second);
129  }
130  return w.disToRoot - w.coordOfPseudoSource.second;
131 }
132 
134 {
135  //if (model.IsStronglyConvexVert(quoteOfPseudoSource.indexOfVert))
136  // return;
137  m_QueueForPseudoSources.push(quoteOfPseudoSource);
138 }
139 
141 {
143  {
144  delete quoteW.pWindow;
145  return;
146  }
147  quoteW.disUptodate = GetMinDisOfWindow(*quoteW.pWindow);
148  m_QueueForWindows.push(quoteW);
150 }
151 
153 {
154  while (!m_QueueForPseudoSources.empty()
155  && m_QueueForPseudoSources.top().birthTime
156  != m_InfoAtVertices[m_QueueForPseudoSources.top().indexOfVert].birthTimeForCheckingValidity)
158 
159  while (!m_QueueForWindows.empty())
160  {
161  const QuoteWindow& quoteW = m_QueueForWindows.top();
162 
164  {
165  if (quoteW.pWindow->birthTimeOfParent !=
166  m_InfoAtVertices[quoteW.pWindow->indexOfBrachParent].birthTimeForCheckingValidity)
167  {
168  delete quoteW.pWindow;
169  m_QueueForWindows.pop();
170  }
171  else
172  break;
173  }
174  else
175  {
176  if (quoteW.pWindow->birthTimeOfParent ==
177  m_InfoAtAngles[quoteW.pWindow->indexOfBrachParent].birthTime)
178  break;
179  else if (quoteW.pWindow->fIsOnLeftSubtree ==
180  (quoteW.pWindow->entryPropOfParent < m_InfoAtAngles[quoteW.pWindow->indexOfBrachParent].entryProp))
181  break;
182  else
183  {
184  delete quoteW.pWindow;
185  m_QueueForWindows.pop();
186  }
187  }
188  }
189 
190  bool fFromQueueOfPseudoSources(false);
191  if (m_QueueForWindows.empty())
192  {
193  if (!m_QueueForPseudoSources.empty())
194  {
195  const InfoAtVertex& infoOfHeadElemOfPseudoSources = m_InfoAtVertices[m_QueueForPseudoSources.top().indexOfVert];
197  infoOfHeadElemOfPseudoSources.levelOnSequenceTree);
198  fFromQueueOfPseudoSources = true;
199  }
200  }
201  else
202  {
203  if (m_QueueForPseudoSources.empty())
204  {
205  const Window& infoOfHeadElemOfWindows = *m_QueueForWindows.top().pWindow;
207  infoOfHeadElemOfWindows.levelOnSequenceTree);
208  fFromQueueOfPseudoSources = false;
209  }
210  else
211  {
212  const QuoteInfoAtVertex& headElemOfPseudoSources = m_QueueForPseudoSources.top();
213  const QuoteWindow& headElemOfWindows = m_QueueForWindows.top();
214  if (headElemOfPseudoSources.disUptodate <=
215  headElemOfWindows.disUptodate)
216  {
218  m_InfoAtVertices[headElemOfPseudoSources.indexOfVert].levelOnSequenceTree);
219  fFromQueueOfPseudoSources = true;
220  }
221  else
222  {
224  headElemOfWindows.pWindow->levelOnSequenceTree);
225  fFromQueueOfPseudoSources = false;
226  }
227  }
228  }
229  return fFromQueueOfPseudoSources;
230 }
231 
233 {
234  return m_fixedSequence;
235 }
pair< double, double > coordOfPseudoSource
Definition: Chen_Han.h:44
void AddIntoQueueOfWindows(QuoteWindow &quoteW)
Definition: Xin_Wang.cpp:140
vector< int > GetFixedVertSequence() const
Definition: Xin_Wang.cpp:232
void AddIntoQueueOfPseudoSources(const QuoteInfoAtVertex &quoteOfPseudoSource)
Definition: Xin_Wang.cpp:133
double entryPropOfParent
Definition: Chen_Han.h:43
double proportions[2]
Definition: Chen_Han.h:42
virtual void Propagate()
Definition: Xin_Wang.cpp:69
int indexOfBrachParent
Definition: Chen_Han.h:36
map< int, double > m_sources
int levelOnSequenceTree
Definition: Chen_Han.h:39
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
vector< int > m_fixedSequence
Definition: Xin_Wang.h:10
priority_queue< QuoteInfoAtVertex > m_QueueForPseudoSources
Definition: Xin_Wang.h:12
const CEdge & Edge(int edgeIndex) const
Definition: RichModel.cpp:669
double disToRoot
Definition: Chen_Han.h:41
bool UpdateTreeDepthBackWithChoice()
Definition: Xin_Wang.cpp:152
bool fBrachParentIsPseudoSource
Definition: Chen_Han.h:32
bool fIsOnLeftSubtree
Definition: Chen_Han.h:31
char birthTimeOfParent
Definition: Chen_Han.h:35
__int64 m_nCountOfWindows
Definition: Chen_Han.h:85
bool IsStronglyConvexVert(int index) const
Definition: RichModel.cpp:649
void ComputeChildrenOfSource()
Definition: Chen_Han.cpp:248
void ComputeChildrenOfPseudoSource(int indexOfParentVertex)
Definition: Chen_Han.cpp:629
int64_t max(int64_t a, const int b)
Definition: Xin_Wang.cpp:10
priority_queue< QuoteWindow > m_QueueForWindows
Definition: Xin_Wang.h:11
__int64 m_nMaxLenOfPseudoSourceQueue
Definition: Chen_Han.h:84
set< int > m_destinations
virtual bool CheckValidityWithXinWangFiltering(Window &w) const
double GetMinDisOfWindow(const Window &w) const
Definition: Xin_Wang.cpp:117
virtual void Dispose()
Definition: Xin_Wang.cpp:59
CXin_Wang(const CRichModel &model, int source)
Definition: Xin_Wang.cpp:17
vector< InfoAtAngle > m_InfoAtAngles
Definition: Chen_Han.h:82
vector< InfoAtVertex > m_InfoAtVertices
const CRichModel & model
__int64 m_nMaxLenOfWindowQueue
Definition: Chen_Han.h:83
__int64 m_depthOfResultingTree
void ComputeChildrenOfWindow(QuoteWindow &quoteParentWindow)
Definition: Chen_Han.cpp:540


co_scan
Author(s):
autogenerated on Mon Feb 28 2022 23:00:56