Class SelfInteractionOptimizer<A extends Being>

  extended by hermes.SelfInteractionOptimizer<A>
Type Parameters:
A - the type of Being the group contains
All Implemented Interfaces:

public class SelfInteractionOptimizer<A extends Being>
extends java.lang.Object
implements Optimizer<A,A,Group<A>,Group<A>>

This Optimizer reduces the time needed to handle interactions between all members of the same group, and also eliminates duplicate interactions. Each member will be checked against each other member of the group exactly once. This works only if the interactions are commutative, ie handle(A,B) is equivalent to handle(B,A).
Detection under this optimizer is still an O(n^2) operation, but using it will reduce total calculation time by a factor of approximately 1/2 (the number of computations performed will be n(n-1) / 2, where n is the number of beings in the group).


Constructor Summary
Method Summary
 void detect(Group<A> group1, Group<A> group2, InteractionHandler<A,A> handler)
          This should detect all possible interactions between the members of groups A and B, using handler.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public SelfInteractionOptimizer()
Method Detail


public void detect(Group<A> group1,
                   Group<A> group2,
                   InteractionHandler<A,A> handler)
Description copied from interface: Optimizer
This should detect all possible interactions between the members of groups A and B, using handler.

Specified by:
detect in interface Optimizer<A extends Being,A extends Being,Group<A extends Being>,Group<A extends Being>>
group1 - a group of beings
group2 - a group of beings
handler - interaction handler that will detect and handle interactions