XCSF  1.4.7
XCSF learning classifier system
act_integer.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 "action.h"
27 #include "xcsf.h"
28 
32 struct ActInteger {
33  int action;
34  double *mu;
35 };
36 
37 bool
38 act_integer_crossover(const struct XCSF *xcsf, const struct Cl *c1,
39  const struct Cl *c2);
40 
41 bool
42 act_integer_general(const struct XCSF *xcsf, const struct Cl *c1,
43  const struct Cl *c2);
44 
45 bool
46 act_integer_mutate(const struct XCSF *xcsf, const struct Cl *c);
47 
48 int
49 act_integer_compute(const struct XCSF *xcsf, const struct Cl *c,
50  const double *x);
51 
52 void
53 act_integer_copy(const struct XCSF *xcsf, struct Cl *dest,
54  const struct Cl *src);
55 
56 void
57 act_integer_cover(const struct XCSF *xcsf, const struct Cl *c, const double *x,
58  const int action);
59 
60 void
61 act_integer_free(const struct XCSF *xcsf, const struct Cl *c);
62 
63 void
64 act_integer_init(const struct XCSF *xcsf, struct Cl *c);
65 
66 void
67 act_integer_print(const struct XCSF *xcsf, const struct Cl *c);
68 
69 void
70 act_integer_update(const struct XCSF *xcsf, const struct Cl *c, const double *x,
71  const double *y);
72 
73 size_t
74 act_integer_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp);
75 
76 size_t
77 act_integer_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp);
78 
79 char *
80 act_integer_json_export(const struct XCSF *xcsf, const struct Cl *c);
81 
82 void
83 act_integer_json_import(const struct XCSF *xcsf, struct Cl *c,
84  const cJSON *json);
85 
89 static struct ActVtbl const act_integer_vtbl = {
95 };
void act_integer_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
Copies an integer action from one classifier to another.
Definition: act_integer.c:117
void act_integer_free(const struct XCSF *xcsf, const struct Cl *c)
Frees the memory used by an integer action.
Definition: act_integer.c:164
bool act_integer_crossover(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Dummy function since integer actions do not perform crossover.
Definition: act_integer.c:43
int act_integer_compute(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Returns a classifier's integer action.
Definition: act_integer.c:101
size_t act_integer_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
Writes an integer action to a file.
Definition: act_integer.c:212
void act_integer_update(const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
Dummy function since integer actions are not updated.
Definition: act_integer.c:195
void act_integer_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
Creates an integer action from a cJSON object.
Definition: act_integer.c:270
static struct ActVtbl const act_integer_vtbl
Integer action implemented functions.
Definition: act_integer.h:89
void act_integer_init(const struct XCSF *xcsf, struct Cl *c)
Initialises an integer action.
Definition: act_integer.c:178
bool act_integer_mutate(const struct XCSF *xcsf, const struct Cl *c)
Mutates an integer action.
Definition: act_integer.c:79
bool act_integer_general(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Returns whether the action of classifier c1 is more general than c2.
Definition: act_integer.c:60
size_t act_integer_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp)
Reads an integer action from a file.
Definition: act_integer.c:230
char * act_integer_json_export(const struct XCSF *xcsf, const struct Cl *c)
Returns a json formatted string representation of an integer action.
Definition: act_integer.c:249
void act_integer_cover(const struct XCSF *xcsf, const struct Cl *c, const double *x, const int action)
Sets an integer action to a specified value.
Definition: act_integer.c:149
void act_integer_print(const struct XCSF *xcsf, const struct Cl *c)
Prints an integer action.
Definition: act_integer.c:134
Interface for classifier actions.
Definition: __init__.py:1
Integer action data structure.
Definition: act_integer.h:32
int action
Integer action.
Definition: act_integer.h:33
double * mu
Mutation rates.
Definition: act_integer.h:34
Action interface data structure.
Definition: action.h:76
Classifier data structure.
Definition: xcsf.h:45
XCSF data structure.
Definition: xcsf.h:85
XCSF data structures.