Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Moves/MultiVRPMoveOperator/MultiVRPMoveTabuMaker.cs @ 13348

Last change on this file since 13348 was 12012, checked in by ascheibe, 10 years ago

#2212 merged r12008, r12009, r12010 back into trunk

File size: 4.4 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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 HeuristicLab.Common;
23using HeuristicLab.Core;
24using HeuristicLab.Data;
25using HeuristicLab.Operators;
26using HeuristicLab.Optimization;
27using HeuristicLab.Parameters;
28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
29using HeuristicLab.Problems.VehicleRouting.Interfaces;
30using HeuristicLab.Problems.VehicleRouting.Variants;
31
32namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
33  [Item("MultiVRPMoveTabuMaker", "A multi VRP move tabu maker.")]
34  [StorableClass]
35  public class MultiVRPMoveTabuMaker : SingleSuccessorOperator, IMultiVRPMoveOperator, ITabuMaker, IGeneralVRPOperator, ISingleObjectiveOperator {
36    public ILookupParameter VRPMoveParameter {
37      get { return (ILookupParameter)Parameters["VRPMove"]; }
38    }
39    public LookupParameter<ItemList<IItem>> TabuListParameter {
40      get { return (LookupParameter<ItemList<IItem>>)Parameters["TabuList"]; }
41    }
42    public ValueLookupParameter<IntValue> TabuTenureParameter {
43      get { return (ValueLookupParameter<IntValue>)Parameters["TabuTenure"]; }
44    }
45    public ILookupParameter<DoubleValue> MoveQualityParameter {
46      get { return (ILookupParameter<DoubleValue>)Parameters["MoveQuality"]; }
47    }
48    public ILookupParameter<DoubleValue> QualityParameter {
49      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
50    }
51    public IValueLookupParameter<BoolValue> MaximizationParameter {
52      get { return (IValueLookupParameter<BoolValue>)Parameters["Maximization"]; }
53    }
54    public ILookupParameter<IVRPEncoding> VRPToursParameter {
55      get { return (ILookupParameter<IVRPEncoding>)Parameters["VRPTours"]; }
56    }
57    public ILookupParameter<IVRPProblemInstance> ProblemInstanceParameter {
58      get { return (LookupParameter<IVRPProblemInstance>)Parameters["ProblemInstance"]; }
59    }
60
61    [StorableConstructor]
62    protected MultiVRPMoveTabuMaker(bool deserializing) : base(deserializing) { }
63
64    public MultiVRPMoveTabuMaker()
65      : base() {
66      Parameters.Add(new LookupParameter<IVRPMove>("VRPMove", "The move."));
67      Parameters.Add(new LookupParameter<ItemList<IItem>>("TabuList", "The tabu list where move attributes are stored."));
68      Parameters.Add(new ValueLookupParameter<IntValue>("TabuTenure", "The tenure of the tabu list."));
69      Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The quality of the move."));
70      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the solution."));
71      Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, else if it is a minimization problem."));
72
73      Parameters.Add(new LookupParameter<IVRPEncoding>("VRPTours", "The VRP tours considered in the move."));
74      Parameters.Add(new LookupParameter<IVRPProblemInstance>("ProblemInstance", "The VRP problem instance"));
75    }
76
77    public override IDeepCloneable Clone(Cloner cloner) {
78      return new MultiVRPMoveTabuMaker(this, cloner);
79    }
80
81    protected MultiVRPMoveTabuMaker(MultiVRPMoveTabuMaker original, Cloner cloner)
82      : base(original, cloner) {
83    }
84
85    public override IOperation Apply() {
86      IVRPMove move = VRPMoveParameter.ActualValue as IVRPMove;
87
88      ITabuMaker moveTabuMaker = move.GetTabuMaker();
89      (moveTabuMaker as IVRPMoveOperator).VRPMoveParameter.ActualName = VRPMoveParameter.Name;
90
91      OperationCollection next = new OperationCollection(base.Apply());
92      next.Insert(0, ExecutionContext.CreateOperation(moveTabuMaker));
93
94      return next;
95    }
96  }
97}
Note: See TracBrowser for help on using the repository browser.