- Timestamp:
- 02/04/18 21:06:14 (7 years ago)
- Location:
- branches/1614_GeneralizedQAP/HeuristicLab.Analysis.FitnessLandscape/3.3/ProblemCharacteristicAnalysis
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1614_GeneralizedQAP/HeuristicLab.Analysis.FitnessLandscape/3.3/ProblemCharacteristicAnalysis/DoubleMatrixCharacteristicCalculator.cs
r14678 r15718 20 20 #endregion 21 21 22 using System; 23 using System.Linq; 22 24 using HeuristicLab.Common; 23 25 using HeuristicLab.Data; 24 using System;25 using System.Linq;26 26 27 27 namespace HeuristicLab.Analysis.FitnessLandscape { … … 30 30 var avg = m.Average(); 31 31 var stdDev = m.StandardDeviation(); 32 return stdDev / avg; 33 } 34 35 public static double CoeffVariationNonZeroes(DoubleMatrix m) { 36 var nonzeroes = m.Where(x => !x.IsAlmost(0)); 37 var avg = nonzeroes.Average(); 38 var stdDev = nonzeroes.StandardDeviation(); 32 39 return stdDev / avg; 33 40 } -
branches/1614_GeneralizedQAP/HeuristicLab.Analysis.FitnessLandscape/3.3/ProblemCharacteristicAnalysis/GQAP/GQAPCharacteristicCalculator.cs
r15713 r15718 66 66 yield return new Result(chara, new DoubleValue(inst.Capacities.Length / (double)inst.Demands.Length)); 67 67 if (chara == "FlowDominance") 68 yield return new Result(chara, new DoubleValue(DoubleMatrixCharacteristicCalculator.CoeffVariation (inst.Weights)));68 yield return new Result(chara, new DoubleValue(DoubleMatrixCharacteristicCalculator.CoeffVariationNonZeroes(inst.Weights))); 69 69 if (chara == "DistanceDominance") 70 yield return new Result(chara, new DoubleValue(DoubleMatrixCharacteristicCalculator.CoeffVariation (inst.Distances)));70 yield return new Result(chara, new DoubleValue(DoubleMatrixCharacteristicCalculator.CoeffVariationNonZeroes(inst.Distances))); 71 71 if (chara == "FlowSparsity") 72 72 yield return new Result(chara, new DoubleValue(DoubleMatrixCharacteristicCalculator.Sparsity(inst.Weights))); -
branches/1614_GeneralizedQAP/HeuristicLab.Analysis.FitnessLandscape/3.3/ProblemCharacteristicAnalysis/GQAP/GQAPDirectedWalk.cs
r15713 r15718 134 134 public static IEnumerable<List<Tuple<IntegerVector, double>>> Run(IRandom random, GQAP gqap, IEnumerable<IntegerVector> points, bool bestImprovement = true) { 135 135 var iter = points.GetEnumerator(); 136 if (!iter.MoveNext()) yield break;136 if (!iter.MoveNext()) return new List<Tuple<IntegerVector, double>>[0]; 137 137 138 138 var start = iter.Current; 139 var walks = new List<List<Tuple<IntegerVector, double>>>(); 139 140 while (iter.MoveNext()) { 140 141 var end = iter.Current; 141 142 142 143 var walk = (bestImprovement ? BestDirectedWalk(gqap, start, end) : FirstDirectedWalk(random, gqap, start, end)).ToList(); 143 yield return walk.ToList();144 walks.Add(walk); 144 145 start = end; 145 146 } // end paths 147 148 var min = walks.SelectMany(x => x.Select(y => y.Item2)).Min(); 149 var max = walks.SelectMany(x => x.Select(y => y.Item2)).Max(); 150 151 if (min == max) max = min + 1; 152 return walks.Select(w => w.Select(x => Tuple.Create(x.Item1, (x.Item2 - min) / (max - min))).ToList()); 146 153 } 147 154
Note: See TracChangeset
for help on using the changeset viewer.