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