The Syracuse (or Collatz) conjecture

DOWNLOAD EXAMPLE

Specification

The problem is the following one, consider the function :
 
let n be a natural integer, f(n)=
n/2 if n is even
3n+1 if n is odd
Then iterates this function until you reach 1 (f(f(...f(n)...)) = 1). The conjecture asserts 1 is reached after a finite number of iterations for every n>0.

The involved agents of the solution

To solve this problem, we define several (very) specialized agents : And we add a supervisor with the four last above agents belonging to its team. The supervisor does nothing else than being the links between other agents and he manages requests routing.
The parity agent is directly connected to the collatz agent, with no hierarchical relationship (just to show it is possible).

Supervisor, adder, divider and multiplier are seated in the same JVM on a given host, collatz and parity agent are distributed over two other machines.

The structure (the agents and their methods) is then :
 

Super
Collatz

xByTwo
testParity
threeTimesPlus1

ParityAgent

isEven

AddingAgent

add

DividerAgent

quotient

MultAgent

mult

Comments