XCSF 1.4.8
XCSF learning classifier system
Loading...
Searching...
No Matches
pred_nlms.h
Go to the documentation of this file.
1/*
2 * This program is free software: you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation, either version 3 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 */
15
24#pragma once
25
26#include "prediction.h"
27#include "xcsf.h"
28
32struct PredNLMS {
33 int n;
35 double *weights;
36 double *mu;
37 double eta;
38 double *tmp_input;
39};
40
41char *
42pred_nlms_param_json_import(struct XCSF *xcsf, cJSON *json);
43
44char *
46
47bool
48pred_nlms_crossover(const struct XCSF *xcsf, const struct Cl *c1,
49 const struct Cl *c2);
50
51bool
52pred_nlms_mutate(const struct XCSF *xcsf, const struct Cl *c);
53
54double
55pred_nlms_size(const struct XCSF *xcsf, const struct Cl *c);
56
57size_t
58pred_nlms_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp);
59
60size_t
61pred_nlms_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp);
62
63void
64pred_nlms_compute(const struct XCSF *xcsf, const struct Cl *c, const double *x);
65
66void
67pred_nlms_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src);
68
69void
70pred_nlms_free(const struct XCSF *xcsf, const struct Cl *c);
71
72void
73pred_nlms_init(const struct XCSF *xcsf, struct Cl *c);
74
75void
76pred_nlms_print(const struct XCSF *xcsf, const struct Cl *c);
77
78void
79pred_nlms_update(const struct XCSF *xcsf, const struct Cl *c, const double *x,
80 const double *y);
81
82char *
83pred_nlms_json_export(const struct XCSF *xcsf, const struct Cl *c);
84
85void
86pred_nlms_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json);
87
char * pred_nlms_param_json_export(const struct XCSF *xcsf)
Returns a json formatted string of the NLMS parameters.
Definition pred_nlms.c:319
void pred_nlms_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
Creates an NLMS prediction from a cJSON object.
Definition pred_nlms.c:290
void pred_nlms_compute(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Computes the current NLMS prediction for a provided input.
Definition pred_nlms.c:138
size_t pred_nlms_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
Writes an NLMS prediction to a file.
Definition pred_nlms.c:223
bool pred_nlms_crossover(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Dummy function since NLMS predictions do not perform crossover.
Definition pred_nlms.c:170
void pred_nlms_print(const struct XCSF *xcsf, const struct Cl *c)
Prints an NLMS prediction.
Definition pred_nlms.c:155
void pred_nlms_init(const struct XCSF *xcsf, struct Cl *c)
Initialises an NLMS prediction.
Definition pred_nlms.c:44
static struct PredVtbl const pred_nlms_vtbl
Normalised least mean squares prediction implemented functions.
Definition pred_nlms.h:91
void pred_nlms_free(const struct XCSF *xcsf, const struct Cl *c)
Frees the memory used by an NLMS prediction.
Definition pred_nlms.c:96
bool pred_nlms_mutate(const struct XCSF *xcsf, const struct Cl *c)
Mutates the gradient descent rate used to update an NLMS prediction.
Definition pred_nlms.c:186
double pred_nlms_size(const struct XCSF *xcsf, const struct Cl *c)
Returns the size of an NLMS prediction.
Definition pred_nlms.c:208
void pred_nlms_update(const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
Updates an NLMS prediction for a given input and truth sample.
Definition pred_nlms.c:115
char * pred_nlms_param_json_import(struct XCSF *xcsf, cJSON *json)
Sets the NLMS parameters from a cJSON object.
Definition pred_nlms.c:341
void pred_nlms_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
Copies an NLMS prediction from one classifier to another.
Definition pred_nlms.c:79
size_t pred_nlms_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp)
Reads an NLMS prediction from a file.
Definition pred_nlms.c:244
char * pred_nlms_json_export(const struct XCSF *xcsf, const struct Cl *c)
Returns a json formatted string representation of an NLMS prediction.
Definition pred_nlms.c:264
Interface for classifier predictions.
Classifier data structure.
Definition xcsf.h:45
Normalised least mean squares prediction data structure.
Definition pred_nlms.h:32
double * mu
Mutation rates.
Definition pred_nlms.h:36
int n_weights
Total number of weights.
Definition pred_nlms.h:34
double * tmp_input
Temporary storage for updating weights.
Definition pred_nlms.h:38
int n
Number of weights for each predicted variable.
Definition pred_nlms.h:33
double eta
Gradient descent rate.
Definition pred_nlms.h:37
double * weights
Weights used to compute prediction.
Definition pred_nlms.h:35
Prediction interface data structure.
Definition prediction.h:96
XCSF data structure.
Definition xcsf.h:85
XCSF data structures.