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.236.230.106 with SMTP id i100mr3568710yhq.27.1403353626924; Sat, 21 Jun 2014 05:27:06 -0700 (PDT) X-Received: by 10.140.18.235 with SMTP id 98mr137512qgf.1.1403353626907; Sat, 21 Jun 2014 05:27:06 -0700 (PDT) Path: border1.nntp.dca.giganews.com!nntp.giganews.com!w8no8160713qac.0!news-out.google.com!a8ni10892qaq.1!nntp.google.com!w8no8160710qac.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 21 Jun 2014 05:27:06 -0700 (PDT) In-Reply-To: <610b9d5b-a9a5-464d-9de3-b2f754f58cff@googlegroups.com> 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: <610b9d5b-a9a5-464d-9de3-b2f754f58cff@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <2aa95b6a-951f-4e1d-adbb-612521fdbe9e@googlegroups.com> Subject: Re: Function definitions From: montgrimpulo Injection-Date: Sat, 21 Jun 2014 12:27:06 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: number.nntp.dca.giganews.com comp.lang.ada:187107 Date: 2014-06-21T05:27:06-07:00 List-Id: Here is another try to describe my problem. I want to conduct a genetic optimisation-program. There is a function F (the objective function), and a function G (the constraint function) which I can define only at runtime. The program handles individuals within a population. The size of an individual as well as the size of the population are dynamic and only known at runtime. The proposed solution to define generic with function F (V : Individual) return Float; with function G (V : Individual; M : Positive); procedure Search (V : Individual) 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. Furthermore a population has a number of individuals (Popsize), 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 ? looking at the proposed record from above: Would it be OK to define 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; -- unconstrained element in array declaration ... begin -- fill Vi with distinct values and put it into an array?, container ?, List ?, whatever -- work on all Vi's within that population ... end Search; What I still need is a definition for the population (a collection of Individuals), which size is determined at runtime.