On 10/11/06, martinus <martin.ankerl / gmail.com> wrote:
> Hi all, I am writing an particle swarm optimizer that tries to find
> good floating point values for optimization problems. I have several
> test cases, and some target fitness value that the optimizer should be
> able to reach. The problem is that since such optimizers make lots of
> use of random numbers, so the optimizer can only find in about 90% of
> the cases the target fitness value. I can relax the target fitness
> value, than 95% of the runs are ok; but that is not really a solution.
>
> Any ideas how to write tests when you have such an uncertainty about
> the result?
>
> Martin

Could you make use of assert_in_delta? It's in Test::Unit. You can
either check that each attempt is within a certain tolerance, or you
can run a number of attempts and check that the number of successfult
ones falls within the threshold.

Farrel