Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/BestAverageWorstTours/CapacitatedTourAnalyzer.cs @ 17716

Last change on this file since 17716 was 17716, checked in by abeham, 4 years ago

#2521: changed storable type guids

File size: 3.8 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.Linq;
23using HEAL.Attic;
24using HeuristicLab.Analysis;
25using HeuristicLab.Common;
26using HeuristicLab.Core;
27using HeuristicLab.Operators;
28using HeuristicLab.Optimization;
29using HeuristicLab.Parameters;
30using HeuristicLab.Problems.VehicleRouting.Interfaces;
31using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
32using HeuristicLab.Problems.VehicleRouting.Variants;
33
34namespace HeuristicLab.Problems.VehicleRouting {
35  /// <summary>
36  /// An operator which analyzes the best, average and worst quality of solutions in the scope tree.
37  /// </summary>
38  [Item("Capacitated Tour Analyzer", "An operator which analyzes the best, average and worst properties of the VRP tours in the scope tree.")]
39  [StorableType("72fdaf0a-4ac7-4ac5-a563-3efb0e3fae9e")]
40  public sealed class CapacitatedTourAnalyzer : InstrumentedOperator, IAnalyzer, ICapacitatedOperator {
41    [Storable] public ILookupParameter<IVRPProblemInstance> ProblemInstanceParameter { get; private set; }
42    [Storable] public IScopeTreeLookupParameter<CVRPEvaluation> EvaluationResultParameter { get; private set; }
43
44    [Storable] public IResultParameter<DataTable> OverloadResult { get; private set; }
45
46    public bool EnabledByDefault {
47      get { return true; }
48    }
49
50    [StorableConstructor]
51    private CapacitatedTourAnalyzer(StorableConstructorFlag _) : base(_) { }
52    private CapacitatedTourAnalyzer(CapacitatedTourAnalyzer original, Cloner cloner)
53      : base(original, cloner) {
54      ProblemInstanceParameter = cloner.Clone(original.ProblemInstanceParameter);
55      EvaluationResultParameter = cloner.Clone(original.EvaluationResultParameter);
56      OverloadResult = cloner.Clone(original.OverloadResult);
57    }
58    public CapacitatedTourAnalyzer()
59      : base() {
60      Parameters.Add(ProblemInstanceParameter = new LookupParameter<IVRPProblemInstance>("ProblemInstance", "The problem instance."));
61      Parameters.Add(EvaluationResultParameter = new ScopeTreeLookupParameter<CVRPEvaluation>("EvaluationResult", "The evaluations of the VRP solutions which should be analyzed."));
62      DataTable defaultOverloadTable = new DataTable("Overload");
63      Parameters.Add(OverloadResult = new ResultParameter<DataTable>("Overload", "The solution overload progress in each iteration.", defaultOverloadTable));
64
65      defaultOverloadTable.Rows.Add(new DataRow("Best (monotonic)"));
66      defaultOverloadTable.Rows.Add(new DataRow("Best"));
67      defaultOverloadTable.Rows.Add(new DataRow("Average"));
68      defaultOverloadTable.Rows.Add(new DataRow("Worst"));
69    }
70
71    public override IDeepCloneable Clone(Cloner cloner) {
72      return new CapacitatedTourAnalyzer(this, cloner);
73    }
74
75    public override IOperation InstrumentedApply() {
76      var evaluations = EvaluationResultParameter.ActualValue;
77      var overloads = evaluations.Select(x => x.Overload);
78
79      BasicVRPTourAnalyzer.Analyze(overloads, OverloadResult.ActualValue);
80
81      return base.InstrumentedApply();
82    }
83  }
84}
Note: See TracBrowser for help on using the repository browser.