Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8172


Ignore:
Timestamp:
07/01/12 14:36:47 (12 years ago)
Author:
gkronber
Message:

#1797: adapted return type of ConstrainedValueParameter properties in FLA branch.

Location:
branches/FitnessLandscapeAnalysis
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/Algorithms/LocalAnalysis.cs

    r8002 r8172  
    5656      get { return (ValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; }
    5757    }
    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"]; }
    6363    }
    6464    private ValueParameter<IntValue> MaximumIterationsParameter {
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/Algorithms/RepeatedLocalAnalysis.cs

    r8002 r8172  
    5858      get { return (ValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; }
    5959    }
    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"]; }
    6565    }
    6666    private ValueParameter<IntValue> MaximumIterationsParameter {
     
    162162      laMainLoop.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
    163163      laMainLoop.ResultsParameter.ActualName = "Results";
    164       laMainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;     
     164      laMainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
    165165
    166166      qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/BoxChart/BoxChartCreator.cs

    r7210 r8172  
    22using System.Collections.Generic;
    33using System.Drawing;
    4 using System.Drawing.Drawing2D;
     4using System.Drawing.Imaging;
    55using System.IO;
    66using System.Linq;
    7 using System.Text;
    87using HeuristicLab.Collections;
    98using HeuristicLab.Common;
     
    1413using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    1514using ICSharpCode.SharpZipLib.Zip;
    16 using System.Drawing.Imaging;
    1715
    1816namespace HeuristicLab.Analysis.FitnessLandscape.BoxCharts {
     
    3533    }
    3634    public ValueParameter<IntValue> PaddingParameter {
    37       get { return (ValueParameter<IntValue>) Parameters["Padding"]; }
     35      get { return (ValueParameter<IntValue>)Parameters["Padding"]; }
    3836    }
    3937    public ValueParameter<StringValue> ZipFileNameParameter {
    40       get { return (ValueParameter<StringValue>) Parameters["ZipFileName"]; }
    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    }
    4543    #endregion
    4644
     
    5149    protected int Padding { get { return PaddingParameter.Value.Value; } }
    5250    protected AppendModes AppendMode { get { return (AppendModes)Enum.Parse(typeof(AppendModes), AppendModeParameter.Value.Value); } }
    53       protected List<IBoxChartElementGenerator> Generators {
     51    protected List<IBoxChartElementGenerator> Generators {
    5452      get {
    5553        return ElementsParameter.Value.CheckedItems.Select(i => i.Value).ToList();
     
    6159    [StorableConstructor]
    6260    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) {
    6463      RegisterEvents();
    6564    }
     
    6766      Parameters.Add(new ValueParameter<StringValue>("ChartName", "The result name of the chart.", new StringValue("Chart")));
    6867      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)));
    7170      Parameters.Add(new ValueParameter<StringValue>("ZipFileName", "The name of the zip file that will contain all generated charts.", new StringValue("")));
    7271      Parameters.Add(new ConstrainedValueParameter<StringValue>("AppendMode", "Determines how coordinates of new elements are calculated.",
    73         new ItemSet<StringValue>(Enum.GetNames(typeof (AppendModes)).Select(v => new StringValue(v)))));
     72        new ItemSet<StringValue>(Enum.GetNames(typeof(AppendModes)).Select(v => new StringValue(v)))));
    7473      AppendModeParameter.Value = AppendModeParameter.ValidValues.SingleOrDefault(v => v.Value == AppendModes.Horizontal.ToString());
    7574      RegisterEvents();
     
    8483      if (!Parameters.ContainsKey("AppendMode")) {
    8584        Parameters.Add(new ConstrainedValueParameter<StringValue>("AppendMode", "Determines how coordinates of new elements are calculated.",
    86           new ItemSet<StringValue>(Enum.GetNames(typeof (AppendModes)).Select(v => new StringValue(v)))));
     85          new ItemSet<StringValue>(Enum.GetNames(typeof(AppendModes)).Select(v => new StringValue(v)))));
    8786        AppendModeParameter.Value = AppendModeParameter.ValidValues.SingleOrDefault(v => v.Value == AppendModes.Horizontal.ToString());
    8887      }
     
    109108        var newItems = e.Items.Select(kvp => kvp.Value).ToList();
    110109        switch (AppendMode) {
    111           case AppendModes.Horizontal: 
     110          case AppendModes.Horizontal:
    112111            foreach (var generator in newItems) {
    113112              generator.Y = generators.Max(g => g.Y + g.RowSpan - 1);
     
    132131      var maxX = generators.Max(g => g.X + g.ColSpan);
    133132      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++) {
    135134        var run = runs[i];
    136         var b = new Bitmap(maxX*Size, maxY*Size);
     135        var b = new Bitmap(maxX * Size, maxY * Size);
    137136        using (var g = Graphics.FromImage(b)) {
    138137          g.FillRectangle(SystemBrushes.Control, 0, 0, b.Width, b.Height);
    139138          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));
    141140            gen.Draw(run, g);
    142141            g.ResetClip();
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/NeutralSelector.cs

    r7783 r8172  
    1 using System.Collections.Generic;
     1using System;
     2using System.Collections.Generic;
    23using System.Linq;
     4using HeuristicLab.Analysis.FitnessLandscape.DistanceCalculators;
    35using HeuristicLab.Common;
    46using HeuristicLab.Core;
    57using HeuristicLab.Data;
     8using HeuristicLab.Operators;
    69using HeuristicLab.Optimization;
    710using HeuristicLab.Parameters;
    811using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    9 using HeuristicLab.Selection;
    1012using HeuristicLab.PluginInfrastructure;
    11 using HeuristicLab.Operators;
    12 using System;
    13 using HeuristicLab.Analysis.FitnessLandscape.DistanceCalculators;
    1413
    1514namespace HeuristicLab.Analysis.FitnessLandscape {
     
    5049      get { return (ILookupParameter<ItemArray<IItem>>)Parameters["Solution"]; }
    5150    }
    52     public ConstrainedValueParameter<IItemDistanceCalculator> SolutionDistanceCalculatorParameter {
    53       get { return (ConstrainedValueParameter<IItemDistanceCalculator>)Parameters["SolutionDistanceCalculator"]; }
     51    public IConstrainedValueParameter<IItemDistanceCalculator> SolutionDistanceCalculatorParameter {
     52      get { return (IConstrainedValueParameter<IItemDistanceCalculator>)Parameters["SolutionDistanceCalculator"]; }
    5453    }
    5554    public ValueLookupParameter<DoubleValue> EpsilonParameter {
     
    5756    }
    5857    public ILookupParameter<DoubleValue> CurrentFractionOfNeutralNeighborsParameter {
    59       get { return (LookupParameter<DoubleValue>) Parameters["CurrentFractionOfNeutralNeighbors"]; }
    60     } 
     58      get { return (LookupParameter<DoubleValue>)Parameters["CurrentFractionOfNeutralNeighbors"]; }
     59    }
    6160    public LookupParameter<DoubleValue> CurrentNeutralDistanceParameter {
    6261      get { return (LookupParameter<DoubleValue>)Parameters["CurrentNeutralDistance"]; }
     
    7877      set {
    7978        if (CurrentNeutralDistanceParameter.ActualValue == null)
    80           CurrentNeutralDistanceParameter.ActualValue= new DoubleValue(value);
    81         else 
     79          CurrentNeutralDistanceParameter.ActualValue = new DoubleValue(value);
     80        else
    8281          CurrentNeutralDistanceParameter.ActualValue.Value = value;
    8382      }
    84      
     83
    8584    }
    8685    protected double CurrentFractionOfNeutralNeighbors {
     
    165164
    166165      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 })
    168167        .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        })
    174173        .Where(n => n.BaseDist > 0)
    175174        .ToList();
     
    181180        if (mostDistantNeutralNeighbor != null && mostDistantNeutralNeighbor.StartDist > currentNeutralDistance) {
    182181          if (currentNeutralDistance == 0) {
    183             StartingPointParameter.ActualValue = (IItem) baseSolution.Clone();
     182            StartingPointParameter.ActualValue = (IItem)baseSolution.Clone();
    184183            CurrentNeutralDistance = mostDistantNeutralNeighbor.BaseDist;
    185184          } else {
     
    199198          CurrentNeutralDistance = 0;
    200199        }
    201         CurrentFractionOfNeutralNeighbors = 1.0*neighbors.Count(n => n.Diff == 0)/neighbors.Count;
     200        CurrentFractionOfNeutralNeighbors = 1.0 * neighbors.Count(n => n.Diff == 0) / neighbors.Count;
    202201      }
    203202      return base.Apply();
    204     }   
     203    }
    205204
    206205    private void Select(int i) {
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/PopDist/PopulationDistributionAnalyzer.cs

    r7176 r8172  
    6666      get { return (OptionalValueParameter<StringValue>)Parameters["Population Log File Name"]; }
    6767    }
    68     public ConstrainedValueParameter<IntValue> NQuantilesParameter {
    69       get { return (ConstrainedValueParameter<IntValue>)Parameters["NQuantiles"]; }
     68    public IConstrainedValueParameter<IntValue> NQuantilesParameter {
     69      get { return (IConstrainedValueParameter<IntValue>)Parameters["NQuantiles"]; }
    7070    }
    7171    #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;
     1using System.Linq;
     2using HeuristicLab.Common;
    53using HeuristicLab.Core;
    64using HeuristicLab.Data;
    7 using HeuristicLab.Common;
    8 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    95using HeuristicLab.Encodings.BinaryVectorEncoding;
    106using HeuristicLab.Parameters;
     7using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    118using HeuristicLab.PluginInfrastructure;
    129
     
    1714  public class SortedRandomInteractionsInitializer : ParameterizedNamedItem, IInteractionInitializer {
    1815
    19     public ConstrainedValueParameter<IBinaryVectorComparer> ComparerParameter {
    20       get { return (ConstrainedValueParameter<IBinaryVectorComparer>)Parameters["Comparer"]; }
     16    public IConstrainedValueParameter<IBinaryVectorComparer> ComparerParameter {
     17      get { return (IConstrainedValueParameter<IBinaryVectorComparer>)Parameters["Comparer"]; }
    2118    }
    2219
     
    2421      get { return ComparerParameter.Value; }
    2522    }
    26    
     23
    2724    [StorableConstructor]
    2825    protected SortedRandomInteractionsInitializer(bool serializing) : base(serializing) { }
     
    4744      try {
    4845        IBinaryVectorComparer comparer = Comparer;
    49       } catch {
     46      }
     47      catch {
    5048        Parameters.Remove("Comparer");
    5149        AddComparerParameter();
     
    6058        if (indices.Count > c) {
    6159          indices.RemoveAt(c);
    62           components[c][c] = true;         
     60          components[c][c] = true;
    6361        }
    6462        while (indices.Count > nInteractions) {
     
    6664        }
    6765        foreach (var i in indices) {
    68           components[c][i] = true;         
     66          components[c][i] = true;
    6967        }
    7068      }
    7169      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++) {
    7472          m[i, c.j] = c.v[i];
    75         }   
     73        }
    7674      }
    7775      return m;
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Problems.NK/NKLandscape.cs

    r8083 r8172  
    4141      get { return (ValueParameter<DoubleArray>)Parameters["Weights"]; }
    4242    }
    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"]; }
    4848    }
    4949    #endregion
     
    6060    private List<IOperator> operators {
    6161      set {
    62        Operators.AddRange(value);
    63       }
    64     } 
     62        Operators.AddRange(value);
     63      }
     64    }
    6565    #endregion
    6666
Note: See TracChangeset for help on using the changeset viewer.