-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathspecie_evo_strat.erl
More file actions
69 lines (59 loc) · 1.96 KB
/
specie_evo_strat.erl
File metadata and controls
69 lines (59 loc) · 1.96 KB
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
%% This source code and work is provided and developed by DXNN Research Group WWW.DXNNResearch.COM
%%
%Copyright (C) 2009 by Gene Sher, DXNN Research Group, CorticalComputer@gmail.com
%All rights reserved.
%
%This code is licensed under the version 3 of the GNU General Public License. Please see the LICENSE file that accompanies this project for the terms of use.
-module(specie_evo_strat).
-compile(export_all).
-include("records.hrl").
init()->
#specie_evo_strat{
strategies_mutation_prob = random:uniform(),
evolution_type = lists:nth(random:uniform(2),[memetic,genetic]),
selection_type = lists:nth(random:uniform(2),[competition,top3]),
selection_threshold = 0.1 + random:uniform(80)/100,
diversity_importance = random:uniform(),
revenent_prob = random:uniform()}.
mutate(PES)->
SMP = PES#specie_evo_strat.strategies_mutation_prob,
U_SMP = dynamic_perturbation(SMP,0.5,0,1),
ET = PES#specie_evo_strat.evolution_type,
U_ET = case random:uniform() < SMP of
true ->
lists:nth(random:uniform(2),[memetic,genetic]);
false ->
ET
end,
ST = PES#specie_evo_strat.selection_type,
U_ST = case random:uniform() < SMP of
true ->
lists:nth(random:uniform(2),[competition,top3]);
false ->
ST
end,
SThreshold = PES#specie_evo_strat.selection_threshold,
U_SThreshold = dynamic_perturbation(SThreshold,SMP,0.1,0.9),
DI = PES#specie_evo_strat.diversity_importance,
U_DI = dynamic_perturbation(DI,SMP,0,1),
RP = PES#specie_evo_strat.revenent_prob,
U_RP = dynamic_perturbation(RP,SMP,0,1),
PES#specie_evo_strat{
strategies_mutation_prob=U_SMP,
evolution_type=U_ET,
selection_type=U_ST,
selection_threshold=U_SThreshold,
diversity_importance=U_DI,
revenent_prob=U_RP}.
dynamic_perturbation(Val,MP,Min,Max)->
case random:uniform() < MP of
true ->
case random:uniform() < 0.5 of
true ->
Val - (Val-Min)*random:uniform()*0.1;
false ->
Val + (Max-Val)*random:uniform()*0.1
end;
false ->
Val
end.