Factorial
This problem was mentioned by the ASA
french research group as the first toy problem for multi-agent programming
platform.
See here.
Specification
Compute n! with one agent who does not know how to multiplicate but knows
n! algorithm and some agents who can only multiply 2 integers. Multiplications
are uniformly distributed over all the multiplier agents and are asynchronously
performed.
The involved agents
We defined 2 classes of agents :
-
an agent (called FactorielleAgent) who knows how to compute
n! : he distributes multiplications among all the multiplier
agents of its team, retrieves the answers and repeat this until all the
necessary multiplications have been performed. The distribution is uniform
over all the multiplier agents and requests are asynchronous.
-
a multiplier agent (called MultiplierAgent) who can
only compute the multiplication of 2 integers
Comments
-
no BigInteger are used then do not use to big value for n
-
It is possible to dynamically add multiplier agents during computing (of
course since the calculus is rather fast, i would be better to slow down
other agents to have enough time), but at now you can not remove an agent.
-
the MultiplierAgent is exactly
the same as in the collatz solution : agents
can be reused in different contexts