Soar Kernel  9.3.2 08-06-12
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
exploration.h
Go to the documentation of this file.
1 /*************************************************************************
2  * PLEASE SEE THE FILE "license.txt" (INCLUDED WITH THIS SOFTWARE PACKAGE)
3  * FOR LICENSE AND COPYRIGHT INFORMATION.
4  *************************************************************************/
5 
6 /*************************************************************************
7  *
8  * file: exploration.h
9  *
10  * =======================================================================
11  */
12 
13 #ifndef EXPLORATION_H
14 #define EXPLORATION_H
15 
16 #include "gdatastructs.h"
17 
19 // Exploration constants
21 #define EXPLORATION_REDUCTION_EXPONENTIAL 0
22 #define EXPLORATION_REDUCTION_LINEAR 1
23 #define EXPLORATION_REDUCTIONS 2 // set as greatest reduction + 1
24 
25 #define EXPLORATION_PARAM_EPSILON 0
26 #define EXPLORATION_PARAM_TEMPERATURE 1
27 #define EXPLORATION_PARAMS 2 // set as greatest param + 1
28 
30 // Exploration Types
33 {
34  const char *name;
35  double value;
37  bool (*val_func)( double );
40 
42 // Exploration Policies
44 
45 // validity
46 extern bool exploration_valid_policy( const char *policy_name );
47 extern bool exploration_valid_policy( const int policy );
48 
49 // policy <=> name conversion
50 extern const int exploration_convert_policy( const char *policy_name );
51 extern const char *exploration_convert_policy( const int policy );
52 
53 // sets exploration policy name
54 extern bool exploration_set_policy( agent *my_agent, const char *policy_name );
55 extern bool exploration_set_policy( agent *my_agent, const int policy );
56 
57 // get exploration policy
58 extern const int exploration_get_policy( agent *my_agent );
59 
61 // Exploration Policy Parameters
63 
64 // add parameter
65 extern exploration_parameter *exploration_add_parameter( double value, bool (*val_func)( double ), const char *name );
66 
67 // convert parameter name
68 extern const int exploration_convert_parameter( agent *my_agent, const char *name );
69 extern const char *exploration_convert_parameter( agent *my_agent, const int parameter );
70 
71 // validate parameter name
72 extern const bool exploration_valid_parameter( agent *my_agent, const char *name );
73 extern const bool exploration_valid_parameter( agent *my_agent, const int parameter );
74 
75 // get parameter value
76 extern double exploration_get_parameter_value( agent *my_agent, const char *parameter );
77 extern double exploration_get_parameter_value( agent *my_agent, const int parameter );
78 
79 // validate parameter value
80 extern bool exploration_validate_epsilon( double value );
81 extern bool exploration_validate_temperature( double value );
82 
83 // validate parameter value
84 extern bool exploration_valid_parameter_value( agent *my_agent, const char *name, double value );
85 extern bool exploration_valid_parameter_value( agent *my_agent, const int parameter, double value );
86 
87 // set parameter value
88 extern bool exploration_set_parameter_value( agent *my_agent, const char *name, double value );
89 extern bool exploration_set_parameter_value( agent *my_agent, const int parameter, double value );
90 
91 // control of auto-updates
92 extern bool exploration_get_auto_update( agent *my_agent );
93 extern bool exploration_set_auto_update( agent *my_agent, bool setting );
94 
95 // update parameters according to their reduction policies/rates
96 extern void exploration_update_parameters( agent *my_agent );
97 
99 // Reduction Policies
101 
102 // policy <=> name conversion
103 extern const int exploration_convert_reduction_policy( const char *policy_name );
104 extern const char *exploration_convert_reduction_policy( const int policy );
105 
106 // get parameter reduction policy
107 extern const int exploration_get_reduction_policy( agent *my_agent, const char *parameter );
108 extern const int exploration_get_reduction_policy( agent *my_agent, const int parameter );
109 
110 // validate reduction policy per parameter
111 extern bool exploration_valid_reduction_policy( agent *my_agent, const char *parameter, const char *policy_name );
112 extern bool exploration_valid_reduction_policy( agent *my_agent, const char *parameter, const int policy );
113 extern bool exploration_valid_reduction_policy( agent *my_agent, const int parameter, const int policy );
114 
115 // set parameter reduction policy
116 extern bool exploration_set_reduction_policy( agent *my_agent, const char *parameter, const char *policy_name );
117 extern bool exploration_set_reduction_policy( agent *my_agent, const int parameter, const int policy );
118 
120 // Reduction Rates
122 
123 // validate reduction rate
124 extern bool exploration_valid_reduction_rate( agent *my_agent, const char *parameter, const char *policy_name, double reduction_rate );
125 extern bool exploration_valid_reduction_rate( agent *my_agent, const int parameter, const int policy, double reduction_rate );
126 extern bool exploration_valid_exponential( double reduction_rate );
127 extern bool exploration_valid_linear( double reduction_rate );
128 
129 // get reduction rate
130 extern double exploration_get_reduction_rate( agent *my_agent, const char *parameter, const char *policy_name );
131 extern double exploration_get_reduction_rate( agent *my_agent, const int parameter, const int policy );
132 
133 // set reduction rate
134 extern bool exploration_set_reduction_rate( agent *my_agent, const char *parameter, const char *policy_name, double reduction_rate );
135 extern bool exploration_set_reduction_rate( agent *my_agent, const int parameter, const int policy, double reduction_rate );
136 
138 // Decision Procedures
140 
141 // selects a candidate based upon the current exploration mode
142 extern preference *exploration_choose_according_to_policy( agent *my_agent, slot *s, preference *candidates );
143 
144 // calculate the probability of a selection given the current exploration mode
145 extern double exploration_probability_according_to_policy( agent *my_agent, slot *s, preference *candidates, preference *selection );
146 
147 // selects a candidate in a random fashion
148 extern preference *exploration_randomly_select( preference *candidates );
149 
150 // selects a candidate in a softmax fashion
152 
153 // selects a candidate based on a boltzmann distribution
154 extern preference *exploration_boltzmann_select( agent *my_agent, preference *candidates );
155 
156 // selects a candidate based upon an epsilon-greedy distribution
157 extern preference *exploration_epsilon_greedy_select( agent *my_agent, preference *candidates );
158 
159 // returns candidate with highest q-value (random amongst ties), assumes computed values
161 
162 // computes total contribution for a candidate from each preference, as well as number of contributions
163 extern void exploration_compute_value_of_candidate( agent *my_agent, preference *cand, slot *s, double default_value = 0 );
164 
165 #endif
166