[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ordering events in a swarm ....
From: |
xueyue |
Subject: |
ordering events in a swarm .... |
Date: |
Sun, 06 Jun 1999 22:02:44 +0000 |
I am testing my swarm programme and running into a problem:
I have an observerSwarm in which there is an object built which is
another:
-buildObjects {
[super buildObjects];
...
schedulerSwarm=[SchedulerSwarm create: self];
[schedulerSwarm buildObjects];
...
}
-buildActions {
...
[schedulerSwarm buildActions];
...
}
-activateIn: context {
...
[schedulerSwarm buildActions];
...
}
where SchedulerSwarm is definded as a swarm which is
able to build a dynamical schedule (the same as
the swarm fest demo: simpleObserverBug-growth) through:
[schedulerSwarm newScheduleAt: (timeval_t) t target: (id) tg message:
(SEL) msg];
as far as I can test, the swarm works well, apart from the following
situation:
in the observerSwarm, I have a test method:
-test {
printf("I am testing schedulerSwarm ....\n");
return self;
}
and a method -step which is scheduled to be called at
at every step:
-step {
timeval_t tm [timeSwarm getTime];
int x = 5;
tm=tm+x;
[schedulerSwarm newScheduleAt: tm target: self message: M(test)];
return self;
}
here timeSwarm is another swarm, which serves as a clock,
and -getTime will get current time.
The programme will work, as I expected, i.e., every step will
-step be called, and -test method will be scheduled at
5 step later at which it is excuted.
Now, I changed -step definition:
-step {
timeval_t tm [timeSwarm getTime];
int x = [uniformIntRand getIntegerWithMin: 5 withMax: 10];
tm=tm+x;
[schedulerSwarm newScheduleAt: tm target: self message: M(test)];
return self;
}
x is an integer produced by uniformIntRand. (there is
<random.h>, x is corretly produced ---can be tested
by printf("x is %d ...", x)), however, the programme will
no longer work!
I found this problem results from the order of the events are sometime
reversed: suppose the first time -step is called,
x by random is 9, and the next time, x is 6, then schedulerSwarm will
receive two schedule:
at tm+9, excute test,
at tm+5, excute test,
Why I am saying so?
I changed -step:
-step {
timeval_t tm [timeSwarm getTime];
int x = 5;
tm=tm+x;
[schedulerSwarm newScheduleAt: tm target: self message: M(test)];
[schedulerSwarm newScheduleAt: tm-2 target: self message: M(test)];
return self;
}
then the programme will not work. However, if
-step {
timeval_t tm [timeSwarm getTime];
int x = 5;
tm=tm+x;
[schedulerSwarm newScheduleAt: tm target: self message: M(test)];
[schedulerSwarm newScheduleAt: tm+2 target: self message: M(test)];
return self;
}
the programme will work!
This brings a conclusion that the dynamical scheduler will
not be able to schedule an event at t-x, (x>0), if there
is already an event scheduled at t (by the same agent or different
agent).
I do not know if anyone can solve this problem.
My intention is: the schedulerSwarm will be used by many
agents each of which do not know what schedule has the other agents have
send to schedulerSwarm, not mentioning the order.
I may have not present the problem clearly, if so, please
ask me to clarify.
Many thanks!
--
Dr Xueyue Huang
Center for Transport Studies
Imperial College
London SW7 2BU
(+44) 171 594 6037
vcard.vcf
Description: Card for Xueyue Huang
- ordering events in a swarm ....,
xueyue <=
- Re: ordering events in a swarm ...., Ken Cline, 1999/06/06
- Re: ordering events in a swarm ...., xueyue, 1999/06/08
- Re: ordering events in a swarm ...., xueyue, 1999/06/08
- Re: ordering events in a swarm ...., Marcus G. Daniels, 1999/06/09
- Re: ordering events in a swarm ...., xueyue, 1999/06/11
- Re: ordering events in a swarm ...., Paul Johnson, 1999/06/11
- Re: ordering events in a swarm ...., xueyue, 1999/06/13
- Re: ordering events in a swarm ...., Marcus G. Daniels, 1999/06/11
- Re: ordering events in a swarm ...., xueyue, 1999/06/13
- Re: ordering events in a swarm ...., Marcus G. Daniels, 1999/06/13