XCSF 1.4.8
XCSF learning classifier system
Loading...
Searching...
No Matches
cond_ternary.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 "condition.h"
27#include "xcsf.h"
28
33 char *string;
34 int length;
35 double *mu;
36 char *tmp_input;
37};
38
39void
41
42char *
44
45char *
46cond_ternary_param_json_import(struct XCSF *xcsf, cJSON *json);
47
48bool
49cond_ternary_crossover(const struct XCSF *xcsf, const struct Cl *c1,
50 const struct Cl *c2);
51
52bool
53cond_ternary_general(const struct XCSF *xcsf, const struct Cl *c1,
54 const struct Cl *c2);
55
56bool
57cond_ternary_match(const struct XCSF *xcsf, const struct Cl *c,
58 const double *x);
59
60bool
61cond_ternary_mutate(const struct XCSF *xcsf, const struct Cl *c);
62
63void
64cond_ternary_copy(const struct XCSF *xcsf, struct Cl *dest,
65 const struct Cl *src);
66
67void
68cond_ternary_cover(const struct XCSF *xcsf, const struct Cl *c,
69 const double *x);
70
71void
72cond_ternary_free(const struct XCSF *xcsf, const struct Cl *c);
73
74void
75cond_ternary_init(const struct XCSF *xcsf, struct Cl *c);
76
77void
78cond_ternary_print(const struct XCSF *xcsf, const struct Cl *c);
79
80void
81cond_ternary_update(const struct XCSF *xcsf, const struct Cl *c,
82 const double *x, const double *y);
83
84double
85cond_ternary_size(const struct XCSF *xcsf, const struct Cl *c);
86
87size_t
88cond_ternary_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp);
89
90size_t
91cond_ternary_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp);
92
93char *
94cond_ternary_json_export(const struct XCSF *xcsf, const struct Cl *c);
95
96void
97cond_ternary_json_import(const struct XCSF *xcsf, struct Cl *c,
98 const cJSON *json);
99
double cond_ternary_size(const struct XCSF *xcsf, const struct Cl *c)
Returns the size of a ternary condition.
static struct CondVtbl const cond_ternary_vtbl
Ternary condition implemented functions.
char * cond_ternary_json_export(const struct XCSF *xcsf, const struct Cl *c)
Returns a json formatted string representation of a ternary condition.
void cond_ternary_init(const struct XCSF *xcsf, struct Cl *c)
Creates and initialises a ternary bitstring condition.
bool cond_ternary_match(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Calculates whether a ternary condition matches an input.
void cond_ternary_update(const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
Dummy update function.
bool cond_ternary_general(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Returns whether classifier c1 has a condition more general than c2.
void cond_ternary_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
Copies a ternary condition from one classifier to another.
void cond_ternary_cover(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Generates a ternary condition that matches the current input.
bool cond_ternary_mutate(const struct XCSF *xcsf, const struct Cl *c)
Mutates a ternary condition.
void cond_ternary_print(const struct XCSF *xcsf, const struct Cl *c)
Prints a ternary condition.
char * cond_ternary_param_json_import(struct XCSF *xcsf, cJSON *json)
Sets the ternary parameters from a cJSON object.
void cond_ternary_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
Creates a ternary condition from a cJSON object.
void cond_ternary_free(const struct XCSF *xcsf, const struct Cl *c)
Frees the memory used by a ternary condition.
bool cond_ternary_crossover(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Performs uniform crossover with two ternary conditions.
char * cond_ternary_param_json_export(const struct XCSF *xcsf)
Returns a json formatted string of the ternary parameters.
size_t cond_ternary_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
Writes a ternary condition to a file.
void cond_ternary_param_defaults(struct XCSF *xcsf)
Initialises default ternary condition parameters.
size_t cond_ternary_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp)
Reads a ternary condition from a file.
Interface for classifier conditions.
Classifier data structure.
Definition xcsf.h:45
Ternary condition data structure.
int length
Length of the bitstring.
char * string
Ternary bitstring.
double * mu
Mutation rates.
char * tmp_input
Temporary storage for float conversion.
Condition interface data structure.
Definition condition.h:104
XCSF data structure.
Definition xcsf.h:85
XCSF data structures.