35 for (
int i = 0; i <
xcsf->pa_size; ++i) {
49 xcsf->pa = malloc(
sizeof(
double) *
xcsf->pa_size);
50 xcsf->nr = malloc(
sizeof(
double) *
xcsf->pa_size);
51 xcsf->cover = calloc(
xcsf->pa_size,
sizeof(
double));
64 const struct Set *set = &
xcsf->mset;
65 double *pa =
xcsf->pa;
66 double *nr =
xcsf->nr;
70 struct Cl *clist[set->
size];
72 for (
int i = 0; i < set->
size; ++i) {
79 #pragma omp parallel for
80 for (
int i = 0; i < set->
size; ++i) {
81 if (clist[i] != NULL) {
88 while (iter != NULL) {
95 while (iter != NULL) {
97 const double fitness = iter->
cl->
fit;
98 for (
int j = 0; j <
xcsf->y_dim; ++j) {
99 pa[iter->
cl->
action *
xcsf->y_dim + j] += pred[j] * fitness;
104 for (
int i = 0; i <
xcsf->n_actions; ++i) {
105 for (
int j = 0; j <
xcsf->y_dim; ++j) {
106 const int k = i *
xcsf->y_dim + j;
125 int *max_i = calloc(
xcsf->n_actions,
sizeof(
int));
126 double max =
xcsf->pa[0];
128 for (
int i = 1; i <
xcsf->n_actions; ++i) {
129 const double val =
xcsf->pa[i];
134 }
else if (val == max) {
155 }
while (
xcsf->nr[action] == 0);
168 return xcsf->pa[max_i];
180 if (action < 0 || action >=
xcsf->n_actions) {
181 printf(
"pa_val() error: invalid action specified: %d\n", action);
184 return xcsf->pa[action];
const double * cl_predict(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Computes the current classifier prediction using the input.
Functions operating on classifiers.
double pa_best_val(const struct XCSF *xcsf)
Returns the highest value in the prediction array.
int pa_rand_action(const struct XCSF *xcsf)
Returns a random action from the prediction array.
static void pa_reset(const struct XCSF *xcsf)
Resets the prediction array to zero.
double pa_val(const struct XCSF *xcsf, const int action)
Returns the value of a specified action in the prediction array.
void pa_build(const struct XCSF *xcsf, const double *x)
Builds the prediction array for the specified input.
void pa_free(const struct XCSF *xcsf)
Frees the prediction array.
int pa_best_action(const struct XCSF *xcsf)
Returns the best action in the prediction array.
void pa_init(struct XCSF *xcsf)
Initialises the prediction array.
Prediction array functions.
Classifier data structure.
int action
Current classifier action.
double * prediction
Current classifier prediction.
struct Clist * next
Pointer to the next list element.
struct Cl * cl
Pointer to classifier data structure.
int size
Number of macro-classifiers.
struct Clist * list
Linked list of classifiers.
int rand_uniform_int(const int min, const int max)
Returns a uniform random integer [min,max] not inclusive of max.
Utility functions for random number handling, etc.
static int argmax(const double *X, const int N)
Returns the index of the largest element in vector X.