All Packages  This Package  Class Hierarchy  Class Search  Index

Class aima.cs.learning.QLearning_Agent

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----aima.cs.learning.QLearning_Agent

A basic Q-learning agent. Both states and actions are represented and communicated using ints.


public class  QLearning_Agent
     extends java.awt.Canvas
     implements java.io.Serializable, 
                aima.cs.learning.StateReward_PerceptListener
{
          // Constructors 2
     public QLearning_Agent();
     public QLearning_Agent(int, int);

          // Methods 28
     public synchronized void addIntActionListener(intActionListener);
     protected void allocParams();
     protected void computePolicy();
     protected void computePolicyOf(int);
     protected void computeValueOf(int);
     protected void computeValues();
     public int getAction();
     public double getDiscountFactor();
     public double getExplorationRate();
     public double getLearningRate();
     public Dimension getMinimumSize();
     public int getNumActions();
     public int getNumStates();
     public int getState();
     public int getVerbosity();
     public synchronized void paint(Graphics);
     public void perceiveStateReward(StateReward_PerceptEvent);
     public void randomlyInitParams(double);
     public synchronized void removeIntActionListener(intActionListener);
     public void setDiscountFactor(double);
     public void setExplorationRate(double);
     public void setLearningRate(double);
     public void setNumActions(int);
     public void setNumStates(int);
     public void setState(int);
     public void setVerbosity(int);
     public int step(int, double);
     public String toString();
}



Constructors


QLearning_Agent

   public QLearning_Agent() 


QLearning_Agent

   public QLearning_Agent(int n, 
                          int na) 



Methods


setState

   public void setState(int s) 

Sets the current state of the agent. The assumption is that this state is detached from the previous state history.



getState

   public int getState() 


setNumStates

   public void setNumStates(int n) 


getNumStates

   public int getNumStates() 


setNumActions

   public void setNumActions(int na) 


getNumActions

   public int getNumActions() 


allocParams

   protected void allocParams() 


randomlyInitParams

   public void randomlyInitParams(double max) 


computeValues

   protected void computeValues() 


computeValueOf

   protected void computeValueOf(int i) 


computePolicy

   protected void computePolicy() 


computePolicyOf

   protected void computePolicyOf(int i) 


setLearningRate

   public void setLearningRate(double r) 


getLearningRate

   public double getLearningRate() 


setExplorationRate

   public void setExplorationRate(double r) 


getExplorationRate

   public double getExplorationRate() 


setDiscountFactor

   public void setDiscountFactor(double d) 


getDiscountFactor

   public double getDiscountFactor() 


step

   public int step(int s, 
                   double r) 

Take a experience/learning step. Input is the new state and reward. Returns an action. Assume that input state of -1 indicates reset (that the previous state was terminal.)



getAction

   public int getAction() 

Returns an action. This method will need to be modified when more sophisticated exploration policies are desired.



toString

   public String toString() 
Overrides:
toString in class Component


setVerbosity

   public void setVerbosity(int n) 


getVerbosity

   public int getVerbosity() 


perceiveStateReward

   public void perceiveStateReward(StateReward_PerceptEvent e) 
Implements:
perceiveStateReward in interface StateReward_PerceptListener


addIntActionListener

   public synchronized void addIntActionListener(intActionListener l) 

The specified ActionListeners actionPerformed method will be called each time the button is clicked. The ActionListener object is added to a list of ActionListeners managed by this button, it can be removed with removeActionListener. Note: the JavaBeans specification does not require ActionListeners to run in any particular order.

Parameter Description
l the ActionListener

See Also: removeActionListener



removeIntActionListener

   public synchronized void removeIntActionListener(intActionListener l) 

Remove this ActionListener from the buttons internal list. If the ActionListener isn't on the list, silently do nothing.

Parameter Description
l the ActionListener

See Also: addActionListener



paint

   public synchronized void paint(Graphics g) 
Overrides:
paint in class Canvas


getMinimumSize

   public Dimension getMinimumSize() 
Overrides:
getMinimumSize in class Component


All Packages  This Package  Class Hierarchy  Class Search  Index
Freshly brewed Java API Documentation automatically generated with polardoc Version 1.0.4