Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/EvaluationResult.cs @ 17357

Last change on this file since 17357 was 17357, checked in by mkommend, 4 years ago

#2521: Added solution context and evaluation results.

File size: 3.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 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
22using System.Collections.Generic;
23using HEAL.Attic;
24using HeuristicLab.Common;
25using HeuristicLab.Core;
26
27namespace HeuristicLab.Optimization {
28
29  //TODO maybe change EvaluationResult from class to struct
30  //TODO implement indexer instead of get/set additional data
31  [StorableType("3E4F5781-0DDB-4B7A-99E2-89C3F1028EB1")]
32  public abstract class EvaluationResult : Item, IEvaluationResult {
33
34    [Storable]
35    private readonly Dictionary<string, object> data = new Dictionary<string, object>();
36
37    protected EvaluationResult() : base() { }
38
39
40    [StorableConstructor]
41    protected EvaluationResult(StorableConstructorFlag _) : base(_) { }
42
43    protected EvaluationResult(EvaluationResult original, Cloner cloner) : base(original, cloner) {
44      //TODO clone data dictionary
45    }
46
47
48    public void SetAdditionalData(string identifier, object o) {
49      data[identifier] = o;
50    }
51    public object GetAdditionalData(string identifier) {
52      return data[identifier];
53    }
54
55  }
56
57  [StorableType("1468E570-64D1-43A5-8B0A-B7821BFAE708")]
58  public class SingleObjectiveEvaluationResult : EvaluationResult, ISingleObjectiveEvaluationResult {
59    [Storable]
60    public double Quality { get; private set; }
61
62    public SingleObjectiveEvaluationResult(double quality) {
63      Quality = quality;
64    }
65
66    [StorableConstructor]
67    protected SingleObjectiveEvaluationResult(StorableConstructorFlag _) : base(_) { }
68
69    public SingleObjectiveEvaluationResult(SingleObjectiveEvaluationResult original, Cloner cloner) : base(original, cloner) {
70      Quality = original.Quality;
71    }
72
73    public override IDeepCloneable Clone(Cloner cloner) {
74      return new SingleObjectiveEvaluationResult(this, cloner);
75    }
76  }
77
78  [StorableType("6D2B628D-E3B0-4C0A-8A2E-61BC8F38439B")]
79  public class MultiObjectiveEvaluationResult : EvaluationResult, IMultiObjectiveEvaluationResult {
80    [Storable]
81    public double[] Quality { get; private set; }
82
83    public MultiObjectiveEvaluationResult(double[] quality) {
84      Quality = quality;
85    }
86
87    [StorableConstructor]
88    protected MultiObjectiveEvaluationResult(StorableConstructorFlag _) : base(_) { }
89
90    public MultiObjectiveEvaluationResult(MultiObjectiveEvaluationResult original, Cloner cloner) : base(original, cloner) {
91      Quality = original.Quality;
92    }
93
94    public override IDeepCloneable Clone(Cloner cloner) {
95      return new MultiObjectiveEvaluationResult(this, cloner);
96    }
97  }
98}
Note: See TracBrowser for help on using the repository browser.