Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'optparse'
- opts = OptionParser.new do |opts|
- opts.on( '-l', '--length INT', 'Length of each individuals genome' ) do |length|
- @length = length
- end
- opts.on( '-p', '--population INT', 'Number of individuals in the population' ) do |population|
- @population = population
- end
- opts.on( '-pc', '--prob-crossover DECIMAL', 'Probability of one point crossover occuring' ) do |pc|
- @pc = pc
- end
- opts.on( '-g', '--generation INT', 'Maximum number of generations to run for' ) do |generations|
- @generations = generations
- end
- opts.on( '-pm', '--prob-mutation DECIMAL', 'Probability of gene mutation' ) do |pm|
- @pm = pm
- end
- opts.on( '-s', '--selection-type', [:roulette, :tournament] , 'Selection method to use, {roulette|tournament}' ) do |method|
- @method = method
- end
- opts.on_tail( '-h', '--h', 'Show this usage statement' ) do |help|
- puts opts
- end
- end
- begin
- opts.parse!( ARGV )
- rescue Exeption => e
- puts e, "", opts
- exit
- end
Add Comment
Please, Sign In to add comment