-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.README.md.html
749 lines (665 loc) · 28.6 KB
/
.README.md.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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>C:\Users\fran\workspace-evolution\evolution\.README.md.html</title>
<style type="text/css">
body {
color: #333;
font: 13px/1.4 "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif;
padding: 0;
margin: 0;
}
a {
background: transparent;
color: #4183c4;
text-decoration: none;
}
a:active,
a:hover {
outline: 0 none;
text-decoration: underline;
}
abbr[title] {
border-bottom: 1px dotted;
}
b,
strong {
font-weight: bold;
}
dfn {
font-style: italic;
}
h1 {
font-size: 2em;
margin: 0.67em 0;
}
mark {
background: #ff0;
color: #000;
}
small {
font-size: 80%;
}
sub, sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sup {
top: -0.5em;
}
sub {
bottom: -0.25em;
}
img {
border: 0 none;
}
svg:not(:root) {
overflow: hidden;
}
figure {
margin: 1em 40px;
}
hr {
box-sizing: content-box;
height: 0;
}
code,
kbd,
pre,
samp {
font-family: monospace,monospace;
font-size: 1em;
}
pre {
overflow: auto;
font: 12px Consolas,"Liberation Mono",Menlo,Courier,monospace;
margin-bottom: 0;
margin-top: 0;
}
.markdown-body {
padding: 30px;
font-size: 16px;
line-height: 1.6;
word-wrap: break-word;
}
.markdown-body>*:first-child {
margin-top: 0 !important;
}
.markdown-body>*:last-child {
margin-bottom: 0 !important;
}
.markdown-body .absent {
color: #c00;
}
.markdown-body .anchor {
position: absolute;
top: 0;
bottom: 0;
left: 0;
display: block;
padding-right: 6px;
padding-left: 30px;
margin-left: -30px;
}
.markdown-body .anchor:focus {
outline: none;
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
position: relative;
margin-top: 1em;
margin-bottom: 16px;
font-weight: bold;
line-height: 1.4;
}
.markdown-body h1 .octicon-link,
.markdown-body h2 .octicon-link,
.markdown-body h3 .octicon-link,
.markdown-body h4 .octicon-link,
.markdown-body h5 .octicon-link,
.markdown-body h6 .octicon-link {
display: none;
color: #000;
vertical-align: middle;
}
.markdown-body h1:hover .anchor,
.markdown-body h2:hover .anchor,
.markdown-body h3:hover .anchor,
.markdown-body h4:hover .anchor,
.markdown-body h5:hover .anchor,
.markdown-body h6:hover .anchor {
padding-left: 8px;
margin-left: -30px;
line-height: 1;
text-decoration: none;
}
.markdown-body h1:hover .anchor .octicon-link,
.markdown-body h2:hover .anchor .octicon-link,
.markdown-body h3:hover .anchor .octicon-link,
.markdown-body h4:hover .anchor .octicon-link,
.markdown-body h5:hover .anchor .octicon-link,
.markdown-body h6:hover .anchor .octicon-link {
display: inline-block;
}
.markdown-body h1 tt,
.markdown-body h1 code,
.markdown-body h2 tt,
.markdown-body h2 code,
.markdown-body h3 tt,
.markdown-body h3 code,
.markdown-body h4 tt,
.markdown-body h4 code,
.markdown-body h5 tt,
.markdown-body h5 code,
.markdown-body h6 tt,
.markdown-body h6 code {
font-size: inherit;
}
.markdown-body h1 {
padding-bottom: 0.3em;
font-size: 2.25em;
line-height: 1.2;
border-bottom: 1px solid #eee;
}
.markdown-body h2 {
padding-bottom: 0.3em;
font-size: 1.75em;
line-height: 1.225;
border-bottom: 1px solid #eee;
}
.markdown-body h3 {
font-size: 1.5em;
line-height: 1.43;
}
.markdown-body h4 {
font-size: 1.25em;
}
.markdown-body h5 {
font-size: 1em;
}
.markdown-body h6 {
font-size: 1em;
color: #777;
}
.markdown-body p,.markdown-body blockquote,
.markdown-body ul,.markdown-body ol,
.markdown-body dl,.markdown-body table,
.markdown-body pre {
margin-top: 0;
margin-bottom: 16px;
}
.markdown-body hr {
height: 4px;
padding: 0;
margin: 16px 0;
background-color: #e7e7e7;
border: 0 none;
}
.markdown-body ul,
.markdown-body ol {
padding-left: 2em;
}
.markdown-body ul.no-list,
.markdown-body ol.no-list {
padding: 0;
list-style-type: none;
}
.markdown-body ul ul,
.markdown-body ul ol,
.markdown-body ol ol,
.markdown-body ol ul {
margin-top: 0;
margin-bottom: 0;
}
.markdown-body li>p {
margin-top: 16px;
}
.markdown-body dl {
padding: 0;
}
.markdown-body dl dt {
padding: 0;
margin-top: 16px;
font-size: 1em;
font-style: italic;
font-weight: bold;
}
.markdown-body dl dd {
padding: 0 16px;
margin-bottom: 16px;
}
.markdown-body blockquote {
padding: 0 15px;
color: #777;
border-left: 4px solid #ddd;
}
.markdown-body blockquote>:first-child {
margin-top: 0;
}
.markdown-body blockquote>:last-child {
margin-bottom: 0;
}
.markdown-body table {
display: block;
width: 100%;
overflow: auto;
word-break: normal;
word-break: keep-all;
}
.markdown-body table th {
font-weight: bold;
}
.markdown-body table th,
.markdown-body table td {
padding: 6px 13px;
border: 1px solid #ddd;
}
.markdown-body table tr {
background-color: #fff;
border-top: 1px solid #ccc;
}
.markdown-body table tr:nth-child(2n) {
background-color: #f8f8f8;
}
.markdown-body img {
max-width: 100%;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.markdown-body span.frame {
display: block;
overflow: hidden;
}
.markdown-body span.frame>span {
display: block;
float: left;
width: auto;
padding: 7px;
margin: 13px 0 0;
overflow: hidden;
border: 1px solid #ddd;
}
.markdown-body span.frame span img {
display: block;
float: left;
}
.markdown-body span.frame span span {
display: block;
padding: 5px 0 0;
clear: both;
color: #333;
}
.markdown-body span.align-center {
display: block;
overflow: hidden;
clear: both;
}
.markdown-body span.align-center>span {
display: block;
margin: 13px auto 0;
overflow: hidden;
text-align: center;
}
.markdown-body span.align-center span img {
margin: 0 auto;
text-align: center;
}
.markdown-body span.align-right {
display: block;
overflow: hidden;
clear: both;
}
.markdown-body span.align-right>span {
display: block;
margin: 13px 0 0;
overflow: hidden;
text-align: right;
}
.markdown-body span.align-right span img {
margin: 0;
text-align: right;
}
.markdown-body span.float-left {
display: block;
float: left;
margin-right: 13px;
overflow: hidden;
}
.markdown-body span.float-left span {
margin: 13px 0 0;
}
.markdown-body span.float-right {
display: block;
float: right;
margin-left: 13px;
overflow: hidden;
}
.markdown-body span.float-right>span {
display: block;
margin: 13px auto 0;
overflow: hidden;
text-align: right;
}
.markdown-body code,.markdown-body tt {
padding: 0;
padding-top: 0.2em;
padding-bottom: 0.2em;
margin: 0;
font-size: 85%;
background-color: rgba(0,0,0,0.04);
border-radius: 3px;
}
.markdown-body code:before,
.markdown-body code:after,
.markdown-body tt:before,
.markdown-body tt:after {
letter-spacing: -0.2em;
content: "\00a0";
}
.markdown-body code br,
.markdown-body tt br {
display: none;
}
.markdown-body del code {
text-decoration: inherit;
}
.markdown-body pre>code {
padding: 0;
margin: 0;
font-size: 100%;
word-break: normal;
white-space: pre;
background: transparent;
border: 0;
}
.markdown-body .highlight {
margin-bottom: 16px;
}
.markdown-body .highlight pre,
.markdown-body pre {
padding: 16px;
overflow: auto;
font-size: 85%;
line-height: 1.45;
background-color: #f7f7f7;
border-radius: 3px;
}
.markdown-body .highlight pre {
margin-bottom: 0;
word-break: normal;
}
.markdown-body pre {
word-wrap: normal;
}
.markdown-body pre code,
.markdown-body pre tt {
display: inline;
max-width: initial;
padding: 0;
margin: 0;
overflow: initial;
line-height: inherit;
word-wrap: normal;
background-color: transparent;
border: 0;
}
.markdown-body pre code:before,
.markdown-body pre code:after,
.markdown-body pre tt:before,
.markdown-body pre tt:after {
content: normal;
}
.highlight .pl-coc,
.highlight .pl-entl,
.highlight .pl-entm,
.highlight .pl-eoa,
.highlight .pl-mai .pl-sf,
.highlight .pl-mm,
.highlight .pl-pdv,
.highlight .pl-sc,
.highlight .pl-som,
.highlight .pl-sr,
.highlight .pl-v,
.highlight .pl-vpf {
color: #0086b3;
}
.highlight .pl-eoac,
.highlight .pl-mdht,
.highlight .pl-mi1,
.highlight .pl-mri,
.highlight .pl-va,
.highlight .pl-vpu {
color: #008080;
}
.highlight .pl-c,
.highlight .pl-pdc {
color: #b4b7b4;
font-style: italic;
}
.highlight .pl-k,
.highlight .pl-ko,
.highlight .pl-kolp,
.highlight .pl-mc,
.highlight .pl-mr,
.highlight .pl-ms,
.highlight .pl-s,
.highlight .pl-sok,
.highlight .pl-st {
color: #6e5494;
}
.highlight .pl-ef,
.highlight .pl-enf,
.highlight .pl-enm,
.highlight .pl-entc,
.highlight .pl-eoi,
.highlight .pl-sf,
.highlight .pl-smc {
color: #d12089;
}
.highlight .pl-ens,
.highlight .pl-eoai,
.highlight .pl-kos,
.highlight .pl-mh .pl-pdh,
.highlight .pl-mp,
.highlight .pl-pde,
.highlight .pl-stp {
color: #458;
}
.highlight .pl-enti {
color: #d12089;
font-weight: bold;
}
.highlight .pl-cce,
.highlight .pl-enc,
.highlight .pl-kou,
.highlight .pl-mq {
color: #f93;
}
.highlight .pl-mp1 .pl-sf {
color: #458;
font-weight: bold;
}
.highlight .pl-cos,
.highlight .pl-ent,
.highlight .pl-md,
.highlight .pl-mdhf,
.highlight .pl-ml,
.highlight .pl-pdc1,
.highlight .pl-pds,
.highlight .pl-s1,
.highlight .pl-scp,
.highlight .pl-sol {
color: #df5000;
}
.highlight .pl-c1,
.highlight .pl-cn,
.highlight .pl-pse,
.highlight .pl-pse .pl-s2,
.highlight .pl-vi {
color: #a31515;
}
.highlight .pl-mb,
.highlight .pl-pdb {
color: #df5000;
font-weight: bold;
}
.highlight .pl-mi,
.highlight .pl-pdi {
color: #6e5494;
font-style: italic;
}
.highlight .pl-ms1 {
background-color: #f5f5f5;
}
.highlight .pl-mdh,
.highlight .pl-mdi {
font-weight: bold;
}
.highlight .pl-mdr {
color: #0086b3;
font-weight: bold;
}
.highlight .pl-s2 {
color: #333;
}
.highlight .pl-ii {
background-color: #df5000;
color: #fff;
}
.highlight .pl-ib {
background-color: #f93;
}
.highlight .pl-id {
background-color: #a31515;
color: #fff;
}
.highlight .pl-iu {
background-color: #b4b7b4;
}
.highlight .pl-mo {
color: #969896;
}
</style>
<script type="text/javascript">
function getDocumentScrollTop()
{
var res = document.body.scrollTop || document.documentElement.scrollTop || window.pageYOffset || 0;
// alert(res);
return res;
}
function setDocumentScrollTop(ypos)
{
window.scrollTo(0, ypos);
}
</script>
</head>
<body class="markdown-body">
<h1> <a id="user-content-differential-evolution" class="anchor" href="#differential-evolution" aria-hidden="true"><span class="octicon octicon-link"></span></a>Differential Evolution</h1>
<p>This project implements differential evolution in pure Java 8. Differential evolution (DE) is a metaheuristic optimization algorithm. Optimization is done iteratively, successively improving candidate solutions with respect to a fitness measure. DE makes very few assumptions about the structure of the problem, and, unlike many other methods, does not require the gradient. Thus, differential evolution can tackle problems that not differentiable, are noisy, or have multiple minima. This implementation can also handle arbitrary (non-linear) constraints. The trade-off is that DE is not guaranteed to find an optimal solution, either local or global.</p>
<p>As mentioned, at a high-level, the DE algorithm consists of continually improving a pool of candidate parameter vectors. The pool of candidates are first initialized by randomly generating candidates within the boundaries of the problem. At each step of the algorithm, each candidate builds a number of <i>child</i> vectors by means of two fundamental operations, <i>differentiation</i> and <i>recombination</i>. Finally, <i>diversity</i> and <i>selection</i> are carried out first determine which is the best child; and, second, if the said child should replace the parent in the candidate pool.</p>
<h2> <a id="user-content-problems" class="anchor" href="#problems" aria-hidden="true"><span class="octicon octicon-link"></span></a>Problems</h2>
<p>A <i><a href="http://syenkoc.github.io/evolution/javadocs/index.html?com/chupacadabra/evolution/DifferentialEvolutionProblem.html">differential evolution problem</a></i> consists (minimally) of the following:</p>
<ul>
<li>The <i>dimension</i> of the problem. This is length (in <i>R</i><sup>n</sup>) of the candidate vectors.</li>
<li>A <i><a href="http://syenkoc.github.io/evolution/javadocs/index.html?com/chupacadabra/evolution/RandomParametersFunction.html">random parameter vector generator</a></i> that randomly constructs candidates over the search space.<br /> </li>
<li>A <i><a href="http://syenkoc.github.io/evolution/javadocs/index.html?com/chupacadabra/evolution/FitnessFunction.html">fitness function </a></i> that measures how well a candidate vector is to achieving the optimal value. This behaves like a cost function in the sense that lower is better. </li>
</ul>
<p>In order to handle constraints, we use a modified version of the method proposed by Mezura-Montes <i>et al</i>. In this scheme, candidates are first <a href="http://syenkoc.github.io/evolution/javadocs/index.html?com/chupacadabra/evolution/FeasibilityFunction.html">classified</a> with respect to some user-defined set of constraints. A <i>feasible</i> candidate is one that is not violating any constraints. A candidate <i>in violation</i> is violating one or more of the constraints, but it is still possible to compute a valid fitness for such a candidate. Finally, a candidate is <i>infeasible</i> if it not possible to compute a fitness measure. This ternary candidate classification exists because we may want to keep a violating candidate in the pool if it is exploring an "interesting" area of the search space; whereas we want to reject outright candidates for which it is impossible to compute a fitness measure.</p>
<p>For a candidate in violation, a <i><a href="http://syenkoc.github.io/evolution/javadocs/index.html?com/chupacadabra/evolution/ViolationFunction.html">violation function</a></i> (essentially a <i>second</i> cost function) measures the degree of violation. This function is <b>not</b> the same as the fitness function, and, in fact, the values from the two function are never directly compared. This avoids the complex "tuning" often required with penalty and barrier methods.</p>
<p>By default, problems assumes that all parameter vectors are feasible; and the violation of all candidates is 0. </p>
<p>Finally, a problem can optionally supply <i><a href="http://syenkoc.github.io/evolution/javadocs/index.html?com/chupacadabra/evolution/TerminationCriterion.html">termination criteria</a></i>. These are user-defined functions that indicate whether the optimization should terminate. A few very common "canned" criteria are already implemented:</p>
<ul>
<li>The optimization reaches a <a href="http://syenkoc.github.io/evolution/javadocs/index.html?com/chupacadabra/evolution/MaximumTime.html">time limit</a>. </li>
<li>The best candidate achieves <a href="http://syenkoc.github.io/evolution/javadocs/com/chupacadabra/evolution/FitnessAchieved.html">a desired level of fitness</a>. By default, </li>
</ul>
<h3> <a id="user-content-simple-example-problem" class="anchor" href="#simple-example-problem" aria-hidden="true"><span class="octicon octicon-link"></span></a>Simple Example Problem</h3>
<p>Here we present a simple example of how to construct and optimize a problem. The problem in this case is to optimize the function <code>f(x) = x<sup>2</sup>/10 + 4 * sin(x)</code> on the interval (-10, 10). If you look at the graph of this function, you will see that it has several local minima, so a gradient-type optimizer could easily become stuck in depending on starting point. This function has a global minimum at <code>x ~ -1.49593</code>, where <code>f(x) ~ -3.76501</code>.</p>
<p><a href="https://camo.githubusercontent.com/3914602950cd74773bd07cf1f838783e55e1479e/687474703a2f2f7379656e6b6f632e6769746875622e696f2f65766f6c7574696f6e2f696d616765732f6578616d706c652e706e67" target="_blank"><img src="https://camo.githubusercontent.com/3914602950cd74773bd07cf1f838783e55e1479e/687474703a2f2f7379656e6b6f632e6769746875622e696f2f65766f6c7574696f6e2f696d616765732f6578616d706c652e706e67" alt="Example function" data-canonical-src="http://syenkoc.github.io/evolution/images/example.png" style="max-width:100%;" /></a></p>
<div class="highlight highlight-source-java">
<pre><span class="pl-c">// construct our fitness function.</span>
<span class="pl-smi">FitnessFunction</span> fitnessFunction <span class="pl-k">=</span> (<span class="pl-k">double</span>[] x) <span class="pl-k">-</span><span class="pl-k">></span> (x[<span class="pl-c1">0</span>] <span class="pl-k">*</span> x[<span class="pl-c1">0</span>] <span class="pl-k">/</span> <span class="pl-c1">10</span>) <span class="pl-k">+</span> (<span class="pl-c1">4</span> <span class="pl-k">*</span> <span class="pl-smi">Math</span><span class="pl-k">.</span>sin(x[<span class="pl-c1">0</span>]));
<span class="pl-c">// on of the most common cases for parameters is that they are described by a n-orthotope, i.e.</span>
<span class="pl-c">// an n-dimensional hypercube. This utility class allows us to easily create such parameter</span>
<span class="pl-c">// functions.</span>
<span class="pl-smi">NOrthotopeRandomParametersFunction</span> parameterFunction <span class="pl-k">=</span> <span class="pl-k">new</span> <span class="pl-smi">NOrthotopeRandomParametersFunction</span>(<span class="pl-c1">1</span>);
<span class="pl-c">// this will distribute the initial values of x on (-10, 10)</span>
parameterFunction<span class="pl-k">.</span>setParameterRange(<span class="pl-c1">0</span>, <span class="pl-k">-</span><span class="pl-c1">10</span>, <span class="pl-c1">10</span>);
<span class="pl-c">// now, set up a problem. The main problem API is an interface of getters; this implementation </span>
<span class="pl-c">// allows us to set everything directly.</span>
<span class="pl-smi">SimpleDifferentialEvolutionProblem</span> problem <span class="pl-k">=</span> <span class="pl-k">new</span> <span class="pl-smi">SimpleDifferentialEvolutionProblem</span>();
problem<span class="pl-k">.</span>setDimension(<span class="pl-c1">1</span>);
problem<span class="pl-k">.</span>setRandomParametersFunction(parameterFunction);
problem<span class="pl-k">.</span>setFitnessFunction(fitnessFunction);
<span class="pl-c">// create a suitable optimizer.</span>
<span class="pl-smi">DifferentialEvolutionOptimizer</span> optimizer <span class="pl-k">=</span> <span class="pl-k">new</span> <span class="pl-smi">SerialDifferentialEvolutionOptimizer</span>();
<span class="pl-c">// now just get the result!</span>
<span class="pl-smi">DifferentialEvolutionResult</span> result <span class="pl-k">=</span> optimizer<span class="pl-k">.</span>optimize(problem);
<span class="pl-c">// extract x and f(x).</span>
<span class="pl-k">double</span> x <span class="pl-k">=</span> result<span class="pl-k">.</span>getBestCandidate()<span class="pl-k">.</span>getParameters()[<span class="pl-c1">0</span>];
<span class="pl-k">double</span> fx <span class="pl-k">=</span> result<span class="pl-k">.</span>getBestCandidate()<span class="pl-k">.</span>getFitness();</pre>
</div>
<h2> <a id="user-content-policies" class="anchor" href="#policies" aria-hidden="true"><span class="octicon octicon-link"></span></a>Policies</h2>
<p>There are myriad variants of DE, but fundamentally they consist only of changing the differentiation, recombination, diversity, and selection methods. This framework uses the <a href="https://en.wikipedia.org/wiki/Strategy_pattern">policy pattern</a> to allow the user to control the inner workings of the optimizer. Specifically, the <i><a href="http://syenkoc.github.io/evolution/javadocs/index.html?com/chupacadabra/evolution/DifferentiationPolicy.html">differentiation policy</a></i>, <i><a href="http://syenkoc.github.io/evolution/javadocs/index.html?com/chupacadabra/evolution/RecombinationPolicy.html">recombination policy</a></i>, <i><a href="http://syenkoc.github.io/evolution/javadocs/index.html?com/chupacadabra/evolution/DiversityPolicy.html">diversity policy</a></i>, and <i><a href="http://syenkoc.github.io/evolution/javadocs/index.html?com/chupacadabra/evolution/SelectionPolicy.html"></a></i> functional interfaces allow you to plug in different strategies at run time.</p>
<p>These policies are grouped into a larger <i><a href="http://syenkoc.github.io/evolution/javadocs/index.html?com/chupacadabra/evolution/DifferentiationEvolutionSettings.html">settings</a></i>, class. Settings are optional, in the sense that "reasonable" defaults will be supplied if you do not configure settings yourself. In addition to the aforementioned policy functions, the settings also allow you to control several other optimizer properties: </p>
<ol>
<li>The <i>Maximum Generation</i> is simply the maximum number of generations that the optimizer will perform - assuming that no user-defined termination criterion (see below) is met. Note that unlike (most) other optimization algorithms, it is not considered an "error" to terminate due to reaching the maximum generation. This defaults to 333. </li>
<li>The <i>Pool Size</i> is the number of candidates in the pool. The default is 71. A good rule-of-thumb is to set this to roughly 10x the dimension of the problem. </li>
<li>The <i>Number of Children</i> that each candidate will generate per generation. Thus, the total number of children per generation is the pool size times the number of children. The default is 1. </li>
<li>The <i>Replacement Policy</i> determines when a more fit child candidate will replace its parent. The two options are to replace immediately, <i>i.e.</i> it will visible to the algorithm intra-generation; and afterwards. The default is to replace immediately.</li>
<li> <i>Exception Handling</i> controls how to deal with a runtime exception tossed by user-level code. The two options are to propagate the exception; or to terminate the algorithm and return the current optimum. The default is to propagate.</li>
<li>A <i>Random Generator</i> represents an abstraction of the <code><a href="https://docs.oracle.com/javase/8/docs/api/java/util/Random.html">java.util.Random</a></code> to allow you plug in different (pseudo) random number generators. The default implementation is a one backed by a bog-standard <code>java.util.Random</code> instance.</li>
</ol>
<h3> <a id="user-content-differentiation" class="anchor" href="#differentiation" aria-hidden="true"><span class="octicon octicon-link"></span></a>Differentiation</h3>
<p>Differentiation generates trial vectors </p>
<h3> <a id="user-content-recombination" class="anchor" href="#recombination" aria-hidden="true"><span class="octicon octicon-link"></span></a>Recombination</h3>
<p>Recombination breeds the trial vectors with the parent to produce <i>child</i> vectors. </p>
<h3> <a id="user-content-selection" class="anchor" href="#selection" aria-hidden="true"><span class="octicon octicon-link"></span></a>Selection</h3>
<p>Selection determines how the optimizer chooses between two candidates. The only provided, and thus default, implementation implements Deb's selection criteria. When comparing two candidates, these rules are:</p>
<ul>
<li>If both candidates are in violation, select the candidate with the lower violation value.</li>
<li>If one candidates is in violation but the other is not, select the non-violating candidate.</li>
<li>If neither candidate is in violation, select the candidate with the lower fitness.</li>
</ul>
<h3> <a id="user-content-diversity" class="anchor" href="#diversity" aria-hidden="true"><span class="octicon octicon-link"></span></a>Diversity</h3>
<p>The diversity policy determines the degree to which the optimizer bypasses the selection criteria and allows candidates into the pool based <i>solely</i> only the fitness measure. Two diversity policies are included by default:</p>
<ul>
<li>The <i><a href="http://syenkoc.github.io/evolution/javadocs/index.html?com/chupacadabra/evolution/NoDiversityPolicy.html">No diversity</a></i> policy does not allow any violating candidate into the pool.</li>
<li>The <i><a href="http://syenkoc.github.io/evolution/javadocs/index.html?com/chupacadabra/evolution/NoDiversityPolicy.html">fixed diversity</a></i> policy considers candidates based only on fitness with a fixed probability. <code>.1</code> is a reasonable choice for the probability in many cases.</li>
</ul>
<h2> <a id="user-content-optimizers" class="anchor" href="#optimizers" aria-hidden="true"><span class="octicon octicon-link"></span></a>Optimizers</h2>
<p>Finally, the <i><a href="http://syenkoc.github.io/evolution/javadocs/index.html?com/chupacadabra/evolution/DifferentialEvolutionOptimizer.html">optimizer interface</a></i> takes a problem (and, optionally, settings) and produces a result. The result contains the optimal candidate and the reason for termination (along with some timing data). There are currently three implementations:</p>
<p><a href="https://docs.oracle.com/javase/tutorial/essential/concurrency/forkjoin.html">fork-join model</a></p>
<h3> <a id="user-content-parallelism-and-threadsafety" class="anchor" href="#parallelism-and-threadsafety" aria-hidden="true"><span class="octicon octicon-link"></span></a>Parallelism and Threadsafety</h3>
<p>Differential evolution is amenable to parallel evaluation. The aforementioned executor and fork-join pool based implementations process each generation in parallel. (The serial optimizer obviously processes each generation serially.) The optimizers do not choose a level of parallelism (or other thread-related properties) directly; instead, that is done at the user-level by configuring a suitable executor or fork-join pool.</p>
<p>If you use a parallel optimizer, all of the problem and policy functions must be safe for use by multiple threads. All of the policy implementations provided with the framework are already threadsafe. You can obtain a threadsafe wrapper around any problem or policy function using the <a href="http://syenkoc.github.io/evolution/javadocs/com/chupacadabra/evolution/threadsafe/Threadsafe.html">Threadsafe</a> provider. This provider allows you to create threadsafe decorators using synchronization or <a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/ReentrantLock.html">java locks</a>. </p>
<h2> <a id="user-content-installation" class="anchor" href="#installation" aria-hidden="true"><span class="octicon octicon-link"></span></a>Installation</h2>
<p>This package is pushed to Maven Central, with the following coordinates:</p>
<h2> <a id="user-content-dependencies" class="anchor" href="#dependencies" aria-hidden="true"><span class="octicon octicon-link"></span></a>Dependencies</h2>
<p>There are no runtime dependencies. JUnit is brought in via Maven for unit testing only.</p>
<h2> <a id="user-content-javadocs" class="anchor" href="#javadocs" aria-hidden="true"><span class="octicon octicon-link"></span></a>Javadocs</h2>
<p>The Javadocs can be found here: <a href="http://syenkoc.github.io/evolution/javadocs/index.html"></a><a href="http://syenkoc.github.io/evolution/javadocs/index.html">http://syenkoc.github.io/evolution/javadocs/index.html</a></p>
<h2> <a id="user-content-contributing" class="anchor" href="#contributing" aria-hidden="true"><span class="octicon octicon-link"></span></a>Contributing</h2>
<ol>
<li>Fork it.</li>
<li>Create your feature branch: <code>git checkout -b my-new-feature</code> </li>
<li>Commit your changes: <code>git commit -am 'Add some feature'</code> </li>
<li>Push to the branch: <code>git push origin my-new-feature</code> </li>
<li>Submit a pull request.</li>
</ol>
<h2> <a id="user-content-history" class="anchor" href="#history" aria-hidden="true"><span class="octicon octicon-link"></span></a>History</h2>
<p>1.0.0, 1/1/2016: Initial release.</p>
<h2> <a id="user-content-license" class="anchor" href="#license" aria-hidden="true"><span class="octicon octicon-link"></span></a>License</h2>
<p>The MIT License (MIT)</p>
<p>Copyright (c) 2015-2016 Fran Lattanzio</p>
<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>
<p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>
<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
</body>
</html>