Some ExSan code regarding clustering implementation
c++ |ExSan| ++ ↄ
iX ilinkedIn exsan.plusplus@gmail.com Fri Mar 14 10:46:16 2025 x: R.J.Y JOB: quantumC_4616quantumC
ExSan's Clusters
  
     
1  
     
2  
     
3  //-------------at the end of the data capture --here clustering-------//
     
4  frameClk[1] = pt::microsec_clock::local_time();
     
6  for (i = 1; i <= net->get_rows_in_page(ppDataIn, 'f'); i++) { aryStockAux[i]  = 0; }  //those complete records
     
7  if (loadNtimeLapse &&  frameClk[1] - frameClk[0] > xClkFrame && frameCounterDatum) { //cluster
     
8     isTimeLapseOver = false;      // reset to start a new time lapse            
     
9     //fout << "\n\t\t\t\t:1940: End Time frameClk[1]: " << frameClk[1];
    
11     fout << "\n\t:*2050*: END CLK -Reset Time Lapse-Frame " << frameClk[1] - frameClk[0] << " > " << xClkFrame << "\ttimelapse = 1";
    
12     //<< "  Reset Time Lapse, stockPtr = stockPtr->get_next()"; // << "  error:" (frameClk[1] - frameClk[0]) / frameClk[0] << "%";
    
14     //fout << "\n\t:1790: AryStock "; for (i = 1; i <= stockCounterDB; i++) { fout << aryStock[i]; }     
    
16     //this 2 instructions maybe later when needed
    
17     // not used this procedure, cluster replase the block             
    
18  
    
19     /*
    
22     stockPtr = net->goto_row(net, ppTime, firstRow, 'f');  // point at the beggining
    
23     for (i = firstRow ; i <= lastRow; ++i) {//error  check for 1 and 2 they are different, take out of this loop
    
24        if (!aryStockAux[i]) { stockPtr = stockPtr->get_down_ptr();  continue; }
    
25        //...
    
26        stockPtr = stockPtr->get_down_ptr();
    
27     }
    
28     */
    
29     //fout << "\n\t:2066: stockCounterDB: " << stockCounterDB;            
    
30     counter = 0;   // counts  the clusters that have valid input
    
31     unsigned short kth(0);
    
32     double spreadCenter(0);            
    
33     
    
37     stockPtr = net->goto_row(net, ppDataIn, firstRow, 'f');  // point at the beggining                        
    
38     minDB = 5;
    
39     unsigned short counToPortfolio(0);
    
40  
    
41     counter = countElementInAry(aryStockActive, true, firstRow, lastRow); //initial counter all are assumed as valid inputs
    
43  
    
44     //--------------------------------------------------------------------------------------------------------     //stPtr
    
45     if (!arySAPrevious[0]) {fout.flush() << "\n\t\t:2103: *0* NO PREVIOUS ARY ACTIVE - FIRST EVER Clusters"; 
    
46        if (counter < minDB) {//ok  *0.0*
    
47           for (i = firstRow; i <= lastRow; ++i) {//first/last from aryStockActive
    
48              if (!aryStockActive[i]) { stockPtr = stockPtr->get_down_ptr(); continue; }
    
50              stockPtr->get_ptrLasTick()->reset_ntCounter();//only resest data in cluster remains, previus was last input
    
52              if (loadNtimeLapse == 1) {
    
53                 stockPtr->get_ptrLasTick()->set_bool(pp_bool, false); // next cluster is set not active
    
55              }
    
56              else {
    
57                 //rowPtr->set_status(1, true); //   index 0 used index 1 to flag this stock activity
    
59                 stockPtr->get_ptrLasTick()->set_bool(pp_bool, true);  //before populating make it available                        
    
61              }
    
62              stockPtr = stockPtr->get_down_ptr();
    
63           }
    
64        }
    
66           //counter = 0;  counter of aryStockActive is set at the begining
    
67           for (i = firstRow; i <= lastRow; ++i) {// //first/last from aryStockActive
    
68              if (!aryStockActive[i]) { stockPtr = stockPtr->get_down_ptr(); continue; }
    
69              //check if cluster representative value is valid
    
70              if (loadNtimeLapse == 1) {
    
71                 ptrAry[0] = stockPtr->get_backward_ptr();  //auxiliar tree
    
72                 ptr = stockPtr->get_ptrLasTick();  //ptr to the current cluster               
    
75                 //ptr->set_timeStamp(frameClk[1]);  //dummy instruction cluster time stamp  ????? wasn't it already set????
    
77                 //fout << "\n\t\t"; ptr->Tree_Inorder_nt_data(ptr, ptr->get_ntHead(), 'f', ppnt_data, 0);  //0 just  _page_nt[page
    
81                 //*//use the auxiliar tree                  
    
82                 ndptrAry[0] = ndptrAry[1] = ptrAry[0]->get_ntHead();
    
83                 while (ndptrAry[0]->get_nt_left_ptr())  ndptrAry[0] = ndptrAry[0]->get_nt_left_ptr(); //find min
    
84                 while (ndptrAry[1]->get_nt_right_ptr()) ndptrAry[1] = ndptrAry[1]->get_nt_right_ptr(); //find mx
    
86                 kth = 0;
    
87                 spreadCenter = 0;
    
89                 spreadCenter = (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_data(ppnt_data)) / 2.;
    
91                 if (ptr->get_ntCounter() % 2) { //   fout << "\n\t:1883: ODD ntCounter:-> " << ptr->get_ntCounter(); //impar      
    
92                    kth = 1 + ptr->get_ntCounter() / 2;  //fout << "\tkth: " << kth;
    
93                    ndptrAry[0] = net->InOrderFindKth_nt(net, stockPtr->get_backward_ptr()->get_ntHead(), kth);  //OK  auxiliar cl
    
94                    //ndptrAry[0] = net->InOrderFindKey_nt(net, ptr->get_ntHead(), kth);  ///NO 
    
96                    ptr->set_data(ppDataIn, ndptrAry[0]->get_nt_data(ppnt_data));
    
97                    //ptr->set_data(ppTime, ndptrAry[0]->get_nt_data(ppnt_time)); //already done during streming
    
98                 }
    
99                 else { //fout << "\n\t:2099: EVEN ntCounter:-> " << ptr->get_ntCounter(); // par                     
    
100                    unsigned short kth = ptr->get_ntCounter() / 2;  //left
   
101                    ndptrAry[0] = net->InOrderFindKth_nt(net, stockPtr->get_backward_ptr()->get_ntHead(), kth);   //OK
   
102                    //ndptrAry[0] = net->InOrderFindKey_nt(net, ptr->get_ntHead(), kth); //NO 
   
104                    kth = 1 + ptr->get_ntCounter() / 2; // right
   
105                    ndptrAry[1] = net->InOrderFindKth_nt(net, stockPtr->get_backward_ptr()->get_ntHead(), kth);
   
106                    if (0) {
   
108                       fout << "\n\t\t:2153: CENTRAL DATUM:-> " << (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_dat
   
109                    }
   
110                    ptr->set_data(ppDataIn, (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_data(ppnt_data)) / 2.);
   
112                    //fout << "\n\t\t:1893: To Cluster Spread - Center:-> " << ptr->get_data(ppDataIn);
   
113                 }
   
114                 //auxiliar ntTree
   
116                 if (stockPtr->get_backward_ptr()->get_ntHead())  fout << "\n\t\t:2161: Errror head of auxiliar Cluster not nill ";
   
117                 if (checkThisRow == ptr->get_row())
   
119              }
   
120              else {//fout << "\n\t\t:2120: New Version - ntNodes Not Deleted" ;                                       
   
121                 // much more simpler instruction from is omited                     
   
122                 ndptrAry[0] = ndptrAry[1] = nullptr;  // ! both initialized in null                     
   
125                 spreadCenter = (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_data(ppnt_data)) / 2.;
   
126  
   
130                    ptr->set_data(ppDataIn, ndptrAry[0]->get_nt_data(ppnt_data));
   
131                    ptr->set_data(ppTime, ndptrAry[0]->get_nt_data(ppnt_time));   ///very important
   
132                 }
   
133                 else {//fout << "\n\t:2139: EVEN key_index:-> " << setprecision(0) << ptr->get_ushort(pp_key_index); // impar                     
   
135                    if (0) {
   
138                       fout << "\n\t\t:2132: CENTRAL DATUM:-> " << (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_dat
   
139                    }
   
140                    ptr->set_data(ppDataIn, (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_data(ppnt_data)) / 2.);
   
142                 }
   
143              }
   
144  
   
147                 /* Dummy block  ok
   
151                 ptr1 = net->go_to(net, ptr->get_row(), 1);
   
152                 for (unsigned short i = 1; i <= net->get_cols_in_page(ppDataIn, 'f'); i++) {
   
153                    fout << ptr1->get_bool(pp_bool);
   
154                    ptr1 = ptr1->get_next_ptr();
   
155                 }
   
156                 //*/
   
157                 --counter;   // because of the discarded value
   
158                 if (counter < minDB) {fout.flush() << "\n\t\t\t *0.1.0.0* Discard the whole entry";                           
   
159                    counter = 0;
   
161                    firstRowPtr = net->goto_row(net, ppDataIn, pfR, 'f');  // point at the beggining                        
   
162                    for (i = pfR; i <= plR; ++i) {//error  check for 1 and 2 they are different, take out of this loop
   
163                       if (!aryStockActive[i]) { firstRowPtr = firstRowPtr->get_down_ptr(); continue;}
   
164                       aryStockActive[i] = 0; //the rest of the main  loop is not executed
   
166  
   
167                       firstRowPtr->get_ptrLasTick()->reset_ntCounter();//only resest data in cluster remains, previus was last i
   
169  
   
170                       if (loadNtimeLapse == 1) {
   
171                          firstRowPtr->get_ptrLasTick()->set_bool(pp_bool, false); // next cluster is set not active
   
173                       }
   
174                       else {
   
175                          //rowPtr->set_status(1, true); //   index 0 used index 1 to flag this stock activity
   
177                          firstRowPtr->get_ptrLasTick()->set_bool(pp_bool, true);  //before populating make it available      
   
179                       }
   
180                       firstRowPtr = firstRowPtr->get_down_ptr();
   
181                    }
   
182                 }
   
183                 else {  //  *0.1.0.1* discard this stock only    //ok
   
184                    aryStockActive[i] = 0; //set to zero 
   
185                    stockPtr->get_ptrLasTick()->reset_ntCounter();//only resest data in cluster remains, previus was last input
   
187                    if (loadNtimeLapse == 1) {
   
188                       stockPtr->get_ptrLasTick()->set_bool(pp_bool, false); // next cluster is set not active
   
190                    }
   
191                    else {
   
192                       //rowPtr->set_status(1, true); //   index 0 used index 1 to flag this stock activity
   
194                       stockPtr->get_ptrLasTick()->set_bool(pp_bool, true);  //before populating make it available                        
   
196                    }
   
197                 }                        
   
198              }
   
199              else {fout.flush() << "\n\t\t\t:2243: *0.1.1* VALID CLUSTER - Move to new Col";
   
200                 if (ptr->get_col() == net->get_cols_in_page(ppDataIn, 'f')) { //end of the record                                                
   
201                    stockPtr->tickInPoinTo(stockPtr->get_forward_ptr()); //next cluster in col 1
   
204                 }
   
205                 else {//fout << "\n\t\t:1890: Update Cluster ---> " << stockPtr->get_ptrLasTick()->get_col();         
   
207                    stockPtr->tickInToNextCluster();  //points the next cluster                     
   
208                    ////  reset  cluster    counter
   
209                    //ptr->set_ushort(pp_key_index, 0); // Node is completed 
   
212                    //creo este block era valido para la version anterior... useless now ?????                  
   
213                    /*
   
214                    double duration = (ptr->get_timeStamp() - stockPtr->get_ptrLasTick()->get_timeStamp()).total_microseconds();
   
215                    //fout << "\t microseconds: " << duration;
   
220                    */
   
221                 }
   
222                 //stockPtr->get_ptrLasTick()->set_bool(pp_bool, false); // next cluster is set not active  nooooo 
   
224                 //} //closes this if (stockPtr->get_ptrLasTick()->get_ntHead()) {                                              
   
225                 /*
   
226                 else{
   
228                    if (stockPtr->get_ptrLasTick()->get_col() == 1) {
   
229                       ptr1 = net->go_to(net, stockPtr->get_ptrLasTick()->get_row(), net->get_cols_in_page(ppDataIn, 'f'));
   
230                    }
   
231                    else ptr1 = stockPtr->get_ptrLasTick()->get_previous_ptr();
   
232                    if (ptr1->get_bool(pp_bool)) {//fout << "\tIt was true";
   
233                       ptr1->set_bool(pp_bool, false);
   
234                    }
   
235                 }
   
236                 */
   
237  
   
238                 /*
   
239                 stockPtr->set_status(0, true);  // SET TRUE ALWAYS AT THE BEGGINING its assume completed
   
241                 ptr1 = net->go_to(net, stockPtr->get_n_row(), 1); //TRAVERSE THE WHOLE RECORD from the begining
   
242                 fout << "\tTraverse Record: " << stockPtr->get_row();
   
243                 for (unsigned short ii = 1; ii <= net->get_cols_in_page(ppDataIn, 'f'); ii++) {
   
244                    if (!(stockPtr->get_status(0) && ptr1->get_bool(pp_bool))) {
   
245                       fout << ptr1->get_bool(pp_bool) << "    this record is incomplete-> disable ";
   
246                       stockPtr->set_status(0, false);
   
247                       break;
   
248                    }
   
249                    //fout << ptr1->get_bool(pp_bool);
   
250                    ptr1 = ptr1->get_next_ptr();
   
251                 }
   
252                 if (stockPtr->get_status(0)) {  //true
   
253                    aryStockAux[stockPtr->get_n_row()] = 1;  //selected for possible portfolio
   
254                    ++counToPortfolio;
   
255                    fout << "\n\t:2291: Record Complete Cluster - Time  counter: " << counToPortfolio;
   
256                 }
   
257                 else { fout << "\n\t\t:2302: Record:" << stockPtr->get_ptrLasTick()->get_row() << " INCOMPLETE Clusters - Record: 
   
258                 */
   
259                 /* no need to execute this block, there is no previous round!!!*/
   
260  
   
261                 //if(!arySAPrevious[0]) arySAPrevious[0] = 1;  //reset to 1                        
   
262                 arySAPrevious[i] = aryStockActive[i];  //make a copy
   
264              }                     
   
265              stockPtr = stockPtr->get_down_ptr();
   
266           }   
   
267           if(counter >= minDB)  arySAPrevious[0] = 1; // there is a previous valid set of clusters
   
268        }
   
269     }
   
270     
   
271     else {fout.flush() << "\n\t\t:2311: *1* //there is already the first initial stage  -TRUE- arySAPrevious[0]: " << arySAPrevious[0]
   
272        if (counter < minDB) {fout.flush() << "\n\t\t:2282: *1.0* RESET clusters    counter " << counter << " < " << minDB << "minDB";
   
273           arySAPrevious[0] = 0;  // previous round is reset
   
275           //lets do a single traversal
   
276           firstRow = min(firstRow, pfR);
   
277           lastRow = max(lastRow, plR);
   
278           stockPtr = net->goto_row(net, ppDataIn, firstRow, 'f'); // firstRow may have changed
   
279           for (i = firstRow; i <= lastRow; ++i) {//error  check for 1 and 2 they are different, take out of this loop                     
   
280              if(aryStockActive[i]){ //RESETS CURRENT ENTRY
   
282  
   
283                 stockPtr->get_ptrLasTick()->reset_ntCounter();//only resest data in cluster remains, previus was last input
   
285  
   
286                 if (loadNtimeLapse == 1) {
   
287                    stockPtr->get_ptrLasTick()->set_bool(pp_bool, false); // next cluster is set not active
   
289                 }
   
290                 else {
   
291                    //rowPtr->set_status(1, true); //   index 
   
292                    // |0 used index 1 to flag this stock activity
   
294                    stockPtr->get_ptrLasTick()->set_bool(pp_bool, true);  //before populating make it available                        
   
296                 }
   
297              }
   
298              if (arySAPrevious[i]) {
   
299                 ptr = stockPtr->get_ptrLasTick(); //ok, previous round point to the last entry ?????
   
300                 if (arySAPrevious[i] == aryStockActive[i]) {//stock has previous entry                           
   
301                    if (ptr->get_col() == 1) ptr1 = net->go_to(net, stockPtr->get_n_row(), net->get_cols_in_page(ppDataIn, 'f'));
   
302                    else ptr = ptr->get_previous_ptr();
   
303                 }
   
304                 else {/*stock DOES NOT has previous entry  -default- */   }                        
   
305  
   
307  
   
308                 ptr->reset_ntCounter();//only resest data in cluster remains, previus was last input
   
309                 fout.flush() << " bool/false counter/0 (" << ptr->get_row() << "," << ptr->get_col() << ")";
   
310  
   
311                 if (loadNtimeLapse == 1) {
   
312                    ptr->set_bool(pp_bool, false); // next cluster is set not active
   
313                    ptr->Discard_nt_Tree(ptr, ptr->get_ntHead()); // if (ptr->get_ntHead()) fout << "\n\t:1877: root no mull";  //
   
314                 }
   
315                 else {
   
316                    //rowPtr->set_status(1, true); //   index 
   
317                    // |0 used index 1 to flag this stock activity
   
319                    ptr->set_bool(pp_bool, true);  //before populating make it available                        
   
321                 }
   
322              }
   
323              arySAPrevious[i] = aryStockActive[i] = 0; // both ary are reset  previous + current
   
324              stockPtr = stockPtr->get_down_ptr();
   
325           }               
   
326        }
   
327        else{ fout.flush() << "\n\t\t:2282: *1.1* OK counter " << counter << " > " << minDB << "minDB";                                    
   
328           //this block after checking integrity of current set of clusters   
   
329           bool goodCluster(true); //check if previous round has the same set of stocks
   
330           for (i = firstRow; i <= lastRow; ++i) {//error  check for 1 and 2 they are different, take out of this loop
   
331              if (!aryStockActive[i]) { //stockPtr = stockPtr->get_down_ptr(); 
   
332                 continue; 
   
333              }
   
334              if (goodCluster  && arySAPrevious[i] != aryStockActive[i]) {
   
335                 goodCluster = !goodCluster;   // not a good cluster not previous activity                        
   
336                 break;  //exit the for loop
   
337              }
   
338              //stockPtr = stockPtr->get_down_ptr();
   
339           }
   
340           if (!goodCluster) {   fout.flush() << "\n\t\t:2348: *1.1.0* discard previous round of clusters " ;                     
   
341              net->boundaries(net, ppDataIn, 'f', 1, arySAPrevious, pfR, plR);
   
342              stPtr = net->goto_row(net, ppDataIn, pfR, 'f');  // point at the beggining   
   
343              for (i = pfR; i <= plR; ++i) {//error  check for 1 and 2 they are different, take out of this loop
   
344                 if (!arySAPrevious[i]) { stockPtr = stockPtr->get_down_ptr(); continue; }
   
345                 arySAPrevious[i] =  0;
   
346                 ptr = stockPtr->get_ptrLasTick();  //ptr to the current cluster               
   
347                 if (ptr->get_col() == 1) 
   
348                    ptr = net->go_to(net, ptr->get_row(), net->get_cols_in_page(ppDataIn, 'f'));                                                    
   
349                 else 
   
350                    ptr = ptr->get_previous_ptr();
   
351                 fout << "\n\t\t:1890: ptr to previous  Cluster ---> " << ptr->get_col();         
   
352  
   
353                 ptr->reset_ntCounter();//only resest data in cluster remains, previus was last input
   
354                 fout.flush() << " bool/false counter/0 (" << ptr->get_row() << "," << ptr->get_col() << ")";
   
355  
   
356                 if (loadNtimeLapse == 1) {
   
357                    ptr->set_bool(pp_bool, false); // next cluster is set not active
   
358                    ptr->Discard_nt_Tree(ptr, ptr->get_ntHead()); // if (ptr->get_ntHead()) fout << "\n\t:1877: root no mull";  //
   
359                 }
   
360                 else {
   
361                    //rowPtr->set_status(1, true); //   index 
   
362                    // |0 used index 1 to flag this stock activity
   
364                    ptr->set_bool(pp_bool, true);  //before populating make it available                        
   
366                 }                        
   
367                 stPtr = stPtr->get_down_ptr();
   
368              }
   
369              fout.flush() << "\n\t\t:2348:  New Previous";
   
370              countElementInAry(aryStockActive, true, pfR, plR);
   
371              stPtr = net->goto_row(net, ppDataIn, pfR, 'f');  // point at the beggining   
   
372              for (i = pfR; i <= plR; ++i) // previous is set for next round                     
   
373                 arySAPrevious[i] = aryStockActive[i];         
   
374  
   
375           }
   
376           //------------------
   
377           for (i = firstRow; i <= lastRow; ++i) {// //first/last from aryStockActive
   
378              if (!aryStockActive[i]) { stockPtr = stockPtr->get_down_ptr(); continue; }
   
379              //check if cluster representative value is valid
   
380              if (loadNtimeLapse == 1) {
   
381                 ptrAry[0] = stockPtr->get_backward_ptr();  //auxiliar tree
   
382                 ptr = stockPtr->get_ptrLasTick();  //ptr to the current cluster               
   
385                 //ptr->set_timeStamp(frameClk[1]);  //dummy instruction cluster time stamp  ????? wasn't it already set????
   
387                 //fout << "\n\t\t"; ptr->Tree_Inorder_nt_data(ptr, ptr->get_ntHead(), 'f', ppnt_data, 0);  //0 just  _page_nt[page
   
391                 //*//use the auxiliar tree                  
   
392                 ndptrAry[0] = ndptrAry[1] = ptrAry[0]->get_ntHead();
   
393                 while (ndptrAry[0]->get_nt_left_ptr())  ndptrAry[0] = ndptrAry[0]->get_nt_left_ptr(); //find min
   
394                 while (ndptrAry[1]->get_nt_right_ptr()) ndptrAry[1] = ndptrAry[1]->get_nt_right_ptr(); //find mx
   
396                 kth = 0;
   
397                 spreadCenter = 0;
   
399                 spreadCenter = (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_data(ppnt_data)) / 2.;
   
401                 if (ptr->get_ntCounter() % 2) { //   fout << "\n\t:1883: ODD ntCounter:-> " << ptr->get_ntCounter(); //impar      
   
402                    kth = 1 + ptr->get_ntCounter() / 2;  //fout << "\tkth: " << kth;
   
403                    ndptrAry[0] = net->InOrderFindKth_nt(net, stockPtr->get_backward_ptr()->get_ntHead(), kth);  //OK  auxiliar cl
   
404                    //ndptrAry[0] = net->InOrderFindKey_nt(net, ptr->get_ntHead(), kth);  ///NO 
   
406                    ptr->set_data(ppDataIn, ndptrAry[0]->get_nt_data(ppnt_data));
   
407                    //ptr->set_data(ppTime, ndptrAry[0]->get_nt_data(ppnt_time)); //already done during streming
   
408                 }
   
409                 else { //fout << "\n\t:2099: EVEN ntCounter:-> " << ptr->get_ntCounter(); // par                     
   
410                    unsigned short kth = ptr->get_ntCounter() / 2;  //left
   
411                    ndptrAry[0] = net->InOrderFindKth_nt(net, stockPtr->get_backward_ptr()->get_ntHead(), kth);   //OK
   
412                    //ndptrAry[0] = net->InOrderFindKey_nt(net, ptr->get_ntHead(), kth); //NO 
   
414                    kth = 1 + ptr->get_ntCounter() / 2; // right
   
415                    ndptrAry[1] = net->InOrderFindKth_nt(net, stockPtr->get_backward_ptr()->get_ntHead(), kth);
   
416                    if (0) {
   
418                       fout << "\n\t\t:2153: CENTRAL DATUM:-> " << (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_dat
   
419                    }
   
420                    ptr->set_data(ppDataIn, (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_data(ppnt_data)) / 2.);
   
422                    //fout << "\n\t\t:1893: To Cluster Spread - Center:-> " << ptr->get_data(ppDataIn);
   
423                 }
   
424                 //auxiliar ntTree
   
426                 if (stockPtr->get_backward_ptr()->get_ntHead())  fout << "\n\t\t:2161: Errror head of auxiliar Cluster not nill ";
   
427                 if (checkThisRow == ptr->get_row())
   
429              }
   
430              else {//fout << "\n\t\t:2120: New Version - ntNodes Not Deleted" ;                                       
   
431                 // much more simpler instruction from is omited                     
   
432                 ndptrAry[0] = ndptrAry[1] = nullptr;  // ! both initialized in null                     
   
435                 spreadCenter = (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_data(ppnt_data)) / 2.;
   
436  
   
440                    ptr->set_data(ppDataIn, ndptrAry[0]->get_nt_data(ppnt_data));
   
441                    ptr->set_data(ppTime, ndptrAry[0]->get_nt_data(ppnt_time));   ///very important
   
442                 }
   
443                 else {//fout << "\n\t:2139: EVEN key_index:-> " << setprecision(0) << ptr->get_ushort(pp_key_index); // impar                     
   
445                    if (0) {
   
448                       fout << "\n\t\t:2132: CENTRAL DATUM:-> " << (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_dat
   
449                    }
   
450                    ptr->set_data(ppDataIn, (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_data(ppnt_data)) / 2.);
   
452                 }
   
453              }
   
454  
   
457                 /* Dummy block  ok
   
461                 ptr1 = net->go_to(net, ptr->get_row(), 1);
   
462                 for (unsigned short i = 1; i <= net->get_cols_in_page(ppDataIn, 'f'); i++) {
   
463                    fout << ptr1->get_bool(pp_bool);
   
464                    ptr1 = ptr1->get_next_ptr();
   
465                 }
   
466                 //*/
   
467                 --counter;   // because of the discarded value
   
468                 if (counter < minDB) {fout.flush() << "\n\t\t\t *1.1.0.0* Discard the whole entry";
   
469                    arySAPrevious[0] = 0;  // previous round is reset
   
470                    counter = 0; // DOES IT NEED TO BE RESET?
   
472                    pfR = min(firstRow, pfR);
   
473                    plR = max(lastRow, plR);
   
474                    firstRowPtr = net->goto_row(net, ppDataIn, pfR, 'f');  // point at the beggining                        
   
475                    for (i = pfR; i <= plR; ++i) {//error  check for 1 and 2 they are different, take out of this loop         
   
476                       if (aryStockActive[i]) { 
   
478  
   
479                          firstRowPtr->get_ptrLasTick()->reset_ntCounter();//only resest data in cluster remains, previus was la
   
481  
   
482                          if (loadNtimeLapse == 1) {
   
483                             firstRowPtr->get_ptrLasTick()->set_bool(pp_bool, false); // next cluster is set not active
   
485                          }
   
486                          else {
   
487                             //rowPtr->set_status(1, true); //   index 
   
488                             // |0 used index 1 to flag this stock activity
   
490                             firstRowPtr->get_ptrLasTick()->set_bool(pp_bool, true);  //before populating make it available   
   
492                          }
   
493                       }
   
494  
   
495                       if (arySAPrevious[i]) {
   
496                          ptr = firstRowPtr->get_ptrLasTick(); //ok, previous round point to the last entry ?????
   
497                          if (arySAPrevious[i] == aryStockActive[i]) {//stock has previous entry                        
   
498                             if (ptr->get_col() == 1) ptr1 = net->go_to(net, firstRowPtr->get_n_row(), net->get_cols_in_page(pp
   
499                             else ptr = ptr->get_previous_ptr();
   
500                          }
   
501                          else {/*stock DOES NOT has previous entry  -default- */ }
   
502  
   
504  
   
505                          ptr->reset_ntCounter();//only resest data in cluster remains, previus was last input
   
506                          fout.flush() << " bool/false counter/0 (" << ptr->get_row() << "," << ptr->get_col() << ")";
   
507  
   
508                          if (loadNtimeLapse == 1) {
   
509                             ptr->set_bool(pp_bool, false); // next cluster is set not active
   
511                          }
   
512                          else {
   
513                             //rowPtr->set_status(1, true); //   index 
   
514                             // |0 used index 1 to flag this stock activity
   
516                             ptr->set_bool(pp_bool, true);  //before populating make it available                        
   
518                          }
   
519                       }                              
   
520                       arySAPrevious[i] = aryStockActive[i] = 0; // both ary are reset  previous + current                              
   
521                       firstRowPtr = firstRowPtr->get_down_ptr();
   
522                    }
   
523                 }
   
524                 else {  //  *0.1.0.1* discard this stock only    //ok
   
525                    aryStockActive[i] = 0; //set to zero 
   
526                    stockPtr->get_ptrLasTick()->reset_ntCounter();//only resest data in cluster remains, previus was last input
   
528                    if (loadNtimeLapse == 1) {
   
529                       stockPtr->get_ptrLasTick()->set_bool(pp_bool, false); // next cluster is set not active
   
531                    }
   
532                    else {
   
533                       //rowPtr->set_status(1, true); //   index 0 used index 1 to flag this stock activity
   
535                       stockPtr->get_ptrLasTick()->set_bool(pp_bool, true);  //before populating make it available                        
   
537                    }
   
538  
   
539                    if (arySAPrevious[i]) {
   
540                       ptr = stockPtr->get_ptrLasTick(); //ok, previous round point to the last entry ?????
   
541                       if (arySAPrevious[i] == aryStockActive[i]) {//stock has previous entry                           
   
542                          if (ptr->get_col() == 1) ptr1 = net->go_to(net, stockPtr->get_n_row(), net->get_cols_in_page(ppDataIn,
   
543                          else ptr = ptr->get_previous_ptr();
   
544                       }
   
545                       else {/*stock DOES NOT has previous entry  -default- */ }
   
546  
   
548  
   
549                       ptr->reset_ntCounter();//only resest data in cluster remains, previus was last input
   
550                       fout.flush() << " bool/false counter/0 (" << ptr->get_row() << "," << ptr->get_col() << ")";
   
551  
   
552                       if (loadNtimeLapse == 1) {
   
553                          ptr->set_bool(pp_bool, false); // next cluster is set not active
   
555                       }
   
556                       else {
   
557                          //rowPtr->set_status(1, true); //   index 
   
558                          // |0 used index 1 to flag this stock activity
   
560                          ptr->set_bool(pp_bool, true);  //before populating make it available                        
   
562                       }
   
563                    }
   
564  
   
565                 }
   
566  
   
567                 ///HERE CHECK THE INTEGRITY OF THE SET OF CLUSTERS.....
   
568              }
   
569              else {
   
570                 fout.flush() << "\n\t\t\t:2243: *0.1.1* VALID CLUSTER - Move to new Col";
   
571                 if (ptr->get_col() == net->get_cols_in_page(ppDataIn, 'f')) { //end of the record                                                
   
572                    stockPtr->tickInPoinTo(stockPtr->get_forward_ptr()); //next cluster in col 1
   
575                 }
   
576                 else {//fout << "\n\t\t:1890: Update Cluster ---> " << stockPtr->get_ptrLasTick()->get_col();         
   
578                    stockPtr->tickInToNextCluster();  //points the next cluster                     
   
579                    ////  reset  cluster    counter
   
580                    //ptr->set_ushort(pp_key_index, 0); // Node is completed 
   
583                    //creo este block era valido para la version anterior... useless now ?????                  
   
584                    /*
   
585                    double duration = (ptr->get_timeStamp() - stockPtr->get_ptrLasTick()->get_timeStamp()).total_microseconds();
   
586                    //fout << "\t microseconds: " << duration;
   
591                    */
   
592                 }
   
593                 //stockPtr->get_ptrLasTick()->set_bool(pp_bool, false); // next cluster is set not active  nooooo 
   
595                 //} //closes this if (stockPtr->get_ptrLasTick()->get_ntHead()) {                                              
   
596                 /*
   
597                 else{
   
599                    if (stockPtr->get_ptrLasTick()->get_col() == 1) {
   
600                       ptr1 = net->go_to(net, stockPtr->get_ptrLasTick()->get_row(), net->get_cols_in_page(ppDataIn, 'f'));
   
601                    }
   
602                    else ptr1 = stockPtr->get_ptrLasTick()->get_previous_ptr();
   
603                    if (ptr1->get_bool(pp_bool)) {//fout << "\tIt was true";
   
604                       ptr1->set_bool(pp_bool, false);
   
605                    }
   
606                 }
   
607                 */
   
608  
   
609                 ///*
   
610                 stockPtr->set_status(0, true);  // SET TRUE ALWAYS AT THE BEGGINING its assume completed
   
612                 ptr1 = net->go_to(net, stockPtr->get_n_row(), 1); //TRAVERSE THE WHOLE RECORD from the begining
   
613                 fout << "\tTraverse Record: " << stockPtr->get_row();
   
614                 for (unsigned short ii = 1; ii <= net->get_cols_in_page(ppDataIn, 'f'); ii++) {
   
615                    if (!(stockPtr->get_status(0) && ptr1->get_bool(pp_bool))) {
   
616                       fout << ptr1->get_bool(pp_bool) << "    this record is incomplete-> disable ";
   
617                       stockPtr->set_status(0, false);
   
618                       break;
   
619                    }
   
620                    //fout << ptr1->get_bool(pp_bool);
   
621                    ptr1 = ptr1->get_next_ptr();
   
622                 }
   
623                 if (stockPtr->get_status(0)) {  //true
   
624                    aryStockAux[stockPtr->get_n_row()] = 1;  //selected for possible portfolio
   
625                    ++counToPortfolio;
   
626                    fout << "\n\t:2291: Record Complete Cluster - Time  counter: " << counToPortfolio;
   
627                 }
   
628                 else { fout << "\n\t\t:2302: Record:" << stockPtr->get_ptrLasTick()->get_row() << " INCOMPLETE Clusters - Record: 
   
629                 //*//* (!no) yes need to execute this block, there is previous round!!!*/
   
630  
   
631                 //if(!arySAPrevious[0]) arySAPrevious[0] = 1;  //reset to 1                        
   
632                 arySAPrevious[i] = aryStockActive[i];  //make a copy
   
634              }
   
635              stockPtr = stockPtr->get_down_ptr();
   
636           }
   
637        }
   
638     }
   
639     
   
640     
   
641     if (counToPortfolio >= minDB) { ///
   
642        
   
643     }
   
644     
   
645     //--------------------------------------------------------------------------
   
647  
   
648        if (!arySAPrevious[0]) { //first ever time lapse just reset, do not advance                  
   
649           for (i = firstRow; i <= lastRow; ++i) {//error  check for 1 and 2 they are different, take out of this loop
   
650              if (!aryStockActive[i]) {    stockPtr = stockPtr->get_down_ptr(); continue;    }
   
651  
   
653        
   
654              stockPtr->get_ptrLasTick()->reset_ntCounter();//only resest data in cluster remains, previus was last input
   
656  
   
657              if (loadNtimeLapse == 1) {
   
658                 stockPtr->get_ptrLasTick()->set_bool(pp_bool, false); // next cluster is set not active
   
660              }
   
661              else {
   
662                 //rowPtr->set_status(1, true); //   index 0 used index 1 to flag this stock activity
   
664                 stockPtr->get_ptrLasTick()->set_bool(pp_bool, true);  //before populating make it available                        
   
666              }
   
667              stockPtr = stockPtr->get_down_ptr();
   
668           }               
   
669        }
   
670     }
   
672        if (!arySAPrevious[0]) { //first ever time lapse
   
673           arySAPrevious[0] != arySAPrevious[0];   // from now on check previous
   
674        
   
675           for (i = firstRow; i <= lastRow; ++i) {//error  check for 1 and 2 they are different, take out of this loop
   
676              if (!aryStockActive[i]) { 
   
677              /*  // This block never 
   
679              ptr = stockPtr->get_ptrLasTick();                     
   
680              if(loadNtimeLapse == 1){                     
   
681                 if (ptr->get_col() == 1) {                        
   
682                    ptr = net->go_to(net, ptr->get_row(), net->get_cols_in_page(ppDataIn, 'f')); //TRAVERSE THE WHOLE RECORD
   
683                    if(ptr->get_ntHead()){
   
684                       fout << "\n\t\t\t:2084: Last time occurred in cluster: " << ptr->get_col();
   
686                       ptr->set_bool(pp_bool, false); // next cluster is set not active
   
687                       ptr->reset_ntCounter();//only resest data in cluster remains, previus was last input
   
688                       fout << "\n\t\t\t:2088: Whipe out nTree -  bool/false counter/0 (" << ptr->get_row() << "," << ptr->get_co
   
689                    }
   
690                 }
   
691                 else {
   
692                    ptr = ptr->get_previous_ptr();
   
693                    fout << "\n\t\t\t:2093: Last time occurred in cluster: " << ptr->get_col();
   
694                    if (ptr->get_ntHead()) {
   
696                       ptr->set_bool(pp_bool, false); // next cluster is set not active
   
697                       ptr->reset_ntCounter();//only resest data in cluster remains, previus was last input
   
698                       fout << "\n\t\t\t:2097: Whipe out nTree -  bool/false counter/0 (" << ptr->get_row() << "," << ptr->get_co
   
699                    }                           
   
700                 }                     
   
701              }
   
702              else{ //static cluster
   
703              }
   
704              */
   
705              stockPtr = stockPtr->get_down_ptr();  
   
706              continue; 
   
707           }  //it was aryStock.... unneccesary, just the active               
   
708  
   
710           ///*      
   
711           //aryStockActive[stockPtr->get_n_row()] = 0;  //ok reset for the next round
   
712           //aryStockActive[i] = 0;  //ok reset for the next round  faster instead of aryStockActive[stockPtr->get_n_row()] = 0
   
713           //if (stockPtr->get_ptrLasTick()->get_ntHead()) { ///it is active there is a head
   
714            
   
715           if(loadNtimeLapse == 1 ){
   
716              ptrAry[0] = stockPtr->get_backward_ptr();  //auxiliar tree
   
717              ptr = stockPtr->get_ptrLasTick();  //ptr to the current cluster               
   
720              //ptr->set_timeStamp(frameClk[1]);  //dummy instruction cluster time stamp  ????? wasn't it already set????
   
722              //fout << "\n\t\t"; ptr->Tree_Inorder_nt_data(ptr, ptr->get_ntHead(), 'f', ppnt_data, 0);  //0 just  _page_nt[page]
   
726              //*//use the auxiliar tree                  
   
727              ndptrAry[0] = ndptrAry[1] =  ptrAry[0]->get_ntHead();
   
728              while (ndptrAry[0]->get_nt_left_ptr())  ndptrAry[0] = ndptrAry[0]->get_nt_left_ptr(); //find min
   
729              while (ndptrAry[1]->get_nt_right_ptr()) ndptrAry[1] = ndptrAry[1]->get_nt_right_ptr(); //find mx
   
731              kth = 0;
   
732              spreadCenter = 0;
   
734              spreadCenter = (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_data(ppnt_data)) / 2.;
   
736              if (ptr->get_ntCounter() % 2) { //   fout << "\n\t:1883: ODD ntCounter:-> " << ptr->get_ntCounter(); //impar      
   
737                 kth = 1 + ptr->get_ntCounter() / 2;  //fout << "\tkth: " << kth;
   
738                 ndptrAry[0] = net->InOrderFindKth_nt(net, stockPtr->get_backward_ptr()->get_ntHead(), kth);  //OK  auxiliar cluste
   
739                 //ndptrAry[0] = net->InOrderFindKey_nt(net, ptr->get_ntHead(), kth);  ///NO 
   
741                 ptr->set_data(ppDataIn, ndptrAry[0]->get_nt_data(ppnt_data));
   
742                 //ptr->set_data(ppTime, ndptrAry[0]->get_nt_data(ppnt_time)); //already done during streming
   
743              }
   
744              else{ //fout << "\n\t:2099: EVEN ntCounter:-> " << ptr->get_ntCounter(); // par                     
   
745                 unsigned short kth = ptr->get_ntCounter()/2;  //left
   
746                 ndptrAry[0] = net->InOrderFindKth_nt(net, stockPtr->get_backward_ptr()->get_ntHead(), kth);   //OK
   
747                 //ndptrAry[0] = net->InOrderFindKey_nt(net, ptr->get_ntHead(), kth); //NO 
   
749                 kth = 1 + ptr->get_ntCounter() / 2; // right
   
750                 ndptrAry[1] = net->InOrderFindKth_nt(net, stockPtr->get_backward_ptr()->get_ntHead(), kth);
   
751                 if(0){
   
753                    fout << "\n\t\t:2153: CENTRAL DATUM:-> "  << (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_data(p
   
754                 }
   
755                 ptr->set_data(ppDataIn, (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_data(ppnt_data)) / 2.);
   
757                 //fout << "\n\t\t:1893: To Cluster Spread - Center:-> " << ptr->get_data(ppDataIn);
   
758              }                     
   
759              //auxiliar ntTree
   
761              if (stockPtr->get_backward_ptr()->get_ntHead())  fout << "\n\t\t:2161: Errror head of auxiliar Cluster not nill ";
   
762              if(checkThisRow == ptr->get_row())
   
764           }
   
765           else {//fout << "\n\t\t:2120: New Version - ntNodes Not Deleted" ;                                          
   
766              // much more simpler instruction from is omited                     
   
767              ndptrAry[0] = ndptrAry[1] = nullptr;  // ! both initialized in null                     
   
770              spreadCenter = (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_data(ppnt_data)) / 2.;
   
771  
   
775                 ptr->set_data(ppDataIn, ndptrAry[0]->get_nt_data(ppnt_data));
   
776                 ptr->set_data(ppTime, ndptrAry[0]->get_nt_data(ppnt_time));   ///very important
   
777              }
   
778              else {//fout << "\n\t:2139: EVEN key_index:-> " << setprecision(0) << ptr->get_ushort(pp_key_index); // impar                     
   
780                 if (0) {
   
783                    fout << "\n\t\t:2132: CENTRAL DATUM:-> " << (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_data(pp
   
784                 }
   
785                 ptr->set_data(ppDataIn, (ndptrAry[0]->get_nt_data(ppnt_data) + ndptrAry[1]->get_nt_data(ppnt_data)) / 2.);
   
786                 ptr->set_data(ppTime, (ndptrAry[0]->get_nt_data(ppnt_time) + ndptrAry[1]->get_nt_data(ppnt_time)) / 2.);   //shoul
   
787              }                     
   
788           }
   
789           
   
790  
   
791           if (1 && ptr->get_data(ppDataIn) <= .9*spreadCenter || 1.1*spreadCenter <= ptr->get_data(ppDataIn)) { //0 all enter to db 
   
793              //ptr->set_data(ppDataIn, 0); // dummy instruction
   
795              /* Dummy block  ok                     
   
799              ptr1 = net->go_to(net, ptr->get_row(), 1);
   
800              for (unsigned short i = 1; i <= net->get_cols_in_page(ppDataIn, 'f'); i++) {
   
801                 fout << ptr1->get_bool(pp_bool);
   
802                 ptr1 = ptr1->get_next_ptr();
   
803              }
   
804              //*/
   
805           }
   
806              //else {fout << "\n\t\t:2160?: OK Valid Cluster ";}
   
807  
   
808           if (ptr->get_col() == net->get_cols_in_page(ppDataIn, 'f')) { //end of the record                                                
   
809                 stockPtr->tickInPoinTo(stockPtr->get_forward_ptr()); //next cluster in col 1
   
812           }
   
814              //fout << "\n\t\t:1890: Update Cluster ---> " << stockPtr->get_ptrLasTick()->get_col();         
   
815              stockPtr->tickInToNextCluster();  //points the next cluster                     
   
816              ////  reset  cluster    counter
   
817              //ptr->set_ushort(pp_key_index, 0); // Node is completed 
   
820              //creo este block era valido para la version anterior... useless now ?????                  
   
821              /*
   
822              double duration = (ptr->get_timeStamp() - stockPtr->get_ptrLasTick()->get_timeStamp()).total_microseconds();
   
823              //fout << "\t microseconds: " << duration;
   
828              */
   
829           }                                    
   
830           //stockPtr->get_ptrLasTick()->set_bool(pp_bool, false); // next cluster is set not active  nooooo 
   
832           //} //closes this if (stockPtr->get_ptrLasTick()->get_ntHead()) {                                              
   
833           /*
   
834           else{                   
   
836              if (stockPtr->get_ptrLasTick()->get_col() == 1) {
   
837                 ptr1 = net->go_to(net, stockPtr->get_ptrLasTick()->get_row(), net->get_cols_in_page(ppDataIn, 'f'));
   
838              }
   
839              else ptr1 = stockPtr->get_ptrLasTick()->get_previous_ptr();
   
840              if (ptr1->get_bool(pp_bool)) {//fout << "\tIt was true";                     
   
841                 ptr1->set_bool(pp_bool, false);
   
842              }
   
843           } 
   
844           */
   
845  
   
846           stockPtr->set_status(0, true);  // SET TRUE ALWAYS AT THE BEGGINING
   
848           //ptr1 = net->go_to(net, stockPtr->get_ptrLasTick()->get_row(), 1); //TRAVERSE THE WHOLE RECORD
   
849           ptr1 = net->go_to(net, stockPtr->get_n_row(), 1); //TRAVERSE THE WHOLE RECORD
   
850           fout << "\tTraverse Record: " << stockPtr->get_row();
   
851           for (unsigned short ii = 1; ii <= net->get_cols_in_page(ppDataIn, 'f'); ii++) {
   
852              if (!(stockPtr->get_status(0) && ptr1->get_bool(pp_bool))) {
   
853                 fout << ptr1->get_bool(pp_bool) << "    this record is incomplete-> disable ";
   
854                 stockPtr->set_status(0, false);
   
855                 break;
   
856              }   
   
857              //fout << ptr1->get_bool(pp_bool);
   
858              ptr1 = ptr1->get_next_ptr();
   
859           }
   
860           if (stockPtr->get_status(0)) {  //true
   
861              aryStockAux[stockPtr->get_n_row()] = 1;  //selected for possible portfolio
   
862              ++counter;
   
863              fout << "\n\t:2291: Record Complete Cluster - Time  counter: " << counter;
   
864           }
   
865           else { fout << "\n\t\t:2293: Record:" << stockPtr->get_ptrLasTick()->get_row() << " INCOMPLETE Clusters - Record: "; }
   
866           //} //closes this if (stockPtr->get_ptrLasTick()->get_ntHead()) {          test                                    
   
867  
   
870              ///*
   
871              stockPtr->get_ptrLasTick()->set_bool(pp_bool, false); // next cluster is set not active
   
872              stockPtr->get_ptrLasTick()->reset_ntCounter();//only resest data in cluster remains, previus was last input
   
874  
   
875              if (loadNtimeLapse == 1) {
   
877              }
   
878              else {
   
879                 //rowPtr->set_status(1, true); //   index 0 used index 1 to flag this stock activity
   
881                 stockPtr->get_ptrLasTick()->set_bool(pp_bool, true);  //before populating make it available                        
   
883              }
   
884              ///*/
   
885           }
   
886           arySAPrevious[i] = aryStockActive[i];  //previous round is saved
   
888           stockPtr = stockPtr->get_down_ptr();  //OK browse all DB  t
   
889        } //fout.flush() << "\n\t:2313:  for (i = firstRow; i <= lastRow; ++i) " <<  endl;                        
   
890  
   
891     }
   
892     else { // second round
   
894     }
   
895        
   
897  
   
898     //net->kill_exsan(net); 
   
899  
   
900     /*
   
901     ndptrAry[0] = ndptrAry[1] = nullptr;
   
902     //ptrAry[0]->inOrderSearch_nt_ptr_minmax(ptrAry[0], ptrAry[0]->get_ntHead(), ndptrAry[0], ndptrAry[1], 'f', ppnt_time);         
   
905     */
   
906  
   
907     //----------------------------------HERE-----------------------------------------------
   
908     if(0) { 
   
911     }
   
913     //if(counter > minDB*2){ fout << "\n\t:2086: counter:-> " << counter << " > " << minDB * 2 << " <-:minDB * 2";   //should be 2   
   
914     //if(counter > minDB*4){ fout << "\n\t:2182: counter: " << counter;   //
   
915     //if (counter >= 2) { fout << "\n\t:2302: Ready - Complete Recordscounter  counter  >= 4  -- RESET is skipped";   //should be 2   
   
916     if(counter > minDB + 10){ fout << "\n\t:2182: counter: " << counter;   //
   
917        net->set_work_sheet(net, ppRTime, rows, cols);
   
922  
   
923        //all clusters start at j = 1
   
924        stockPtr = net->goto_row(net, ppTime, firstRow, 'f');  // point at the beggining
   
925        for (i = firstRow; i <= lastRow; ++i) {//error  check for 1 and 2 they are different, take out of this loop
   
926           if (!aryStockAux[i]) { stockPtr = stockPtr->get_down_ptr();  continue; }
   
927  
   
928           //ptrAry[0] = stockPtr->get_ptrLasTick();  //ptr to the current cluster               
   
929           //ptr = net->net_point_to(net, net->get_net_rows(), 1);
   
930           ptr = stockPtr->get_forward_ptr()->get_next_ptr(); //on j = 2
   
931           for (j = 1; j < net->get_cols_in_page(ppTime, 'f'); j++) { // j - 1 clusters
   
932              if (ptr->get_data(ppTime)  < ptr->get_previous_ptr()->get_data(ppTime) ||
   
933                 ptr->get_data(ppRTime) < ptr->get_previous_ptr()->get_data(ppRTime)  ) {
   
934                 --counter;
   
935                 fout << "\n\t\t\t:2320: Reset - Discard  this record of clusters Time not consistent  j:  " << j << " counter: " <
   
936  
   
937                 ptrAry[0] = stockPtr->get_forward_ptr()->get_next_ptr(); //
   
938                 for (j = 1; j <= net->get_cols_in_page(ppTime, 'f'); j++) { 
   
939  
   
940                    ptrAry[0]->set_bool(pp_bool, false); // next cluster is set not active
   
941                    ptrAry[0]->reset_ntCounter();//only resest data in cluster remains, previus was last input               
   
943                    ptrAry[0] = ptrAry[0]->get_next_ptr();
   
944                 }
   
945                 //set auxary this index zero
   
946              }
   
947  
   
948              /*
   
949              for (i = firstRow; i <= lastRow; ++i) {//error  check for 1 and 2 they are different, take out of this loop
   
950                 if(ptrAry[0]->get_data(ppTime) <  (ptrAry[0]->get_data(ppRtime   ){
   
951  
   
952                 }
   
953              }
   
954              */
   
955              ptr = ptr->get_next_ptr();
   
956           }
   
957           //fout << endl;
   
958           stockPtr = stockPtr->get_down_ptr();
   
959        }
   
961        //------------- new block               
   
962        //-------------
   
963     }
   
965     /*
   
966     stockPtr = net->goto_row(net, ppDataIn, 1, 'f');  fout << "\n\t RESET CLUSTER: ";  // point at the beggining                           
   
967     do{  //this ttwo instructions pending   stockPtr->get_ptrLasTick()->get_col()
   
968        if(stockPtr->get_ptrLasTick()->get_ntHead()){ //only if there is a nt tree
   
969  
   
970           stockPtr->get_ptrLasTick()->set_bool(pp_bool, false); // next cluster is set not active
   
971           stockPtr->get_ptrLasTick()->reset_ntCounter();//only resest data in cluster remains, previus was last input
   
973           if(loadNtimeLapse == 1){ 
   
974              //*dummy
   
975              ndptrAry[0] = ndptrAry[1] = nullptr;
   
976              unsigned short lastIn = ptr->get_ntCounter();  //left
   
977              fout << "\n\tThis Cluster nNodes: " << lastIn;
   
978              //ndptrAry[0] = net->InOrderFindKth_nt(net, stockPtr->get_backward_ptr()->get_ntHead(), 1);   //OK
   
979              //ndptrAry[1] = net->InOrderFindKth_nt(net, stockPtr->get_backward_ptr()->get_ntHead(), kth);   //OK                        
   
983              ////*/
   
984     /*
   
986           }
   
987           else{
   
988              //rowPtr->set_status(1, true); //   index 0 used index 1 to flag this stock activity
   
990              stockPtr->get_ptrLasTick()->set_bool(pp_bool, true);  //before populating make it available                        
   
992           }
   
993        }
   
994  
   
995        stockPtr = stockPtr->get_down_ptr();  //OK browse all DB
   
996        if (!stockPtr ) break;
   
997     } while (aryStock[stockPtr->get_n_row()] && stockPtr->get_n_row() <= stockCounterDB);               
   
998     //*/
   
999  
   
1000     //*
   
1001        if(1){
   
1002           stockPtr = net->goto_row(net, ppDataIn, firstRow, 'f');  // point at the beggining                           
   
1004  
   
1005              if (!aryStockActive[i]) { stockPtr = stockPtr->get_down_ptr();  continue; }  //it was aryStock.... unneccesary, just t
   
1007              //if (stockPtr->get_ptrLasTick()->get_ntHead()) { //only if there is a nt tree
   
1008                 stockPtr->get_ptrLasTick()->set_bool(pp_bool, false); // next cluster is set not active
   
1009                 stockPtr->get_ptrLasTick()->reset_ntCounter();//only resest data in cluster remains, previus was last input
   
1011  
   
1012                 if (loadNtimeLapse == 1) {
   
1014                 }
   
1015                 else {
   
1016                    //rowPtr->set_status(1, true); //   index 0 used index 1 to flag this stock activity
   
1018                    stockPtr->get_ptrLasTick()->set_bool(pp_bool, true);  //before populating make it available                        
   
1020                 }
   
1021              //}
   
1022  
   
1023              stockPtr = stockPtr->get_down_ptr();  //OK browse all DB
   
1024           }
   
1025        }
   
1026        //*/
   
1027        //system("pause");
   
1028        //} while (stockPtr);
   
1029     }            
   
1030  
   
1031     }
   
1032  
   
1033  }//closes if (loadNtimeLapse &&  frameClk[1] ....
   
1034  
   
1035  
   
1036  }
   
1037  //else fout << "\n\t\t\t\t:2470: Invalid datum -not a number- Stock: "  << setw(7) << stockID[s] << " " << val.get_token();         
   
1038  //*
   
1039  if(0 && inData){         
   
1041  fout << "\n\t:2076: (inData)TIME STAMP ppTime";   net->displayMKT(net,   ppTime, aryStock, nullptr, 0, 5, widthCol, presCol - 2);
   
1042  inData = 0;  // to show only once¡????
   
1043  }
   
1044  
   
1045  //*/
   
1046  //check = false; //test input a singl stock enable next instruction          
   
1047  
   
1048  ///CLUSTERS SET UP   ends here
   
1049  
  
  
      
      
Comments
Post a Comment