forked from gidili/WasDarwinWrong
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
65 lines (59 loc) · 2.37 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<title>Immune genetic algorithm</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="ga.js"></script>
<script type="text/javascript" src="levenshtein.js"></script>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
</head>
<body>
<br>
<div style="text-align: center; width:50%;">
<form class="form-inline">
<input type="text" id="target" class="form-control" value="Genetic algorithm" style="width:80%" />
<input id="evolveBtn" type="button" value="Start" class="btn btn-default" />
</form>
</div>
<div id="wrapper" style="text-align: center; margin-top: 25px">
<div class="col-md-4">
<h3>Without immunization</h3>
<div id="evolutionPlaceHolder">
</div>
</div>
<div class="col-md-4">
<h3>With random immunization</h3>
<div id="immunePlaceHolder">
</div>
</div>
<div class="col-md-4">
<h3>With aware immunization</h3>
<div id="immuneAwarePlaceHolder">
</div>
</div>
</div>
</body>
<script type="text/javascript">
var convertInfidelsHndlr = function(){
// clean output area
$('#evolutionPlaceHolder').html('');
$('#immunePlaceHolder').html('');
$('#immuneAwarePlaceHolder').html('');
evolutionTarget = $("#target").val();
INDIVIDUAL_SIZE = $("#target").val().length;
// generate initial population of random strings
var initialPopulation = generateInitialPop(INDIVIDUAL_SIZE, INITIAL_POP_SIZE);
var currentGeneration = initialPopulation;
var maxFitness = 0;
var generationCounter = 0;
evolve(currentGeneration, generationCounter, 'evolutionPlaceHolder');
evolve(currentGeneration, generationCounter, 'immunePlaceHolder', true, inoculateRandom);
evolve(currentGeneration, generationCounter, 'immuneAwarePlaceHolder', true, inoculateAware);
return 0;
}
$(document).ready(function(){
$('#evolveBtn').click(convertInfidelsHndlr);
});
</script>
</html>