-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.html
382 lines (354 loc) · 23.6 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
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
<!DOCTYPE html>
<html lang="en" class="h-100">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>ACO Simulator</title>
<meta name="author" content="Thiago Ferreira">
<meta name="description" content="Ant Colony Optimization Simulator developed in HTML">
<meta name="keywords" content="aco, ant colony optimization, ant system, as, simulation, tsp, travelling salesman problem">
<meta name="robots" content="index, follow">
<!-- Vendor -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.5.0/css/flag-icon.min.css">
<!-- Application -->
<link rel="stylesheet" href="css/style.css" />
</head>
<body class="d-flex flex-column h-100">
<header>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary fixed-top">
<div class="container-fluid">
<a class="navbar-brand" href="#">ACO Simulator</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbar">
<ul class="navbar-nav me-auto">
</ul>
</div>
</div>
</nav>
</header>
<main class="flex-shrink-0">
<nav class="navbar navbar-expand navbar-light bg-light menubar py-0 my-0">
<div class="container-fluid">
<div class="collapse navbar-collapse" id="navbar">
<ul class="navbar-nav me-auto">
<li class="nav-item dropdown">
<a class="nav-link" href="#" id="navbarDropdown" data-bs-toggle="dropdown">File</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#" data-bs-toggle="modal" data-bs-target="#modal-import-csv"><i class="fa fa-upload"></i><span>Import .CSV</span></a></li>
<li><hr class="dropdown-divider"></li>
<li>
<a class="dropdown-item dropdown-item-no-click" href="#"><i class="fa fa-blank"></i><span>Export</span><i class="fa fa-chevron-right float-end mt-1"></i></a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item" href="#" id="menubar-export-canvas"><i class="fa fa-blank"></i><span>Canvas</span></a></li>
<li><a class="dropdown-item" href="#" id="menubar-export-positions"><i class="fa fa-blank"></i><span>Positions</span></a></li>
</ul>
</li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link" href="#" id="navbarDropdown" data-bs-toggle="dropdown">Edit</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" id="menubar-clear-all" href="#"><i class="fa fa-blank"></i><span>Clear All</span></a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" data-bs-toggle="modal" data-bs-target="#modal-settings" href="#"><i class="fa fa-cog"></i><span>Settings</span></a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link" href="#" id="navbarDropdown" data-bs-toggle="dropdown">View</a>
<ul class="dropdown-menu">
<li>
<label class="dropdown-item dropdown-item-checkbox" for="menubar-view-pheromones">
<input class="form-check-input" type="checkbox" value="" id="menubar-view-pheromones"/>
<span>Pheromones</span>
</label>
</li>
<li>
<label class="dropdown-item dropdown-item-checkbox" for="menubar-view-shortest-path">
<input class="form-check-input" type="checkbox" value="" id="menubar-view-shortest-path" checked/>
<span>Shortest Path</span>
</label>
</li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link" href="#" id="navbarDropdown" data-bs-toggle="dropdown">Insert</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" id="menubar-insert-circles" href="#"><i class="far fa-circle"></i><span>Circles</span></a></li>
<li><a class="dropdown-item" id="menubar-insert-squares" href="#"><i class="far fa-square"></i><span>Squares</span></a></li>
<li><hr class="dropdown-divider"></li>
<li>
<a class="dropdown-item dropdown-item-no-click" href="#"><i class="fa fa-blank"></i><span>Examples</span><i class="fa fa-chevron-right float-end mt-1"></i></a>
<ul class="submenu dropdown-menu">
<li><a class="dropdown-item examples" data-file="dj30.csv" href="#"><i class="fa fa-blank"></i><span>dj30.csv</span></a></li>
<li><a class="dropdown-item examples" data-file="oliver55.csv" href="#"><i class="fa fa-blank"></i><span>oliver55.csv</span></a></li>
</ul>
</li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item random" href="#"><i class="fa fa-dice"></i><span>Random</span></a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link" href="#" id="navbarDropdown" data-bs-toggle="dropdown">Help</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" target="_blank" href="https://en.wikipedia.org/wiki/Ant_colony_optimization_algorithms"><i class="fa fa-blank"></i><span>About ACO</span></a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div class="toolbar">
<div class="container-fluid">
<div class="row py-2">
<div class="col">
<div class="btn-toolbar">
<div class="btn-group disable-when-playing me-2 btn-group-control ">
<button id="play" class="btn btn-sm btn-outline-primary disable-when-playing"><i class="fa fa-play me-1"></i>Play</button>
<button id="step" class="btn btn-sm btn-outline-primary"><i class="fa fa-step-forward me-1"></i>Step</button>
<button id="stop" class="btn btn-sm btn-outline-primary" disabled><i class="fa fa-stop me-1"></i>Stop</button>
</div>
<div class="btn-group disable-when-playing me-2 btn-group-move">
<input type="radio" class="btn-check" name="options" id="add-node" autocomplete="off" checked>
<label class="btn btn-sm btn-outline-secondary text-center" for="add-node"><i class="fa fa-plus"></i></label>
<input type="radio" class="btn-check" name="options" id="move-node" autocomplete="off">
<label class="btn btn-sm btn-outline-secondary text-center" for="move-node"><i class="fa fa-mouse-pointer"></i></label>
</div>
<div class="btn-group btn-group-sm me-2 btn-group-speed">
<input type="radio" class="btn-check" name="ant-speed" id="slow" autocomplete="off" value="80" >
<label class="btn btn-outline-primary" for="slow">Slow</label>
<input type="radio" class="btn-check" name="ant-speed" id="normal" autocomplete="off" value="20" checked>
<label class="btn btn-outline-primary" for="normal">Normal</label>
<input type="radio" class="btn-check" name="ant-speed" id="fast" autocomplete="off" value="5">
<label class="btn btn-outline-primary" for="fast">Fast</label>
<input type="radio" class="btn-check" name="ant-speed" id="crazy" autocomplete="off" value="1">
<label class="btn btn-outline-primary" for="crazy">Crazy</label>
</div>
</div>
</div>
<div class="col-auto">
<!-- <a class="btn btn-sm btn-success" href=""><i class="fa fa-share-alt me-1"></i>Share</a> -->
</div>
</div>
</div>
</div>
<div class="container-fluid mt-2">
<div class="row">
<div class="col-lg-9 mb-0 mb-3 mb-lg-0">
<canvas id="canvas"></canvas>
</div>
<div class="col-lg-3 mb-0 mb-3 mb-lg-0">
<div id="sidebar" class="card">
<div class="card-header">
<ul class="nav nav-tabs card-header-tabs">
<li class="nav-item">
<button class="nav-link active" data-toggle="tab" data-bs-toggle="tab" data-bs-target="#info" data-i18n="info">Info</button >
</li>
<li class="nav-item">
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#parameters" data-i18n="parameters">Parameters</button >
</li>
</ul>
</div>
<div class="card-body overflow-auto">
<div class="tab-content">
<div class="tab-pane fade show active" id="info">
<div class="row mb-3">
<div class="col-6">
<div class="card card-body text-center text-dark bg-light px-0 py-1">
<p class="fs-5 mb-0 generation-counter">0</p>
<small class="text-muted">Generations</small>
</div>
</div>
<div class="col-6">
<div class="card card-body text-center text-dark bg-light px-0 py-1">
<p class="fs-5 mb-0 shortest-distance">NaN</p>
<small class="text-muted">Shortest Distance</small>
</div>
</div>
</div>
<div class="input-group input-group-sm mb-3">
<label class="input-group-text bg-light fw-normal text-muted" for="shortest-path">Shortest Path</label >
<input type="text" class="form-control bg-white" id="shortest-path" readonly>
</div>
<hr/>
<div class="charts ">
<div id="chart-global-shortest-distance"></div>
<div id="chart-average-shortest-distance"></div>
</div>
</div>
<div class="tab-pane fade" id="parameters">
<form id="form-parameters">
<div class="row mb-3">
<div class="col-6">
<label for="alpha" class="form-label" title="Relative influence of the pheromone">α (Pheromone)</label>
<input type="number" class="form-control" id="alpha" step="0.1" min="0.0" value="1.0" data-default-value="1.0" required>
</div>
<div class="col-6">
<label for="beta" class="form-label" title="Relative influence of the heuristic information">β (Heuristic)</label>
<input type="number" class="form-control" id="beta" step="0.1" min="0.0" value="2.0" data-default-value="2.0" required>
</div>
</div>
<div class="mb-3">
<label for="rho" class="form-label" title="pheromone trail evaporation">ρ (Evaporation)</label>
<input type="number" class="form-control" id="rho" step="0.1" min="0.0" max="1.0" value="0.1" data-default-value="0.1" required>
</div>
<div class="acs-parameters">
<div class="row mb-3">
<div class="col-6">
<label for="omega" class="form-label">Omega</label>
<input type="number" class="form-control" id="omega" step="0.1" min="0.0" max="1.0" value="0.1" data-default-value="0.1" required>
</div>
<div class="col-6">
<label for="q0" class="form-label">Q0</label>
<input type="number" class="form-control" id="q0" step="0.1" min="0.0" max="1.0" value="0.9" data-default-value="0.9" required>
</div>
</div>
</div>
<hr/>
<button type="submit" class="btn btn-success btn-sm">Update</button>
<button type="button" class="btn btn-light btn-sm" id="btn-reset-default-values">Reset</button>
</form>
</div>
</div>
</div>
</div> <!-- sidebar -->
</div>
</div>
</div>
<img id="ant-image" class="d-none" src="img/ant.png"/>
</main>
<footer class="footer mt-auto py-2 bg-light">
<div class="container-fluid small text-muted">
<div class="row">
<div class="col me-auto">
<span >Made with <i class="far fa-heart"></i> in JS</span>
</div>
<div class="col-auto">
<a href="old-version" class="text-decoration-none text-muted" target="_blank">Old Version</a>
<span class="mx-2">|</span>
<a href="https://github.com/thiagodnf/aco-simulator" class="text-decoration-none text-muted" target="_blank">Source Code</a>
<span class="mx-2">|</span>
<a href="#" class="text-decoration-none text-muted flag-icon flag-icon-us"></a>
<a href="#" class="text-decoration-none text-muted flag-icon flag-icon-br"></a>
</div>
</div>
</div>
</footer>
<!-- Modal -->
<div class="modal" id="modal-import-csv" tabindex="-1">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<form id="form-import-csv" action="#">
<div class="modal-header">
<h5 class="modal-title"><i class="fa fa-upload me-2"></i>Import .CSV</h5>
</div>
<div class="modal-body">
<div class="mb-3">
<label for="csv-file" class="form-label">File</label>
<input class="form-control" type="file" id="csv-file" required>
<small class="form-text">Use a comma to separate values.</small>
</div>
<div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="has-header">
<label class="form-check-label" for="has-header">Has Header</label>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Import</button>
<button type="button" class="btn btn-light" data-bs-dismiss="modal">Cancel</button>
</div>
</form>
</div>
</div>
</div>
<div class="modal" id="modal-settings" tabindex="-1">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<form id="form-settings" action="#">
<div class="modal-header">
<h5 class="modal-title"><i class="fa fa-cog me-2"></i>Settings</h5>
</div>
<div class="modal-body">
<div>
<label class="form-label" for="aco">ACO</label>
<select class="form-select" id="aco" required>
<option value="as" selected>Ant System</option>
<option value="acs">Ant Colony System</option>
</select>
</div>
<div class="mt-3">
<label for="random-seed" class="form-label">Random Seed</label>
<input type="number" class="form-control" id="random-seed" required>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Save</button>
<button type="button" class="btn btn-light" data-bs-dismiss="modal">Cancel</button>
</div>
</form>
</div>
</div>
</div>
<!-- Vendor -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/domurl@2.3.4/url.min.js"></script>
<script src="https://code.highcharts.com/highcharts.src.js"></script>
<script src="https://chancejs.com/chance.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/4.4.0/fabric.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/js/all.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.4/FileSaver.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/5.5.2/bootbox.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.i18n/1.0.7/jquery.i18n.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.i18n/1.0.7/jquery.i18n.messagestore.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.i18n/1.0.7/jquery.i18n.fallbacks.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.i18n/1.0.7/jquery.i18n.language.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.i18n/1.0.7/jquery.i18n.parser.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.i18n/1.0.7/jquery.i18n.emitter.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.i18n/1.0.7/jquery.i18n.emitter.bidi.min.js"></script>
<!-- Application -->
<!-- Util-->
<script src="js/utils/fabricjs-utils.js"></script>
<script src="js/utils/normalize-utils.js"></script>
<script src="js/utils/random-utils.js"></script>
<script src="js/utils/array-utils.js"></script>
<script src="js/utils/chart-utils.js"></script>
<script src="js/utils/file-utils.js"></script>
<script src="js/utils/bootbox-utils.js"></script>
<script src="js/utils/generator-utils.js"></script>
<script src="js/utils/nearest-neighbour.js"></script>
<script src="js/aco/subset/all-ants.js"></script>
<script src="js/aco/subset/global-best.js"></script>
<!-- Evaporation and Deposit-->
<script src="js/aco/pheromone/local-update/acs-local-update.js"></script>
<script src="js/aco/pheromone/global-update/global-update.js"></script>
<script src="js/aco/pheromone/global-update/evaporation/full-evaporation.js"></script>
<script src="js/aco/pheromone/global-update/deposit/partial-deposit.js"></script>
<script src="js/aco/pheromone/global-update/deposit/full-deposit.js"></script>
<!-- Exploration-->
<script src="js/aco/exploration/ant-exploration.js"></script>
<script src="js/aco/exploration/pseudo-random-proportional.js"></script>
<script src="js/aco/exploration/q-selection.js"></script>
<!-- Selection-->
<script src="js/aco/selection/ant-selection.js"></script>
<script src="js/aco/selection/roulette-wheel.js"></script>
<!-- ACO-->
<script src="js/aco/aco.js"></script>
<script src="js/aco/random-system.js"></script>
<script src="js/aco/ant-system.js"></script>
<script src="js/aco/ant-colony-system.js"></script>
<!-- Model -->
<script src="js/aco/model/ant.js"></script>
<script src="js/aco/model/node.js"></script>
<script src="js/aco/model/environment.js"></script>
<script src="js/canvas.js"></script>
<script src="js/events.js"></script>
<script src="js/script.js"></script>
</body>
</html>