Line | |
---|
1 | using System.Collections.Generic;
|
---|
2 | using System.Drawing;
|
---|
3 | using System.Linq;
|
---|
4 | using HeuristicLab.Common;
|
---|
5 | using HeuristicLab.Common.Resources;
|
---|
6 | using HeuristicLab.Core;
|
---|
7 | using HeuristicLab.Optimization;
|
---|
8 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
9 |
|
---|
10 | namespace HeuristicLab.Analysis.FitnessLandscape {
|
---|
11 |
|
---|
12 | [Item("Aggregator", "Base class of aggreagtors that aggregate results collected from several trajectories.")]
|
---|
13 | [StorableClass]
|
---|
14 | public abstract class Aggregator<T> : NamedItem, IAggregator where T : class, IItem {
|
---|
15 |
|
---|
16 | public static new Image StaticItemImage { get { return VSImageLibrary.Database; } }
|
---|
17 | public override bool CanChangeName { get { return false; } }
|
---|
18 |
|
---|
19 | protected List<T> items = new List<T>();
|
---|
20 |
|
---|
21 | [StorableConstructor]
|
---|
22 | protected Aggregator(bool deserializing) : base(deserializing) { }
|
---|
23 | protected Aggregator(Aggregator<T> original, Cloner cloner)
|
---|
24 | : base(original, cloner) {
|
---|
25 | items = original.items.Select(i => cloner.Clone<IItem>(i)).Cast<T>().ToList();
|
---|
26 | }
|
---|
27 | public Aggregator() {
|
---|
28 | name = ItemName;
|
---|
29 | description = ItemDescription;
|
---|
30 | }
|
---|
31 | public virtual void MaybeAddResult(IResult result) {
|
---|
32 | T t = result.Value as T;
|
---|
33 | if (t != null)
|
---|
34 | items.Add(t);
|
---|
35 | }
|
---|
36 | public virtual void Reset() {
|
---|
37 | items.Clear();
|
---|
38 | }
|
---|
39 | public abstract IResult CreateResult();
|
---|
40 | }
|
---|
41 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.