CCL Library  1.0
ccl_learn_policy.h
Go to the documentation of this file.
1 
6 #ifndef __CCL_LEARN_POLICY_H
7 #define __CCL_LEARN_POLICY_H
8 
9 #include <ccl_math.h>
10 #include <gsl/gsl_linalg.h>
11 #include <gsl/gsl_blas.h>
12 #include <gsl/gsl_math.h>
13 #include <gsl/gsl_eigen.h>
14 #include <gsl/gsl_sf.h>
15 #include <stdio.h>
16 #include <string.h>
17 #include <stdlib.h>
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
23 #define NUM_CENTRES 20
24 
33 typedef struct {
34  gsl_matrix* HS;
35  gsl_matrix* g;
36  gsl_matrix* Y_T;
37  gsl_matrix* Y_;
38  gsl_matrix* H;
39  gsl_matrix* BX_T;
40  gsl_matrix* BX_;
41  gsl_matrix* w_;
42  gsl_matrix* pinvH1;
43  gsl_vector* V;
44  gsl_matrix* D;
45  int * idx;
47 
53 typedef struct{
54  int dim_y;
55  int dim_x;
56  int dim_n;
57  int dim_b;
58  double * w;
60 
67 typedef struct{
68  int dim_y;
69  int dim_x;
70  int dim_n;
71  int dim_b;
72  int dim_phi;
73  double * c;
74  double s2;
75  double * w[NUM_CENTRES];
77 
86 typedef struct {
87  gsl_vector* g;
88  gsl_matrix* Y_N;
89  gsl_vector* YN_vec;
90  gsl_matrix* Y_Phit;
91  gsl_matrix* ones;
92  gsl_matrix* Y_;
93  gsl_matrix* H;
94  gsl_matrix* Phi;
95  gsl_vector* Phi_vec;
96  gsl_matrix* Phi_vec_T;
97  gsl_matrix* YN_Phit;
98  gsl_vector* YN_Phi_vec;
99  gsl_matrix* YN_Phi_vec_T;
100  gsl_matrix* vv;
101  gsl_matrix* WX_;
102  gsl_vector* WX_row;
103  gsl_matrix* WPhi;
104  gsl_matrix* WPhi_T;
105  gsl_matrix* pinvH1;
106  gsl_vector* V;
107  gsl_vector* r;
108  gsl_matrix* r_rep;
109  gsl_matrix* D;
110  int * idx;
111  gsl_vector* w_vec;
112  gsl_matrix* w_;
113  gsl_matrix* w_T;
114  gsl_matrix* w[NUM_CENTRES];
116 
124 void ccl_learn_policy_pi(LEARN_MODEL_PI *model, const double *BX, const double *Y);
125 
135 
144 
153 void ccl_learn_policy_lw_pi(LEARN_MODEL_LW_PI *model, const double *WX, const double *X, const double *Y);
154 
163 
172 
182 
191 
200 void predict_linear(const double* X, const double* centres,const double variance,const LEARN_MODEL_PI *model,double* Yp);
201 
210 void predict_local_linear(const double* X, const double* centres,const double variance,const LEARN_MODEL_LW_PI *model,double* Yp);
211 
222 int ccl_read_data_from_file(char* filename, int dim_x, int dim_n, double* mat);
223 
232 int ccl_write_lwmodel_to_file(char* filename, LEARN_MODEL_LW_PI* model);
233 #ifdef __cplusplus
234 }
235 #endif
236 #endif
237 
gsl_vector * g
Col vector of YPhit.
Definition: ccl_learn_policy.h:87
gsl_matrix * w_
Model parameters.
Definition: ccl_learn_policy.h:41
void ccl_learn_policy_pi(LEARN_MODEL_PI *model, const double *BX, const double *Y)
Main computation routine for learning linear policy.
int dim_b
Number of rbf centers.
Definition: ccl_learn_policy.h:57
gsl_matrix * WPhi_T
Transpose of WPhi.
Definition: ccl_learn_policy.h:104
void predict_local_linear(const double *X, const double *centres, const double variance, const LEARN_MODEL_LW_PI *model, double *Yp)
Predictions based on locally weighted linear policy model.
gsl_matrix * YN_Phit
Dot prodcut of YN * Phit.
Definition: ccl_learn_policy.h:97
int ccl_learn_policy_lw_pi_model_alloc(LEARN_MODEL_LW_PI *model)
Allocates the memory for locally weighted linear policy LEARN_MODEL_LW_PI.
gsl_matrix * H
Dot product of BX and BX'.
Definition: ccl_learn_policy.h:38
gsl_vector * Phi_vec
Feature vector.
Definition: ccl_learn_policy.h:95
int ccl_learn_model_lw_pi_ws_alloc(LEARN_MODEL_LW_PI *model, LEARN_MODEL_LW_PI_WS *ws)
Allocates the workspace memory for locally weighted linear policy LEARN_MODEL_LW_PI_WS.
gsl_matrix * Y_T
Transpose of Y_.
Definition: ccl_learn_policy.h:36
int ccl_read_data_from_file(char *filename, int dim_x, int dim_n, double *mat)
Read data from .txt file.
int dim_y
Dimentionality of output variable.
Definition: ccl_learn_policy.h:54
int dim_b
Number of rbf centers.
Definition: ccl_learn_policy.h:71
gsl_matrix * w_T
Transpose of model parameter w for each center.
Definition: ccl_learn_policy.h:113
double s2
rbf variance
Definition: ccl_learn_policy.h:74
gsl_matrix * H
Accumulated Hessian.
Definition: ccl_learn_policy.h:93
gsl_matrix * Y_
Output variable.
Definition: ccl_learn_policy.h:92
int dim_n
Number of data samples.
Definition: ccl_learn_policy.h:56
int dim_n
Number of data samples.
Definition: ccl_learn_policy.h:70
gsl_vector * YN_vec
Vector view of Y_N.
Definition: ccl_learn_policy.h:89
gsl_matrix * HS
Regularization basis for the H matrix.
Definition: ccl_learn_policy.h:34
This structure describes workspace for directly learning the policy model parameters using locally we...
Definition: ccl_learn_policy.h:86
gsl_matrix * D
Eigen values of H.
Definition: ccl_learn_policy.h:109
gsl_matrix * Y_N
Normalised Y.
Definition: ccl_learn_policy.h:88
gsl_matrix * Y_
Output variable.
Definition: ccl_learn_policy.h:37
gsl_matrix * BX_
High dimensionality of the input data.
Definition: ccl_learn_policy.h:40
gsl_vector * w_vec
Vector view of model parameter w for each center.
Definition: ccl_learn_policy.h:111
gsl_matrix * WX_
Dot product of W * X_.
Definition: ccl_learn_policy.h:101
int ccl_learn_model_lw_pi_ws_free(LEARN_MODEL_LW_PI_WS *ws)
Free the workspace memory for locally weighted linear policy LEARN_MODEL_LW_PI_WS.
double * c
rbf centers
Definition: ccl_learn_policy.h:73
gsl_matrix * ones
Matrix of all ones.
Definition: ccl_learn_policy.h:91
int dim_phi
Dimensionality of feature.
Definition: ccl_learn_policy.h:72
gsl_matrix * pinvH1
Peuso inverse of H1.
Definition: ccl_learn_policy.h:42
#define NUM_CENTRES
Definition: ccl_learn_policy.h:23
void predict_linear(const double *X, const double *centres, const double variance, const LEARN_MODEL_PI *model, double *Yp)
Predictions based on linear policy model.
gsl_vector * r
Normalisation scaler for YN.
Definition: ccl_learn_policy.h:107
int ccl_learn_policy_lw_pi_model_free(LEARN_MODEL_LW_PI *model)
Free the memory for locally weighted linear policy LEARN_MODEL_LW_PI.
gsl_vector * V
Eigen vector of H.
Definition: ccl_learn_policy.h:106
gsl_matrix * w_
Model parameter w for each center.
Definition: ccl_learn_policy.h:112
gsl_matrix * D
Diagobal matrix with eigen values of H.
Definition: ccl_learn_policy.h:44
int dim_x
Dimentionality of input state variable.
Definition: ccl_learn_policy.h:69
gsl_matrix * Phi_vec_T
Transpose of Feature vector.
Definition: ccl_learn_policy.h:96
gsl_matrix * pinvH1
Peudo inverse of H1.
Definition: ccl_learn_policy.h:105
double * w
Model parameters.
Definition: ccl_learn_policy.h:58
int ccl_write_lwmodel_to_file(char *filename, LEARN_MODEL_LW_PI *model)
Write locally weighted model to .txt file.
gsl_matrix * vv
Dot product of v * v.
Definition: ccl_learn_policy.h:100
gsl_matrix * WPhi
Dot product of W * Phi.
Definition: ccl_learn_policy.h:103
int * idx
index
Definition: ccl_learn_policy.h:45
gsl_matrix * r_rep
Replication matrix of r.
Definition: ccl_learn_policy.h:108
This structure describes workspace for directly learning the policy model parameters using linear reg...
Definition: ccl_learn_policy.h:33
gsl_vector * V
Eigen vector of H.
Definition: ccl_learn_policy.h:43
CCL header file for math.
gsl_vector * WX_row
Row vector of WX_.
Definition: ccl_learn_policy.h:102
int ccl_learn_model_pi_ws_alloc(LEARN_MODEL_PI *model, LEARN_MODEL_PI_WS *ws)
Allocates the workspace memory for directly learning policy pi.
gsl_matrix * BX_T
Transpose of BX_.
Definition: ccl_learn_policy.h:39
void ccl_learn_policy_lw_pi(LEARN_MODEL_LW_PI *model, const double *WX, const double *X, const double *Y)
Main computation routine for locally weighted linear policy.
gsl_matrix * g
Dot product of BX and U.
Definition: ccl_learn_policy.h:35
int dim_y
Dimentionality of output variable.
Definition: ccl_learn_policy.h:68
gsl_matrix * YN_Phi_vec_T
Transpose of YN_Phi_vec.
Definition: ccl_learn_policy.h:99
This structure describes learning a direct locally weighted linear policy model parameters LEARN_MODE...
Definition: ccl_learn_policy.h:67
This structure describes learning a direct linear policy model parameters LEARN_MODEL_PI.
Definition: ccl_learn_policy.h:53
gsl_vector * YN_Phi_vec
Vector view of YN_Phit.
Definition: ccl_learn_policy.h:98
gsl_matrix * Y_Phit
Dot product of Y * WPhi'.
Definition: ccl_learn_policy.h:90
int ccl_learn_model_pi_ws_free(LEARN_MODEL_PI_WS *ws)
Free the workspace memory for directly learning policy pi.
gsl_matrix * Phi
Feature matrix.
Definition: ccl_learn_policy.h:94
int * idx
Index.
Definition: ccl_learn_policy.h:110
int dim_x
Dimentionality of input state variable.
Definition: ccl_learn_policy.h:55