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 |
|
---|
22 | using System.Linq;
|
---|
23 | using HEAL.Attic;
|
---|
24 | using HeuristicLab.Analysis;
|
---|
25 | using HeuristicLab.Common;
|
---|
26 | using HeuristicLab.Core;
|
---|
27 | using HeuristicLab.Operators;
|
---|
28 | using HeuristicLab.Optimization;
|
---|
29 | using HeuristicLab.Parameters;
|
---|
30 | using HeuristicLab.Problems.VehicleRouting.Interfaces;
|
---|
31 | using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
|
---|
32 | using HeuristicLab.Problems.VehicleRouting.Variants;
|
---|
33 |
|
---|
34 | namespace 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("Time Window Tour Analyzer", "An operator which analyzes the best, average and worst properties of the VRP tours in the scope tree.")]
|
---|
39 | [StorableType("5DF1280C-5FEB-451E-8132-168E515CF47D")]
|
---|
40 | public sealed class TimeWindowTourAnalyzer : InstrumentedOperator, IAnalyzer, ITimeWindowedOperator {
|
---|
41 | [Storable] public ILookupParameter<IVRPProblemInstance> ProblemInstanceParameter { get; private set; }
|
---|
42 | [Storable] public IScopeTreeLookupParameter<CVRPTWEvaluation> EvaluationResultParameter { get; private set; }
|
---|
43 |
|
---|
44 | [Storable] public IResultParameter<DataTable> TardinessResult { get; private set; }
|
---|
45 | [Storable] public IResultParameter<DataTable> TravelTimeResult { get; private set; }
|
---|
46 |
|
---|
47 | public bool EnabledByDefault {
|
---|
48 | get { return true; }
|
---|
49 | }
|
---|
50 |
|
---|
51 | [StorableConstructor]
|
---|
52 | private TimeWindowTourAnalyzer(StorableConstructorFlag _) : base(_) { }
|
---|
53 | private TimeWindowTourAnalyzer(TimeWindowTourAnalyzer original, Cloner cloner)
|
---|
54 | : base(original, cloner) {
|
---|
55 | ProblemInstanceParameter = cloner.Clone(original.ProblemInstanceParameter);
|
---|
56 | EvaluationResultParameter = cloner.Clone(original.EvaluationResultParameter);
|
---|
57 | TardinessResult = cloner.Clone(original.TardinessResult);
|
---|
58 | TravelTimeResult = cloner.Clone(original.TravelTimeResult);
|
---|
59 | }
|
---|
60 | public TimeWindowTourAnalyzer()
|
---|
61 | : base() {
|
---|
62 | Parameters.Add(ProblemInstanceParameter = new LookupParameter<IVRPProblemInstance>("ProblemInstance", "The problem instance."));
|
---|
63 | Parameters.Add(EvaluationResultParameter = new ScopeTreeLookupParameter<CVRPTWEvaluation>("EvaluationResult", "The evaluations of the VRP solutions which should be analyzed."));
|
---|
64 | DataTable defaultTardinessTable = new DataTable("Tardiness"), defaultTravelTimeTable = new DataTable("Travel Times");
|
---|
65 | Parameters.Add(TardinessResult = new ResultParameter<DataTable>("Tardiness", "The solution tardiness progress in each iteration.", defaultTardinessTable));
|
---|
66 | Parameters.Add(TravelTimeResult = new ResultParameter<DataTable>("Travel Times", "The solution travel time progress in each iteration.", defaultTravelTimeTable));
|
---|
67 |
|
---|
68 | defaultTardinessTable.Rows.Add(new DataRow("Best (monotonic)"));
|
---|
69 | defaultTardinessTable.Rows.Add(new DataRow("Best"));
|
---|
70 | defaultTardinessTable.Rows.Add(new DataRow("Average"));
|
---|
71 | defaultTardinessTable.Rows.Add(new DataRow("Worst"));
|
---|
72 |
|
---|
73 | defaultTravelTimeTable.Rows.Add(new DataRow("Best (monotonic)"));
|
---|
74 | defaultTravelTimeTable.Rows.Add(new DataRow("Best"));
|
---|
75 | defaultTravelTimeTable.Rows.Add(new DataRow("Average"));
|
---|
76 | defaultTravelTimeTable.Rows.Add(new DataRow("Worst"));
|
---|
77 | }
|
---|
78 |
|
---|
79 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
80 | return new TimeWindowTourAnalyzer(this, cloner);
|
---|
81 | }
|
---|
82 |
|
---|
83 | public override IOperation InstrumentedApply() {
|
---|
84 | var evaluations = EvaluationResultParameter.ActualValue;
|
---|
85 | var tardiness = evaluations.Select(x => x.Tardiness);
|
---|
86 | var travelTimes = evaluations.Select(x => (double)x.TravelTime);
|
---|
87 |
|
---|
88 | BasicVRPTourAnalyzer.Analyze(tardiness, TardinessResult.ActualValue);
|
---|
89 | BasicVRPTourAnalyzer.Analyze(travelTimes, TravelTimeResult.ActualValue);
|
---|
90 |
|
---|
91 | return base.InstrumentedApply();
|
---|
92 | }
|
---|
93 | }
|
---|
94 | }
|
---|