From: montgrimpulo <aghte@hotlinemail.com>
Subject: Function definitions - with clarification
Date: Sun, 22 Jun 2014 04:34:09 -0700 (PDT)
Date: 2014-06-22T04:34:09-07:00 [thread overview]
Message-ID: <f12eba4c-2757-4496-861b-101cb7e355d6@googlegroups.com> (raw)
Here is another try to describe my problem.
I want to conduct a genetic search-program. There is a function F (the objective function),
and a function G (the constraint function) which I want to define only at runtime. The search-program handles individuals within a population. The size of an individual as well as the size of the population is dynamic and is known at runtime.
There is a proposed solution to define (in search.ads)
...
generic
with function F (V : Individual) return Float;
with function G (V : Individual; M : Positive) return Float;
procedure Search (V : Individual);
which seems to be an appropriate solution for that part.
The search program handles individuals from a population.
type x_array is array (positive range <>) of Float;
type y_array is array (positive range <>) of Integer;
type z_array is array (positive range <>) of Boolean;
type Individual (P, Q, R) is record
X : x_array (0..P);
Y : y_array (0..Q);
Z : z_array (0..R);
end record;
P,Q and R are only known at runtime.
A population has a number (Popsize) of individuals (definition see above), which is also only known at runtime.
Due to some reading, I learned that dynamic arrays in Ada
- can be declared in blocks, meaning no inheritance
- by limits passed as parameters in subprograms
- by use of linked lists
- by use of containers ?
- by use of discriminated records ?
Using the proposed record type from above,
my search-program may look like: (in search.adb)
procedure Search (V : Individual) is
P : Natural := V.P;
Q : Natural := V.Q;
R : Natural := V.R;
Vi : Individual := V;
-- type population is array (1 .. Popsize) of Individual;
-- gives: unconstrained element in array declaration
...
begin
-- fill Vi with distinct values and put it into an (array?, container ?, List ?, whatever)
-- to get a population with size Popsize
-- work on all individuals within that population
...
end Search;
What I still need is a definition for the population (a collection of Individuals) of size Popsize, which is only defined at runtime.
I want to use my search program for a specific objective- and for a specific constraint-function with a certain size for an individual and a certain size of population. If I do not find a solution then I want to change some elements, eg. size of the population, size of an individual, or to try modified objective- or constraint-functions.
After I have found a solution or not, I want to use the same search program with a new and different objective- and a new and different constraint function with a different size of an individual and different population size.
next reply other threads:[~2014-06-22 11:34 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-22 11:34 montgrimpulo [this message]
2014-06-22 12:04 ` Function definitions - with clarification Simon Clubley
2014-06-22 14:25 ` montgrimpulo
2014-06-22 15:30 ` Georg Bauhaus
2014-06-22 17:29 ` montgrimpulo
2014-06-22 17:45 ` Shark8
2014-06-22 18:03 ` montgrimpulo
2014-06-22 18:45 ` Simon Clubley
2014-06-22 19:28 ` montgrimpulo
2014-06-22 21:04 ` Simon Wright
2014-06-22 21:17 ` Jeffrey Carter
2014-06-22 19:55 ` Shark8
2014-06-23 16:26 ` Adam Beneschan
2014-06-29 15:31 ` cotswold
2014-06-29 19:20 ` montgrimpulo
2014-06-30 9:29 ` G.B.
2014-06-30 17:55 ` Shark8
2014-07-01 8:58 ` Georg Bauhaus
2014-07-04 6:45 ` J-P. Rosen
2014-06-30 13:23 ` 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