-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchopper.hh
77 lines (56 loc) · 1.91 KB
/
chopper.hh
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
68
69
70
71
72
73
74
75
76
77
/*
* Code by Chris Mansley
*/
#ifndef CHOPPER_HH
#define CHOPPER_HH
/* Definition dependencies */
#include <cmath>
#include "state.hh"
#include "action.hh"
#include "domain.hh"
class Chopper
{
public:
/** Constructor */
Chopper(Domain *d, int s, int a);
/** Destructor */
~Chopper( ) { }
/** Convert domain continuous to discrete state */
std::vector<int> discretizeState(State s);
/** Convert domain continuous to discrete action */
int discretizeAction(Action a);
/* This is fundementally different from discretizeState for the
following reason: most of the time you need to perform the max
over actions, which is easier if you can just iterate over the
ints from 0 to maxAction instead of some other scheme */
/** Convert domain continuous to continuous state */
State rescaleState(State s);
/** Convert domain continuous to continuous action */
Action scaledownAction(Action a);
/** Convert domain continuous to continuous action */
Action scaleupAction(Action a);
/** Concert discrete state back to continuous state */
/** Convert discrete action to domain continuous action */
Action continuousAction(int a);
/** Return number of discrete actions offered by this chopper */
int getNumDiscreteActions() { return (int)pow(actionGrid, maxActionRange.size()); }
std::vector<double> minActionZero() { return zero; }
std::vector<double> maxActionOne() { return one; }
private:
/** Storage for domain */
Domain *domain;
/** State discretization by dimension */
//std::vector<int> stateGrid;
int stateGrid;
/** Action discretization by dimension */
//std::vector<int> actionGrid;
int actionGrid;
/** Local domain storage */
std::vector<double> maxStateRange;
std::vector<double> minStateRange;
std::vector<double> maxActionRange;
std::vector<double> minActionRange;
std::vector<double> zero;
std::vector<double> one;
};
#endif // CHOPPER_HH