Commit 00830b11 authored by jben's avatar jben

Homogenisation sorties

parent c42bb3e9
......@@ -11,7 +11,8 @@ node database::get_node(const unsigned long long & ull_id)
if(r.size()==0)
{
fprintf(stderr,"\nMissing node %llu\n",ull_id);
fprintf(stdout,"\n# fatal error: missing node %llu\n",ull_id);
fflush(stdout);
abort();
}
......@@ -26,7 +27,7 @@ node database::get_node(const unsigned long long & ull_id)
std::list<unsigned long long> database::find_nodes(std::list< std::pair<double,double> > & l_points)
bool database::find_nodes(std::list< std::pair<double,double> > & l_points, std::list<unsigned long long> & lull_id)
{
// On trouve la cc
......@@ -36,9 +37,9 @@ std::list<unsigned long long> database::find_nodes(std::list< std::pair<double,d
unsigned long long ull_cc;
if(!find_one_node(*(l_points.begin()),false,0,ull_begin,ull_begin_cc,dist_begin))
abort();
return false;
if(!find_one_node(*(l_points.rbegin()),false,0,ull_end,ull_end_cc,dist_end))
abort();
return false;
if(ull_begin_cc==ull_end_cc)
{
......@@ -84,13 +85,11 @@ std::list<unsigned long long> database::find_nodes(std::list< std::pair<double,d
}
else
{
abort();
return false;
}
}
}
std::list<unsigned long long> lull_id;
std::list< std::pair<double,double> >::iterator it=l_points.begin();
while(it!=l_points.end())
{
......@@ -121,13 +120,13 @@ std::list<unsigned long long> database::find_nodes(std::list< std::pair<double,d
unsigned long long ull_cc_poubelle;
if(!find_one_node(P,true,ull_cc,id,ull_cc_poubelle,dist_poubelle))
abort();
return(false);
}
lull_id.push_back(id);
}
return(lull_id);
return(true);
}
......@@ -173,7 +172,8 @@ std::pair<unsigned long long, unsigned int> database::get_edge(const unsigned lo
pqxx::result r=txn.exec(z_req);
if(r.size()==0)
{
fprintf(stderr,"\nMissing edge (%llu,%llu)\n",ull_from,ull_to);
fprintf(stdout,"\n# fatal error: missing edge (%llu,%llu)\n",ull_from,ull_to);
fflush(stdout);
abort();
}
......
......@@ -26,7 +26,6 @@ class database
std::pair<unsigned long long, unsigned int> get_edge(const unsigned long long & ull_from, const unsigned long long & ull_to);
std::list<unsigned long long> get_adjoining(const unsigned long long & ull_id);
std::list<unsigned long long> find_nodes(const std::list< std::pair<double,double> > & l_points);
double get_height_s(const int & lon_s, const int & lat_s);
......@@ -34,8 +33,7 @@ class database
bool find_one_node(std::pair<double,double> P, bool respect_cc, unsigned long long ull_cc, unsigned long long & ull_result_id, unsigned long long & ull_result_cc, double & dist);
std::list<unsigned long long> find_nodes(std::list< std::pair<double,double> > & l_points);
bool find_nodes(std::list< std::pair<double,double> > & l_points, std::list<unsigned long long> &);
};
......
......@@ -18,6 +18,9 @@ int main(int argc, char* argv[])
double d_vent_VKMH=0;
char mode='e';
printf("# init\n");
fflush(stdout);
while (1)
{
static struct option long_options[] = {
......@@ -126,7 +129,8 @@ int main(int argc, char* argv[])
if(l_points.size()<2)
{
fprintf(stderr,"Must have at least 2 points\n");
printf("# fatal error: must have at least 2 points\n");
fflush(stdout);
abort();
}
......@@ -134,13 +138,18 @@ int main(int argc, char* argv[])
model m_model(mode,d_VplatKMH,d_masse,d_Cr,d_SCx,d_rho_air,d_vent_from,d_vent_VKMH);
double d_total_dist=0;
printf("# searching\n");
fflush(stdout);
std::list<unsigned long long> l_id;
std::list<double> l_distances;
{ // to destroy database object
database D_db(s_db);
l_id=D_db.find_nodes(l_points);
if(!D_db.find_nodes(l_points, l_id))
return 17;
unsigned long long previous=0;
......@@ -162,13 +171,15 @@ int main(int argc, char* argv[])
}
}
printf("# routing\n");
fflush(stdout);
unsigned long long previous=0;
etat_cycliste e_courant;
int troncon=0;
double d_status_offset=0;
std::list<double>::iterator it_dist=l_distances.begin();
printf("#troncon\tnode_id\tlon\tlat\theight\tway_from\tway_from_rev\tvitesse\tdistance\tdeniv\tenergie\ttps\n");
for(std::list<unsigned long long>::iterator it_id=l_id.begin();it_id!=l_id.end();it_id++)
{
if(it_id==l_id.begin())
......@@ -194,13 +205,16 @@ int main(int argc, char* argv[])
for(std::list<instant>::iterator it=lI_result.begin();it!=lI_result.end();it++)
{
printf("%lu\t",troncon);
printf("# node: ");
printf("%i\t",troncon);
printf("%llu\t",it->ull_id);
printf("%f\t%f\t%f\t",it->d_lon,it->d_lat,it->d_height);
printf("%llu\t%lu\t",it->ull_way_from_id,it->ull_way_from_rev);
printf("%f\t%f\t%f\t%f\t%f",it->d_V,it->d_dist,it->d_deniv_pos,it->d_ET,it->d_ET/m_model.d_P);
printf("%f\t%f\t%f\t%f\t%f",it->d_V * 3.6,it->d_dist,it->d_deniv_pos,it->d_ET,it->d_ET/m_model.d_P);
printf("\n");
}
printf("# section: %i\n",troncon);
fflush(stdout);
previous=*it_id;
......
......@@ -30,7 +30,8 @@ model::model(char c_model_type, double d_VplatKMH, double d_masse_i, double d_Cr
}
else
{
fprintf(stderr,"error model type\n");
fprintf(stdout,"# fatal error: model type\n");
fflush(stdout);
abort();
}
}
......
......@@ -35,20 +35,22 @@ void route::go()
unsigned long long ull_en_cours = S_queue.pop();
node_parcouru & P_en_cours = M_map[ull_en_cours];
P_en_cours.b_frozen=true;
// fprintf(stderr,"%10llu ->%10llu\t%f\t%f\n",P_en_cours.ull_from,ull_en_cours,P_en_cours.d_cout_minimal,P_en_cours.d_cout_minimal_arrive);
double d_nstatus=1-P_en_cours.d_dist_min_arrive/d_dist_min_totale;
if(d_nstatus>d_status)
{
d_status=d_nstatus;
double d_realstatus = d_status*d_status*d_status_echelle+d_status_offset;
printf("### status %.3f\n",d_realstatus);
printf("# status: %.4f\n",d_realstatus);
fflush(stdout);
}
// Si on vient de geler le noeud de fin, on s'arrete la.
if(ull_en_cours == ull_arrivee)
{
// YEAH !
printf("# info : done\n");
fflush(stdout);
break;
}
......@@ -86,7 +88,6 @@ void route::go()
if(m_model.cout_etat(etat_cycliste_voisin) < P_voisin.d_cout_minimal)
{
// fprintf(stderr,"\t\t\t->%10llu\t%f\t%f\t%f\n",ull_voisin,m_model.cout_etat(etat_cycliste_voisin),etat_cycliste_voisin.d_ET,etat_cycliste_voisin.d_V);
// Ce nouveau chemin est preferable pour aller a ce noeud
P_voisin.d_cout_minimal=m_model.cout_etat(etat_cycliste_voisin);
P_voisin.e_etat_cycliste_optimal=etat_cycliste_voisin;
......@@ -100,7 +101,8 @@ void route::go()
if(!P_arrivee.b_frozen)
{
fprintf(stderr,"graphe non connexe\n");
fprintf(stdout,"# fatal error : graphe non connexe\n");
fflush(stdout);
abort();
}
......
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