- Timestamp:
- 01/07/14 15:05:58 (11 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Crossovers/BiasedMultiVRPSolutionCrossover.cs
r10295 r10298 131 131 } 132 132 133 return base.InstrumentedApply(); 133 //////////////// 134 IRandom random = RandomParameter.ActualValue; 135 DoubleArray probabilities = ActualProbabilitiesParameter.ActualValue; 136 if (probabilities.Length != Operators.Count) { 137 throw new InvalidOperationException(Name + ": The list of probabilities has to match the number of operators"); 138 } 139 var checkedOperators = Operators.CheckedItems; 140 if (checkedOperators.Count() > 0) { 141 // select a random operator from the checked operators 142 double sum = (from indexedItem in checkedOperators select probabilities[indexedItem.Index]).Sum(); 143 if (sum == 0) throw new InvalidOperationException(Name + ": All selected operators have zero probability."); 144 double r = random.NextDouble() * sum; 145 sum = 0; 146 foreach (var indexedItem in checkedOperators) { 147 sum += probabilities[indexedItem.Index]; 148 if (sum > r) { 149 successor = indexedItem.Value; 150 break; 151 } 152 } 153 } 154 155 IOperation successorOp = null; 156 if (Successor != null) 157 successorOp = ExecutionContext.CreateOperation(Successor); 158 OperationCollection next = new OperationCollection(successorOp); 159 if (successor != null) { 160 SelectedOperatorParameter.ActualValue = new StringValue(successor.Name); 161 162 if (CreateChildOperation) 163 next.Insert(0, ExecutionContext.CreateChildOperation(successor)); 164 else next.Insert(0, ExecutionContext.CreateOperation(successor)); 165 } else { 166 SelectedOperatorParameter.ActualValue = new StringValue(""); 167 } 168 169 return next; 134 170 } 135 171 } -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Crossovers/RandomParentCloneCrossover.cs
r9456 r10298 65 65 } 66 66 67 public override IOperation Apply() {67 public override IOperation InstrumentedApply() { 68 68 if (RandomParameter.ActualValue.Next() < 0.5) 69 69 ChildParameter.ActualValue = ParentsParameter.ActualValue[0].Clone() as IVRPEncoding; … … 71 71 ChildParameter.ActualValue = ParentsParameter.ActualValue[1].Clone() as IVRPEncoding; 72 72 73 return base. Apply();73 return base.InstrumentedApply(); 74 74 } 75 75 } -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Manipulators/BiasedMultiVRPSolutionManipulator.cs
r10295 r10298 131 131 } 132 132 133 return base.InstrumentedApply(); 133 //////////////// 134 IRandom random = RandomParameter.ActualValue; 135 DoubleArray probabilities = ActualProbabilitiesParameter.ActualValue; 136 if (probabilities.Length != Operators.Count) { 137 throw new InvalidOperationException(Name + ": The list of probabilities has to match the number of operators"); 138 } 139 var checkedOperators = Operators.CheckedItems; 140 if (checkedOperators.Count() > 0) { 141 // select a random operator from the checked operators 142 double sum = (from indexedItem in checkedOperators select probabilities[indexedItem.Index]).Sum(); 143 if (sum == 0) throw new InvalidOperationException(Name + ": All selected operators have zero probability."); 144 double r = random.NextDouble() * sum; 145 sum = 0; 146 foreach (var indexedItem in checkedOperators) { 147 sum += probabilities[indexedItem.Index]; 148 if (sum > r) { 149 successor = indexedItem.Value; 150 break; 151 } 152 } 153 } 154 155 IOperation successorOp = null; 156 if (Successor != null) 157 successorOp = ExecutionContext.CreateOperation(Successor); 158 OperationCollection next = new OperationCollection(successorOp); 159 if (successor != null) { 160 SelectedOperatorParameter.ActualValue = new StringValue(successor.Name); 161 162 if (CreateChildOperation) 163 next.Insert(0, ExecutionContext.CreateChildOperation(successor)); 164 else next.Insert(0, ExecutionContext.CreateOperation(successor)); 165 } else { 166 SelectedOperatorParameter.ActualValue = new StringValue(""); 167 } 168 169 return next; 134 170 } 135 171 } -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Moves/MultiVRPMoveOperator/MultiVRPMoveEvaluator.cs
r9456 r10298 53 53 protected override void EvaluateMove() { } 54 54 55 public override IOperation Apply() {55 public override IOperation InstrumentedApply() { 56 56 IVRPMove move = VRPMoveParameter.ActualValue as IVRPMove; 57 57 … … 59 59 moveEvaluator.VRPMoveParameter.ActualName = VRPMoveParameter.Name; 60 60 61 OperationCollection next = new OperationCollection(base. Apply());61 OperationCollection next = new OperationCollection(base.InstrumentedApply()); 62 62 next.Insert(0, ExecutionContext.CreateOperation(moveEvaluator)); 63 63 -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Moves/VRPMoveEvaluator.cs
r9456 r10298 76 76 protected abstract void EvaluateMove(); 77 77 78 public override IOperation Apply() {78 public override IOperation InstrumentedApply() { 79 79 EvaluateMove(); 80 80 81 return base. Apply();81 return base.InstrumentedApply(); 82 82 } 83 83 } -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Moves/VRPMoveMaker.cs
r9456 r10298 99 99 } 100 100 101 public override IOperation Apply() {101 public override IOperation InstrumentedApply() { 102 102 PerformMove(); 103 103 UpdateMoveEvaluation(); 104 104 105 return base. Apply();105 return base.InstrumentedApply(); 106 106 } 107 107 }
Note: See TracChangeset
for help on using the changeset viewer.