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.Collections.Generic;
|
---|
23 | using System.Linq;
|
---|
24 | using HEAL.Attic;
|
---|
25 | using HeuristicLab.Common;
|
---|
26 | using HeuristicLab.Core;
|
---|
27 | using HeuristicLab.Optimization;
|
---|
28 |
|
---|
29 | namespace HeuristicLab.Problems.VehicleRouting.ProblemInstances {
|
---|
30 | [Item("StopInsertionInfo", "")]
|
---|
31 | [StorableType("e4e2657a-0af9-4f1c-b396-887ad5b6f459")]
|
---|
32 | public class StopInsertionInfo : Item {
|
---|
33 | [Storable] public int Start { get; private set; }
|
---|
34 | [Storable] public int End { get; private set; }
|
---|
35 |
|
---|
36 |
|
---|
37 | [StorableConstructor]
|
---|
38 | protected StopInsertionInfo(StorableConstructorFlag _) : base(_) { }
|
---|
39 | protected StopInsertionInfo(StopInsertionInfo original, Cloner cloner)
|
---|
40 | : base(original, cloner) {
|
---|
41 | Start = original.Start;
|
---|
42 | End = original.End;
|
---|
43 | }
|
---|
44 | public StopInsertionInfo(int start, int end)
|
---|
45 | : base() {
|
---|
46 | Start = start;
|
---|
47 | End = end;
|
---|
48 | }
|
---|
49 |
|
---|
50 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
51 | return new StopInsertionInfo(this, cloner);
|
---|
52 | }
|
---|
53 | }
|
---|
54 |
|
---|
55 | [Item("TourInsertionInfo", "")]
|
---|
56 | [StorableType("25a61cca-120b-43e2-845a-d290352ca1e9")]
|
---|
57 | public class TourInsertionInfo : Item {
|
---|
58 | [Storable] public double Penalty { get; set; }
|
---|
59 | [Storable] public double Quality { get; set; }
|
---|
60 | [Storable] public int Vehicle { get; set; }
|
---|
61 | [Storable] private List<StopInsertionInfo> stopInsertionInfos;
|
---|
62 |
|
---|
63 | [StorableConstructor]
|
---|
64 | protected TourInsertionInfo(StorableConstructorFlag _) : base(_) { }
|
---|
65 | protected TourInsertionInfo(TourInsertionInfo original, Cloner cloner)
|
---|
66 | : base(original, cloner) {
|
---|
67 | Penalty = original.Penalty;
|
---|
68 | Quality = original.Quality;
|
---|
69 | Vehicle = original.Vehicle;
|
---|
70 | stopInsertionInfos = original.stopInsertionInfos.Select(cloner.Clone).ToList();
|
---|
71 | }
|
---|
72 | public TourInsertionInfo(int vehicle)
|
---|
73 | : base() {
|
---|
74 | stopInsertionInfos = new List<StopInsertionInfo>();
|
---|
75 | Vehicle = vehicle;
|
---|
76 | }
|
---|
77 |
|
---|
78 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
79 | return new TourInsertionInfo(this, cloner);
|
---|
80 | }
|
---|
81 |
|
---|
82 | public void AddStopInsertionInfo(StopInsertionInfo info) {
|
---|
83 | stopInsertionInfos.Add(info);
|
---|
84 | }
|
---|
85 |
|
---|
86 | public StopInsertionInfo GetStopInsertionInfo(int stop) {
|
---|
87 | return stopInsertionInfos[stop];
|
---|
88 | }
|
---|
89 |
|
---|
90 | public int GetStopCount() {
|
---|
91 | return stopInsertionInfos.Count;
|
---|
92 | }
|
---|
93 | }
|
---|
94 |
|
---|
95 | [Item("InsertionInfo", "")]
|
---|
96 | [StorableType("ba569eb3-df25-4f73-bfa0-246b38c1d520")]
|
---|
97 | public class InsertionInfo : Item {
|
---|
98 | [Storable] private List<TourInsertionInfo> tourInsertionInfos;
|
---|
99 |
|
---|
100 | [StorableConstructor]
|
---|
101 | protected InsertionInfo(StorableConstructorFlag _) : base(_) { }
|
---|
102 | protected InsertionInfo(InsertionInfo original, Cloner cloner)
|
---|
103 | : base(original, cloner) {
|
---|
104 | tourInsertionInfos = original.tourInsertionInfos.Select(cloner.Clone).ToList();
|
---|
105 | }
|
---|
106 | public InsertionInfo()
|
---|
107 | : base() {
|
---|
108 | tourInsertionInfos = new List<TourInsertionInfo>();
|
---|
109 | }
|
---|
110 |
|
---|
111 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
112 | return new InsertionInfo(this, cloner);
|
---|
113 | }
|
---|
114 |
|
---|
115 | public void AddTourInsertionInfo(TourInsertionInfo info) {
|
---|
116 | tourInsertionInfos.Add(info);
|
---|
117 | }
|
---|
118 |
|
---|
119 | public TourInsertionInfo GetTourInsertionInfo(int tour) {
|
---|
120 | return tourInsertionInfos[tour];
|
---|
121 | }
|
---|
122 | }
|
---|
123 |
|
---|
124 | [Item("VRPEvaluation", "")]
|
---|
125 | [StorableType("0c4dfa78-8e41-4558-b2dd-4a22954c35ba")]
|
---|
126 | public class VRPEvaluation : EvaluationResult, ISingleObjectiveEvaluationResult {
|
---|
127 | // TODO: Would be nice to collect these, into individual results in a run
|
---|
128 | [Storable] public double Quality { get; set; }
|
---|
129 | [Storable] public double Distance { get; set; }
|
---|
130 | [Storable] public int VehicleUtilization { get; set; }
|
---|
131 | [Storable] public InsertionInfo InsertionInfo { get; set; }
|
---|
132 | [Storable] public double Penalty { get; set; }
|
---|
133 | [Storable] public bool IsFeasible { get; set; }
|
---|
134 |
|
---|
135 | [StorableConstructor]
|
---|
136 | protected VRPEvaluation(StorableConstructorFlag _) : base(_) { }
|
---|
137 | protected VRPEvaluation(VRPEvaluation original, Cloner cloner)
|
---|
138 | : base(original, cloner) {
|
---|
139 | Quality = original.Quality;
|
---|
140 | Distance = original.Distance;
|
---|
141 | VehicleUtilization = original.VehicleUtilization;
|
---|
142 | InsertionInfo = cloner.Clone(original.InsertionInfo);
|
---|
143 | Penalty = original.Penalty;
|
---|
144 | IsFeasible = original.IsFeasible;
|
---|
145 | }
|
---|
146 | public VRPEvaluation() : base() {
|
---|
147 | InsertionInfo = new InsertionInfo();
|
---|
148 | }
|
---|
149 |
|
---|
150 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
151 | return new VRPEvaluation(this, cloner);
|
---|
152 | }
|
---|
153 | }
|
---|
154 | }
|
---|