Changeset 10474 for trunk/sources/HeuristicLab.Problems.VehicleRouting
- Timestamp:
- 02/20/14 13:15:22 (11 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Crossovers/BiasedMultiVRPSolutionCrossover.cs
r10472 r10474 30 30 using HeuristicLab.Parameters; 31 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 32 using HeuristicLab.Random; 32 33 33 34 namespace HeuristicLab.Problems.VehicleRouting.Encodings.General { … … 142 143 if (checkedOperators.Count() > 0) { 143 144 // select a random operator from the checked operators 144 double sum = (from indexedItem in checkedOperators select probabilities[indexedItem.Index]).Sum(); 145 if (sum == 0) throw new InvalidOperationException(Name + ": All selected operators have zero probability."); 146 double r = random.NextDouble() * sum; 147 sum = 0; 148 foreach (var indexedItem in checkedOperators) { 149 sum += probabilities[indexedItem.Index]; 150 if (sum > r) { 151 successor = indexedItem.Value; 152 break; 153 } 154 } 145 successor = checkedOperators.SampleProportional(random, 1, probabilities, false, false).First().Value; 155 146 } 156 147 -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Manipulators/BiasedMultiVRPSolutionManipulator.cs
r10472 r10474 30 30 using HeuristicLab.Parameters; 31 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 32 using HeuristicLab.Random; 32 33 33 34 namespace HeuristicLab.Problems.VehicleRouting.Encodings.General { … … 142 143 if (checkedOperators.Count() > 0) { 143 144 // select a random operator from the checked operators 144 double sum = (from indexedItem in checkedOperators select probabilities[indexedItem.Index]).Sum(); 145 if (sum == 0) throw new InvalidOperationException(Name + ": All selected operators have zero probability."); 146 double r = random.NextDouble() * sum; 147 sum = 0; 148 foreach (var indexedItem in checkedOperators) { 149 sum += probabilities[indexedItem.Index]; 150 if (sum > r) { 151 successor = indexedItem.Value; 152 break; 153 } 154 } 145 successor = 146 checkedOperators.SampleProportional(random, 1, probabilities, false, false).First().Value; 155 147 } 156 148 -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/HeuristicLab.Problems.VehicleRouting-3.4.csproj
r8894 r10474 465 465 <Private>False</Private> 466 466 </ProjectReference> 467 <ProjectReference Include="..\..\HeuristicLab.Random\3.3\HeuristicLab.Random-3.3.csproj"> 468 <Project>{F4539FB6-4708-40C9-BE64-0A1390AEA197}</Project> 469 <Name>HeuristicLab.Random-3.3</Name> 470 </ProjectReference> 467 471 </ItemGroup> 468 472 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Plugin.cs.frame
r10037 r10474 41 41 [PluginDependency("HeuristicLab.Persistence", "3.3")] 42 42 [PluginDependency("HeuristicLab.Problems.Instances", "3.3")] 43 [PluginDependency("HeuristicLab.Random", "3.3")] 43 44 public class HeuristicLabProblemsVehicleRoutingPlugin : PluginBase { 44 45 }
Note: See TracChangeset
for help on using the changeset viewer.