Changeset 1405 for applications

Show
Ignore:
Timestamp:
11/11/11 21:27:50 (12 years ago)
Author:
sindj
Message:
 
Location:
applications/robust
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • applications/robust/main.cpp

    r1401 r1405  
    2929const int max_model_order = 2; 
    3030const double apriorno     = 0.01; 
    31 const int max_window_size = 30; 
     31const int max_window_size = 40; 
     32 
     33/* 
     34HDDEDATA CALLBACK DdeCallback( 
     35        UINT uType,     // Transaction type. 
     36        UINT uFmt,      // Clipboard data format. 
     37        HCONV hconv,    // Handle to the conversation. 
     38        HSZ hsz1,       // Handle to a string. 
     39        HSZ hsz2,       // Handle to a string. 
     40        HDDEDATA hdata, // Handle to a global memory object. 
     41        DWORD dwData1,  // Transaction-specific data. 
     42        DWORD dwData2)  // Transaction-specific data. 
     43{ 
     44        return 0; 
     45} 
     46 
     47void DDERequest(DWORD idInst, HCONV hConv, char* szItem) 
     48{ 
     49        HSZ hszItem = DdeCreateStringHandle(idInst, szItem, 0); 
     50        HDDEDATA hData = DdeClientTransaction(NULL,0,hConv,hszItem,CF_TEXT,  
     51                                                                        XTYP_ADVSTART,TIMEOUT_ASYNC , NULL); //TIMEOUT_ASYNC 
     52        if (hData==NULL) 
     53        { 
     54                printf("Request failed: %s\n", szItem); 
     55        } 
     56 
     57        if (hData==0) 
     58        { 
     59                printf("Request failed: %s\n", szItem); 
     60        } 
     61} 
     62 
     63DWORD WINAPI ThrdFunc( LPVOID n ) 
     64{     
     65    return 0; 
     66} 
     67*/ 
    3268 
    3369class model 
     
    4783        vec  predictions; 
    4884        char name[80]; 
     85 
     86        double previous_lognc; 
    4987         
    5088        model(set<pair<int,int>> ar_components, //funkcie treidz model-konstruktor 
     
    5492                  int predicted_channel, 
    5593                  mat* data_matrix) 
    56         { 
     94        {                
    5795                this->ar_components.insert(ar_components.begin(),ar_components.end()); 
    5896 
     
    84122                if(robust) 
    85123                { 
     124                        previous_lognc = 0; 
    86125                        strcat(name,"R"); 
    87126 
    88127                        if(has_constant) 
    89128                        { 
    90                                 my_rarx = new RARX(ar_components.size()+1,window_size,true,sqrt(2*apriorno),sqrt(2*apriorno),ar_components.size()+4); 
     129                                my_rarx = new RARX(ar_components.size()+1,window_size,true,sqrt(2*apriorno),sqrt(2*apriorno),ar_components.size()+3); 
    91130                                my_arx  = NULL; 
    92131                        } 
    93132                else 
    94133                        { 
    95                                 my_rarx = new RARX(ar_components.size(),window_size,false,sqrt(2*apriorno),sqrt(2*apriorno),ar_components.size()+3); 
     134                                my_rarx = new RARX(ar_components.size(),window_size,false,sqrt(2*apriorno),sqrt(2*apriorno),ar_components.size()+2); 
    96135                                my_arx  = NULL; 
    97136                        } 
     
    106145                        {                                
    107146                                V0  = apriorno * eye(ar_components.size()+2); //aj tu konst 
    108                                 //V0(0,0) = 0; 
    109                                 my_arx->set_constant(true);                              
     147                                V0(0,0) = 0; 
     148                                my_arx->set_constant(true); 
     149                                my_arx->set_statistics(1, V0, V0.rows()+1);  
    110150                        } 
    111151                        else 
     
    113153                                 
    114154                                V0  = apriorno * eye(ar_components.size()+1);//menit konstantu 
     155                                V0(0,0) = 0; 
    115156                                //V0(0,1) = -0.01; 
    116157                                //V0(1,0) = -0.01; 
    117                                 my_arx->set_constant(false);                             
    118                                  
    119                         } 
    120  
    121                         my_arx->set_statistics(1, V0, V0.rows()+2);                      
     158                                my_arx->set_constant(false); 
     159                                my_arx->set_statistics(1, V0, V0.rows()+1);  
     160                                 
     161                        }                                                
     162                         
    122163                        my_arx->set_parameters(window_size); 
    123164                        my_arx->validate(); 
    124165 
     166                        previous_lognc = my_arx->posterior().lognc(); 
     167 
     168                        /* 
    125169                        vec mean = my_arx->posterior().mean(); 
    126170                        cout << mean << endl; 
    127                 } 
    128         } 
    129  
    130         void data_update(int time) //vlozime cas a ono vlozi do data_vector podmineky(conditions) a predikce, ktore pouzije do bayes 
     171                        */ 
     172                } 
     173        } 
     174 
     175        void data_update(int time)  
    131176        { 
    132177                vec data_vector; 
     
    158203                if(my_rarx!=NULL) 
    159204                { 
    160                         pair<vec,mat> imp_samples = my_rarx->posterior->sample(sample_size,false); 
     205                        pair<vec,mat> imp_samples = my_rarx->posterior->sample(sample_size,true); 
    161206 
    162207                        //cout << imp_samples.first << endl;                     
    163208                         
    164209                        vec sample_prediction;                   
    165                         for(int t = 0;t<sample_size;t++) 
     210                        for(int t = 0;t<imp_samples.second.cols();t++) 
    166211                        { 
    167212                                vec lap_sample = condition_vector; 
     
    208253                set<set<pair<int,int>>> created_model_types;             
    209254 
    210                 if(max_order == 1) 
     255                if(max_order == 1)//ukoncovacia vetva 
    211256                {                        
    212                         for(int channel = 0;channel<number_of_channels;channel++) 
     257                        for(int channel = 0;channel<number_of_channels;channel++)//pre AR 1 model vytvori kombinace kanalov v prvom kroku poyadu 
    213258                        { 
    214259                                set<pair<int,int>> returned_type; 
    215                                 returned_type.insert(pair<int,int>(channel,1));   
     260                                returned_type.insert(pair<int,int>(channel,1));  //?? 
    216261                                created_model_types.insert(returned_type); 
    217262                        } 
     
    221266                else 
    222267                { 
    223                         created_model_types = possible_models_recurse(max_order-1,number_of_channels); 
     268                        created_model_types = possible_models_recurse(max_order-1,number_of_channels);//tu uz mame ulozene kombinace o jeden krok dozadu  //rekuryivne volanie 
    224269                        set<set<pair<int,int>>> returned_types; 
    225270                         
     
    232277                                        { 
    233278                                                set<pair<int,int>> returned_type; 
    234                                                 pair<int,int> new_pair = pair<int,int>(channel,order); 
    235                                                 if(find((*model_ref).begin(),(*model_ref).end(),new_pair)==(*model_ref).end())  
     279                                                pair<int,int> new_pair = pair<int,int>(channel,order);//?? 
     280                                                if(find((*model_ref).begin(),(*model_ref).end(),new_pair)==(*model_ref).end()) //?? 
    236281                                                { 
    237                                                         returned_type.insert((*model_ref).begin(),(*model_ref).end());  
    238                                                         returned_type.insert(new_pair); 
    239                                                          
     282                                                        returned_type.insert((*model_ref).begin(),(*model_ref).end()); //co vlozi na zaciatok retuned_type? 
     283                                                        returned_type.insert(new_pair);                                                  
    240284 
    241285                                                        returned_types.insert(returned_type);                                                    
     
    257301int main ( int argc, char* argv[] )  
    258302{ 
     303         
     304        // EXPERIMENT: A moving window estimation and prediction of RARX is tested on data generated from  
     305    // y_t=0.95*y_(t-1)+0.05*y_(t-2)+0.2*e_t, where e_t is normally, student(4) and cauchy distributed. It 
     306    // can be compared to the classical setup. 
     307         
     308        itpp::Laplace_RNG LapRNG = Laplace_RNG();        
     309 
    259310        vector<vector<string>> strings; 
    260311 
    261         char* file_string =  "C:\\results\\normalM"; // "C:\\dataADClosePercDiff"; //   
     312        char* file_string =  "C:\\CD2"; // "C:\\dataADClosePercDiff"; //   
    262313 
    263314        char dfstring[80]; 
     
    274325                {                        
    275326                        vec data_vector; 
    276                         while(line.find(',') != string::npos)  
    277                         {                                
     327                        while(line.find(',') != string::npos) //zmenil som ciarku za medzeru 
     328                        { 
     329                                //line.erase(0,1); // toto som sem pridal 
    278330                                int loc2 = line.find('\n'); 
    279331                                int loc  = line.find(','); 
     
    291343                cout << "Can't open data file!" << endl; 
    292344        } 
    293  
    294         set<pair<int,int>> model_type; 
    295         model_type.insert(pair<int,int>(0,1)); 
    296         model_type.insert(pair<int,int>(0,2)); 
    297  
     345         
     346        //konec nacitavania dat 
     347        set<set<pair<int,int>>> model_types = model::possible_models_recurse(max_model_order,data_matrix.rows()); //volanie funkce kde robi kombinace modelov 
     348                                                                                                //to priradime do model_types, data_matrix.row urcuje pocet kanalov dat 
    298349        vector<model*> models; 
     350        for(set<set<pair<int,int>>>::iterator model_type = model_types.begin();model_type!=model_types.end();model_type++) 
     351        {// prechadza rozne typy kanalov, a poctu regresorov 
     352                for(int window_size = max_window_size-1;window_size < max_window_size;window_size++) 
     353                { 
     354                        models.push_back(new model((*model_type),true,true,window_size,0,&data_matrix));   // to su len konstruktory, len inicializujeme rozne typy 
     355                        models.push_back(new model((*model_type),false,true,window_size,0,&data_matrix)); 
     356                        models.push_back(new model((*model_type),true,false,window_size,0,&data_matrix)); 
     357                        models.push_back(new model((*model_type),false,false,window_size,0,&data_matrix));               
     358                } 
     359 
     360                //set<pair<int,int>> empty_list; 
     361                //models.push_back(new model(empty_list,false,true,100,0,&data_matrix)); 
     362        } 
     363         
     364        mat result_lognc; 
     365        // mat result_preds; 
    299366 
    300367        ofstream myfilew; 
    301                  
    302  
    303         while(data_matrix.rows()!=0) 
    304         { 
    305                 for(int i=0;i<models.size();i++) 
    306                 { 
    307                         delete models[i]; 
    308                 } 
    309                  
    310                 models.clear(); 
    311                 models.push_back(new model(model_type,true,false,max_window_size,0,&data_matrix)); 
    312                 models.push_back(new model(model_type,false,false,max_window_size,0,&data_matrix)); 
    313  
    314                 for(int time = max_model_order;time<max_window_size;time++) //time<data_matrix.cols()  
    315                 {                
    316                         vec cur_res_lognc; 
    317                  
    318                         vector<string> nazvy; 
    319                         for(vector<model*>::iterator model_ref = models.begin();model_ref!=models.end();model_ref++) 
    320                         { 
    321                                 (*model_ref)->data_update(time); 
    322  
    323                                 cout << "Updated:" << time << endl;      
    324  
    325                                 if(time == max_window_size-1) 
    326                                 { 
    327                                         char fstring[80];                                        
    328                                         strcpy(fstring,file_string); 
    329                                         strcat(fstring,"ml");                                    
    330                                         strcat(fstring,(*model_ref)->name); 
    331                                         strcat(fstring,".txt"); 
    332  
    333                                         vec coords; 
    334                                         if((*model_ref)->my_arx!=NULL) 
     368        char fstring[80];                                        
     369        strcpy(fstring,file_string); 
     370        //strcat(fstring,"lognc.txt"); 
     371        strcat(fstring,"preds.txt");     
     372 
     373        for(int time = max_model_order;time<data_matrix.cols();time++) //time<data_matrix.cols()  
     374        {        
     375                cout << "Steps: " << time << endl; 
     376                 
     377                /* 
     378                if(time==max_window_size) 
     379                { 
     380                        exit(1); 
     381                }*/ 
     382                 
     383                //pocet stlpcov data_matrix je pocet casovych krokov 
     384                vec cur_res_lognc; 
     385                // vec preds; 
     386                vector<string> nazvy; 
     387                for(vector<model*>::iterator model_ref = models.begin();model_ref!=models.end();model_ref++) 
     388                {//posuvam s apo models, co je pole modelov urobene o cyklus vyssie. Teda som v case time a robim to tam pre vsetky typy modelov, kombinace regresorov 
     389                        (*model_ref)->data_update(time); //pozret sa preco je toto tu nutne 
     390 
     391                        //cout << "Updated." << endl; 
     392                        //if (time = max_model_order) nazvy.push_back(models.model_ref]);// ako by som mohol dostat nazov modelu? 
     393 
     394                        if((*model_ref)->my_rarx!=NULL) //vklada normalizacni faktor do cur_res_lognc 
     395                        { 
     396                                //cout << "Maxlik vertex:" << (*model_ref)->my_rarx->posterior->minimal_vertex->get_coordinates() << endl; 
     397                                cur_res_lognc.ins(cur_res_lognc.size(),(*model_ref)->my_rarx->posterior->_ll());                                 
     398                        } 
     399                        else 
     400                        { 
     401                                double cur_lognc = (*model_ref)->my_arx->posterior().lognc(); 
     402                                double cur_ll = cur_lognc-(*model_ref)->previous_lognc; 
     403                                 
     404                                /* 
     405                                if(time<(*model_ref)->window_size) 
     406                                { 
     407                                        cur_ll-=1.83787706640935; 
     408                                }*/ 
     409                                 
     410                                (*model_ref)->my_arx->_ll(); 
     411 
     412                                cur_res_lognc.ins(cur_res_lognc.size(),cur_ll); 
     413                                 
     414                                (*model_ref)->previous_lognc = cur_lognc;                                
     415                        } 
     416                         
     417                        /* 
     418                        if(time == max_window_size-1) 
     419                        { 
     420                                //*********************** 
     421                                int sample_size = 100000; 
     422                                //*********************** 
     423                                 
     424                                pair<vec,mat> samples; 
     425                                if((*model_ref)->my_arx!=NULL) 
     426                                { 
     427                                        mat samp_mat = (*model_ref)->my_arx->posterior().sample_mat(sample_size); 
     428                                        samples = pair<vec,mat>(ones(samp_mat.cols()),samp_mat); 
     429                                } 
     430                                else 
     431                                { 
     432                                        samples = (*model_ref)->my_rarx->posterior->sample(sample_size,true);                                    
     433                                } 
     434 
     435                                char fstring[80];                                        
     436                                strcpy(fstring,file_string); 
     437                                strcat(fstring,(*model_ref)->name); 
     438                                strcat(fstring,".txt"); 
     439                                 
     440                                //cout << samples.first << endl; 
     441                                 
     442                                myfilew.open(fstring,ios::app); 
     443                                 
     444                                 
     445                                //for(int i = 0;i<samples.first.size();i++) 
     446                                //{ 
     447                                //      myfilew << samples.first.get(i) << ","; 
     448                                //} 
     449                                //myfilew << endl; 
     450                                 
     451 
     452                                for(int j = 0;j<samples.second.rows()+1;j++) 
     453                                {                        
     454                                        for(int i = 0;i<samples.second.cols();i++) 
    335455                                        { 
    336                                                 coords = (*model_ref)->my_arx->posterior().est_theta(); 
    337                                         } 
    338                                         else 
    339                                         { 
    340                                                 coords = (*model_ref)->my_rarx->posterior->minimal_vertex->get_coordinates();                                            
    341                                         } 
    342  
    343                                         myfilew.open(fstring,ios::app); 
    344  
    345                                         for(int i=0;i<coords.size();i++) 
    346                                         { 
    347                                                 myfilew << coords.get(i) << ","; 
    348                                         } 
     456                                                if(j!=samples.second.rows()) 
     457                                                { 
     458                                                        myfilew << samples.second.get(j,i) << ","; 
     459                                                } 
     460                                                 
     461                                                //else 
     462                                                //{ 
     463                                                //      myfilew << "0,"; 
     464                                                //} 
     465                                                 
     466                                        }                                
    349467                                        myfilew << endl; 
    350  
    351                                         myfilew.close();                                 
    352                                 } 
    353                         } 
    354                 } 
    355  
    356                 data_matrix.del_row(0); 
    357         } 
    358          
    359  
    360  
    361          
     468                                } 
     469 
     470                                cout << "*************************************" << endl; 
     471 
     472                                myfilew.close();                                 
     473                        } 
     474                        */               
     475 
     476                         // PREDICTIONS 
     477                        pair<vec,vec> predictions = (*model_ref)->predict(3000,time,&LapRNG); 
     478 
     479                        /* 
     480                        cout << predictions.first << endl << endl << predictions.second << endl << "*************************************" ; 
     481                        pause(5); 
     482                        */               
     483 
     484                        double avg_prediction = (predictions.first*predictions.second)/(predictions.first*ones(predictions.first.size())); 
     485 
     486                        (*model_ref)->predictions.ins((*model_ref)->predictions.size(),avg_prediction); 
     487                                         
     488                        myfilew.open(fstring,ios::app); 
     489                        myfilew << avg_prediction << ",";  
     490                        myfilew.close(); 
     491                         
     492 
     493                        //preds.ins(0,data_matrix.get(0,time+1)); 
     494                } 
     495 
     496                 
     497                // REAL PRICE 
     498                myfilew.open(fstring,ios::app); 
     499                myfilew << data_matrix.get(0,time+1) << endl; 
     500                myfilew.close(); 
     501                 
     502 
     503                result_lognc.ins_col(result_lognc.cols(),cur_res_lognc); 
     504                //result_preds.ins_col(result_preds.cols(),preds); 
     505 
     506                // cout << "Updated." << endl;   
     507                                                         
     508                /* 
     509                myfilew.open(fstring,ios::app); 
     510                 
     511                // myfile << my_rarx->posterior->minimal_vertex->get_coordinates()[0]; 
     512                 
     513                if(time == max_model_order) 
     514                {  
     515                        for(int i = 0;i<cur_res_lognc.size();i++) 
     516                        { 
     517                                for(set<pair<int,int>>::iterator ar_ref = models[i]->ar_components.begin();ar_ref != models[i]->ar_components.end();ar_ref++) 
     518                                { 
     519                                        myfilew << (*ar_ref).second << (*ar_ref).first;                                                  
     520                                } 
     521 
     522                                myfilew << "."; 
     523 
     524                                if(models[i]->my_arx == NULL) 
     525                                { 
     526                                        myfilew << "1"; 
     527                                } 
     528                                else 
     529                                { 
     530                                        myfilew << "0"; 
     531                                } 
     532                                         
     533                                if(models[i]->has_constant) 
     534                                { 
     535                                        myfilew << "1"; 
     536                                } 
     537                                else 
     538                                { 
     539                                        myfilew << "0"; 
     540                                } 
     541 
     542                                myfilew << ","; 
     543                        } 
     544 
     545                        myfilew << endl; 
     546                } 
     547                 
     548                 
     549                for(int i = 0;i<cur_res_lognc.size();i++) 
     550                { 
     551                   myfilew << cur_res_lognc[i] << ' ';//zmenil som ciarku ze medzeru 
     552                } 
     553 
     554                myfilew << endl;                 
     555                myfilew.close();         
     556                */ 
     557} 
     558 
     559        // EXPERIMENT: One step ahead price prediction. Comparison of classical and robust model using optimal trading 
     560    //             with maximization of logarithm of one-step ahead wealth. 
     561 
     562         
     563                 
     564                /* 
     565                cout << "One experiment finished." << endl; 
     566 
     567                ofstream myfile; 
     568                myfile.open("c:\\robust_ar1.txt",ios::app); 
     569                myfile << endl; 
     570                myfile.close(); 
     571 
     572                myfile.open("c:\\robust_ar2.txt",ios::app); 
     573                myfile << endl; 
     574                myfile.close();*/ 
     575         
     576 
     577        //emlig* emlig1 = new emlig(emlig_size); 
     578 
     579        //emlig1->step_me(0); 
     580        //emlig* emlig2 = new emlig(emlig_size); 
     581         
     582        /* 
     583        emlig1->set_correction_factors(4); 
     584 
     585        for(int j = 0;j<emlig1->correction_factors.size();j++) 
     586        { 
     587                for(set<my_ivec>::iterator vec_ref = emlig1->correction_factors[j].begin();vec_ref!=emlig1->correction_factors[j].end();vec_ref++) 
     588                { 
     589                        cout << j << "    "; 
     590                         
     591                        for(int i=0;i<(*vec_ref).size();i++) 
     592                        { 
     593                                cout << (*vec_ref)[i]; 
     594                        } 
     595 
     596                        cout << endl; 
     597                } 
     598        }*/ 
     599         
     600        /* 
     601    vec condition5 = "1.0 1.0 1.01";//"-0.3 1.7 1.5"; 
     602 
     603        emlig1->add_condition(condition5); 
     604        //emlig1->step_me(0); 
     605 
     606 
     607        vec condition1a = "-1.0 1.02 0.5"; 
     608        //vec condition1b = "1.0 1.0 1.01"; 
     609        emlig1->add_condition(condition1a); 
     610        //emlig2->add_condition(condition1b); 
     611 
     612        vec condition2a = "-0.3 1.7 1.5"; 
     613        //vec condition2b = "-1.0 1.0 1.0"; 
     614        emlig1->add_condition(condition2a); 
     615        //emlig2->add_condition(condition2b); 
     616 
     617        vec condition3a = "0.5 -1.01 1.0"; 
     618        //vec condition3b = "0.5 -1.01 1.0"; 
     619 
     620        emlig1->add_condition(condition3a); 
     621        //emlig2->add_condition(condition3b);    
     622 
     623        vec condition4a = "-0.5 -1.0 1.0"; 
     624        //vec condition4b = "-0.5 -1.0 1.0";     
     625 
     626        emlig1->add_condition(condition4a); 
     627        //cout << "************************************************" << endl; 
     628        //emlig2->add_condition(condition4b); 
     629        //cout << "************************************************" << endl; 
     630         
     631        //cout << emlig1->minimal_vertex->get_coordinates(); 
     632         
     633        //emlig1->remove_condition(condition3a); 
     634        //emlig1->step_me(0); 
     635        //emlig1->remove_condition(condition2a); 
     636        //emlig1->remove_condition(condition1a); 
     637        //emlig1->remove_condition(condition5); 
     638         
     639 
     640        //emlig1->step_me(0); 
     641        //emlig2->step_me(0); 
     642         
     643 
     644        // DA SE POUZIT PRO VYPIS DO SOUBORU 
     645        // emlig1->step_me(0); 
     646 
     647        //emlig1->remove_condition(condition1); 
     648         
     649         
     650 
     651         
     652         
     653        /* 
     654        for(int i = 0;i<100;i++) 
     655        { 
     656                cout << endl << "Step:" << i << endl;            
     657 
     658                double condition[emlig_size+1];          
     659 
     660                for(int k = 0;k<=emlig_size;k++) 
     661                { 
     662                        condition[k] = (rand()-RAND_MAX/2)/1000.0;               
     663                } 
     664                         
     665 
     666                vec* condition_vec = new vec(condition,emlig_size+1); 
     667                emlig1->add_condition(*condition_vec); 
     668 
     669                /* 
     670                for(polyhedron* toprow_ref = emlig1->statistic.rows[emlig_size]; toprow_ref != emlig1->statistic.end_poly; toprow_ref = toprow_ref->next_poly) 
     671                { 
     672                        cout << ((toprow*)toprow_ref)->probability << endl; 
     673                } 
     674                */ 
     675                /* 
     676                cout << emlig1->statistic_rowsize(emlig_size) << endl << endl; 
     677         
     678                /* 
     679                if(i-emlig1->number_of_parameters >= 0) 
     680                { 
     681                        pause(30); 
     682                } 
     683                */ 
     684 
     685                // emlig1->step_me(i); 
     686                 
     687                /* 
     688                vector<int> sizevector; 
     689                for(int s = 0;s<=emlig1->number_of_parameters;s++) 
     690                { 
     691                        sizevector.push_back(emlig1->statistic_rowsize(s)); 
     692                } 
     693                */ 
     694        //} 
     695     
     696 
     697 
     698         
     699        /* 
     700        emlig1->step_me(1); 
     701 
     702        vec condition = "2.0 0.0 1.0";   
     703 
     704        emlig1->add_condition(condition); 
     705 
     706        vector<int> sizevector; 
     707        for(int s = 0;s<=emlig1->number_of_parameters;s++) 
     708        { 
     709                sizevector.push_back(emlig1->statistic_rowsize(s)); 
     710        } 
     711 
     712        emlig1->step_me(2); 
     713 
     714        condition = "2.0 1.0 0.0"; 
     715 
     716        emlig1->add_condition(condition); 
     717 
     718        sizevector.clear(); 
     719        for(int s = 0;s<=emlig1->number_of_parameters;s++) 
     720        { 
     721                sizevector.push_back(emlig1->statistic_rowsize(s)); 
     722        } 
     723        */ 
    362724 
    363725        return 0; 
  • applications/robust/robustlib.h

    r1396 r1405  
    16581658                                                // ************************************************************************** 
    16591659 
     1660                                                if(current_negative->get_state(SPLIT)==0) 
     1661                                                { 
     1662                                                        for_splitting[k].remove(current_negative); 
     1663                                                }                                                
     1664                                                 
    16601665                                                if(!current_positive->totally_neutral) 
    16611666                                                { 
     
    16871692                                                                // polyhedron to neutral 
    16881693                                                                current_positive->set_state(0,SPLIT); 
    1689  
    1690                                                                 for_splitting[k].remove(current_negative); 
     1694                                                                 
    16911695                                                                // and we add it to the list of polyhedrons to be SPLIT 
    16921696                                                                for_splitting[k].push_back(current_positive);                                                    
     
    16961700                                                        // If the MERGEd polyhedron is to be split.. 
    16971701                                                        if(current_positive->get_state(SPLIT)==0) 
    1698                                                         { 
     1702                                                        {                                                                
    16991703                                                                // We need to fill the lists related to split with correct values, adding the SPLIT 
    17001704                                                                // positive, negative and neutral children to according list in the MERGE positive, 
     
    17591763 
    17601764                                                // We clear the grandparents list for further reuse. 
    1761                                                 current_positive->grandparents.clear(); 
    1762                                  
    1763                                                 // Triangulate the newly created polyhedron and compute its normalization integral if the 
    1764                                                 // polyhedron is a toprow. 
    1765                                                 normalization_factor += current_positive->triangulate(k==for_splitting.size()-1 && !will_be_split); 
     1765                                                current_positive->grandparents.clear();                          
     1766                                                 
    17661767                                                 
    17671768                                                // Delete the negative polyhedron from the Hasse diagram (rewire all the connections) 
     
    18171818                                                {                                                        
    18181819                                                        vertices_to_be_reduced.insert((vertex*)(*merge_ref));                                                    
    1819                                                 }                                                                                                
     1820                                                }        
     1821 
     1822                                                // Triangulate the newly created polyhedron and compute its normalization integral if the 
     1823                                                // polyhedron is a toprow. 
     1824                                                normalization_factor += current_positive->triangulate(k==for_splitting.size()-1 && !will_be_split); 
    18201825                                        } 
    18211826                                }                        
     
    19261931                                                toprow* neutral_toprow = new toprow(); 
    19271932                                                 
    1928                                                 // A toprow needs a valid condition 
    1929                                                 neutral_toprow->condition_sum   = ((toprow*)current_polyhedron)->condition_sum; // tohle tu bylo driv: zeros(number_of_parameters+1); 
    1930                                                 neutral_toprow->condition_order = ((toprow*)current_polyhedron)->condition_order+1; 
     1933                                                if(k==number_of_parameters) 
     1934                                                { 
     1935                                                        // A toprow needs a valid condition 
     1936                                                        neutral_toprow->condition_sum   = ((toprow*)current_polyhedron)->condition_sum; // tohle tu bylo driv: zeros(number_of_parameters+1); 
     1937                                                        neutral_toprow->condition_order = ((toprow*)current_polyhedron)->condition_order+1; 
     1938                                                } 
    19311939 
    19321940                                                // We assign it to the totally neutral child variable