[7247] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[7259] | 3 | * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[7247] | 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Drawing;
|
---|
| 24 | using System.Threading;
|
---|
| 25 | using HeuristicLab.Common;
|
---|
| 26 | using HeuristicLab.Core;
|
---|
| 27 | using HeuristicLab.Optimization;
|
---|
| 28 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 29 |
|
---|
| 30 | namespace HeuristicLab.Algorithms.Benchmarks {
|
---|
| 31 | [Item("Benchmark", "Base class for benchmarks.")]
|
---|
| 32 | [StorableClass]
|
---|
| 33 | public abstract class Benchmark : IBenchmark {
|
---|
| 34 | public virtual string ItemName {
|
---|
| 35 | get { return ItemAttribute.GetName(this.GetType()); }
|
---|
| 36 | }
|
---|
| 37 | public virtual string ItemDescription {
|
---|
| 38 | get { return ItemAttribute.GetDescription(this.GetType()); }
|
---|
| 39 | }
|
---|
| 40 | public Version ItemVersion {
|
---|
| 41 | get { return ItemAttribute.GetVersion(this.GetType()); }
|
---|
| 42 | }
|
---|
| 43 | public static Image StaticItemImage {
|
---|
| 44 | get { return HeuristicLab.Common.Resources.VSImageLibrary.Event; }
|
---|
| 45 | }
|
---|
| 46 | public virtual Image ItemImage {
|
---|
| 47 | get { return ItemAttribute.GetImage(this.GetType()); }
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | [Storable]
|
---|
| 51 | private byte[][] chunk;
|
---|
| 52 | public byte[][] ChunkData {
|
---|
| 53 | get { return chunk; }
|
---|
| 54 | set { chunk = value; }
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | [Storable]
|
---|
| 58 | private TimeSpan timeLimit;
|
---|
| 59 | public TimeSpan TimeLimit {
|
---|
| 60 | get { return timeLimit; }
|
---|
| 61 | set { timeLimit = value; }
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | [StorableConstructor]
|
---|
| 65 | protected Benchmark(bool deserializing) { }
|
---|
| 66 | protected Benchmark(Benchmark original, Cloner cloner) {
|
---|
| 67 | cloner.RegisterClonedObject(original, this);
|
---|
| 68 | }
|
---|
| 69 | protected Benchmark() { }
|
---|
| 70 |
|
---|
| 71 | public object Clone() {
|
---|
| 72 | return Clone(new Cloner());
|
---|
| 73 | }
|
---|
| 74 | public abstract IDeepCloneable Clone(Cloner cloner);
|
---|
| 75 |
|
---|
| 76 | public abstract void Run(CancellationToken token, ResultCollection results);
|
---|
| 77 |
|
---|
| 78 | public override string ToString() {
|
---|
| 79 | return ItemName;
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | public event EventHandler ItemImageChanged;
|
---|
| 83 | protected virtual void OnItemImageChanged() {
|
---|
| 84 | EventHandler handler = ItemImageChanged;
|
---|
| 85 | if (handler != null) handler(this, EventArgs.Empty);
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | public event EventHandler ToStringChanged;
|
---|
| 89 | protected virtual void OnToStringChanged() {
|
---|
| 90 | EventHandler handler = ToStringChanged;
|
---|
| 91 | if (handler != null) handler(this, EventArgs.Empty);
|
---|
| 92 | }
|
---|
| 93 | }
|
---|
| 94 | }
|
---|