commit bbdab32dfcd6baac68b3e285a35762ef0248c44b
parent 6b5a3888b30edb830f98a3507057d3d5723e1da1
Author: Jachiet Louis <louis@jachiet.com>
Date: Sat, 5 Apr 2014 15:10:36 +0200
Complete complete
Diffstat:
4 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/contest/louis/algo.cpp b/contest/louis/algo.cpp
@@ -22,7 +22,8 @@ int main()
// fprintf(stderr,"%d %d %d\n",i,chem[i].back(),arrivee);
}
}
+ fprintf(stderr,"%d !\n",score_solution(chem));
ameliore_louis(chem);
- //affiche_sortie(chem);
+ // affiche_sortie(chem);
}
diff --git a/contest/louis/ameliore.cpp b/contest/louis/ameliore.cpp
@@ -1,3 +1,5 @@
+#include <assert.h>
+
class sol_louis
{
public:
@@ -15,11 +17,15 @@ public:
sol_louis(vector<int> c[])
{
for(int i = 0 ; i < 8 ; i++ )
- cibles[i] = c[i];
+ {
+ cibles[i] = c[i];
+ for(int c = 0 ; c < 100 ; c++ )
+ cibles[i].push_back(rand()%n_sommets);
+ }
note();
}
- sol_louis(sol_louis & o)
+ sol_louis(const sol_louis& o)
{
score = o.score ;
for(int i = 0 ; i < 8 ; i++ )
@@ -42,7 +48,7 @@ void ameliore_louis(vector<int> c[])
{
sol_louis r_best(c) ;
double temp = 1000 * 1000 ;
- const int nb_iter_max = 100 ;
+ const int nb_iter_max = 100*1000 ;
//for( int i = 0 ; i < 10 ; i++ )
{
temp = 1000 * 1000 ;
@@ -53,11 +59,12 @@ void ameliore_louis(vector<int> c[])
while( nb_iter < nb_iter_max )
{
- fprintf(stderr,"cur_score %d[%d] | %d | %d \n",cur.score,cur.cibles[0].size(),r_best.score,score_solution(cur.cibles));
+ if(nb_iter %200 == 0)
+ fprintf(stderr,"cur_score %d[%d] | %d | %d \n",cur.score,cur.cibles[0].size(),r_best.score);
cur = best;
cur.update();
- if( cur.score > best.score || ((double(rand())/RAND_MAX) > (cur.score-best.score) * temp / (1000*1000) ))
+ if( cur.score > best.score)
{
best = cur ;
if( best.score > r_best.score )
diff --git a/contest/louis/louis.cpp b/contest/louis/louis.cpp
@@ -60,14 +60,14 @@ int go_to( int depart, int arrivee)
return use[depart][arrivee] ;
}
*/
-vector<int> complete ( vector<int> c)
+vector<int> complete ( vector<int> & c)
{
vector<int> r ;
+ r.push_back(c[0]);
for(size_t i = 0 ; i+1 < c.size() ; i++ )
{
- r.push_back(c[i]);
while(r.back() != c[i+1])
- r.push_back(use[r.back()][c[i]]);
+ r.push_back(use[r.back()][c[i+1]]);
}
return r ;
}
diff --git a/contest/mc/lecture.cpp b/contest/mc/lecture.cpp
@@ -61,12 +61,12 @@ vector<int> evalue_solution(vector<int> trajectoires[]) {
pair<int, int> p = make_pair(trajectoires[i][j], trajectoires[i][j+1]);
int a = id_arete[p];
if (!a) {
- fprintf(stderr,"ERREUR !");
+ fprintf(stderr,"ERREUR ! %d %d [%d -> %d]",i,j,trajectoires[i][j], trajectoires[i][j+1]);
resultat.clear();
return resultat;
}
temps += cout[a];
- if (temps > t_autorise) {
+ if (temps >= t_autorise) {
// undo
temps -= cout[a];
break;