comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Function definitions
Date: Sat, 21 Jun 2014 10:57:53 -0700
Date: 2014-06-21T10:57:53-07:00	[thread overview]
Message-ID: <lo4h31$vr0$1@dont-email.me> (raw)
In-Reply-To: <2aa95b6a-951f-4e1d-adbb-612521fdbe9e@googlegroups.com>

On 06/21/2014 05:27 AM, montgrimpulo wrote:
>
> I want to conduct a genetic optimisation-program.

You probably want to do something like this:

subtype Probability is Float range 0.0 .. 1.0;

generic -- Search
    type Gene is private;

    with function Random return Gene;
    -- For an initial random population

    with function Fitness (Individual : Gene) return Float;
    -- To evaluate Individual

    with function Mate (Left : Gene; Right : Gene) return Gene;
    -- Combines 2 individuals to produce an offspring

    with procedure Mutate (Individual : in out Gene);
    -- Randomly mutate Individual
procedure Search (Population_Size      : in     Positive;
                   Num_Generations      : in     Positive;
                   Mutation_Probability : in     Probability;
                   Best                 :    out Gene;
                   Fit                  :    out Float);

You can look at PragmARC.Genetic_Algorithm for an example

http://pragmada.x10hosting.com/pragmarc.htm

-- 
Jeff Carter
"If you don't get the President of the United States on that
phone, ... you're going to have to answer to the Coca-Cola
Company."
Dr. Strangelove
32


  parent reply	other threads:[~2014-06-21 17:57 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-20 15:18 Function definitions montgrimpulo
2014-06-20 15:44 ` Adam Beneschan
2014-06-20 16:22 ` montgrimpulo
2014-06-20 16:43   ` Adam Beneschan
2014-06-20 16:52     ` Simon Clubley
2014-06-20 17:05       ` Adam Beneschan
2014-06-20 16:43   ` Simon Clubley
2014-06-22  6:59   ` Shark8
2014-06-20 17:39 ` montgrimpulo
2014-06-20 18:19   ` Adam Beneschan
2014-06-20 18:20     ` Adam Beneschan
2014-06-21 20:56     ` Stephen Leake
2014-06-22 12:27     ` Simon Clubley
2014-06-20 20:39   ` Robert A Duff
2014-06-21 12:27 ` montgrimpulo
2014-06-21 12:38   ` Simon Clubley
2014-06-21 17:57   ` Jeffrey Carter [this message]
2014-06-21 13:40 ` montgrimpulo
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox