Changeset 8172
- Timestamp:
- 07/01/12 14:36:47 (12 years ago)
- Location:
- branches/FitnessLandscapeAnalysis
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/Algorithms/LocalAnalysis.cs
r8002 r8172 56 56 get { return (ValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; } 57 57 } 58 public ConstrainedValueParameter<IManipulator> MutatorParameter {59 get { return ( ConstrainedValueParameter<IManipulator>)Parameters["Mutator"]; }60 } 61 public ConstrainedValueParameter<ISelector> SelectorParameter {62 get { return ( ConstrainedValueParameter<ISelector>)Parameters["Selector"]; }58 public IConstrainedValueParameter<IManipulator> MutatorParameter { 59 get { return (IConstrainedValueParameter<IManipulator>)Parameters["Mutator"]; } 60 } 61 public IConstrainedValueParameter<ISelector> SelectorParameter { 62 get { return (IConstrainedValueParameter<ISelector>)Parameters["Selector"]; } 63 63 } 64 64 private ValueParameter<IntValue> MaximumIterationsParameter { -
branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/Algorithms/RepeatedLocalAnalysis.cs
r8002 r8172 58 58 get { return (ValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; } 59 59 } 60 public ConstrainedValueParameter<IManipulator> MutatorParameter {61 get { return ( ConstrainedValueParameter<IManipulator>)Parameters["Mutator"]; }62 } 63 public ConstrainedValueParameter<ISelector> SelectorParameter {64 get { return ( ConstrainedValueParameter<ISelector>)Parameters["Selector"]; }60 public IConstrainedValueParameter<IManipulator> MutatorParameter { 61 get { return (IConstrainedValueParameter<IManipulator>)Parameters["Mutator"]; } 62 } 63 public IConstrainedValueParameter<ISelector> SelectorParameter { 64 get { return (IConstrainedValueParameter<ISelector>)Parameters["Selector"]; } 65 65 } 66 66 private ValueParameter<IntValue> MaximumIterationsParameter { … … 162 162 laMainLoop.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName; 163 163 laMainLoop.ResultsParameter.ActualName = "Results"; 164 laMainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name; 164 laMainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name; 165 165 166 166 qualityAnalyzer = new BestAverageWorstQualityAnalyzer(); -
branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/BoxChart/BoxChartCreator.cs
r7210 r8172 2 2 using System.Collections.Generic; 3 3 using System.Drawing; 4 using System.Drawing. Drawing2D;4 using System.Drawing.Imaging; 5 5 using System.IO; 6 6 using System.Linq; 7 using System.Text;8 7 using HeuristicLab.Collections; 9 8 using HeuristicLab.Common; … … 14 13 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 15 14 using ICSharpCode.SharpZipLib.Zip; 16 using System.Drawing.Imaging;17 15 18 16 namespace HeuristicLab.Analysis.FitnessLandscape.BoxCharts { … … 35 33 } 36 34 public ValueParameter<IntValue> PaddingParameter { 37 get { return (ValueParameter<IntValue>) 35 get { return (ValueParameter<IntValue>)Parameters["Padding"]; } 38 36 } 39 37 public ValueParameter<StringValue> ZipFileNameParameter { 40 get { return (ValueParameter<StringValue>) 41 } 42 public ConstrainedValueParameter<StringValue> AppendModeParameter {43 get { return ( ConstrainedValueParameter<StringValue>)Parameters["AppendMode"]; }44 } 38 get { return (ValueParameter<StringValue>)Parameters["ZipFileName"]; } 39 } 40 public IConstrainedValueParameter<StringValue> AppendModeParameter { 41 get { return (IConstrainedValueParameter<StringValue>)Parameters["AppendMode"]; } 42 } 45 43 #endregion 46 44 … … 51 49 protected int Padding { get { return PaddingParameter.Value.Value; } } 52 50 protected AppendModes AppendMode { get { return (AppendModes)Enum.Parse(typeof(AppendModes), AppendModeParameter.Value.Value); } } 53 51 protected List<IBoxChartElementGenerator> Generators { 54 52 get { 55 53 return ElementsParameter.Value.CheckedItems.Select(i => i.Value).ToList(); … … 61 59 [StorableConstructor] 62 60 protected BoxChartCreator(bool deserializing) : base(deserializing) { } 63 protected BoxChartCreator(BoxChartCreator original, Cloner cloner) : base(original, cloner) { 61 protected BoxChartCreator(BoxChartCreator original, Cloner cloner) 62 : base(original, cloner) { 64 63 RegisterEvents(); 65 64 } … … 67 66 Parameters.Add(new ValueParameter<StringValue>("ChartName", "The result name of the chart.", new StringValue("Chart"))); 68 67 Parameters.Add(new ValueParameter<CheckedItemList<IBoxChartElementGenerator>>("Elements", "List of patient chart element generators.", new CheckedItemList<IBoxChartElementGenerator>())); 69 Parameters.Add(new ValueParameter<IntValue>("Size", "The size of one box in pixels.", new IntValue(50))); 70 Parameters.Add(new ValueParameter<IntValue>("Padding", "The padding inside the boxes", new IntValue(1))); 68 Parameters.Add(new ValueParameter<IntValue>("Size", "The size of one box in pixels.", new IntValue(50))); 69 Parameters.Add(new ValueParameter<IntValue>("Padding", "The padding inside the boxes", new IntValue(1))); 71 70 Parameters.Add(new ValueParameter<StringValue>("ZipFileName", "The name of the zip file that will contain all generated charts.", new StringValue(""))); 72 71 Parameters.Add(new ConstrainedValueParameter<StringValue>("AppendMode", "Determines how coordinates of new elements are calculated.", 73 new ItemSet<StringValue>(Enum.GetNames(typeof 72 new ItemSet<StringValue>(Enum.GetNames(typeof(AppendModes)).Select(v => new StringValue(v))))); 74 73 AppendModeParameter.Value = AppendModeParameter.ValidValues.SingleOrDefault(v => v.Value == AppendModes.Horizontal.ToString()); 75 74 RegisterEvents(); … … 84 83 if (!Parameters.ContainsKey("AppendMode")) { 85 84 Parameters.Add(new ConstrainedValueParameter<StringValue>("AppendMode", "Determines how coordinates of new elements are calculated.", 86 new ItemSet<StringValue>(Enum.GetNames(typeof 85 new ItemSet<StringValue>(Enum.GetNames(typeof(AppendModes)).Select(v => new StringValue(v))))); 87 86 AppendModeParameter.Value = AppendModeParameter.ValidValues.SingleOrDefault(v => v.Value == AppendModes.Horizontal.ToString()); 88 87 } … … 109 108 var newItems = e.Items.Select(kvp => kvp.Value).ToList(); 110 109 switch (AppendMode) { 111 case AppendModes.Horizontal: 110 case AppendModes.Horizontal: 112 111 foreach (var generator in newItems) { 113 112 generator.Y = generators.Max(g => g.Y + g.RowSpan - 1); … … 132 131 var maxX = generators.Max(g => g.X + g.ColSpan); 133 132 var maxY = generators.Max(g => g.Y + g.RowSpan); 134 for (int i = 0; i <runs.Count; i++) {133 for (int i = 0; i < runs.Count; i++) { 135 134 var run = runs[i]; 136 var b = new Bitmap(maxX *Size, maxY*Size);135 var b = new Bitmap(maxX * Size, maxY * Size); 137 136 using (var g = Graphics.FromImage(b)) { 138 137 g.FillRectangle(SystemBrushes.Control, 0, 0, b.Width, b.Height); 139 138 foreach (var gen in generators) { 140 g.SetClip(new Rectangle(gen.X *Size+Padding, gen.Y*Size+Padding, gen.ColSpan*Size-2*Padding, gen.RowSpan*Size-2*Padding));139 g.SetClip(new Rectangle(gen.X * Size + Padding, gen.Y * Size + Padding, gen.ColSpan * Size - 2 * Padding, gen.RowSpan * Size - 2 * Padding)); 141 140 gen.Draw(run, g); 142 141 g.ResetClip(); -
branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/NeutralSelector.cs
r7783 r8172 1 using System.Collections.Generic; 1 using System; 2 using System.Collections.Generic; 2 3 using System.Linq; 4 using HeuristicLab.Analysis.FitnessLandscape.DistanceCalculators; 3 5 using HeuristicLab.Common; 4 6 using HeuristicLab.Core; 5 7 using HeuristicLab.Data; 8 using HeuristicLab.Operators; 6 9 using HeuristicLab.Optimization; 7 10 using HeuristicLab.Parameters; 8 11 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 9 using HeuristicLab.Selection;10 12 using HeuristicLab.PluginInfrastructure; 11 using HeuristicLab.Operators;12 using System;13 using HeuristicLab.Analysis.FitnessLandscape.DistanceCalculators;14 13 15 14 namespace HeuristicLab.Analysis.FitnessLandscape { … … 50 49 get { return (ILookupParameter<ItemArray<IItem>>)Parameters["Solution"]; } 51 50 } 52 public ConstrainedValueParameter<IItemDistanceCalculator> SolutionDistanceCalculatorParameter {53 get { return ( ConstrainedValueParameter<IItemDistanceCalculator>)Parameters["SolutionDistanceCalculator"]; }51 public IConstrainedValueParameter<IItemDistanceCalculator> SolutionDistanceCalculatorParameter { 52 get { return (IConstrainedValueParameter<IItemDistanceCalculator>)Parameters["SolutionDistanceCalculator"]; } 54 53 } 55 54 public ValueLookupParameter<DoubleValue> EpsilonParameter { … … 57 56 } 58 57 public ILookupParameter<DoubleValue> CurrentFractionOfNeutralNeighborsParameter { 59 get { return (LookupParameter<DoubleValue>) 60 } 58 get { return (LookupParameter<DoubleValue>)Parameters["CurrentFractionOfNeutralNeighbors"]; } 59 } 61 60 public LookupParameter<DoubleValue> CurrentNeutralDistanceParameter { 62 61 get { return (LookupParameter<DoubleValue>)Parameters["CurrentNeutralDistance"]; } … … 78 77 set { 79 78 if (CurrentNeutralDistanceParameter.ActualValue == null) 80 CurrentNeutralDistanceParameter.ActualValue = new DoubleValue(value);81 else 79 CurrentNeutralDistanceParameter.ActualValue = new DoubleValue(value); 80 else 82 81 CurrentNeutralDistanceParameter.ActualValue.Value = value; 83 82 } 84 83 85 84 } 86 85 protected double CurrentFractionOfNeutralNeighbors { … … 165 164 166 165 var neighbors = QualityParameter.ActualValue 167 .Zip(items, (q, i) => new { Quality =q.Value, Item=i })166 .Zip(items, (q, i) => new { Quality = q.Value, Item = i }) 168 167 .Select((p, i) => new { 169 Idx =i,170 Diff =Squash(Math.Abs(baseQuality-p.Quality), eps),171 StartDist =calc.Distance(startingPoint, p.Item),172 BaseDist =calc.Distance(baseSolution, p.Item)173 }) 168 Idx = i, 169 Diff = Squash(Math.Abs(baseQuality - p.Quality), eps), 170 StartDist = calc.Distance(startingPoint, p.Item), 171 BaseDist = calc.Distance(baseSolution, p.Item) 172 }) 174 173 .Where(n => n.BaseDist > 0) 175 174 .ToList(); … … 181 180 if (mostDistantNeutralNeighbor != null && mostDistantNeutralNeighbor.StartDist > currentNeutralDistance) { 182 181 if (currentNeutralDistance == 0) { 183 StartingPointParameter.ActualValue = (IItem) 182 StartingPointParameter.ActualValue = (IItem)baseSolution.Clone(); 184 183 CurrentNeutralDistance = mostDistantNeutralNeighbor.BaseDist; 185 184 } else { … … 199 198 CurrentNeutralDistance = 0; 200 199 } 201 CurrentFractionOfNeutralNeighbors = 1.0 *neighbors.Count(n => n.Diff == 0)/neighbors.Count;200 CurrentFractionOfNeutralNeighbors = 1.0 * neighbors.Count(n => n.Diff == 0) / neighbors.Count; 202 201 } 203 202 return base.Apply(); 204 } 203 } 205 204 206 205 private void Select(int i) { -
branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/PopDist/PopulationDistributionAnalyzer.cs
r7176 r8172 66 66 get { return (OptionalValueParameter<StringValue>)Parameters["Population Log File Name"]; } 67 67 } 68 public ConstrainedValueParameter<IntValue> NQuantilesParameter {69 get { return ( ConstrainedValueParameter<IntValue>)Parameters["NQuantiles"]; }68 public IConstrainedValueParameter<IntValue> NQuantilesParameter { 69 get { return (IConstrainedValueParameter<IntValue>)Parameters["NQuantiles"]; } 70 70 } 71 71 #endregion -
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; -
branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/NKLandscape.cs
r8083 r8172 41 41 get { return (ValueParameter<DoubleArray>)Parameters["Weights"]; } 42 42 } 43 public OptionalConstrainedValueParameter<IInteractionInitializer> InteractionInitializerParameter {44 get { return ( OptionalConstrainedValueParameter<IInteractionInitializer>)Parameters["InteractionInitializer"]; }45 } 46 public OptionalConstrainedValueParameter<IWeightsInitializer> WeightsInitializerParameter {47 get { return ( OptionalConstrainedValueParameter<IWeightsInitializer>)Parameters["WeightsInitializer"]; }43 public IConstrainedValueParameter<IInteractionInitializer> InteractionInitializerParameter { 44 get { return (IConstrainedValueParameter<IInteractionInitializer>)Parameters["InteractionInitializer"]; } 45 } 46 public IConstrainedValueParameter<IWeightsInitializer> WeightsInitializerParameter { 47 get { return (IConstrainedValueParameter<IWeightsInitializer>)Parameters["WeightsInitializer"]; } 48 48 } 49 49 #endregion … … 60 60 private List<IOperator> operators { 61 61 set { 62 Operators.AddRange(value);63 } 64 } 62 Operators.AddRange(value); 63 } 64 } 65 65 #endregion 66 66
Note: See TracChangeset
for help on using the changeset viewer.