Free cookie consent management tool by TermsFeed Policy Generator

source: branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Moves/LambdaInterchange/AlbaLambdaInterchangeMove.cs @ 4370

Last change on this file since 4370 was 4370, checked in by svonolfe, 14 years ago

Added move operators (WIP) (#1177)

File size: 3.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.Persistence.Default.CompositeSerializers.Storable;
24using HeuristicLab.Encodings.PermutationEncoding;
25using HeuristicLab.Common;
26using System.Collections.Generic;
27using HeuristicLab.Problems.VehicleRouting.Encodings.General;
28using HeuristicLab.Data;
29using HeuristicLab.Problems.VehicleRouting.Interfaces;
30
31namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba {
32  [Item("InversionMove", "Item that describes a lambda move on a VRP representation.  It is implemented as described in Alba, E. and Dorronsoro, B. (2004). Solving the Vehicle Routing Problem by Using Cellular Genetic Algorithms.")]
33  [StorableClass]
34  public class AlbaLambdaInterchangeMove: Item, IVRPMove {
35    [Storable]
36    public IVRPEncoding Individual { get; protected set; }
37   
38    [Storable]
39    public int Tour1 { get; protected set; }
40
41    [Storable]
42    public int Position1 { get; protected set; }
43
44    [Storable]
45    public int Length1 { get; protected set; }
46
47    [Storable]
48    public int Tour2 { get; protected set; }
49
50    [Storable]
51    public int Position2 { get; protected set; }
52
53    [Storable]
54    public int Length2 { get; protected set; }
55   
56    public AlbaLambdaInterchangeMove(): base() {
57      Tour1 = -1;
58      Position1 = -1;
59      Length1 = -1;
60
61      Tour2 = -1;
62      Position2 = -1;
63      Length2 = -1;
64
65      Individual = null;
66    }
67
68    public AlbaLambdaInterchangeMove(int tour1, int position1, int length1,
69      int tour2, int position2, int length2, AlbaEncoding permutation) {
70        Tour1 = tour1;
71        Position1 = position1;
72        Length1 = length1;
73
74        Tour2 = tour2;
75        Position2 = position2;
76        Length2 = length2;
77
78        this.Individual = permutation.Clone() as AlbaEncoding;
79    }
80
81    public override IDeepCloneable Clone(HeuristicLab.Common.Cloner cloner) {
82      AlbaLambdaInterchangeMove clone = new AlbaLambdaInterchangeMove();
83
84      clone.Tour1 = Tour1;
85      clone.Position1 = Position1;
86      clone.Length1 = Length1;
87
88      clone.Tour2 = Tour2;
89      clone.Position2 = Position2;
90      clone.Length2 = Length2;
91
92      if (Individual != null)
93        clone.Individual = (AlbaEncoding)cloner.Clone(Individual);
94
95      cloner.RegisterClonedObject(this, clone);
96      return clone;
97    }
98
99
100
101    #region IVRPMove Members
102
103    public VRPMoveEvaluator GetMoveEvaluator() {
104      return new AlbaLambdaInterchangeMoveEvaluator();
105    }
106
107    public VRPMoveMaker GetMoveMaker() {
108      return new AlbaLambdaInterchangeMoveMaker();
109    }
110
111    #endregion
112  }
113}
Note: See TracBrowser for help on using the repository browser.