1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
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.Linq;
|
---|
24 | using HeuristicLab.Common;
|
---|
25 | using HeuristicLab.Core;
|
---|
26 | using HeuristicLab.Data;
|
---|
27 | using HeuristicLab.Optimization;
|
---|
28 | using HeuristicLab.Parameters;
|
---|
29 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
30 | using HeuristicLab.Problems.DataAnalysis;
|
---|
31 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
32 | using System.Collections.Generic;
|
---|
33 | using HeuristicLab.Problems.DataAnalysis.Symbolic;
|
---|
34 |
|
---|
35 | namespace HeuristicLab.Algorithms.DataAnalysis {
|
---|
36 | [StorableClass]
|
---|
37 | public abstract class FixedDataAnalysisAlgorithm<T> : Algorithm,
|
---|
38 | IDataAnalysisAlgorithm<T>,
|
---|
39 | IStorableContent
|
---|
40 | where T : class, IDataAnalysisProblem {
|
---|
41 | public string Filename { get; set; }
|
---|
42 |
|
---|
43 | #region Properties
|
---|
44 | public override Type ProblemType {
|
---|
45 | get { return typeof(T); }
|
---|
46 | }
|
---|
47 | public new T Problem {
|
---|
48 | get { return (T)base.Problem; }
|
---|
49 | set { base.Problem = value; }
|
---|
50 | }
|
---|
51 | [Storable]
|
---|
52 | private ResultCollection results;
|
---|
53 | public override ResultCollection Results {
|
---|
54 | get { return results; }
|
---|
55 | }
|
---|
56 | #endregion
|
---|
57 |
|
---|
58 | [StorableConstructor]
|
---|
59 | protected FixedDataAnalysisAlgorithm(bool deserializing) : base(deserializing) { }
|
---|
60 | protected FixedDataAnalysisAlgorithm(FixedDataAnalysisAlgorithm<T> original, Cloner cloner)
|
---|
61 | : base(original, cloner) {
|
---|
62 | results = cloner.Clone(original.Results);
|
---|
63 | }
|
---|
64 | public FixedDataAnalysisAlgorithm()
|
---|
65 | : base() {
|
---|
66 | results = new ResultCollection();
|
---|
67 | }
|
---|
68 |
|
---|
69 | public override void Prepare() {
|
---|
70 | if (Problem != null) base.Prepare();
|
---|
71 | results.Clear();
|
---|
72 | OnPrepared();
|
---|
73 | }
|
---|
74 |
|
---|
75 | public override void Start() {
|
---|
76 | base.Start();
|
---|
77 | OnStarted();
|
---|
78 | Run();
|
---|
79 | OnStopped();
|
---|
80 | }
|
---|
81 |
|
---|
82 | #region Events
|
---|
83 | protected override void OnProblemChanged() {
|
---|
84 | Problem.Reset += new EventHandler(Problem_Reset);
|
---|
85 | base.OnProblemChanged();
|
---|
86 | }
|
---|
87 |
|
---|
88 | #endregion
|
---|
89 |
|
---|
90 | protected abstract void Run();
|
---|
91 | }
|
---|
92 | }
|
---|