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.222.162 with SMTP id t32mr5620743yhp.47.1403436849294; Sun, 22 Jun 2014 04:34:09 -0700 (PDT) X-Received: by 10.140.51.18 with SMTP id t18mr1332qga.27.1403436849274; Sun, 22 Jun 2014 04:34:09 -0700 (PDT) Path: border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!buffer2.nntp.dca1.giganews.com!border2.nntp.dca3.giganews.com!backlog4.nntp.dca3.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!w8no9294294qac.0!news-out.google.com!a8ni10892qaq.1!nntp.google.com!w8no9294289qac.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 22 Jun 2014 04:34:09 -0700 (PDT) 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 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Function definitions - with clarification From: montgrimpulo Injection-Date: Sun, 22 Jun 2014 11:34:09 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Original-Bytes: 4019 Xref: number.nntp.dca.giganews.com comp.lang.ada:187147 Date: 2014-06-22T04:34:09-07:00 List-Id: Here is another try to describe my problem.=20 I want to conduct a genetic search-program. There is a function F (the obje= ctive function),=20 and a function G (the constraint function) which I want to define only at r= untime. The search-program handles individuals within a population. The siz= e of an individual as well as the size of the population is dynamic and is = known at runtime.=20 There is a proposed solution to define (in search.ads) ... generic=20 with function F (V : Individual) return Float;=20 with function G (V : Individual; M : Positive) return Float;=20 procedure Search (V : Individual);=20 which seems to be an appropriate solution for that part.=20 The search program handles individuals from a population.=20 type x_array is array (positive range <>) of Float;=20 type y_array is array (positive range <>) of Integer;=20 type z_array is array (positive range <>) of Boolean;=20 type Individual (P, Q, R) is record=20 X : x_array (0..P);=20 Y : y_array (0..Q);=20 Z : z_array (0..R);=20 end record;=20 P,Q and R are only known at runtime.=20 A population has a number (Popsize) of individuals (definition see above), = which is also only known at runtime.=20 Due to some reading, I learned that dynamic arrays in Ada=20 - can be declared in blocks, meaning no inheritance=20 - by limits passed as parameters in subprograms=20 - by use of linked lists=20 - by use of containers ?=20 - by use of discriminated records ?=20 Using the proposed record type from above,=20 my search-program may look like: (in search.adb) procedure Search (V : Individual) is=20 P : Natural :=3D V.P;=20 Q : Natural :=3D V.Q;=20 R : Natural :=3D V.R;=20 Vi : Individual :=3D V;=20 -- type population is array (1 .. Popsize) of Individual;=20 -- gives: unconstrained element in array declaration=20 ...=20 begin=20 -- fill Vi with distinct values and put it into an (array?, container ?, Li= st ?, whatever)=20 -- to get a population with size Popsize -- work on all individuals within that population=20 ...=20 end Search;=20 What I still need is a definition for the population (a collection of Indiv= iduals) of size Popsize, which is only defined at runtime. I want to use my search program for a specific objective- and for a specifi= c constraint-function with a certain size for an individual and a certain s= ize of population. If I do not find a solution then I want to change some e= lements, eg. size of the population, size of an individual, or to try modif= ied objective- or constraint-functions.=20 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 fun= ction with a different size of an individual and different population size= .=20