@@ -74,7 +74,7 @@ enum Distance_type {
74
74
75
75
static Distance_type distance_type ;
76
76
77
- public static final String PROG_ID_STR = "ACO algorithms for the TSP, v1.02 " ;
77
+ public static final String PROG_ID_STR = "ACO algorithms for the TSP" ;
78
78
79
79
static int [] best_in_try ;
80
80
static int [] best_found_at ;
@@ -136,7 +136,7 @@ static Tsp.point[] read_etsp(String tsp_file_name) throws IOException
136
136
System .exit (1 );
137
137
}
138
138
139
- System .out .println ("reading tsp-file " + tsp_file_name + " ... " );
139
+ System .out .println ("\n reading tsp-file " + tsp_file_name + " ... " );
140
140
141
141
i = 0 ;
142
142
boolean found_coord_section = false ;
@@ -201,6 +201,8 @@ static Tsp.point[] read_etsp(String tsp_file_name) throws IOException
201
201
202
202
// TRACE ( System.out.println("number of cities is %ld\n",Tsp.n); )
203
203
// TRACE ( System.out.println("\n... done\n"); )
204
+ System .out .println ();
205
+
204
206
return (nodeptr );
205
207
}
206
208
@@ -417,9 +419,9 @@ static void population_statistics()
417
419
avg_distance /= ((double ) Ants .n_ants * (double ) (Ants .n_ants - 1 ) / 2. );
418
420
419
421
if (stat_report != null ) {
420
- printToFile (stat_report , iteration + "\t " + pop_mean + "\t " + pop_stddev + "\t " + pop_stddev + " \t "
421
- + pop_mean + "\t " + branching_factor + "\t " + (branching_factor - 1. ) * (double ) Tsp .n + "\t "
422
- + avg_distance + "\t " + avg_distance / (double ) Tsp .n );
422
+ printToFile (stat_report , iteration + "\t " + pop_mean + "\t " + pop_stddev + "\t " + ( pop_stddev / pop_mean )
423
+ + "\t " + branching_factor + "\t " + (( branching_factor - 1. ) * (double ) Tsp .n ) + "\t " + avg_distance
424
+ + "\t " + ( avg_distance / (double ) Tsp .n ) );
423
425
}
424
426
}
425
427
@@ -550,8 +552,8 @@ static void exit_program()
550
552
551
553
if (report != null ) {
552
554
printToFile (report , "\n Average-Best: " + avg_sol_quality + "\t Average-Iterations: " + avg_cyc_to_bst );
553
- printToFile (report , "\n Stddev -Best: " + stddev_best + " \t Stddev Iterations: " + stddev_iterations );
554
- printToFile (report , "\n Best try: " + best_tour_length + "\t \t Worst try: " + worst_tour_length );
555
+ printToFile (report , "Stddev -Best: " + stddev_best + " \t Stddev Iterations: " + stddev_iterations );
556
+ printToFile (report , "Best try: " + best_tour_length + "\t \t Worst try: " + worst_tour_length );
555
557
printToFile (report , "\n Avg.time-best: " + t_avgbest + " stddev.time-best: " + t_stdbest );
556
558
printToFile (report , "\n Avg.time-Ants.total: " + t_avgtotal + " stddev.time-Ants.total: " + t_stdtotal );
557
559
@@ -655,14 +657,14 @@ static void init_program(String[] args)
655
657
stat_report = null ;
656
658
}
657
659
658
- System .out .println ("calculating distance matrix ..\n \n " );
660
+ System .out .println ("calculating distance matrix .." );
659
661
Tsp .instance .distance = Tsp .compute_distances ();
660
662
System .out .println (" .. done\n " );
661
663
write_params ();
662
664
663
665
if (comp_report != null )
664
666
printToFile (comp_report , "begin problem " + name_buf );
665
- System .out .println ("allocate ants' memory ..\n \n " );
667
+ System .out .println ("allocate ants' memory .." );
666
668
Ants .allocate_ants ();
667
669
System .out .println (" .. done\n " );
668
670
}
@@ -860,30 +862,30 @@ static void write_params()
860
862
* OUTPUT: none
861
863
*/
862
864
{
863
- System .out .println ("\n Parameter -settings: \n \n " );
865
+ System .out .println ("Parameter -settings:\n " );
864
866
fprintf_parameters (null );
865
867
System .out .println ("\n " );
866
868
867
869
if (report != null ) {
868
- printToFile (report , "\n Parameter -settings: \n \n " );
870
+ printToFile (report , "Parameter -settings: \n \n " );
869
871
fprintf_parameters (report );
870
872
printToFile (report , "\n " );
871
873
}
872
874
873
875
if (comp_report != null ) {
874
876
printToFile (comp_report , PROG_ID_STR );
875
- printToFile (comp_report , "\n Parameter -settings: \n \n " );
877
+ printToFile (comp_report , "Parameter -settings: \n \n " );
876
878
fprintf_parameters (comp_report );
877
879
printToFile (comp_report , "\n " );
878
880
}
879
881
}
880
882
881
883
static void printToFile (File file , String string ) {
882
884
if (file == null ) {
883
- System .out .println (string + " \n " );
885
+ System .out .println (string );
884
886
} else {
885
887
try {
886
- writer .get (file .getName ()).write (string );
888
+ writer .get (file .getName ()).write (string + " \n " );
887
889
} catch (IOException e ) {
888
890
System .err .print ("Could not write file " + file .getName () + " " + e .getMessage ());
889
891
System .exit (1 );
0 commit comments