com.agentfactory.cldc.logic
Class Commitment

java.lang.Object
  extended by com.agentfactory.cldc.logic.Commitment

public class Commitment
extends java.lang.Object

In AFME, behaviour is modelled throught the use of beliefs and commitments. The commitment class contains the functionality for managing the commitment life cycle process.

Author:
Conor Muldoon

Constructor Summary
Commitment(FOS inAgent, java.util.Calendar inTime, FOS maintenance, FOS inActivity, Commitment inParent, FOS val, FOS cost, FOS ident)
          Creates an instance of Commitment.
 
Method Summary
 void addChild(Agent agent)
          For each child commitment of this commitment, add a child commitment to the agent.
 void addValues(int[] val, int[] cost, int i)
          Adds the value and cost of the commitment to the specified arrays and the specified index.
 void append(java.lang.StringBuffer buffer)
          Appends the commitment to the specified string buffer.
 boolean process(Agent agent, java.util.Hashtable actuators)
          Manages the current commitment state.
 void removeVarVals(Agent agent)
          Removes the commitment from the table of commitments that are to have their values and costs altered.
 FOS toCommitBelief()
          Coverts the commitment to a commitment belief.
 void updateValues(FOS val, FOS cost)
          Updates the values and cost of the commitment.
 void variableVals(Agent agent)
          Adds the commitment to the table of commitments that are to have their values and costs altered.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Commitment

public Commitment(FOS inAgent,
                  java.util.Calendar inTime,
                  FOS maintenance,
                  FOS inActivity,
                  Commitment inParent,
                  FOS val,
                  FOS cost,
                  FOS ident)
Creates an instance of Commitment.

Parameters:
inAgent - the agent that the commitment belongs to.
inTime - the time before which the commitment will not be executed.
maintenance - the maintenance condition of the commitment.
inActivity - the activity (action or plan) of the commitment.
inParent - the commitment's parent commitment.
val - the value of the commitment.
cost - the cost of the commitment.
ident - the identifier for the commitment.
Method Detail

variableVals

public void variableVals(Agent agent)
Adds the commitment to the table of commitments that are to have their values and costs altered. The identifier of the commitment is used as the key in the hash table.

Parameters:
agent - the agent that has made the commitment.

removeVarVals

public void removeVarVals(Agent agent)
Removes the commitment from the table of commitments that are to have their values and costs altered.

Parameters:
agent - the agent that has made the commitment.

updateValues

public void updateValues(FOS val,
                         FOS cost)
Updates the values and cost of the commitment.

Parameters:
val - the new value of the commitment.
cost - the new cost of the commitment.

addValues

public void addValues(int[] val,
                      int[] cost,
                      int i)
Adds the value and cost of the commitment to the specified arrays and the specified index.

Parameters:
val - the value array.
cost - the cost array.
i - the index of the value and cost array to update.

process

public boolean process(Agent agent,
                       java.util.Hashtable actuators)
                throws MalformedLogicException
Manages the current commitment state. If the commitment is a direct action, the action will be performed provided that the maintenance condition is true. If the commitment is a plan, the plan state will be updated.

Parameters:
agent - the agent that has made the commitment.
actuators - the hash table that matches actuators to their triggers.
Returns:
false if the commitment is completed, is redundant, or is to be removed, true otherwise.
Throws:
MalformedLogicException - if there is a logic error.

addChild

public void addChild(Agent agent)
              throws MalformedLogicException
For each child commitment of this commitment, add a child commitment to the agent.

Parameters:
agent - the agent that has made the commitment.
Throws:
MalformedLogicException - if there is a logic error.

toCommitBelief

public FOS toCommitBelief()
                   throws MalformedLogicException
Coverts the commitment to a commitment belief. The belief takes the form always(committed_to(?activity)).

Returns:
the commitment belief.
Throws:
MalformedLogicException - if there is a logic error.

append

public void append(java.lang.StringBuffer buffer)
Appends the commitment to the specified string buffer.

Parameters:
buffer - the string buffer the commitment will be appended to.