Class TreeAlgAgentAdapter<TAgent extends IAgent>

java.lang.Object
  extended by TreeAlgAgentAdapter<TAgent>
Type Parameters:
TAgent - This is the type of the agent it wraps. I think everything should be okay if you don't supply it (thus making it default to IAgent), but if you need to access class-specific member functions for whatever agent you pass, the TAgent class helps alleviate unneccessary casting.
All Implemented Interfaces:
IAgent, ITreeAlgAgent

public class TreeAlgAgentAdapter<TAgent extends IAgent>
extends java.lang.Object
implements ITreeAlgAgent

This class lets you take a class which derives from IAgent and wrap it as a TreeAlgAgent, so you can use it with the tree-based connectivity maintenance algorithm. It automatically makes the "parent preference relation" into "prefer nodes which are closer to you".


Constructor Summary
TreeAlgAgentAdapter(TAgent agentToWrap)
           
TreeAlgAgentAdapter(TreeAlgAgentAdapter<TAgent> src)
           
 
Method Summary
 TAgent accessAgent()
           
 boolean checkStateValidity(StateBundle state)
          checks that a particular discrete state is valid for this agent
 java.lang.reflect.Type getAnnoteType()
          Mike, add some comments here
 IMsg getMsgAnnotation(ILogicVarBundle vars, double[] arrLfState, int nIdx)
          gets the message to annotate the TreeConstraintState recieved by neighbors in TreeConstraintAgent algorithm
 void getMsgs(ILogicVarBundle discreteState, IDiscreteDynamicsCallback dynCallback, double[] arrLfStateCont, double lfCurrTime, int nIdxStateOffset, java.util.Iterator<CommLink> channelsToSendOn)
           Given the state of an agent, and the channels it can send messages on, push the next set of messages onto the appropriate channels.
 java.util.Comparator<TreeConstraintState> getPrefComp(TreeConstraintState agentSorting)
          gets a comparator for sorting ITreeAlgAgent nodes by preference
 ITreeAlgAgent makeCopy()
          in case the agent has some internal state, this allows synchronized wrapper calls to cache a snapshot of the agent at some rational point in time.
 StateBundle updateState(ILogicVarBundle statePrev, double[] arrLfStateCont, double lfCurrTime, int nIdxStateOffset, IEnvironment env, java.util.Iterator<CommLink> channelsRecieveFrom)
           Given the previous state of an agent, and the channels to recieve messages from, recieve messages (destructively) and return new state (non-destructively).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeAlgAgentAdapter

public TreeAlgAgentAdapter(TAgent agentToWrap)

TreeAlgAgentAdapter

public TreeAlgAgentAdapter(TreeAlgAgentAdapter<TAgent> src)
Method Detail

accessAgent

public TAgent accessAgent()

getMsgAnnotation

public IMsg getMsgAnnotation(ILogicVarBundle vars,
                             double[] arrLfState,
                             int nIdx)
Description copied from interface: ITreeAlgAgent
gets the message to annotate the TreeConstraintState recieved by neighbors in TreeConstraintAgent algorithm

Specified by:
getMsgAnnotation in interface ITreeAlgAgent
Parameters:
vars - logic state of this agent.
arrLfState - position of whole swarm (requires programmer discipline to only access current robot's position)
nIdx - index of current robot.
Returns:
something deriving form IMsg must be what this agent's getPrefComp is expecting.

getAnnoteType

public java.lang.reflect.Type getAnnoteType()
Description copied from interface: ITreeAlgAgent
Mike, add some comments here

Specified by:
getAnnoteType in interface ITreeAlgAgent
Returns:

getPrefComp

public java.util.Comparator<TreeConstraintState> getPrefComp(TreeConstraintState agentSorting)
gets a comparator for sorting ITreeAlgAgent nodes by preference

Specified by:
getPrefComp in interface ITreeAlgAgent
Returns:
Comparator -- smaller number means more preference

makeCopy

public ITreeAlgAgent makeCopy()
Description copied from interface: IAgent
in case the agent has some internal state, this allows synchronized wrapper calls to cache a snapshot of the agent at some rational point in time. If the agent has no internal state, this function can just return "this".

Specified by:
makeCopy in interface IAgent
Specified by:
makeCopy in interface ITreeAlgAgent

checkStateValidity

public boolean checkStateValidity(StateBundle state)
Description copied from interface: IAgent
checks that a particular discrete state is valid for this agent

Specified by:
checkStateValidity in interface IAgent

getMsgs

public void getMsgs(ILogicVarBundle discreteState,
                    IDiscreteDynamicsCallback dynCallback,
                    double[] arrLfStateCont,
                    double lfCurrTime,
                    int nIdxStateOffset,
                    java.util.Iterator<CommLink> channelsToSendOn)
Description copied from interface: IAgent

Given the state of an agent, and the channels it can send messages on, push the next set of messages onto the appropriate channels. Channels are assumed to be modified by this operation. One weakness of this signature is that it requires programmer discipline not to look at the continuous state of agents other then your neighbors.

Specified by:
getMsgs in interface IAgent
Parameters:
discreteState - discrete component of agent state
arrLfStateCont - global vector of continuous state
nIdxStateOffset - offset into global state vector corresonding to this agent.
channelsToSendOn - Iterator containing objects of type CommLink corresponding to channels to send messages on (neighbor indices can be ascertained from channels).
See Also:
for type handled by iterator

updateState

public StateBundle updateState(ILogicVarBundle statePrev,
                               double[] arrLfStateCont,
                               double lfCurrTime,
                               int nIdxStateOffset,
                               IEnvironment env,
                               java.util.Iterator<CommLink> channelsRecieveFrom)
Description copied from interface: IAgent

Given the previous state of an agent, and the channels to recieve messages from, recieve messages (destructively) and return new state (non-destructively).

Specified by:
updateState in interface IAgent
Parameters:
statePrev - previous state (do not modify)
arrLfStateCont - vector of all continuous states (do not modify)
nIdxStateOffset - offset into arrLfStateCont corresponding to start of this agents continuous variables
channelsRecieveFrom - iterator storing CommLink classes corresponding incoming channels
Returns:
new state bundle containing discrete state of agent and new control function
See Also:
for type handled by iterator