Re: [abc-users] probability

From: Eric Bodden <eric.bodden_at_mail.mcgill.ca>
Date: Sat, 4 Apr 2009 16:56:45 -0400

Ah, I see.

In this case you should return neither AlwaysMatch nor NeverMatch but
instead a custom residue. This residue should insert some code:

a) a call to the random-number generator
b) fetch the resuling boolean value and
c) return a reference to the local that holds this boolean.

It may help to look at ThisResidue. That residue checks for the
dynamic runtime type of an object and enables/disables the advice
depending on this dynamic check. Your residue must do something
similar.

Eric

2009/4/4 Amjad Nusayr <anusayr_at_cs.nmsu.edu>:
> NO man its not that. Its how could make my extension generate random numbers
> at runtime!!
> I have to make my self more clear. In my residue  I AlwaysMatch shadows
> within a certain probability.
>
> public Residue optimize() {
>      probGenerated=generator.nextInt(100)+1;
>      if (probGenerated<=prob)
>      {                    return AlwaysMatch.v();
>      }
>      else
>          return NeverMatch.v();
>  }
>
> This give me a problem of having the same shadows every time I run my
> program. I want the random shadow match generation to be at runtime.
> I hope I'm more clear this time.
>
> I know to generate random numbers. I first did that in MSX Basic when I 10
> years old :-)
>
> Amjad
>
> Eric Bodden wrote:
>>
>> So you are asking how to generate random numbers at runtime?
>>
>> Simply insert a call to...
>>
>> http://java.sun.com/j2se/1.4.2/docs/api/java/util/Random.html
>>
>> Hope that helps
>>
>> 2009/4/4 Amjad Nusayr <anusayr_at_cs.nmsu.edu>:
>>
>>>
>>> I thought I knew how to generate random numbers at runtime. BUT I dont.
>>> How
>>> can make my aspect (or my extension) generate random numbers every time I
>>> run my code. I created a probability PC but generates random numbers at
>>> compile time. This does not what I wanted cause it means I'm executes the
>>> same sites over and over again.
>>>
>>> Amjad
>>>
>>> Eric Bodden wrote:
>>>
>>>>
>>>> Still, you should probably try this first and then you can still
>>>> change it later if required.
>>>>
>>>> When you generate random numbers at runtime, then all you need to do
>>>> is create a dynamic residue that returns the result of a call to some
>>>> function "shouldExecute()". This function should return a random
>>>> boolean.
>>>>
>>>> Eric
>>>>
>>>> 2009/3/31 Amjad Nusayr <anusayr_at_cs.nmsu.edu>:
>>>>
>>>>
>>>>>
>>>>> I thought of that, but that means more overhead time at runtime. Thats
>>>>> why I
>>>>> wanted to generate the trace when compiling.
>>>>>
>>>>> Amjad
>>>>>
>>>>>
>>>>> Eric Bodden wrote:
>>>>>
>>>>>
>>>>>>
>>>>>> Hi Amjad. Why don't you compute the random number at runtime? That
>>>>>> would be way easier than storing it in a trace. Would that work for
>>>>>> you?
>>>>>>
>>>>>> Eric
>>>>>>
>>>>>> 2009/3/31 Amjad Nusayr <anusayr_at_cs.nmsu.edu>:
>>>>>>
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> Hello
>>>>>>> I want to design a PC called probability(p) i n which advice is woven
>>>>>>> at
>>>>>>> each joinpoint but is executed only with P probability. My main
>>>>>>> concern
>>>>>>> here
>>>>>>> is that a dynamic check is needed to create this action. To check the
>>>>>>> probability I want to pre-compute a "trace" of random numbers, then
>>>>>>> just
>>>>>>> pull the next unused number out of the trace. There are two things I
>>>>>>> need
>>>>>>> to
>>>>>>> ask of. First, How can I create this dynamic check? Second. How can I
>>>>>>> get
>>>>>>> the trace of random numbers to be a part of my generated code?
>>>>>>>
>>>>>>> Thanks
>>>>>>> Amjad
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>>
>>
>
>
>

-- 
Eric Bodden
Sable Research Group, McGill University
Montréal, Québec, Canada
Received on Sat Apr 04 2009 - 21:56:54 BST

This archive was generated by hypermail 2.2.0 : Tue Apr 07 2009 - 07:40:11 BST