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

CCL header file for learning state dependent constraint. More...

#include <ccl_math.h>
#include <gsl/gsl_linalg.h>
#include <gsl/gsl_blas.h>
#include <gsl/gsl_math.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_A_MODEL
 This structure describes a "LEARN_A_MODEL" (a learn alpha model). This structure constains the dimentionality of the defined problems and the model parameters. It should always initialised with ccl_learn_alpha_model_alloc, and destroyed with ccl_learn_alpha_model_free. More...
 
struct  OPTION
 This structure defines the OPTION for the optimizer. More...
 
struct  SOLVE_LM_WS
 This structure defines the workspace variables for solving the non-linear LM optimization. More...
 

Macros

#define NUM_CONSTRAINT   3
 

Functions

int ccl_learn_alpha_model_alloc (LEARN_A_MODEL *model)
 Allocates the memory for the learn_alpha model. More...
 
int ccl_learn_alpha_model_free (LEARN_A_MODEL *model)
 Free the memory for the learn_alpha model. More...
 
int ccl_solve_lm_ws_alloc (const LEARN_A_MODEL *model, SOLVE_LM_WS *lm_ws)
 Allocates the workspace memory for the LM solver. More...
 
int ccl_solve_lm_ws_free (SOLVE_LM_WS *lm_ws)
 Free the memory for the LM solver. More...
 
void ccl_learn_alpha (const double *Un, const double *X, const int dim_b, const int dim_r, const int dim_n, const int dim_x, const int dim_u, LEARN_A_MODEL optimal)
 Main computation routine for learning state dependent constraint A. More...
 
void search_learn_alpha (const double *BX, const double *RnUn, LEARN_A_MODEL *model)
 Main computation routine for learning a model of A. More...
 
void obj_AUn (const LEARN_A_MODEL *model, const double *W, const double *BX, const double *RnUn, double *fun_out)
 Computation routine for learning constraint by increasing the dimensionality of k. More...
 
void ccl_get_unit_vector_from_matrix (const double *theta, int dim_n, int dim_t, double *alpha)
 Computation routine for generating unit vector for row vector alpha by given theta anlges. More...
 
void ccl_solve_lm (const LEARN_A_MODEL *model, const double *RnUn, const double *BX, const OPTION option, SOLVE_LM_WS *lm_ws_param, double *W)
 Computation routine for optimizing non-linear objective functions using LM approach. More...
 
void findjac (const LEARN_A_MODEL *model, const int dim_x, const double *BX, const double *RnUn, const double *y, const double *x, double epsx, double *J)
 Computation routine for numerical approximation of the objevtive jacobian matrix. More...
 
void ccl_get_rotation_matrix (const double *theta, const double *currentRn, const LEARN_A_MODEL *model, const int alpha_id, double *Rn)
 Computation routine for rotation matrix after finding the k^th constraint vector. More...
 
void ccl_make_given_matrix (const double theta, int i, int j, int dim, double *G)
 Computation routine for generating roation matrix of a plane rotation of degree theta in an arbitrary plane and dimension R. More...
 
void predict_proj_alpha (double *x, LEARN_A_MODEL *model, double *centres, double variance, double *Iu, double *A)
 Computation routine for prediction of the A matrix. More...
 

Detailed Description

CCL header file for learning state dependent constraint.

Macro Definition Documentation

#define NUM_CONSTRAINT   3

NUM_CONSTRAINT is the default full rank of the task constraint

Function Documentation

void ccl_get_rotation_matrix ( const double *  theta,
const double *  currentRn,
const LEARN_A_MODEL model,
const int  alpha_id,
double *  Rn 
)

Computation routine for rotation matrix after finding the k^th constraint vector.

Parameters
[in]thetaTheta from kth constrains, must point to an arrary of 1 * dim_t doubles
[in]currentRn Rotation matrix from the last iteration, must point to an array of dim_u * dim_u of doubles
[in]model Must be pointer to a valid LEARN_A_MODEL structure
[in]alpha_id Current searching dimension of alpha
[out]Rn Returned rotation matrix, must point to an array of dim_u * dum_u doubles
void ccl_get_unit_vector_from_matrix ( const double *  theta,
int  dim_n,
int  dim_t,
double *  alpha 
)

Computation routine for generating unit vector for row vector alpha by given theta anlges.

Parameters
[in]thetaLearned constraint parameters, must point to an array of dim_n * dim_t doubles
[in]dim_n Number of data samples
[in]dim_t Number of constraint parameters
[out] A uit vector of constraint basis, must point to an array of dim_n * dim_u doubles
void ccl_learn_alpha ( const double *  Un,
const double *  X,
const int  dim_b,
const int  dim_r,
const int  dim_n,
const int  dim_x,
const int  dim_u,
LEARN_A_MODEL  optimal 
)

Main computation routine for learning state dependent constraint A.

Parameters
[in]UnObserved actions, Must point to an array of dim_u * dim_n of doubles
[in]X Observed state variables, Must point to an array of dim_x * dim_n of doubles
[in]dim_b Number of basis functions
[in]dim_r Dimensionality of the task space
[in]dim_n NUmber of data points
[in]dim_x Dimensionality of the state variables
[in]dim_u Dimensionality of the action space
[out]optimal,optimalmodel paramters
int ccl_learn_alpha_model_alloc ( LEARN_A_MODEL model)

Allocates the memory for the learn_alpha model.

Parameters
[in]modelMust point to a valid LEARN_A_MODEL structure
Returns
  • 1 in case of succes
  • 0 in case of failure (e.g. memory could not be allocated)
int ccl_learn_alpha_model_free ( LEARN_A_MODEL model)

Free the memory for the learn_alpha model.

Parameters
[in]modelMust point to a valid LEARN_A_MODEL structure
Returns
  • 1 in case of succes
  • 0 in case of failure (e.g. memory could not be freed)
void ccl_make_given_matrix ( const double  theta,
int  i,
int  j,
int  dim,
double *  G 
)

Computation routine for generating roation matrix of a plane rotation of degree theta in an arbitrary plane and dimension R.

Parameters
[in]thetaDegree of rotation, must point to a scalar doubles
[in]iRow index of matrix
[in]jCol index of matrix
[in]dimDimensionality of the rotation matrix
[out]GReturned rotation matrix, must point to an array of dim_u * dum_u doubles
void ccl_solve_lm ( const LEARN_A_MODEL model,
const double *  RnUn,
const double *  BX,
const OPTION  option,
SOLVE_LM_WS lm_ws_param,
double *  W 
)

Computation routine for optimizing non-linear objective functions using LM approach.

Parameters
[in]modelMust be pointer to a valid LEARN_A_MODEL structure.
[in]RnUnPre-calculated dot product of Rn and Un, must point to an array of dim_u * dim_n of doubles
[in]BX Transformed state variables, must point to an array of dim_b * dim_n of doubles
[in]option Options for optimizer
[in]lm_ws_paramMust point to a valid structure of SOLVE_LM_WS for LM optimizer workspace variables
[out]W Returned model parameter, must point to an array of dim_u-dum_k doubles
int ccl_solve_lm_ws_alloc ( const LEARN_A_MODEL model,
SOLVE_LM_WS lm_ws 
)

Allocates the workspace memory for the LM solver.

Parameters
[in]modelMust point to a valid LEARN_A_MODEL structure
[in]lm_wsMust point to a valid lm workspace structure
Returns
  • 1 in case of succes
  • 0 in case of failure (e.g. memory could not be allocated).
int ccl_solve_lm_ws_free ( SOLVE_LM_WS lm_ws)

Free the memory for the LM solver.

Parameters
[in]lm_wsMust point to a valid lm workspace structure
Returns
  • 1 in case of succes
  • 0 in case of failure (e.g. memory could not be freed).
void findjac ( const LEARN_A_MODEL model,
const int  dim_x,
const double *  BX,
const double *  RnUn,
const double *  y,
const double *  x,
double  epsx,
double *  J 
)

Computation routine for numerical approximation of the objevtive jacobian matrix.

Parameters
[in]modelMust be pointer to a valid LEARN_A_MODEL structure
[in]dim_xDimensionality of the model parameters
[in]BXTransformed state variables, must point to an array of dim_b * dim_n of doubles
[in]RnUn Pre-calculated dot product of Rn and Un, must point to an array of dim_u * dim_n of doubles
[in]y Residual calculated at x, must point to a scalar of double.
[in]x Current model parameter x, must point to an array of dim_x doubles, note here dim_x is not the dimension of the state variable
[in]epsx Tolerance of the model parameters
[out]J Returned jocabian matrix, must point to an array of dim_n * dim_x doubles
void obj_AUn ( const LEARN_A_MODEL model,
const double *  W,
const double *  BX,
const double *  RnUn,
double *  fun_out 
)

Computation routine for learning constraint by increasing the dimensionality of k.

Parameters
[in]modelMust be pointer to a valid LEARN_A_MODEL structure.
[in]WCurrent model parameter, must point to an array of dim_u-dum_k doubles.
[in]RnUn Pre-calculated dot product of Rn and Un, must point to an array of dim_u * dim_n of doubles
[out]Residual value returned from the objective function, must point to a scalar of double
void predict_proj_alpha ( double *  x,
LEARN_A_MODEL model,
double *  centres,
double  variance,
double *  Iu,
double *  A 
)

Computation routine for prediction of the A matrix.

Parameters
[in]xInput state variable, must point to an array of dim_x doubles
[in]model Must be pointer to a valid LEARN_A_MODEL structure
[in]centres Rbf centers, must point to an array of 1 * dim_b doubles.
[in]variance Variance of the rbf
[in]Iu Identity matrix, must point to an array of dim_u * dim_u doubles
[out]A Constraint A matrix, must point to an array of dim_k * dum_u doubles
void search_learn_alpha ( const double *  BX,
const double *  RnUn,
LEARN_A_MODEL model 
)

Main computation routine for learning a model of A.

Parameters
[in]BXTransformed state variables, must point to an array of dim_b * dim_n of doubles
[in]RnUn Pre-calculated dot product of Rn and Un, must point to an array of dim_u * dim_n of doubles
[in]model model paramters, must point to a valid LEARN_A_MODEL structure
[out]modelmodel paramters, must point to a valid LEARN_A_MODEL structure