Commit ce76aa80 authored by Romina Julieta Parada Venossa's avatar Romina Julieta Parada Venossa
Browse files

frontiers have only one critics represented by a pos

parent 1fed6bb4
......@@ -69,13 +69,12 @@ void DisMapIC::save_frontier_old_source(pos frontier){
if(is_elem((*frontiers), frontier) && !is_elem(updated_frontiers, frontier)){
pos first_source = cell_data[frontier].first_source;
if(first_source != NULL_POS){
//updated_frontiers[frontier] = cell_data[frontier].first_source;
updated_frontiers[frontier].clear();
updated_frontiers[frontier].insert(first_source);
updated_frontiers[frontier] = cell_data[frontier].first_source;
//updated_frontiers[frontier].insert(first_source);
//updated_frontiers[frontier] = cell_data[frontier].sources;
}else{
//updated_frontiers[frontier] = NULL_POS;
updated_frontiers[frontier].clear();
updated_frontiers[frontier] = NULL_POS;
//updated_frontiers[frontier].clear();
}
}
}
......
......@@ -60,7 +60,7 @@ class DisMapIC{
// these are only the FREE FRONTIERS
pos_set* frontiers;
//for updating critics, old sources for frontiers are saved, new frontiers and frontiers with new critics with same distance are also saved with empty set
boost::unordered_map<pos, pos_set> updated_frontiers;
boost::unordered_map<pos, pos> updated_frontiers;
//pos_set new_frontiers;
void save_frontier_old_source(pos frontier);
......
......@@ -738,22 +738,15 @@ void GVDIC::update_possible_crit(pos_set to_add_gvd, pos_set to_erase_gvd) {
// pcrit distance map
///
void GVDIC::update_possible_crit_distance_map(){
// update frontiers
/*disMapIC->frontiers.insert(frontier_to_true.begin(), frontier_to_true.end());
for(auto it = frontier_to_false.begin(); it != frontier_to_false.end(); it++){
pos frontier = *it;
// erase frontiers, so they are no longer consider for the recognition of new critics
disMapIC->frontiers.erase(frontier);
//disMapIC->save_frontier_old_source(f_pos); should be already saved from last iteration??
}*/
for(auto it = free_frontier_to_false.begin(); it != free_frontier_to_false.end(); it++){
pos frontier = (*it);
cout<<"free frontier to false "<<frontier<<endl;
pos_set criticals_to_update = disMapIC->cell_data[frontier].sources;
for(auto it_crit = criticals_to_update.begin(); it_crit != criticals_to_update.end(); it_crit++){
pos critical = (*it_crit);
cout<<"criticals to update "<<critical<<" ";
erase_frontier(critical, frontier);
pos critical_to_update = disMapIC->cell_data[frontier].first_source;
if(critical_to_update != NULL_POS){
cout<<"criticals to update "<<critical_to_update<<" ";
erase_frontier(critical_to_update, frontier);
}
cout<<endl;
}
......@@ -817,65 +810,31 @@ void GVDIC::add_frontier(pos critical, pos frontier){
}
void GVDIC::update_criticals(){
//old crits
//for each frontier_to_false and frontier changed remove frontier from old sources
//delete from crit frontiers
// if no longer crit then
//delete from crit
//paso 1 (agregar descricpion del trello)
/*
for(auto it = frontier_to_false.begin(); it != frontier_to_false.end(); it++){
pos frontier = (*it);
cout<<"frontier to eliminate "<<frontier<<endl;
pos_set criticals_to_update = disMapIC->cell_data[frontier].sources;
for(auto it_crit = criticals_to_update.begin(); it_crit != criticals_to_update.end(); it_crit++){
pos critical = (*it_crit);
cout<<"critical to update "<<critical<<endl;
erase_frontier(critical, frontier);
}
}*/
for(auto it = disMapIC->updated_frontiers.begin(); it != disMapIC->updated_frontiers.end(); it++){
pos frontier = it->first;
pos_set old_criticals = it->second;
if(!old_criticals.empty()){
cout<<"frontier to erase from old source "<<frontier<<endl;
}
pos old_critical = it->second;
// delete frotier from old critic
for(auto it_old_crit = old_criticals.begin(); it_old_crit != old_criticals.end(); it_old_crit++){
pos critical = (*it_old_crit);
cout<<"criticals to update "<<critical<<" ";
erase_frontier(critical, frontier);
if(old_critical != NULL_POS){
cout<<"frontier to erase from old source "<<frontier<<endl;
cout<<"criticals to update "<<old_critical<<" ";
erase_frontier(old_critical, frontier);
}
cout<<endl;
// add or update (change new criticals name)
pos_set new_criticals = disMapIC->cell_data[frontier].sources;
if(!new_criticals.empty()){
pos new_critical = disMapIC->cell_data[frontier].first_source;
if(new_critical != NULL_POS){
cout << "frontier to add to new source " << frontier << endl;
}
for(auto it_new_crit = new_criticals.begin(); it_new_crit != new_criticals.end(); it_new_crit++){
pos critical = (*it_new_crit);
cout<<"criticals to update "<<critical<<" ";
add_frontier(critical, frontier);
/*if(!is_elem(criticals, critical)){
criticals[critical] = critical_info2();
criticals[critical].mind_f = pair(pos(),MAXFLOAT);
}
criticals[critical].frontiers.insert(frontier);
float frontier_dist = disMapIC->cell_data[frontier].dist;
if(criticals[critical].mind_f > frontier_dist){
criticals[critical].mind_f = frontier_dist;
}*/
cout<<"criticals to update "<<new_critical<<" ";
add_frontier(new_critical, frontier);
}
cout<<endl;
}
update_criticals_mind_f();
for(auto it = criticals.begin(); it != criticals.end(); it++){
cout<<(*it).first<<" fronteras: ";
for(auto it_f = (*it).second.frontiers.begin();it_f != (*it).second.frontiers.end(); it_f++){
......@@ -883,12 +842,6 @@ void GVDIC::update_criticals(){
}
cout<<endl;
}
//delete from old_source frontier the ones in frontier_to_false
//new crits
//for each forntier that changed
//add crit or update crit
}
//////////
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment