hermes
Class SelfInteractionOptimizer<A extends Being>
java.lang.Object
hermes.SelfInteractionOptimizer<A>
- Type Parameters:
A
- the type of Being the group contains
- All Implemented Interfaces:
- Optimizer<A,A,Group<A>,Group<A>>
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).
- Author:
- Sam
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 |
SelfInteractionOptimizer
public SelfInteractionOptimizer()
detect
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>>
- Parameters:
group1
- a group of beingsgroup2
- a group of beingshandler
- interaction handler that will detect and handle interactions