Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10474 for trunk/sources


Ignore:
Timestamp:
02/20/14 13:15:22 (10 years ago)
Author:
gkronber
Message:

#2119: using RandomEnumerable.SampleProportional in BiasedMultiVRPOperators.

Location:
trunk/sources
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.HLScript.Views/3.3

    • Property svn:ignore set to
      obj
      Plugin.cs
  • trunk/sources/HeuristicLab.HLScript.Views/3.3/Properties

    • Property svn:ignore set to
      AssemblyInfo.cs
  • trunk/sources/HeuristicLab.HLScript/3.3

    • Property svn:ignore
      •  

        old new  
        11VariableStoreSerializer.cs
         2obj
         3Plugin.cs
  • trunk/sources/HeuristicLab.HLScript/3.3/Properties

    • Property svn:ignore set to
      AssemblyInfo.cs
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Crossovers/BiasedMultiVRPSolutionCrossover.cs

    r10472 r10474  
    3030using HeuristicLab.Parameters;
    3131using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     32using HeuristicLab.Random;
    3233
    3334namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
     
    142143      if (checkedOperators.Count() > 0) {
    143144        // 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;
    155146      }
    156147
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Manipulators/BiasedMultiVRPSolutionManipulator.cs

    r10472 r10474  
    3030using HeuristicLab.Parameters;
    3131using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     32using HeuristicLab.Random;
    3233
    3334namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
     
    142143      if (checkedOperators.Count() > 0) {
    143144        // 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;
    155147      }
    156148
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/HeuristicLab.Problems.VehicleRouting-3.4.csproj

    r8894 r10474  
    465465      <Private>False</Private>
    466466    </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>
    467471  </ItemGroup>
    468472  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Plugin.cs.frame

    r10037 r10474  
    4141  [PluginDependency("HeuristicLab.Persistence", "3.3")]
    4242  [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
     43  [PluginDependency("HeuristicLab.Random", "3.3")]
    4344  public class HeuristicLabProblemsVehicleRoutingPlugin : PluginBase {
    4445  }
Note: See TracChangeset for help on using the changeset viewer.