Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/BestAverageWorstTours/PickupAndDeliveryTourAnalyzer.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: 4.0 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("Pickup & Delivery Tour Analyzer", "An operator which analyzes the best, average and worst properties of the VRP tours in the scope tree.")]
39  [StorableType("0a108965-fb1a-47a3-a5d4-11d1bfa51b0d")]
40  public sealed class PickupAndDeliveryTourAnalyzer : InstrumentedOperator, IAnalyzer, ICapacitatedOperator {
41    [Storable] public ILookupParameter<IVRPProblemInstance> ProblemInstanceParameter { get; private set; }
42    [Storable] public IScopeTreeLookupParameter<CVRPPDTWEvaluation> EvaluationResultParameter { get; private set; }
43
44    [Storable] public IResultParameter<DataTable> PickupViolationsResult { get; private set; }
45
46    public bool EnabledByDefault {
47      get { return true; }
48    }
49
50    [StorableConstructor]
51    private PickupAndDeliveryTourAnalyzer(StorableConstructorFlag _) : base(_) { }
52    private PickupAndDeliveryTourAnalyzer(PickupAndDeliveryTourAnalyzer original, Cloner cloner)
53      : base(original, cloner) {
54      ProblemInstanceParameter = cloner.Clone(original.ProblemInstanceParameter);
55      EvaluationResultParameter = cloner.Clone(original.EvaluationResultParameter);
56      PickupViolationsResult = cloner.Clone(original.PickupViolationsResult);
57    }
58    public PickupAndDeliveryTourAnalyzer()
59      : base() {
60      Parameters.Add(ProblemInstanceParameter = new LookupParameter<IVRPProblemInstance>("ProblemInstance", "The problem instance."));
61      Parameters.Add(EvaluationResultParameter = new ScopeTreeLookupParameter<CVRPPDTWEvaluation>("EvaluationResult", "The evaluations of the VRP solutions which should be analyzed."));
62      DataTable defaultPickupViolationsTable = new DataTable("Pickup Violations");
63      Parameters.Add(PickupViolationsResult = new ResultParameter<DataTable>("Pickup Violations", "The solution pickup violation progress in each iteration.", defaultPickupViolationsTable));
64
65      defaultPickupViolationsTable.Rows.Add(new DataRow("Best (monotonic)"));
66      defaultPickupViolationsTable.Rows.Add(new DataRow("Best"));
67      defaultPickupViolationsTable.Rows.Add(new DataRow("Average"));
68      defaultPickupViolationsTable.Rows.Add(new DataRow("Worst"));
69    }
70
71    public override IDeepCloneable Clone(Cloner cloner) {
72      return new PickupAndDeliveryTourAnalyzer(this, cloner);
73    }
74
75    public override IOperation InstrumentedApply() {
76      var evaluations = EvaluationResultParameter.ActualValue;
77      var pickupViolations = evaluations.Select(x => (double)x.PickupViolations);
78
79      BasicVRPTourAnalyzer.Analyze(pickupViolations, PickupViolationsResult.ActualValue);
80
81      return base.InstrumentedApply();
82    }
83  }
84}
Note: See TracBrowser for help on using the repository browser.