Smith Dhumbumroong avatar Smith Dhumbumroong committed 1185d7f

Further refactoring the code

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:

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 """
 ===========================
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.