Changeset 6760 for branches/PersistenceSpeedUp/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinManipulator.cs
- Timestamp:
- 09/14/11 13:59:25 (13 years ago)
- Location:
- branches/PersistenceSpeedUp
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PersistenceSpeedUp
- Property svn:ignore
-
old new 12 12 *.psess 13 13 *.vsp 14 *.docstates
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/PersistenceSpeedUp/HeuristicLab.Problems.VehicleRouting
- Property svn:mergeinfo changed
-
branches/PersistenceSpeedUp/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinManipulator.cs
r5445 r6760 25 25 using HeuristicLab.Parameters; 26 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using HeuristicLab.Data; 27 28 28 29 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin { … … 34 35 } 35 36 37 public IValueParameter<BoolValue> AllowInfeasibleSolutions { 38 get { return (IValueParameter<BoolValue>)Parameters["AllowInfeasibleSolutions"]; } 39 } 40 41 [StorableHook(HookType.AfterDeserialization)] 42 private void AfterDeserialization() { 43 // BackwardsCompatibility3.3 44 #region Backwards compatible code (remove with 3.4) 45 if (!Parameters.ContainsKey("AllowInfeasibleSolutions")) { 46 Parameters.Add(new ValueParameter<BoolValue>("AllowInfeasibleSolutions", "Indicates if infeasible solutions should be allowed.", new BoolValue(false))); 47 } 48 #endregion 49 } 50 36 51 [StorableConstructor] 37 52 protected PotvinManipulator(bool deserializing) : base(deserializing) { } … … 41 56 public PotvinManipulator() { 42 57 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); 58 Parameters.Add(new ValueParameter<BoolValue>("AllowInfeasibleSolutions", "Indicates if infeasible solutions should be allowed.", new BoolValue(false))); 43 59 } 44 60 45 61 protected abstract void Manipulate(IRandom random, PotvinEncoding individual); 46 62 47 protected int SelectRandomTourBiasedByLength(IRandom random, PotvinEncoding individual) {63 protected static int SelectRandomTourBiasedByLength(IRandom random, PotvinEncoding individual) { 48 64 int tourIndex = -1; 49 65 … … 51 67 double[] probabilities = new double[individual.Tours.Count]; 52 68 for (int i = 0; i < individual.Tours.Count; i++) { 53 probabilities[i] = 1.0 / ((double)individual.Tours[i].Cities.Count / (double) Cities);69 probabilities[i] = 1.0 / ((double)individual.Tours[i].Cities.Count / (double)individual.Cities); 54 70 sum += probabilities[i]; 55 71 } … … 72 88 } 73 89 74 protected bool FindInsertionPlace(PotvinEncoding individual, int city, int routeToAvoid, out int route, out int place) { 90 protected static bool FindInsertionPlace(PotvinEncoding individual, int city, int routeToAvoid, 91 DoubleArray dueTime, DoubleArray serviceTime, DoubleArray readyTime, DoubleArray demand, 92 DoubleValue capacity, DistanceMatrix distMatrix, bool allowInfeasible, 93 out int route, out int place) { 75 94 return individual.FindInsertionPlace( 76 DueTimeParameter.ActualValue, ServiceTimeParameter.ActualValue, ReadyTimeParameter.ActualValue,77 DemandParameter.ActualValue, CapacityParameter.ActualValue, CoordinatesParameter.ActualValue,78 DistanceMatrixParameter, UseDistanceMatrixParameter.ActualValue,79 city, routeToAvoid,out route, out place);95 dueTime, serviceTime, readyTime, 96 demand, capacity, distMatrix, 97 city, routeToAvoid, allowInfeasible, 98 out route, out place); 80 99 } 100 81 101 82 102 public override IOperation Apply() {
Note: See TracChangeset
for help on using the changeset viewer.