Changeset 8172 for branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/InteractionInitializers
- Timestamp:
- 07/01/12 14:36:47 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/InteractionInitializers/SortedRandomInteractionsInitializer.cs
r7128 r8172 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 1 using System.Linq; 2 using HeuristicLab.Common; 5 3 using HeuristicLab.Core; 6 4 using HeuristicLab.Data; 7 using HeuristicLab.Common;8 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;9 5 using HeuristicLab.Encodings.BinaryVectorEncoding; 10 6 using HeuristicLab.Parameters; 7 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 11 8 using HeuristicLab.PluginInfrastructure; 12 9 … … 17 14 public class SortedRandomInteractionsInitializer : ParameterizedNamedItem, IInteractionInitializer { 18 15 19 public ConstrainedValueParameter<IBinaryVectorComparer> ComparerParameter {20 get { return ( ConstrainedValueParameter<IBinaryVectorComparer>)Parameters["Comparer"]; }16 public IConstrainedValueParameter<IBinaryVectorComparer> ComparerParameter { 17 get { return (IConstrainedValueParameter<IBinaryVectorComparer>)Parameters["Comparer"]; } 21 18 } 22 19 … … 24 21 get { return ComparerParameter.Value; } 25 22 } 26 23 27 24 [StorableConstructor] 28 25 protected SortedRandomInteractionsInitializer(bool serializing) : base(serializing) { } … … 47 44 try { 48 45 IBinaryVectorComparer comparer = Comparer; 49 } catch { 46 } 47 catch { 50 48 Parameters.Remove("Comparer"); 51 49 AddComparerParameter(); … … 60 58 if (indices.Count > c) { 61 59 indices.RemoveAt(c); 62 components[c][c] = true; 60 components[c][c] = true; 63 61 } 64 62 while (indices.Count > nInteractions) { … … 66 64 } 67 65 foreach (var i in indices) { 68 components[c][i] = true; 66 components[c][i] = true; 69 67 } 70 68 } 71 69 BoolMatrix m = new BoolMatrix(length, nComponents); 72 foreach (var c in components.OrderBy(v => v, Comparer).Select((v, j) => new { v, j})) {73 for (int i = 0; i <c.v.Length; i++) {70 foreach (var c in components.OrderBy(v => v, Comparer).Select((v, j) => new { v, j })) { 71 for (int i = 0; i < c.v.Length; i++) { 74 72 m[i, c.j] = c.v[i]; 75 } 73 } 76 74 } 77 75 return m;
Note: See TracChangeset
for help on using the changeset viewer.