fr.lifl.jedi.model.interactionDeclaration
Class InteractionMatrixLine

java.lang.Object
  extended by java.util.Observable
      extended by fr.lifl.jedi.model.interactionDeclaration.InteractionMatrixLine

public class InteractionMatrixLine
extends java.util.Observable

This class represents a line of the interaction matrix. Such a line represents the interactions that a particular agent family (the source) is able to initiate.

Each cell of the interaction matrix contains AbstractAssignationElement, which are tuples that represent either :

Behavior Specification

Agent behavior relies on the notion of realizable tuple. A tuple (Source Agent, Single Target Interaction, Target Agent), (Source Agent, Degenerate Interaction) or (Source Agent, Multiple Target Interaction, List of Target Agents) is said realizable if and only if :

Agents behavior is split in two phases :

  1. First, it will perceive its neighboring environment -- i.e. closeby agents (see Agent.getHalo()).
  2. Then, it will perform its interaction selection process.

    This process uses a subsumption-like architecture to select what the agent performs :
    every assignation element involved in the action selection process is given a priority, with the methods add(DegenerateInteraction, int), add(MultipleTargetInteraction, Class, double, int) or add(SingleTargetInteraction, Class, double, int). Interaction selection takes place in decreasing value of priority, and checks every priority until a realizable tuple is selected.

    For each priority, the selection is made with an interaction selection policy. Such policies defines how the selection of a tuple takes place. For instance, it can :

    See InteractionSelectionPolicy for more details on interaction selection policies. This policy is defined thanks to the setSelectionPolicy(int, InteractionSelectionPolicy) method.

Version:
JEDI V 2.2
Created the 5th nov. 2008
Created the 5th may 2009
Author:
Yoann Kubera
SMAC Team (Systèmes Multi-Agents et Comportement)
LIFL (Laboratoire d'Informatique Fondamentale de Lille)
University of Lille, France

Constructor Summary
InteractionMatrixLine()
          Constructor of the interaction matrix line.
 
Method Summary
 void add(DegenerateInteraction interaction, int priority)
           Tell that the source agent owning this interaction matrix line is able to initiate a degenerate target.
 void add(MultipleTargetInteraction interaction, java.lang.Class<?> target, double limit, int priority)
           Tell that the source agent owning this interaction matrix line is able to initiate a multiple target interaction with instances of a target agent family.
 void add(SingleTargetInteraction interaction, java.lang.Class<?> target, double limit, int priority)
           Tell that the source agent owning this interaction matrix line is able to initiate a single target interaction with an instance of a target agent family.
 boolean canBehave()
          Checks if the agent owning this matrix line is able to initiate at least one interaction.
 void changePriority(AbstractAssignationElement<?> e, int priority)
           Changes the priority of an assignation element of the interaction matrix line.
 InteractionMatrixLine clone()
           
 java.util.List<AbstractAssignationElement<?>> getAssignationElements(int priority)
          Gets the set of all assignation elements that have a particular priority for the interaction selection process of this matrix.
 InteractionSelectionPolicy getPolicy(int priority)
          Gets the interaction selection policy associated with a particular priority of assignation element.
 java.util.SortedSet<java.lang.Integer> getPriorities()
          Gets the set of all priorities used in the interaction selection process of this matrix.
 boolean removeAssignationElement(AbstractAssignationElement<?> element)
           Removes one assignation element from the set of interactions used by the interaction selection process.
 boolean setSelectionPolicy(int priority, InteractionSelectionPolicy policy)
          Sets an interaction selection policy for a particular priority of assignation elements.
 java.lang.String toString()
           
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InteractionMatrixLine

public InteractionMatrixLine()
Constructor of the interaction matrix line.

It initializes the behavior of agents why an empty one.

Method Detail

add

public void add(SingleTargetInteraction interaction,
                java.lang.Class<?> target,
                double limit,
                int priority)

Tell that the source agent owning this interaction matrix line is able to initiate a single target interaction with an instance of a target agent family. Such an interaction is possible only if the distance separating source and target is lower or equal to a limit distance.

The priority is used in the interaction selection process, to determine in which order interactions are tried (see InteractionMatrixLine).

Parameters:
interaction - The single target interaction the source becomes able to initiate.
target - The class of the target agent with how the source becomes able to interact.
limit - The maximal distance allowed between source and target so that they can interact.
priority - The priority of this assignation element.

add

public void add(MultipleTargetInteraction interaction,
                java.lang.Class<?> target,
                double limit,
                int priority)

Tell that the source agent owning this interaction matrix line is able to initiate a multiple target interaction with instances of a target agent family. Such an interaction is possible only if the distance separating source and each target is lower or equal to a limit distance.

The priority is used in the interaction selection process, to determine in which order interactions are tried (see InteractionMatrixLine).

Parameters:
interaction - The multiple target interaction the source becomes able to initiate.
target - The class of the target agents with how the source becomes able to interact.
limit - The maximal distance allowed between source and each target so that they can interact.
priority - The priority of this assignation element.

add

public void add(DegenerateInteraction interaction,
                int priority)

Tell that the source agent owning this interaction matrix line is able to initiate a degenerate target.

The priority is used in the interaction selection process, to determine in which order interactions are tried (see InteractionMatrixLine).

Parameters:
interaction - The degenerate interaction the source becomes able to initiate.
priority - The priority of this assignation element.

removeAssignationElement

public boolean removeAssignationElement(AbstractAssignationElement<?> element)

Removes one assignation element from the set of interactions used by the interaction selection process.

Parameters:
element - The assignation element to remove.
Returns:
true if the element has been removed successfully.

changePriority

public void changePriority(AbstractAssignationElement<?> e,
                           int priority)

Changes the priority of an assignation element of the interaction matrix line.

Parameters:
e - The assignation element for which the priority is changed.
priority - The new priority of that assignation element.

getPriorities

public java.util.SortedSet<java.lang.Integer> getPriorities()
Gets the set of all priorities used in the interaction selection process of this matrix.

Do not make modifications in this set.

Returns:
the set of all priorities used in the interaction selection process of this matrix.
See Also:
InteractionMatrixLine

getAssignationElements

public java.util.List<AbstractAssignationElement<?>> getAssignationElements(int priority)
Gets the set of all assignation elements that have a particular priority for the interaction selection process of this matrix.

Parameters:
priority - The priority for which the set of all assignation elements are retrieved.
Returns:
the set of all assignation elements that are retrieved.

Returns null if no assignation elements of such priority exist.


setSelectionPolicy

public boolean setSelectionPolicy(int priority,
                                  InteractionSelectionPolicy policy)
Sets an interaction selection policy for a particular priority of assignation elements.

Parameters:
priority - The priority of the interaction selection policy to change or to define.
policy - The new interaction selection policy used for that priority.
Returns:
true if the line of the matrix contains at least one assignation element for that priority. Else, it returns false, and the selection policy is not added.
See Also:
InteractionMatrixLine

getPolicy

public InteractionSelectionPolicy getPolicy(int priority)
Gets the interaction selection policy associated with a particular priority of assignation element.

Parameters:
priority - The priority of the retrieved interaction selection policy.
Returns:
The interaction selection policy, null if such element does not exist.

canBehave

public boolean canBehave()
Checks if the agent owning this matrix line is able to initiate at least one interaction.

Returns:
true if the agent owning this matrix line is able to initiate at least one interaction.

clone

public InteractionMatrixLine clone()
Overrides:
clone in class java.lang.Object
See Also:
Object.clone()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()