TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
ann_policy.h
Go to the documentation of this file.
1// -*- Mode: c++ -*-
2// copyright (c) 2004 by Christos Dimitrakakis <dimitrak@idiap.ch>
3// $Id$
4
5
6/***************************************************************************
7 * *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 ***************************************************************************/
14
15#ifndef ANN_POLICY_H
16#define ANN_POLICY_H
17
18#include <learning/policy.h>
36{
37protected:
38 ANN* J;
39 ANN** Ja;
46public:
48 ANN_Policy (int n_states, int n_actions, int n_hidden = 0, real alpha=0.1, real gamma=0.8, real lambda=0.8, bool eligibility = false, bool softmax = false, real randomness=0.1, real init_eval=0.0, bool separate_actions = false);
49 virtual ~ANN_Policy();
51 virtual int SelectAction(int s, real r, int forced_a=-1);
54 virtual int SelectAction(real* s, real r, int forced_a=-1);
56 virtual void Reset();
58 virtual real getLastActionValue () {return J_ps_pa;}
61 real sum = 0.0;
62 int i;
63 for (i=0; i<n_actions; i++) {
64 sum += eval[i];
65 }
66 for (i=0; i<n_actions; i++) {
67 eval[i] = eval[i]/sum;
68 }
69 return eval;
70 }
71
73 virtual bool useConfidenceEstimates(bool confidence, real zeta=0.01);
74};
75
76
77#endif
struct ANN_ ANN
ANN management structure.
real J_ps_pa
Evaluation of last action.
Definition ann_policy.h:42
virtual real getLastActionValue()
Return the last action value.
Definition ann_policy.h:58
virtual int SelectAction(int s, real r, int forced_a=-1)
Keep the base discrete-state overload visible for callers using DiscretePolicy's interface.
virtual real * getActionProbabilities()
Definition ann_policy.h:60
ANN * J
Evaluation network.
Definition ann_policy.h:38
virtual void Reset()
Reset eligibility traces.
bool eligibility
eligibility option
Definition ann_policy.h:44
ANN_Policy(int n_states, int n_actions, int n_hidden=0, real alpha=0.1, real gamma=0.8, real lambda=0.8, bool eligibility=false, bool softmax=false, real randomness=0.1, real init_eval=0.0, bool separate_actions=false)
Make a new policy.
ANN ** Ja
Evaluation networks (for separate_actions case)
Definition ann_policy.h:39
virtual bool useConfidenceEstimates(bool confidence, real zeta, bool confidence_eligibility)
Use confidence estimates with the base class signature.
real * JQs
Placeholder for evaluation vector (separate_actions)
Definition ann_policy.h:41
bool separate_actions
Single/separate evaluation option.
Definition ann_policy.h:45
real * ps
Previous state vector.
Definition ann_policy.h:40
virtual ~ANN_Policy()
real * delta_vector
Scratch vector for TD error.
Definition ann_policy.h:43
int n_states
number of states
Definition policy.h:149
DiscretePolicy(int n_states, int n_actions, real alpha=0.1, real gamma=0.8, real lambda=0.8, bool softmax=false, real randomness=0.1, real init_eval=0.0)
Create a new discrete policy.
Definition policy.cpp:42
int n_actions
number of actions
Definition policy.h:150
real zeta
Confidence smoothing.
Definition policy.h:179
real lambda
Eligibility trace decay.
Definition policy.h:165
bool confidence
Confidence estimates option.
Definition policy.h:174
real alpha
learning rate
Definition policy.h:166
real r
reward
Definition policy.h:158
real gamma
Future discount parameter.
Definition policy.h:164
bool confidence_eligibility
Apply eligibility traces to confidence.
Definition policy.h:175
real * eval
evaluation of current aciton
Definition policy.h:153
float real
Definition real.h:13