Guest User

Untitled

a guest
Apr 21st, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. require 'optparse'
  2.  
  3. opts = OptionParser.new do |opts|
  4. opts.on( '-l', '--length INT', 'Length of each individuals genome' ) do |length|
  5. @length = length
  6. end
  7.  
  8. opts.on( '-p', '--population INT', 'Number of individuals in the population' ) do |population|
  9. @population = population
  10. end
  11.  
  12. opts.on( '-pc', '--prob-crossover DECIMAL', 'Probability of one point crossover occuring' ) do |pc|
  13. @pc = pc
  14. end
  15.  
  16. opts.on( '-g', '--generation INT', 'Maximum number of generations to run for' ) do |generations|
  17. @generations = generations
  18. end
  19.  
  20. opts.on( '-pm', '--prob-mutation DECIMAL', 'Probability of gene mutation' ) do |pm|
  21. @pm = pm
  22. end
  23.  
  24. opts.on( '-s', '--selection-type', [:roulette, :tournament] , 'Selection method to use, {roulette|tournament}' ) do |method|
  25. @method = method
  26. end
  27.  
  28. opts.on_tail( '-h', '--h', 'Show this usage statement' ) do |help|
  29. puts opts
  30. end
  31. end
  32.  
  33. begin
  34. opts.parse!( ARGV )
  35. rescue Exeption => e
  36. puts e, "", opts
  37. exit
  38. end
Add Comment
Please, Sign In to add comment