From: Brian Candler Date: 2009-11-24T15:47:40+09:00 Subject: Re: ideas for a "parameter sweep" program? Diego Virasoro wrote: > I often need to run my computational experiments with a combination of > parameter values, and I was thinking of automatising it with Ruby. Any > idea on what would be the best way to go about it? Is the computational experiment written in Ruby? Then wrap it in a class, and pass the parameters to your initialize method. This allows you to re-use the code in different ways. For example, you can create one runner program which takes the parameters from the command line; another runner program which repeatedly runs the experiment but sweeping across a range of values; and so on. Even if the experiment is not written in ruby, you can still wrap it in a ruby class and call it as an external program using %x{}, system() or IO.popen(). > Or maybe should I cook up something with Rake? rake supports passing (string) parameters as environment variables: rake mytest FOO=xyz BAR=456 so a 'rake runner' might look like this: require 'experiment' task :mytest do result = Experiment.new(:foo => ENV['FOO'], :bar => ENV['BAR'].to_f).run puts result end -- Posted via http://www.ruby-forum.com/.