From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.58.160.72 with SMTP id xi8mr7364118veb.15.1403458173709; Sun, 22 Jun 2014 10:29:33 -0700 (PDT) X-Received: by 10.140.42.47 with SMTP id b44mr80qga.8.1403458173687; Sun, 22 Jun 2014 10:29:33 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!i13no9328315qae.1!news-out.google.com!a8ni10892qaq.1!nntp.google.com!w8no9582752qac.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 22 Jun 2014 10:29:33 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=109.233.148.43; posting-account=ZoAlyAoAAACOOtSiXyaM8n3y8T4ScfeH NNTP-Posting-Host: 109.233.148.43 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <4e475fa7-632b-4ef3-b0aa-e0587ddda741@googlegroups.com> Subject: Re: Function definitions - with clarification From: montgrimpulo Injection-Date: Sun, 22 Jun 2014 17:29:33 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 5150 X-Received-Body-CRC: 2017635835 Xref: news.eternal-september.org comp.lang.ada:20518 Date: 2014-06-22T10:29:33-07:00 List-Id: ... > -- type population is array (1 .. Popsize) of Individual;=20 > -- gives: unconstrained element in array declaration=20 Georg Bauhaus wrote " this means that type individual is a record that has discriminants without default values ... ... " Sorry, this was not the question. The implicit question (also put later in my text) was which alternatives do I have,=20 as I want to finish programming my complete system=20 first without default values, and specify then the size=20 before running the system. On Sunday, June 22, 2014 1:34:09 PM UTC+2, montgrimpulo wrote: > Here is another try to describe my problem.=20 >=20 >=20 >=20 > I want to conduct a genetic search-program. There is a function F (the ob= jective function),=20 >=20 > and a function G (the constraint function) which I want to define only at= runtime. The search-program handles individuals within a population. The s= ize of an individual as well as the size of the population is dynamic and i= s known at runtime.=20 >=20 >=20 >=20 > There is a proposed solution to define (in search.ads) >=20 >=20 >=20 > ... >=20 > generic=20 >=20 > with function F (V : Individual) return Float;=20 >=20 > with function G (V : Individual; M : Positive) return Float;=20 >=20 > procedure Search (V : Individual);=20 >=20 >=20 >=20 > which seems to be an appropriate solution for that part.=20 >=20 >=20 >=20 > The search program handles individuals from a population.=20 >=20 >=20 >=20 > type x_array is array (positive range <>) of Float;=20 >=20 > type y_array is array (positive range <>) of Integer;=20 >=20 > type z_array is array (positive range <>) of Boolean;=20 >=20 >=20 >=20 > type Individual (P, Q, R) is record=20 >=20 > X : x_array (0..P);=20 >=20 > Y : y_array (0..Q);=20 >=20 > Z : z_array (0..R);=20 >=20 > end record;=20 >=20 >=20 >=20 > P,Q and R are only known at runtime.=20 >=20 >=20 >=20 > A population has a number (Popsize) of individuals (definition see above)= , which is also only known at runtime.=20 >=20 >=20 >=20 > Due to some reading, I learned that dynamic arrays in Ada=20 >=20 >=20 >=20 > - can be declared in blocks, meaning no inheritance=20 >=20 > - by limits passed as parameters in subprograms=20 >=20 > - by use of linked lists=20 >=20 > - by use of containers ?=20 >=20 > - by use of discriminated records ?=20 >=20 >=20 >=20 > Using the proposed record type from above,=20 >=20 > my search-program may look like: (in search.adb) >=20 >=20 >=20 > procedure Search (V : Individual) is=20 >=20 >=20 >=20 > P : Natural :=3D V.P;=20 >=20 > Q : Natural :=3D V.Q;=20 >=20 > R : Natural :=3D V.R;=20 >=20 > Vi : Individual :=3D V;=20 >=20 >=20 >=20 >=20 >=20 > -- type population is array (1 .. Popsize) of Individual;=20 >=20 > -- gives: unconstrained element in array declaration=20 >=20 >=20 >=20 > ...=20 >=20 > begin=20 >=20 > -- fill Vi with distinct values and put it into an (array?, container ?, = List ?, whatever)=20 >=20 > -- to get a population with size Popsize >=20 > -- work on all individuals within that population=20 >=20 > ...=20 >=20 > end Search;=20 >=20 >=20 >=20 > What I still need is a definition for the population (a collection of Ind= ividuals) of size Popsize, which is only defined at runtime. >=20 > I want to use my search program for a specific objective- and for a speci= fic 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 mod= ified objective- or constraint-functions.=20 >=20 > After I have found a solution or not, I want to use the same search progr= am with a new and different objective- and a new and different constraint f= unction with a different size of an individual and different population si= ze.