# Code from Chapter 10 of Machine Learning: An Algorithmic Perspective (2nd Edition) # by Stephen Marsland (http://stephenmonika.net) # You are free to use, change, or redistribute the code in any way you wish for # non-commercial purposes, but please maintain the name of the original author. # This code comes with no warranty of any kind. # Stephen Marsland, 2008, 2014 # A runner for the Genetic Algorithm import ga import pylab as pl pl.ion() pl.show() plotfig = pl.figure() ga = ga.ga(30, "fF.fourpeaks", 301, 100, -1, "un", 4, True) ga.runGA(plotfig) pl.pause(0) # pl.show()
# Code from Chapter 12 of Machine Learning: An Algorithmic Perspective # by Stephen Marsland (http://seat.massey.ac.nz/personal/s.r.marsland/MLBook.html) # You are free to use, change, or redistribute the code in any way you wish for # non-commercial purposes, but please maintain the name of the original author. # This code comes with no warranty of any kind. # Stephen Marsland, 2008 # A runner for the Genetic Algorithm import ga ga = ga.ga(20, 'fF.knapsack', 101, 100, -1, 'sp', 4, True) ga.runGA()
def main(): print "Problem 1 Test 1:" ga1 = ga.parseInput(1, 'problem1_test1.txt') ga.runGA(ga1, 10, 'prob1_test1_results.csv') print "Problem 1 Test 2:" ga1 = ga.parseInput(1, 'problem1_test2.txt',) ga.runGA(ga1, 10, 'prob1_test2_results.csv') print "Problem 1 Test 3:" ga1 = ga.parseInput(1, 'problem1_test3.txt') ga.runGA(ga1, 10, 'prob1_test3_results.csv') print "Problem 2 Test 1:" ga1 = ga.parseInput(2, 'problem2_test1.txt') ga.runGA(ga1, 10, 'prob2_test1_results.csv') print "Problem 2 Test 2:" ga1 = ga.parseInput(2, 'problem2_test2.txt') ga.runGA(ga1, 10, 'prob2_test2_results.csv') print "Problem 2 Test 3:" ga1 = ga.parseInput(2, 'problem2_test3.txt') ga.runGA(ga1, 10, 'prob2_test3_results.csv') print "Problem 3 Test 1:" ga1 = ga.parseInput(3, 'problem3_test1.txt') ga.runGA(ga1, 10, 'prob3_test1_results.csv') print "Problem 3 Test 2:" ga1 = ga.parseInput(3, 'problem3_test2.txt') ga.runGA(ga1, 10, 'prob3_test2_results.csv') print "Problem 3 Test 3:" ga1 = ga.parseInput(3, 'problem3_test3.txt') ga.runGA(ga1, 10, 'prob3_test3_results.csv')
# Code from Chapter 12 of Machine Learning: An Algorithmic Perspective # by Stephen Marsland (http://seat.massey.ac.nz/personal/s.r.marsland/MLBook.html) # You are free to use, change, or redistribute the code in any way you wish for # non-commercial purposes, but please maintain the name of the original author. # This code comes with no warranty of any kind. # Stephen Marsland, 2008 # A runner for the Genetic Algorithm import ga ga = ga.ga(20,'fF.knapsack',101,100,-1,'sp',4,True) ga.runGA()
# Code from Chapter 10 of Machine Learning: An Algorithmic Perspective (2nd Edition) # by Stephen Marsland (http://stephenmonika.net) # You are free to use, change, or redistribute the code in any way you wish for # non-commercial purposes, but please maintain the name of the original author. # This code comes with no warranty of any kind. # Stephen Marsland, 2008, 2014 # A runner for the Genetic Algorithm import ga import pylab as pl pl.ion() pl.show() plotfig = pl.figure() ga = ga.ga(30, 'fF.fourpeaks', 301, 100, -1, 'un', 4, True) ga.runGA(plotfig) pl.pause(0) #pl.show()