-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdomain.h
67 lines (59 loc) · 1.98 KB
/
domain.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/** \file
* \brief Defines the interface to a reinforcement learning algorithm.
*
* Copyright (c) 2008-2014 Robert D. Vincent.
*/
/** The structure that represents the result of taking one time step
* in the domain.
*/
class OneStepResult {
public:
const vector<double> state; /*!< The successor state. */
const double reward; /*!< The reward observed. */
/** The constructor for the class.
*/
OneStepResult(const vector<double> &s, double r): state(s), reward(r)
{
}
};
/** Abstract base class for a reinforcement learning environment.
*/
class Domain {
public:
int numSteps; /*!< Maximum number of time steps allowed. */
int numActions; /*!< Number of possible actions. */
int numDimensions; /*!< Dimensionality of the state space. */
/**
* Given an action and a state, perform the action and transition to
* the successor state.
* \param s The current state.
* \param a The chosen action.
* \return A pair consisting of the new state and the reward.
*/
virtual OneStepResult performAction(vector<double> s, int a) = 0;
/**
* Return the reward for this state and action.
* \param s The state vector.
* \param a The action.
* \return The reward received.
*/
virtual double getReward(vector<double> s, int a) const = 0;
/**
* Get the initial state of the domain. This could be constant, or it
* could be a random state.
* \return An initial state.
*/
virtual vector<double> initialState() = 0;
/**
* Return a boolean that indicates whether the state is "terminal".
* \param s The state to evaluate.
* \return True if the state ends a trajectory.
*/
virtual bool isTerminal(vector<double> s) const { return false; }
/**
* Returns a boolean that indicates whether the state transition function
* of the domain is stochastic.
*/
virtual bool isStochastic() { return false; }
};
extern Domain *CreateDomain(const char *dname, const char *propfile);