-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpdemo3_config.m
152 lines (97 loc) · 4.54 KB
/
gpdemo3_config.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
function [gp]=gpdemo3_config(gp)
%GPDEMO3_CONFIG Example GPTIPS configuration file demonstrating multiple
%gene symbolic regression on data from a simulated pH neutralisation process.
%
% This is the configuration file that GPDEMO3 calls.
%
% [GP]=GPDEMO3_CONFIG(GP) generates a parameter structure GP that
% specifies the GPTIPS run settings.
%
% Remarks:
% The data in this example is taken a simulation of a pH neutralisation
% process with one output (pH), which is a non-linear function of the
% four inputs.
%
% Example:
% [GP]=RUNGP('gpdemo3_config') uses this configuration file to perform
% symbolic regression with multiple gene individuals on the pH data. The
% results and parameters used are stored in fields of the returned GP
% structure.
%
% (C) Dominic Searson 2009
%
% v1.0
%
% See also: REGRESSMULTI_FITFUN, GPDEMO4, GPDEMO3 GPDEMO2, GPDEMO1, RUNGP
% Main run control parameters
% --------------------------
gp.runcontrol.pop_size=150; % Population size
gp.runcontrol.num_gen=150; % Number of generations to run for including generation zero
gp.runcontrol.verbose=10; % Set to n to display run information to screen every n generations
% Selection method options
% -------------------------
gp.selection.tournament.size=4;
gp.selection.tournament.lex_pressure=true; % True to use Luke & Panait's plain lexicographic tournament selection
gp.selection.elite_fraction=0.02; % Elitist selection.
% Fraction of population to copy
% directly to next generation without modification.
% Fitness function specification
% ------------------------------
gp.fitness.fitfun=@regressmulti_fitfun; % Function handle to name of the user's fitness function (filename with no .m extension).
gp.fitness.minimisation=true; % Set to true if you want to minimise the fitness function (if false it is maximised).
gp.fitness.terminate=true;
gp.fitness.terminate_value=0.25;
% Set up user data
% ----------------
load ph2data %load in the raw x and y data from a simulation of a pH neutralisation process
gp.userdata.xtest=nx; %testing set (inputs)
gp.userdata.ytest=ny; %testing set (output)
gp.userdata.xtrain=x; %training set (inputs)
gp.userdata.ytrain=y; %training set (output)
% Input configuration
% -------------------
gp.nodes.inputs.num_inp=size(gp.userdata.xtrain,2); % This sets the number of inputs (i.e. the size of the terminal set NOT including constants)
% Tree build options
% ------------------
gp.treedef.max_depth=4; % Maximum depth of trees
% Multiple gene settings
% ----------------------
gp.genes.multigene=true; % Set to true to use multigene individuals and false to use ordinary single gene individuals.
gp.genes.max_genes=4; % The absolute maximum number of genes allowed in an individual.
% Define functions
% ----------------
%
% (Below are some definitions of functions that have been used for symbolic regression problems)
%
% Function name (must be an mfile or builtin function on the path).
gp.nodes.functions.name{1}='times' ;
gp.nodes.functions.name{2}='minus' ;
gp.nodes.functions.name{3}='plus' ;
gp.nodes.functions.name{4}='rdivide' ; % unprotected divide
gp.nodes.functions.name{5}='psqroot' ; % protected sqrt
gp.nodes.functions.name{6}='plog' ; % protected natural log
gp.nodes.functions.name{7}='square' ; % .^2 square
gp.nodes.functions.name{8}='tanh' ; % tanh function
gp.nodes.functions.name{9}='pdivide' ; % protected divide function
gp.nodes.functions.name{10}='iflte' ; % IF-THEN-ELSE function
gp.nodes.functions.name{11}='sin' ;
gp.nodes.functions.name{12}='cos' ;
gp.nodes.functions.name{13}='exp' ;
% Active functions
% ----------------
%
% Manually setting a function node to inactive allows you to exclude a function node in a
% particular run.
gp.nodes.functions.active(1)=1;
gp.nodes.functions.active(2)=1;
gp.nodes.functions.active(3)=1;
gp.nodes.functions.active(4)=0;
gp.nodes.functions.active(5)=0;
gp.nodes.functions.active(6)=0;
gp.nodes.functions.active(7)=0;
gp.nodes.functions.active(8)=1;
gp.nodes.functions.active(9)=0;
gp.nodes.functions.active(10)=0;
gp.nodes.functions.active(11)=0;
gp.nodes.functions.active(12)=0;
gp.nodes.functions.active(13)=0;