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

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

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

Go to the source code of this file.

Data Structures

struct  NHAT_search
 This structure defines the searching parameters for NHAT_search. More...
 
struct  NHAT_Model
 This structure defines the model parameters for NHAT_Model. More...
 
struct  NHAT_result
 This structure defines the model parameters for NHAT_result. More...
 

Macros

#define NUM_SEARCH   27000
 
#define NUM_CONSTRAINT   4
 

Functions

int init_search_param (NHAT_search *search, int dim_u, int dim_n, int num_theta)
 Initialisation of the searching parameters. More...
 
int nhat_mem_alloc_search (NHAT_search *search)
 Allocates the memory for NHAT_search. More...
 
int nhat_mem_free_search (NHAT_search *search)
 Free the memory for NHAT_search. More...
 
int nhat_mem_alloc_model (NHAT_Model *model, const NHAT_search *search)
 Allocates the memory for NHAT_Model. More...
 
int nhat_mem_free_model (NHAT_Model *model)
 Free the memory for NHAT_Model. More...
 
int nhat_duplicate_model (NHAT_Model *dest, const NHAT_Model *src)
 Duplicate the NHAT_Model model from src to dest. More...
 
void get_unit_vector (const double *theta, int dim_t, double *alpha)
 Computation routine for generating unit vector for row vector alpha by given theta anlges. More...
 
void generate_search_space (NHAT_search *search)
 Generate search space. More...
 
void search_first_alpha (const double *Vn, const double *Un, NHAT_Model *model, const NHAT_search *search, double *stats)
 Search first row of A matrix. More...
 
void search_alpha_nhat (const double *Vn, const double *Un, NHAT_Model *model, const NHAT_search *search, NHAT_Model *model_out, double *stats)
 Search the rest rows of A matrix. More...
 
void learn_nhat (const double *Un, const int dim_u, const int dim_n, NHAT_Model *optimal)
 Main computation routine for learn nhat. More...
 
void calclate_N (double *N, const double *A, int row, int col)
 Calculation of nullspace projection matrix. More...
 
int nhat_mem_alloc_result (NHAT_Model *model, const NHAT_search search, int dim_c)
 Allocates the memory for model results. More...
 
int nhat_mem_free_result (NHAT_result *result, int n_models)
 Free the memory for model results. More...
 
int nhat_mem_alloc_optimal (NHAT_Model *optimal, const NHAT_search search, int dim_c)
 Allocates the memory for optimal model. More...
 
int nhat_mem_free_optimal (NHAT_Model *optimal)
 Free the memory for optimal model. More...
 

Detailed Description

CCL header file for learning state independent constraint.

Macro Definition Documentation

#define NUM_CONSTRAINT   4

NUM_CONSTRAINT is the default full rank of the task constraint

#define NUM_SEARCH   27000

NUM_SEARCH is the search dimension

Function Documentation

void calclate_N ( double *  N,
const double *  A,
int  row,
int  col 
)

Calculation of nullspace projection matrix.

Parameters
[in]AConstraint matrix, must point to an array of dim_u * dim_u doubles
[in]row Number of rows
[in]col Number of cols
[out]N Projection matrix
void generate_search_space ( NHAT_search search)

Generate search space.

Parameters
[in]searchMust point to a valid NHAT_search structure
[out]searchMust point to a valid NHAT_search structure
void get_unit_vector ( const double *  theta,
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 1 * dim_t doubles
[in]dim_t Number of constraint parameters
[out] A uit vector of constraint basis, must point to an array of 1 * dim_u doubles
int init_search_param ( NHAT_search search,
int  dim_u,
int  dim_n,
int  num_theta 
)

Initialisation of the searching parameters.

Parameters
[in]searchMust be pointer to a valid NHAT_search structure
[in]dim_uDimensionality of action space
[in]dim_nNumber of data samples
[in]num_thetaNumber of candidate constraints (from 0 to pi)
Returns
  • 1 in case of succes
  • 0 in case of failure (e.g. memory could not be initialised)
void learn_nhat ( const double *  Un,
const int  dim_u,
const int  dim_n,
NHAT_Model optimal 
)

Main computation routine for learn nhat.

Parameters
[in]UnObserved actions
[in]dim_uDimensionality of action space
[in]dim_nNumber of data samples
[out]optimalMust point to a valid NHAT_Model structure
int nhat_duplicate_model ( NHAT_Model dest,
const NHAT_Model src 
)

Duplicate the NHAT_Model model from src to dest.

Parameters
[in]destMust point to a valid NHAT_Model structure
[in]srcMust point to a valid NHAT_Model structure
Returns
  • 1 in case of succes
  • 0 in case of failure (e.g. memory could not be duplicated)
int nhat_mem_alloc_model ( NHAT_Model model,
const NHAT_search search 
)

Allocates the memory for NHAT_Model.

Parameters
[in]modelMust point to a valid NHAT_Model structure
[in]searchMust point to a valid NHAT_search structure
Returns
  • 1 in case of succes
  • 0 in case of failure (e.g. memory could not be allocated)
int nhat_mem_alloc_optimal ( NHAT_Model optimal,
const NHAT_search  search,
int  dim_c 
)

Allocates the memory for optimal model.

Parameters
[in]optimalMust point to a valid NHAT_Model structure
[in]searchMust point to a valid NHAT_search structure
[in]dim_cCurrent dimension of constraints
Returns
  • 1 in case of succes
  • 0 in case of failure (e.g. memory could not be allocated for the optimal)
int nhat_mem_alloc_result ( NHAT_Model model,
const NHAT_search  search,
int  dim_c 
)

Allocates the memory for model results.

Parameters
[in]modelMust point to a valid NHAT_Model structure
[in]searchMust point to a valid NHAT_search structure
[in]dim_cCurrent dimension of constraints
Returns
  • 1 in case of succes
  • 0 in case of failure (e.g. memory could not be allocated for the results)
int nhat_mem_alloc_search ( NHAT_search search)

Allocates the memory for NHAT_search.

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

Free the memory for NHAT_Model.

Parameters
[in]modelMust point to a valid NHAT_Model structure
Returns
  • 1 in case of succes
  • 0 in case of failure (e.g. memory could not be freed)
int nhat_mem_free_optimal ( NHAT_Model optimal)

Free the memory for optimal model.

Parameters
[in]optimalMust point to a valid NHAT_Model structure
Returns
  • 1 in case of succes
  • 0 in case of failure (e.g. memory could not be freed for the optimal)
int nhat_mem_free_result ( NHAT_result result,
int  n_models 
)

Free the memory for model results.

Parameters
[in]resultMust point to a valid NHAT_result structure
[in]n_modelsNumber of constraints
Returns
  • 1 in case of succes
  • 0 in case of failure (e.g. memory could not be freed for the results)
int nhat_mem_free_search ( NHAT_search search)

Free the memory for NHAT_search.

Parameters
[in]searchMust point to a valid NHAT_search structure
Returns
  • 1 in case of succes
  • 0 in case of failure (e.g. memory could not be freed)
void search_alpha_nhat ( const double *  Vn,
const double *  Un,
NHAT_Model model,
const NHAT_search search,
NHAT_Model model_out,
double *  stats 
)

Search the rest rows of A matrix.

Parameters
[in]VnPre-calculation of Un*Un'
[in]UnObserved actions
[in]modelMust point to a valid NHAT_Model structure from a previous model
[in]searchMust point to a valid NHAT_search structure
[out]modelMust point to a valid NHAT_Model structure
[out]statsStatistics of model learning
void search_first_alpha ( const double *  Vn,
const double *  Un,
NHAT_Model model,
const NHAT_search search,
double *  stats 
)

Search first row of A matrix.

Parameters
[in]VnPre-calculation of Un*Un'
[in]UnObserved actions
[in]searchMust point to a valid NHAT_search structure
[out]modelMust point to a valid NHAT_Model structure
[out]statsStatistics of model learning