de.cesr.lara.components
Class LaraBehaviouralOption<A extends LaraAgent<? super A,?>,BO extends LaraBehaviouralOption<?,?>>

java.lang.Object
  extended by de.cesr.lara.components.LaraProperty<BO,Map<Class<? extends LaraPreference>,Double>>
      extended by de.cesr.lara.components.LaraBehaviouralOption<A,BO>
Type Parameters:
A - the agent class that may deal with these BOs
BO - the behavioural option type
All Implemented Interfaces:
Comparable<LaraBehaviouralOption<A,BO>>
Direct Known Subclasses:
AbstractIrrigationBehaviouralOption, LAbstractSNBO, MyAbstractBehaviouralOption

public abstract class LaraBehaviouralOption<A extends LaraAgent<? super A,?>,BO extends LaraBehaviouralOption<?,?>>
extends LaraProperty<BO,Map<Class<? extends LaraPreference>,Double>>
implements Comparable<LaraBehaviouralOption<A,BO>>

LaraBehaviouralOption declares behavioural options an agent may choose from to perform. The agent type parameter allows the user to access agent members without casting, for instance to preselect the behavioural option with respect to agent properties. Instances of this class are only modifiable by invoking the instance methods getBO(). The load of the necessity to implement such methods for _every_ subclass is unavoidable. Otherwise, the user receives an instance of the next superclass that implements that method (an exception may be thrown to prevent such a behaviour)! Subclasses may not provide means to alter their fields. Otherwise, the consistency of these fields across agents is not guaranteed (e.g. hash codes are computed at initialisation)! BO also work with agents that require (only) a super type of their (the BO's) own class. See Type parameters


Constructor Summary
LaraBehaviouralOption(String key, A agent)
          Does not call constructor with more parameters above to prevent double initialisation of preferenceUtilities
LaraBehaviouralOption(String key, A agent, LPrefEntry... prefEntry)
          constructor
LaraBehaviouralOption(String key, A agent, Map<Class<? extends LaraPreference>,Double> preferenceUtilities)
          constructor
 
Method Summary
protected  int calculateHashCode()
          calculate hash code:
 int compareTo(LaraBehaviouralOption<A,BO> bo1)
           
 boolean equals(Object o)
          NOTE: Subclasses that add fields need to redefine the method appropriately according to the contract of equals() of Object.
 A getAgent()
          Returns the agent this BO belongs to
 Map<Class<? extends LaraPreference>,Double> getModifiableUtilities()
          Returns a copy of the internal utility map that may be edited.
 BO getModifiedAgentBO(A agent)
           
abstract  BO getModifiedBO(A agent, Map<Class<? extends LaraPreference>,Double> preferenceUtilities)
           
 BO getModifiedProperty(Map<Class<? extends LaraPreference>,Double> value)
           
 BO getModifiedUtilitiesBO(Map<Class<? extends LaraPreference>,Double> preferenceUtilities)
           
abstract  Map<Class<? extends LaraPreference>,Double> getSituationalUtilities(LaraDecisionConfiguration dBuilder)
           
 float getTotalSituationalUtility(LaraDecisionConfiguration dConfig)
          Returns the sum of BO-utility * agent'S situational preference over all preferenceWeights.
 Map<Class<? extends LaraPreference>,Double> getValue()
          Returns an unmodifiable(!)
 int hashCode()
           
 boolean isCurrentlyApplicable()
          This method may be called by LaraBOPreselector to check whether the BO is applicable under current environmental and agent conditions.
 String toString()
          The returned String representation has the format [, :, <...>, TS:
 
Methods inherited from class de.cesr.lara.components.LaraProperty
getKey, getRefreshedProperty, getTimestamp
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LaraBehaviouralOption

public LaraBehaviouralOption(String key,
                             A agent)
Does not call constructor with more parameters above to prevent double initialisation of preferenceUtilities

Parameters:
key -
agent -

LaraBehaviouralOption

public LaraBehaviouralOption(String key,
                             A agent,
                             LPrefEntry... prefEntry)
constructor

Parameters:
key -
agent -
prefEntry - list of LPrefEntrys

LaraBehaviouralOption

public LaraBehaviouralOption(String key,
                             A agent,
                             Map<Class<? extends LaraPreference>,Double> preferenceUtilities)
constructor

Parameters:
key -
agent -
preferenceUtilities -
Method Detail

compareTo

public int compareTo(LaraBehaviouralOption<A,BO> bo1)
Specified by:
compareTo in interface Comparable<LaraBehaviouralOption<A extends LaraAgent<? super A,?>,BO extends LaraBehaviouralOption<?,?>>>
Parameters:
bo1 -
Returns:
a negative int if the given BO is larger, a positive int if the given BO is smaller and 0 otherwise

equals

public boolean equals(Object o)
NOTE: Subclasses that add fields need to redefine the method appropriately according to the contract of equals() of Object.

Overrides:
equals in class LaraProperty<BO extends LaraBehaviouralOption<?,?>,Map<Class<? extends LaraPreference>,Double>>
See Also:
Object.equals(java.lang.Object)

getAgent

public A getAgent()
Returns the agent this BO belongs to

Returns:
the agent this BO belongs to

getModifiableUtilities

public Map<Class<? extends LaraPreference>,Double> getModifiableUtilities()
Returns a copy of the internal utility map that may be edited.

Returns:
an editable copy of the internal utility map

getModifiedAgentBO

public BO getModifiedAgentBO(A agent)
Parameters:
agent -
Returns:
a new BO with modified agent

getModifiedBO

public abstract BO getModifiedBO(A agent,
                                 Map<Class<? extends LaraPreference>,Double> preferenceUtilities)
Parameters:
agent -
preferenceUtilities -
Returns:
behavioural option

getModifiedProperty

public BO getModifiedProperty(Map<Class<? extends LaraPreference>,Double> value)
Specified by:
getModifiedProperty in class LaraProperty<BO extends LaraBehaviouralOption<?,?>,Map<Class<? extends LaraPreference>,Double>>
Returns:
a new property with new value and key and current time stamp
See Also:
LaraProperty.getModifiedProperty(java.lang.Object)

getModifiedUtilitiesBO

public BO getModifiedUtilitiesBO(Map<Class<? extends LaraPreference>,Double> preferenceUtilities)
Parameters:
preferenceUtilities - map of preferenceWeights and values
Returns:
new BO that contains the given preferenceUtilities

getSituationalUtilities

public abstract Map<Class<? extends LaraPreference>,Double> getSituationalUtilities(LaraDecisionConfiguration dBuilder)
Parameters:
dConfig -
Returns:
the current preferenceUtilities of this behavioural option

getTotalSituationalUtility

public float getTotalSituationalUtility(LaraDecisionConfiguration dConfig)
Returns the sum of BO-utility * agent'S situational preference over all preferenceWeights. Sorts preferenceWeights only when agent debugging is enabled.

Parameters:
dConfig - the LaraDecisionConfiguration the situational preferenceWeights apply to
Returns:
sum of situational preferenceUtilities over all preferenceWeights.

getValue

public Map<Class<? extends LaraPreference>,Double> getValue()
Returns an unmodifiable(!) map Therefore, in order to edit utility values, the user needs to make a deep copy, edit and return it.

Specified by:
getValue in class LaraProperty<BO extends LaraBehaviouralOption<?,?>,Map<Class<? extends LaraPreference>,Double>>
Returns:
the property's value

hashCode

public int hashCode()
Overrides:
hashCode in class LaraProperty<BO extends LaraBehaviouralOption<?,?>,Map<Class<? extends LaraPreference>,Double>>
See Also:
LaraProperty.hashCode()

isCurrentlyApplicable

public boolean isCurrentlyApplicable()
This method may be called by LaraBOPreselector to check whether the BO is applicable under current environmental and agent conditions.

Returns:
true if the BO is applicable

toString

public String toString()
The returned String representation has the format [, :, <...>, TS:
Overrides:
toString in class LaraProperty<BO extends LaraBehaviouralOption<?,?>,Map<Class<? extends LaraPreference>,Double>>
See Also:
LaraProperty.toString()

calculateHashCode

protected int calculateHashCode()
calculate hash code:

Returns:
the hash code