CCL Library  1.0
Data Structures | Macros | Functions
ccl_learn_policy.h File Reference

CCL header file for learning unconstraint policy. More...

#include <ccl_math.h>
#include <gsl/gsl_linalg.h>
#include <gsl/gsl_blas.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_eigen.h>
#include <gsl/gsl_sf.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

Go to the source code of this file.

Data Structures

struct  LEARN_MODEL_PI_WS
 This structure describes workspace for directly learning the policy model parameters using linear regression. More...
 
struct  LEARN_MODEL_PI
 This structure describes learning a direct linear policy model parameters LEARN_MODEL_PI. More...
 
struct  LEARN_MODEL_LW_PI
 This structure describes learning a direct locally weighted linear policy model parameters LEARN_MODEL_LW_PI. More...
 
struct  LEARN_MODEL_LW_PI_WS
 This structure describes workspace for directly learning the policy model parameters using locally weighted linear regression. More...
 

Macros

#define NUM_CENTRES   20
 

Functions

void ccl_learn_policy_pi (LEARN_MODEL_PI *model, const double *BX, const double *Y)
 Main computation routine for learning linear policy. More...
 
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. More...
 
int ccl_learn_model_pi_ws_free (LEARN_MODEL_PI_WS *ws)
 Free the workspace memory for directly learning policy pi. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
int ccl_read_data_from_file (char *filename, int dim_x, int dim_n, double *mat)
 Read data from .txt file. More...
 
int ccl_write_lwmodel_to_file (char *filename, LEARN_MODEL_LW_PI *model)
 Write locally weighted model to .txt file. More...
 

Detailed Description

CCL header file for learning unconstraint policy.

Macro Definition Documentation

#define NUM_CENTRES   20

NUM_CENTRES is the number of rbf centers

Function Documentation

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.

Parameters
[in]modelMust point to a valid LEARN_MODEL_LW_PI structure
[in]wsMust point to a valid LEARN_MODEL_LW_PI_WS structure
Returns
  • 1 in case of succes
  • 0 in case of failure (e.g. memory could not be allocated).
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.

Parameters
[in]wsMust point to a valid LEARN_MODEL_LW_PI_WS structure
Returns
  • 1 in case of succes
  • 0 in case of failure (e.g. memory could not be freed).
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.

Parameters
[in]modelMust point to a valid LEARN_MODEL_PI structure
[in]wsMust point to a valid LEARN_MODEL_PI_WS structure
Returns
  • 1 in case of succes
  • 0 in case of failure (e.g. memory could not be allocated).
int ccl_learn_model_pi_ws_free ( LEARN_MODEL_PI_WS ws)

Free the workspace memory for directly learning policy pi.

Parameters
[in]wsMust point to a valid LEARN_MODEL_PI_WS structure
Returns
  • 1 in case of succes
  • 0 in case of failure (e.g. memory could not be freed).
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.

Parameters
[in]modelMust point to a valid LEARN_MODEL_LW_PI structure
[in]WXLocally weighted inputs, must point to an array of dim_b * dim_n doubles
[in]X Inputs variables, must point to an array of dim_x * dim_n doubles
[in]Y Output variables, must point to an array of dim_y * dim_n doubles
[out]modelMust point to a valid LEARN_MODEL_LW_PI structure
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.

Parameters
[in]modelMust point to a valid LEARN_MODEL_LW_PI structure
Returns
  • 1 in case of succes
  • 0 in case of failure (e.g. memory could not be allocated).
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.

Parameters
[in]modelMust point to a valid LEARN_MODEL_LW_PI structure
Returns
  • 1 in case of succes
  • 0 in case of failure (e.g. memory could not be freed).
void ccl_learn_policy_pi ( LEARN_MODEL_PI model,
const double *  BX,
const double *  Y 
)

Main computation routine for learning linear policy.

Parameters
[in]modelMust point to a valid LEARN_MODEL_PI structure
[in]BXHigher dimensionality of input variable, must point to an array of dim_b * dim_n doubles
[in]Y Ouput variable, must point to an array of dim_y * dim_n doubles.
[in]model Must point to a valid LEARN_MODEL_PI structure
int ccl_read_data_from_file ( char *  filename,
int  dim_x,
int  dim_n,
double *  mat 
)

Read data from .txt file.

Parameters
[in]filenameName of file
[in]dim_xDimensionality of input variable
[in]dim_nNumber of data samples
[out]matReturned data matrix
Returns
  • 1 in case of succes
  • 0 in case of failure (e.g. memory could not be freed).
int ccl_write_lwmodel_to_file ( char *  filename,
LEARN_MODEL_LW_PI model 
)

Write locally weighted model to .txt file.

Parameters
[in]filenameName of file
[in]modelMust point to a valid LEARN_MODEL_LW_PI structure
Returns
  • 1 in case of succes
  • 0 in case of failure (e.g. memory could not be freed).
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.

Parameters
[in]XInputs variables, must point to an array of dim_x * dim_n doubles
[in]centres Center of rbf, must point to an array of 1 * dim_b doubles
[in]variance Variance of rbf
[in]model Must point to a valid LEARN_MODEL_PI structure
[out]Yp Predictions
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.

Parameters
[in]XInputs variables, must point to an array of dim_x * dim_n doubles
[in]centres Center of rbf, must point to an array of 1 * dim_b doubles
[in]variance Variance of rbf
[in]model Must point to a valid LEARN_MODEL_LW_PI structure
[out]Yp Predictions