Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 13368 was 13368, checked in by ascheibe, 8 years ago

#2520 added guids to storable classes

File size: 4.4 KB
RevLine 
[13368]1#region License Information
[6772]2/* HeuristicLab
[12012]3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[6772]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
[8053]22using HeuristicLab.Common;
[6772]23using HeuristicLab.Core;
24using HeuristicLab.Data;
25using HeuristicLab.Operators;
26using HeuristicLab.Optimization;
27using HeuristicLab.Parameters;
28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
[8053]29using HeuristicLab.Problems.VehicleRouting.Interfaces;
[6772]30using HeuristicLab.Problems.VehicleRouting.Variants;
31
[8053]32namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
[6772]33  [Item("MultiVRPMoveTabuMaker", "A multi VRP move tabu maker.")]
[13368]34  [StorableClass("DFB702B8-8887-4986-A8B3-8405DB300C7F")]
[11970]35  public class MultiVRPMoveTabuMaker : SingleSuccessorOperator, IMultiVRPMoveOperator, ITabuMaker, IGeneralVRPOperator, ISingleObjectiveOperator {
[6772]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    }
[8053]60
[6772]61    [StorableConstructor]
[7906]62    protected MultiVRPMoveTabuMaker(bool deserializing) : base(deserializing) { }
[6772]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.