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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fa81b07d7c3d2d7d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-01 22:35:06 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!canoe.uoregon.edu!logbridge.uoregon.edu!newsfeed.cs.utexas.edu!geraldo.cc.utexas.edu!not-for-mail From: "Bobby D. Bryant" Newsgroups: comp.lang.ada Subject: Re: Random numbers in tasks Date: Sun, 01 Jun 2003 23:32:56 -0600 Organization: dis- Message-ID: References: <3EDAC482.40604@attbi.com> NNTP-Posting-Host: dial-81-13.ots.utexas.edu Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: geraldo.cc.utexas.edu 1054532005 29238 128.83.219.29 (2 Jun 2003 05:33:25 GMT) X-Complaints-To: abuse@utexas.edu NNTP-Posting-Date: Mon, 2 Jun 2003 05:33:25 +0000 (UTC) User-Agent: Pan/0.14.0 (I'm Being Nibbled to Death by Cats!) Xref: archiver1.google.com comp.lang.ada:38306 Date: 2003-06-01T23:32:56-06:00 List-Id: On Mon, 02 Jun 2003 03:29:33 +0000, Robert I. Eachus wrote: > Papastefanos Serafeim wrote: >> There is a small problem in that solution, I cannot just declare the >> generator in the task type: There is a function in a different package >> that is used to return a random number in a given range and that >> function is used at other places too... > > There is magic in Ada for especially this purpose. It is in Annex C, so > it is possible that some compilers don't support it. Look at C.7.2 The > Package Task_Attributes. Here is an example and output using GNAT. > Notice that this version uses a fixed seed for each different task. If > you want different seeds for every run modify the body of > My_Float_Random.Gen_Source. But notice that just using a call to get > seeds based on the clock may not be sufficient, unless you put a delay > in. FWIW, I have a GA solver with similar requirements, and I just have the tasks rendezvous with a 'controller' task that dispenses individual seeds for them to initialize on. After that they can run independently. -- Bobby Bryant Austin, Texas