- Timestamp:
- 07/22/10 00:44:01 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/AlbaEncoding.cs
r3938 r4068 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 25 using System.Text; 26 using HeuristicLab.Encodings.PermutationEncoding; 22 using HeuristicLab.Common; 27 23 using HeuristicLab.Core; 28 24 using HeuristicLab.Data; 25 using HeuristicLab.Encodings.PermutationEncoding; 29 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 using HeuristicLab.Common;31 27 32 28 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { 33 29 [Item("AlbaEncoding", "Represents an alba encoding of VRP solutions.")] 34 30 [StorableClass] 35 class AlbaEncoding : Permutation, IVRPEncoding {31 class AlbaEncoding : Permutation, IVRPEncoding { 36 32 #region IVRPEncoding Members 37 33 [Storable] … … 46 42 } 47 43 48 public AlbaEncoding(Permutation permutation, int cities): base(PermutationTypes.RelativeDirected) { 44 public AlbaEncoding(Permutation permutation, int cities) 45 : base(PermutationTypes.RelativeDirected) { 49 46 this.array = new int[permutation.Length]; 50 47 for (int i = 0; i < array.Length; i++) … … 76 73 } else { 77 74 tour.Add(new IntValue(this.array[i] + 1)); 78 } 75 } 79 76 } 80 77 … … 95 92 96 93 public static AlbaEncoding ConvertFrom(IVRPEncoding encoding) { 97 94 ItemList<Tour> tours = encoding.Tours; 98 95 99 int cities = 0; 100 foreach (Tour tour in tours) { 101 cities += tour.Count; 96 int cities = 0; 97 foreach (Tour tour in tours) { 98 cities += tour.Count; 99 } 100 int[] array = new int[cities + tours.Count - 2]; 101 int delimiter = cities; 102 int arrayIndex = 0; 103 104 foreach (Tour tour in tours) { 105 foreach (IntValue city in tour) { 106 array[arrayIndex] = city.Value; 107 108 arrayIndex++; 102 109 } 103 int[] array = new int[cities + tours.Count - 2];104 int delimiter = cities;105 int arrayIndex = 0;106 110 107 foreach (Tour tour in tours) { 108 foreach(IntValue city in tour) { 109 array[arrayIndex] = city.Value; 110 111 arrayIndex++; 112 } 113 114 if (arrayIndex != array.Length) { 115 array[arrayIndex] = delimiter; 116 delimiter++; 117 arrayIndex++; 118 } 111 if (arrayIndex != array.Length) { 112 array[arrayIndex] = delimiter; 113 delimiter++; 114 arrayIndex++; 119 115 } 116 } 120 117 121 118 AlbaEncoding solution = new AlbaEncoding(new Permutation(PermutationTypes.RelativeUndirected), cities); … … 124 121 } 125 122 126 123 127 124 128 125 } -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Creators/AlbaPermutationCreator.cs
r3991 r4068 21 21 22 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 25 using System.Text; 26 using HeuristicLab.Operators; 23 using HeuristicLab.Common; 27 24 using HeuristicLab.Core; 28 25 using HeuristicLab.Data; 26 using HeuristicLab.Encodings.PermutationEncoding; 27 using HeuristicLab.Optimization; 29 28 using HeuristicLab.Parameters; 30 using HeuristicLab.Encodings.PermutationEncoding;31 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 32 using HeuristicLab.Common;33 using HeuristicLab.Optimization;34 30 35 31 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 46 42 } 47 43 #endregion 48 44 49 45 public AlbaPermutationCreator() 50 46 : base() { … … 62 58 private void Initialize() { 63 59 CitiesParameter.ValueChanged += new EventHandler(CitiesParameter_ValueChanged); 64 if (CitiesParameter.Value != null)65 CitiesParameter.Value.ValueChanged += new EventHandler(CitiesValue_ValueChanged); 60 if (CitiesParameter.Value != null) 61 CitiesParameter.Value.ValueChanged += new EventHandler(CitiesValue_ValueChanged); 66 62 } 67 63 -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Creators/AlbaPushForwardInsertionCreator.cs
r3938 r4068 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq;25 using System.Text;26 using HeuristicLab.Operators;27 24 using HeuristicLab.Core; 28 25 using HeuristicLab.Data; 26 using HeuristicLab.Encodings.PermutationEncoding; 27 using HeuristicLab.Optimization; 29 28 using HeuristicLab.Parameters; 30 using HeuristicLab.Encodings.PermutationEncoding;31 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 32 using HeuristicLab.Common;33 using HeuristicLab.Optimization;34 30 35 31 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 195 191 gamma = N(Gamma.Value.Value, Math.Sqrt(GammaVariance.Value.Value), RandomParameter.ActualValue); 196 192 197 double x0 = CoordinatesParameter.ActualValue[0, 0];198 double y0 = CoordinatesParameter.ActualValue[0, 1];193 double x0 = CoordinatesParameter.ActualValue[0, 0]; 194 double y0 = CoordinatesParameter.ActualValue[0, 1]; 199 195 double distance = 0; 200 196 double cost = 0; … … 212 208 for (int i = 1; i <= CitiesParameter.ActualValue.Value; i++) { 213 209 distance = Distance(i, 0); 214 if (CoordinatesParameter.ActualValue[i, 0] < x0) distance = -distance;210 if (CoordinatesParameter.ActualValue[i, 0] < x0) distance = -distance; 215 211 cost = -alpha * distance + // distance 0 <-> City[i] 216 212 beta * (DueTimeParameter.ActualValue[i]) + // latest arrival time 217 gamma * (Math.Asin((CoordinatesParameter.ActualValue[i, 1] - y0) / distance) / 360 * distance); // polar angle213 gamma * (Math.Asin((CoordinatesParameter.ActualValue[i, 1] - y0) / distance) / 360 * distance); // polar angle 218 214 219 215 index = 0; -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Crossovers/AlbaPermutationCrossover.cs
r3938 r4068 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Linq;25 using System.Text;26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;27 22 using HeuristicLab.Core; 28 23 using HeuristicLab.Encodings.PermutationEncoding; 29 using HeuristicLab.Operators;30 24 using HeuristicLab.Parameters; 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 26 32 27 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 46 41 int cities = 0; 47 42 48 for (int i = 0; i < ParentsParameter.ActualValue.Length; i++) {49 50 43 for (int i = 0; i < ParentsParameter.ActualValue.Length; i++) { 44 IVRPEncoding solution = ParentsParameter.ActualValue[i]; 45 cities = solution.Cities; 51 46 if (!(solution is AlbaEncoding)) { 52 47 ParentsParameter.ActualValue[i] = AlbaEncoding.ConvertFrom(solution); -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Interfaces/IAlbaTranslocationMoveOperator.cs
r4047 r4068 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 25 using System.Text; 22 using HeuristicLab.Core; 23 using HeuristicLab.Encodings.PermutationEncoding; 26 24 using HeuristicLab.Optimization; 27 using HeuristicLab.Encodings.PermutationEncoding;28 using HeuristicLab.Core;29 25 30 26 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Manipulators/AlbaPermutationManipulator.cs
r3938 r4068 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Linq;25 using System.Text;26 22 using HeuristicLab.Core; 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;28 23 using HeuristicLab.Encodings.PermutationEncoding; 29 24 using HeuristicLab.Parameters; 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 26 31 27 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/AlbaMoveMaker.cs
r3938 r4068 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Linq;25 using System.Text;26 using HeuristicLab.Encodings.PermutationEncoding;27 using HeuristicLab.Optimization;28 22 using HeuristicLab.Core; 23 using HeuristicLab.Data; 24 using HeuristicLab.Parameters; 29 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 using HeuristicLab.Parameters;31 using HeuristicLab.Data;32 26 33 27 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/AlbaMoveOperator.cs
r3947 r4068 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Linq;25 using System.Text;26 22 using HeuristicLab.Core; 23 using HeuristicLab.Encodings.PermutationEncoding; 27 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Encodings.PermutationEncoding;29 using HeuristicLab.Parameters;30 25 31 26 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 35 30 [Storable] 36 31 protected abstract IPermutationMoveOperator PermutationMoveOperatorParameter { get; set; } 37 32 38 33 public override IOperation Apply() { 39 34 IVRPEncoding solution = VRPSolutionParameter.ActualValue; -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveEvaluator.cs
r3947 r4068 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 25 using System.Text; 22 using HeuristicLab.Core; 23 using HeuristicLab.Encodings.PermutationEncoding; 24 using HeuristicLab.Parameters; 26 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using HeuristicLab.Core;28 using HeuristicLab.Parameters;29 using HeuristicLab.Encodings.PermutationEncoding;30 26 using HeuristicLab.Problems.VehicleRouting.Encodings.Alba; 31 using HeuristicLab.Data;32 27 33 28 namespace HeuristicLab.Problems.VehicleRouting { 34 29 [Item("AlbaTranslocationMoveEvaluator", "Evaluates a translocation or insertion move (3-opt) for the VRP.")] 35 30 [StorableClass] 36 public sealed class AlbaTranslocationMoveEvaluator : VRPMoveEvaluator {31 public sealed class AlbaTranslocationMoveEvaluator : VRPMoveEvaluator { 37 32 public ILookupParameter<TranslocationMove> TranslocationMoveParameter { 38 33 get { return (ILookupParameter<TranslocationMove>)Parameters["TranslocationMove"]; } -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveGenerator.cs
r4047 r4068 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 using System.Linq;25 using System.Text;23 using HeuristicLab.Core; 24 using HeuristicLab.Data; 26 25 using HeuristicLab.Encodings.PermutationEncoding; 27 26 using HeuristicLab.Optimization; 28 using HeuristicLab. Core;27 using HeuristicLab.Parameters; 29 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 using HeuristicLab.Parameters;31 using HeuristicLab.Data;32 29 33 30 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 41 38 protected override IPermutationMoveOperator PermutationMoveOperatorParameter { 42 39 get { return TranslocationMoveGeneratorParameter.Value; } 43 set { 40 set { 44 41 TranslocationMoveGeneratorParameter.Value = value as TranslocationMoveGenerator; 45 42 if (TranslocationMoveGeneratorParameter.Value is IMultiMoveGenerator) { … … 71 68 } 72 69 73 public AlbaTranslocationMoveGenerator(): base() { 74 Parameters.Add(new ValueLookupParameter<TranslocationMoveGenerator>("TranslocationMoveGenerator", "The move generator.", 70 public AlbaTranslocationMoveGenerator() 71 : base() { 72 Parameters.Add(new ValueLookupParameter<TranslocationMoveGenerator>("TranslocationMoveGenerator", "The move generator.", 75 73 new StochasticTranslocationMultiMoveGenerator())); 76 74 Parameters.Add(new ValueLookupParameter<IntValue>("SampleSize", "The number of moves to generate.")); … … 93 91 if (move != null) { 94 92 bool criteria1 = true; 95 if (move.Index1 - 1 >= 0 &&96 move.Index3 - 1 >= 0)93 if (move.Index1 - 1 >= 0 && 94 move.Index3 - 1 >= 0) 97 95 criteria1 = (permutation[move.Index1] >= cities && 98 96 permutation[move.Index1 - 1] >= cities && … … 107 105 permutation[index3] >= cities); 108 106 109 if (criteria1 && criteria2)107 if (criteria1 && criteria2) 110 108 toBeDeleted.Add(scope); 111 109 } -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveHardTabuCriterion.cs
r4047 r4068 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 25 using System.Text; 22 using HeuristicLab.Core; 23 using HeuristicLab.Data; 26 24 using HeuristicLab.Encodings.PermutationEncoding; 27 25 using HeuristicLab.Optimization; 28 using HeuristicLab.Core;29 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 using HeuristicLab.Parameters;31 using HeuristicLab.Data;32 27 33 28 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveMaker.cs
r4047 r4068 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 25 using System.Text; 22 using HeuristicLab.Core; 23 using HeuristicLab.Data; 26 24 using HeuristicLab.Encodings.PermutationEncoding; 27 25 using HeuristicLab.Optimization; 28 using HeuristicLab.Core;29 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 using HeuristicLab.Parameters;31 using HeuristicLab.Data;32 27 33 28 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 57 52 } 58 53 59 public AlbaTranslocationMoveMaker(): base() { 54 public AlbaTranslocationMoveMaker() 55 : base() { 60 56 moveMaker = new TranslocationMoveMaker(); 61 57 } -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveSoftTabuCriterion.cs
r4047 r4068 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 25 using System.Text; 22 using HeuristicLab.Core; 23 using HeuristicLab.Data; 26 24 using HeuristicLab.Encodings.PermutationEncoding; 27 25 using HeuristicLab.Optimization; 28 using HeuristicLab.Core;29 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 using HeuristicLab.Parameters;31 using HeuristicLab.Data;32 27 33 28 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveTabuMaker.cs
r4047 r4068 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 25 using System.Text; 22 using HeuristicLab.Core; 23 using HeuristicLab.Data; 26 24 using HeuristicLab.Encodings.PermutationEncoding; 27 25 using HeuristicLab.Optimization; 28 using HeuristicLab.Core;29 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 using HeuristicLab.Parameters;31 using HeuristicLab.Data;32 27 33 28 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Tour.cs
r3938 r4068 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 25 using System.Text; 22 using HeuristicLab.Core; 26 23 using HeuristicLab.Data; 27 using HeuristicLab.Core;28 24 29 25 namespace HeuristicLab.Problems.VehicleRouting.Encodings { -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/VRPCreator.cs
r3938 r4068 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Linq;25 using System.Text;26 using HeuristicLab.Operators;27 22 using HeuristicLab.Core; 28 23 using HeuristicLab.Data; 24 using HeuristicLab.Operators; 29 25 using HeuristicLab.Parameters; 30 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 36 32 get { return false; } 37 33 } 38 34 39 35 #region IVRPCreator Members 40 36 public IValueLookupParameter<IntValue> CitiesParameter { -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/VRPCrossover.cs
r3938 r4068 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Linq;25 using System.Text;26 22 using HeuristicLab.Core; 23 using HeuristicLab.Data; 27 24 using HeuristicLab.Operators; 28 25 using HeuristicLab.Parameters; 29 using HeuristicLab.Data;30 26 31 27 namespace HeuristicLab.Problems.VehicleRouting.Encodings { 32 public abstract class VRPCrossover : SingleSuccessorOperator, IVRPCrossover {28 public abstract class VRPCrossover : SingleSuccessorOperator, IVRPCrossover { 33 29 #region IVRPCrossover Members 34 30 … … 50 46 ChildParameter.ActualName = "VRPSolution"; 51 47 Parameters.Add(new ValueLookupParameter<IntValue>("Cities", "The city count.")); 52 } 48 } 53 49 } 54 50 } -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/VRPManipulator.cs
r3938 r4068 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Linq;25 using System.Text;26 22 using HeuristicLab.Core; 27 23 using HeuristicLab.Operators; … … 29 25 30 26 namespace HeuristicLab.Problems.VehicleRouting.Encodings { 31 public abstract class VRPManipulator : SingleSuccessorOperator, IVRPManipulator {27 public abstract class VRPManipulator : SingleSuccessorOperator, IVRPManipulator { 32 28 #region IVRPManipulator Members 33 29 -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/VRPMoveOperator.cs
r3938 r4068 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Linq;25 using System.Text;26 22 using HeuristicLab.Core; 27 23 using HeuristicLab.Operators; … … 29 25 30 26 namespace HeuristicLab.Problems.VehicleRouting.Encodings { 31 public abstract class VRPMoveOperator : SingleSuccessorOperator, IVRPMoveOperator {27 public abstract class VRPMoveOperator : SingleSuccessorOperator, IVRPMoveOperator { 32 28 #region IVRPManipulator Members 33 29
Note: See TracChangeset
for help on using the changeset viewer.