Commits

Smith Dhumbumroong  committed 1185d7f

Further refactoring the code

  • Participants
  • Parent commits d03f2dd

Comments (0)

Files changed (2)

 
     # the main loop
     for g in xrange(1, max_iter + 1):
+        # the main part of the loop, where most of the cGA-related works are done 
+
         # use the probability vector to generate candidates
         c1 = generate_candidate(pvector)
         c2 = generate_candidate(pvector)
         # update the probability vector using the result of the competition
         update_pvector(pvector, winner[0], loser[0], pop_size)
 
+        # end of the main part of the loop
+
         # update the information of the best candidate
         best_cand = winner[0]
         best_cand_score = winner[1]
             cur_gen_pvector = list(pvector) 
             hist_pvector.append(cur_gen_pvector)
 
-    console_output.print_greeting_message(clength, pop_size)
-
     # print the final result
     console_output.print_final_result(max_iter,
                                       best_cand, 
                                       pvector,
                                       clength,
                                       pop_size)
+
     if args.plot_graph:
         return hist_best_cand_scores, hist_loser_cand_scores, hist_pvector
     else:

File console_output.py

 #
 # Author: Smith Dhumbumroong (zodmaner@gmail.com)
 
-def print_greeting_message(clength, pop_size):
-    print """
-=====
-PyCGA
-=====
-
-Setup:
-------
-Chromosome length is {0}
-Population size is {1}""".format(clength, pop_size)
-
 def print_init_pvector(pvector):
     print """
 ===========================