Last change
on this file since 17717 was
17479,
checked in by kyang, 5 years ago
|
#3057
- upload the latest version of ALPS with SMS-EMOA
- upload the related dynamic test problems (dynamic, single-objective symbolic regression), written by David Daninel.
|
File size:
1.7 KB
|
Line | |
---|
1 | using HEAL.Attic;
|
---|
2 | using System;
|
---|
3 | using System.Collections.Generic;
|
---|
4 | using System.Linq;
|
---|
5 | using System.Text;
|
---|
6 | using System.Threading.Tasks;
|
---|
7 |
|
---|
8 | namespace HeuristicLab.Algorithms.OESRALPS.DriftDetection
|
---|
9 | {
|
---|
10 | [StorableType("719CE0E4-A88F-44A1-A2D0-92F4D8052C04")]
|
---|
11 | class ADWINWrapper
|
---|
12 | {
|
---|
13 | [Storable]
|
---|
14 | private ADWIN adwin;
|
---|
15 |
|
---|
16 | [Storable]
|
---|
17 | private Histogram histogram;
|
---|
18 |
|
---|
19 | [Storable]
|
---|
20 | public int Count { get; set; }
|
---|
21 | [Storable]
|
---|
22 | public int NumElementsProcessed { get; set; }
|
---|
23 | [Storable]
|
---|
24 | public int MaximumBucketsPerContainer { get; set; }
|
---|
25 |
|
---|
26 | public ADWINWrapper() { }
|
---|
27 |
|
---|
28 | public ADWINWrapper(double delta, int maximumBucketsPerContainer, int minKeepSize = 100, int minCutSize = 100)
|
---|
29 | {
|
---|
30 | histogram = new Histogram(maximumBucketsPerContainer);
|
---|
31 | adwin = new SequentialADWIN(delta, minKeepSize, minCutSize);
|
---|
32 | NumElementsProcessed = 0;
|
---|
33 | Count = 0;
|
---|
34 | MaximumBucketsPerContainer = maximumBucketsPerContainer;
|
---|
35 | }
|
---|
36 |
|
---|
37 | public bool AddElement(double element)
|
---|
38 | {
|
---|
39 | NumElementsProcessed++;
|
---|
40 | histogram.AddElement(element);
|
---|
41 | Count++;
|
---|
42 | return adwin.Execute(ref histogram);
|
---|
43 | }
|
---|
44 |
|
---|
45 |
|
---|
46 | public void Reset()
|
---|
47 | {
|
---|
48 | Count = 0;
|
---|
49 | }
|
---|
50 |
|
---|
51 | public int WindowSize {
|
---|
52 | get { return histogram.NumElements; }
|
---|
53 | }
|
---|
54 |
|
---|
55 | public int RemoveOldestInstances()
|
---|
56 | {
|
---|
57 | int startElementsCount = WindowSize;
|
---|
58 | histogram.RemoveBuckets(1);
|
---|
59 | return startElementsCount - WindowSize;
|
---|
60 | }
|
---|
61 | }
|
---|
62 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.