Free cookie consent management tool by TermsFeed Policy Generator

source: branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Moves/MultiVRPMoveOperator/MultiVRPMoveTabuMaker.cs @ 6772

Last change on this file since 6772 was 6772, checked in by svonolfe, 13 years ago

Added support for multiple moves in tabu search (#1177)

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