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("Capacitated 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 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 | }
|
---|