MACS
Class MACSActionSelector

java.lang.Object
  |
  +--MACS.MACSActionSelector

final class MACSActionSelector
extends java.lang.Object

The MACSActionSelector class is in charge of choosing the next action both in the context of actual action and in the context of "mental" propagation of values. In order to choose the best action, it must access both the model of transitions and the models of payoff.

Author:
Olivier Sigaud and Pierre Gérard.

Field Summary
protected  Classifier.Action[] actions
           
private  MACS.HierarchicalAgregator agregator
           
protected  Classifier.Perception[] anticipations
           
static boolean DEBUG
           
private  MACS.ExploMemory exploMemory
           
protected  double maxValueOfPossibleActions
           
private  int[] modelNumber
           
protected  MACS.MultiModelOfPayoff modelOfPayoff
           
protected  MACS.ClassifierSystem modelOfTransitions
           
protected  int nbPossibilities
           
protected  MACS.ModularClassifierSystemTraceManager traceManager
           
 
Constructor Summary
protected MACSActionSelector(MACS.ModularClassifierSystemTraceManager tm, MACS.ClassifierSystem modTrans, MACS.MultiModelOfPayoff mp, MACS.ExploMemory explo)
           
 
Method Summary
protected  Classifier.Action chooseActualAction(Classifier.Perception currentPerception)
          Performing actual actions nb : several selection modes can be performed in parallel
protected  void fillArrays(java.util.Vector[] possib, Classifier.Perception currentPerception)
           
 MACS.MultiModelOfPayoff getModelOfPayoff()
           
 MACS.PerceptionList getPerceptionList()
           
protected  void initArrays(int nbPoss)
          Init all the tables
 Classifier.Action selectAction(Classifier.Action lastAction, Classifier.Perception currentPerception, boolean actualAction, java.util.Vector[] possib)
          Choose the action to be performed if actualAction = true, it is the action of the agent.
private  Classifier.Action selectActionAtRandom()
          Choose a random action
private  int selectBestPossibility(int hierarchyLevel, boolean totallyGreedy)
          This method returns the index of the best possible action -> positive or null if there is one -> -1 if there is no -> -2 if the possibilities are equivalent The algorithm is the following: for each action, retreive the best anticipated situation corresponding to that action and its value.
private  int selectPossibility(int hierarchyLevel, Classifier.Action action, boolean best)
          This method is slightly less efficient than Pierre's (calling selectWorstPossibilityForAction and selectBestPossibilityForAction), but far more clear...
 void setModelNumber(int model, int value)
           
 java.lang.String toString()
           
protected  void updateModels(Classifier.Perception currentPerception)
          Performing a mental action nb : several selection modes can be performed in parallel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEBUG

public static boolean DEBUG

modelOfTransitions

protected MACS.ClassifierSystem modelOfTransitions

modelOfPayoff

protected MACS.MultiModelOfPayoff modelOfPayoff

traceManager

protected MACS.ModularClassifierSystemTraceManager traceManager

maxValueOfPossibleActions

protected double maxValueOfPossibleActions

nbPossibilities

protected int nbPossibilities

agregator

private MACS.HierarchicalAgregator agregator

exploMemory

private MACS.ExploMemory exploMemory

actions

protected Classifier.Action[] actions

anticipations

protected Classifier.Perception[] anticipations

modelNumber

private int[] modelNumber
Constructor Detail

MACSActionSelector

protected MACSActionSelector(MACS.ModularClassifierSystemTraceManager tm,
                             MACS.ClassifierSystem modTrans,
                             MACS.MultiModelOfPayoff mp,
                             MACS.ExploMemory explo)
Parameters:
tm -
modTrans -
Method Detail

getModelOfPayoff

public MACS.MultiModelOfPayoff getModelOfPayoff()
Returns:
MACS.ModelOfPayoff

getPerceptionList

public MACS.PerceptionList getPerceptionList()
Returns:
MACS.PerceptionList

selectActionAtRandom

private Classifier.Action selectActionAtRandom()
Choose a random action

Returns:
Classifier.Action

setModelNumber

public void setModelNumber(int model,
                           int value)

initArrays

protected final void initArrays(int nbPoss)
Init all the tables

Parameters:
nbPoss - : number of situations that are supposed to be reachable

fillArrays

protected final void fillArrays(java.util.Vector[] possib,
                                Classifier.Perception currentPerception)
Parameters:
possib -

selectBestPossibility

private int selectBestPossibility(int hierarchyLevel,
                                  boolean totallyGreedy)
This method returns the index of the best possible action -> positive or null if there is one -> -1 if there is no -> -2 if the possibilities are equivalent The algorithm is the following: for each action, retreive the best anticipated situation corresponding to that action and its value. Then pick the best anticipated situation among those generated by each action (or one of them if several share the same value)

Parameters:
hierarchyLevel - : actionSelection Mode : 0 = information, 1 = external reward, 2 = rehearsal
totallyGreedy - : if true, choose the best action. If not, choose the worst
Returns:
int : the number of the best anticipated situation Note: the number of the best anticipated situation is also the number of the corresponding action, beacuse tables have been generated that way (@see fillArrays)

updateModels

protected final void updateModels(Classifier.Perception currentPerception)
Performing a mental action nb : several selection modes can be performed in parallel

Parameters:
currentPerception -

selectPossibility

private int selectPossibility(int hierarchyLevel,
                              Classifier.Action action,
                              boolean best)
This method is slightly less efficient than Pierre's (calling selectWorstPossibilityForAction and selectBestPossibilityForAction), but far more clear... The inefficiency comes from the fact that, if we only consider in the ValuesDistribution the values such that actions[i].equals(action), we loose memory of indexes... It happens that the efficiency difference is very small...

Returns:
int : the index of the anticipated situation chosen

chooseActualAction

protected final Classifier.Action chooseActualAction(Classifier.Perception currentPerception)
Performing actual actions nb : several selection modes can be performed in parallel

Parameters:
currentPerception -
Returns:
Classifier.Action

selectAction

public Classifier.Action selectAction(Classifier.Action lastAction,
                                      Classifier.Perception currentPerception,
                                      boolean actualAction,
                                      java.util.Vector[] possib)
Choose the action to be performed if actualAction = true, it is the action of the agent. Otherwise, it is a "mental" action in the model possib contains the list of possible actions and information gains to choose the best

Parameters:
lastAction -
currentPerception -
actualAction -
Returns:
Classifier.Action

toString

public final java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
String