Changeset 12969 for branches/gteufl/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Crossovers/BiasedMultiVRPSolutionCrossover.cs
- Timestamp:
- 09/25/15 14:39:59 (9 years ago)
- Location:
- branches/gteufl
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gteufl
- Property svn:ignore
-
old new 8 8 FxCopResults.txt 9 9 Google.ProtocolBuffers-0.9.1.dll 10 Google.ProtocolBuffers-2.4.1.473.dll 10 11 HeuristicLab 3.3.5.1.ReSharper.user 11 12 HeuristicLab 3.3.6.0.ReSharper.user 12 13 HeuristicLab.4.5.resharper.user 13 14 HeuristicLab.ExtLibs.6.0.ReSharper.user 15 HeuristicLab.Scripting.Development 14 16 HeuristicLab.resharper.user 15 17 ProtoGen.exe … … 17 19 _ReSharper.HeuristicLab 18 20 _ReSharper.HeuristicLab 3.3 21 _ReSharper.HeuristicLab 3.3 Tests 19 22 _ReSharper.HeuristicLab.ExtLibs 20 23 bin 21 24 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests 23 Google.ProtocolBuffers-2.4.1.473.dll 25 obj
-
- Property svn:mergeinfo changed
-
Property
svn:global-ignores
set to
*.nuget
packages
- Property svn:ignore
-
branches/gteufl/HeuristicLab.Problems.VehicleRouting
- Property svn:mergeinfo changed
-
branches/gteufl/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/General/Crossovers/BiasedMultiVRPSolutionCrossover.cs
r9462 r12969 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 21 21 22 22 using System; 23 using System.Collections.Generic;24 23 using System.Linq; 25 using System.Text; 24 using HeuristicLab.Analysis; 25 using HeuristicLab.Collections; 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 28 using HeuristicLab.Data; 29 using HeuristicLab.Optimization; 30 using HeuristicLab.Parameters; 27 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Common; 29 using HeuristicLab.Analysis; 30 using HeuristicLab.Parameters; 31 using HeuristicLab.Optimization; 32 using HeuristicLab.Data; 33 using HeuristicLab.Collections; 32 using HeuristicLab.Random; 34 33 35 34 namespace HeuristicLab.Problems.VehicleRouting.Encodings.General { … … 69 68 Parameters.Add(new ValueParameter<DoubleValue>("LowerBound", "The depth of the individuals in the scope tree.", new DoubleValue(0.01))); 70 69 Parameters.Add(new ValueParameter<IntValue>("Depth", "The depth of the individuals in the scope tree.", new IntValue(1))); 70 71 SelectedOperatorParameter.ActualName = "SelectedCrossoverOperator"; 71 72 } 72 73 … … 81 82 } 82 83 83 public override IOperation Apply() {84 public override IOperation InstrumentedApply() { 84 85 IOperator successor = null; 85 86 … … 133 134 } 134 135 135 //////////////// 136 //////////////// code has to be duplicated since ActualProbabilitiesParameter.ActualValue are updated and used for operator selection 136 137 IRandom random = RandomParameter.ActualValue; 137 138 DoubleArray probabilities = ActualProbabilitiesParameter.ActualValue; … … 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, checkedOperators.Select(x => probabilities[x.Index]), false, false).First().Value; 155 146 } 156 147
Note: See TracChangeset
for help on using the changeset viewer.