Changeset 14353


Ignore:
Timestamp:
10/23/16 19:31:18 (3 years ago)
Author:
bburlacu
Message:

#2685: Add correction step for values miscalculated due to cyclical symbol dependencies in the grammar. Updated unit test.

Location:
trunk/sources
Files:
1 added
49 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithmMainLoop.cs

    r14185 r14353  
    162162      Comparator maxSelectionPressureComparator = new Comparator();
    163163      Comparator maxEvaluatedSolutionsComparator = new Comparator();
     164      Comparator maxSolutionQualityComparator = new Comparator();
    164165      Placeholder comparisonFactorModifier = new Placeholder();
    165166      Placeholder analyzer2 = new Placeholder();
     
    167168      ConditionalBranch conditionalBranch2 = new ConditionalBranch();
    168169      ConditionalBranch conditionalBranch3 = new ConditionalBranch();
     170      ConditionalBranch conditionalBranch4 = new ConditionalBranch();
    169171
    170172      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class OffspringSelectionGeneticAlgorithm expects this to be called Generations
     
    223225      maxEvaluatedSolutionsComparator.RightSideParameter.ActualName = "MaximumEvaluatedSolutions";
    224226
     227      maxSolutionQualityComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
     228      maxSolutionQualityComparator.LeftSideParameter.ActualName = "MaximumQuality";
     229      maxSolutionQualityComparator.ResultParameter.ActualName = "TerminateMaximumQuality";
     230      maxSolutionQualityComparator.RightSideParameter.ActualName = "BestQuality";
     231
    225232      comparisonFactorModifier.Name = "Update ComparisonFactor (placeholder)";
    226233      comparisonFactorModifier.OperatorParameter.ActualName = ComparisonFactorModifierParameter.Name;
     
    237244      conditionalBranch3.Name = "MaximumEvaluatedSolutions reached?";
    238245      conditionalBranch3.ConditionParameter.ActualName = "TerminateEvaluatedSolutions";
     246
     247      conditionalBranch4.Name = "MaximumQuality reached?";
     248      conditionalBranch3.ConditionParameter.ActualName = "TerminateMaximumQuality";
    239249      #endregion
    240250
     
    249259      maxGenerationsComparator.Successor = maxSelectionPressureComparator;
    250260      maxSelectionPressureComparator.Successor = maxEvaluatedSolutionsComparator;
    251       maxEvaluatedSolutionsComparator.Successor = comparisonFactorModifier;
     261      maxEvaluatedSolutionsComparator.Successor = maxSolutionQualityComparator;
     262      maxSolutionQualityComparator.Successor = comparisonFactorModifier;
    252263      comparisonFactorModifier.Successor = analyzer2;
    253264      analyzer2.Successor = conditionalBranch1;
     
    258269      conditionalBranch2.TrueBranch = null;
    259270      conditionalBranch2.Successor = null;
    260       conditionalBranch3.FalseBranch = mainOperator;
     271      conditionalBranch3.FalseBranch = conditionalBranch4;
    261272      conditionalBranch3.TrueBranch = null;
    262273      conditionalBranch3.Successor = null;
     274      conditionalBranch4.FalseBranch = mainOperator;
     275      conditionalBranch4.TrueBranch = null;
     276      conditionalBranch4.Successor = null;
    263277      #endregion
    264278    }
  • trunk/sources/HeuristicLab.Analysis/3.3/PopulationSimilarityAnalysis/PopulationSimilarityAnalyzer.cs

    r14185 r14353  
    136136      var similarityCalculators = SimilarityCalculatorParameter.ValidValues;
    137137      foreach (var similarityCalculator in similarityCalculators) {
     138        if (similarityCalculator == null) continue;
    138139        similarityCalculator.ExecuteInParallel = ExecuteInParallel;
    139140        similarityCalculator.MaxDegreeOfParallelism = MaxDegreeOfParallelism;
  • trunk/sources/HeuristicLab.Clients.Hive.Slave/3.3/Manager/ConfigManager.cs

    r14185 r14353  
    7070      slave.Name = Environment.MachineName;
    7171      if (Settings.Default.NrOfCoresToScavenge < 1 || Settings.Default.NrOfCoresToScavenge > Environment.ProcessorCount) {
    72         slave.Cores = Environment.ProcessorCount;
     72        slave.Cores = Environment.ProcessorCount / 2;
    7373      } else {
    7474        slave.Cores = Settings.Default.NrOfCoresToScavenge;
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/GrammarUtils.cs

    r14352 r14353  
    6666                continue;
    6767
    68               if (visited.Add(childSymbol)) {
     68              if (visited.Add(childSymbol))
    6969                numberedSymbols.Add(Tuple.Create(childSymbol, ++index));
    70               }
    7170            }
    7271          }
     
    8887            minLength = Math.Min(minLength, oldLength);
    8988          minimumExpressionLengths[symbol.Name] = (int)Math.Min(int.MaxValue, minLength);
     89        }
     90        // correction step for cycles
     91        bool changed = true;
     92        while (changed) {
     93          changed = false;
     94          foreach (var symbol in numberedSymbols.Select(x => x.Item1)) {
     95            long minLength = Enumerable.Range(0, grammar.GetMinimumSubtreeCount(symbol))
     96              .Sum(x => grammar.GetAllowedChildSymbols(symbol, x)
     97              .Min(s => (long)minimumExpressionLengths[s.Name])) + 1;
     98            if (minLength < minimumExpressionLengths[symbol.Name]) {
     99              minimumExpressionLengths[symbol.Name] = (int)Math.Min(minLength, int.MaxValue);
     100              changed = true;
     101            }
     102          }
    90103        }
    91104      }
     
    121134                continue;
    122135
    123               if (visited.Add(childSymbol)) {
     136              if (visited.Add(childSymbol))
    124137                numberedSymbols.Add(Tuple.Create(childSymbol, ++index));
    125               }
    126138            }
    127139          }
     
    132144        // going bottom-up (reverse breadth order), we ensure depths are calculated bottom-up
    133145        foreach (var symbol in numberedSymbols.Select(x => x.Item1)) {
    134           long minDepth = int.MaxValue;
     146          long minDepth = -1;
    135147          for (int argIndex = 0; argIndex < grammar.GetMinimumSubtreeCount(symbol); ++argIndex) {
    136148            long depth = grammar.GetAllowedChildSymbols(symbol, argIndex)
    137149              .Where(x => minimumExpressionDepths.ContainsKey(x.Name))
    138               .Select(x => minimumExpressionDepths[x.Name]).DefaultIfEmpty(int.MaxValue).Min();
    139             minDepth = Math.Min(minDepth, depth + 1);
     150              .Select(x => (long)minimumExpressionDepths[x.Name]).DefaultIfEmpty(int.MaxValue).Min() + 1;
     151            minDepth = Math.Max(minDepth, depth);
    140152          }
    141153          int oldDepth;
     
    143155            minDepth = Math.Min(minDepth, oldDepth);
    144156          minimumExpressionDepths[symbol.Name] = (int)Math.Min(int.MaxValue, minDepth);
     157        }
     158        // correction step for cycles
     159        bool changed = true;
     160        while (changed) {
     161          changed = false;
     162          foreach (var symbol in numberedSymbols.Select(x => x.Item1)) {
     163            long minDepth = Enumerable.Range(0, grammar.GetMinimumSubtreeCount(symbol))
     164              .Max(x => grammar.GetAllowedChildSymbols(symbol, x)
     165              .Min(s => (long)minimumExpressionDepths[s.Name])) + 1;
     166            if (minDepth < minimumExpressionDepths[symbol.Name]) {
     167              minimumExpressionDepths[symbol.Name] = (int)Math.Min(minDepth, int.MaxValue);
     168              changed = true;
     169            }
     170          }
    145171        }
    146172      }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.cs

    r14185 r14353  
    7070      }
    7171      if (errorState != OnlineCalculatorError.None) return double.NaN;
    72       return r*r;
     72      return r * r;
    7373    }
    7474
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionPhenotypicDiversityAnalyzer.cs

    r14185 r14353  
    4242    private const string ProblemDataParameterName = "ProblemData";
    4343    private const string EstimationLimitsParameterName = "EstimationLimits";
     44    private const string ApplyLinearScalingParameterName = "ApplyLinearScaling";
    4445    #endregion
    4546
     
    6061      get { return (IValueLookupParameter<DoubleLimit>)Parameters[EstimationLimitsParameterName]; }
    6162    }
     63    public ILookupParameter<BoolValue> ApplyLinearScalingParameter {
     64      get { return (ILookupParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; }
     65    }
    6266    #endregion
    6367
     
    7074      Parameters.Add(new ValueLookupParameter<IRegressionProblemData>(ProblemDataParameterName, "The problem data on which the symbolic data analysis solution should be evaluated."));
    7175      Parameters.Add(new ValueLookupParameter<DoubleLimit>(EstimationLimitsParameterName, "The upper and lower limit that should be used as cut off value for the output values of symbolic data analysis trees."));
     76      Parameters.Add(new LookupParameter<BoolValue>(ApplyLinearScalingParameterName, "Whether or not to apply linear scaling to the estimated values"));
    7277      #endregion
    7378
     
    7984    protected SymbolicRegressionPhenotypicDiversityAnalyzer(bool deserializing)
    8085      : base(deserializing) {
     86    }
     87
     88    [StorableHook(HookType.AfterDeserialization)]
     89    private void AfterDeserialization() {
     90      if (!Parameters.ContainsKey(ApplyLinearScalingParameterName))
     91        Parameters.Add(new LookupParameter<BoolValue>(ApplyLinearScalingParameterName, "Whether or not to apply linear scaling to the estimated values"));
    8192    }
    8293
     
    98109      }
    99110
    100       if (updateCounter.Value == updateInterval) {
    101         var trees = SymbolicExpressionTreeParameter.ActualValue;
     111      if (updateCounter.Value != updateInterval) return base.Apply();
     112
     113      var scopes = ExecutionContext.Scope.SubScopes;
     114      var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value;
     115
     116      foreach (var scope in scopes.Where(x => !x.Variables.ContainsKey("EstimatedValues"))) {
     117        var tree = (ISymbolicExpressionTree)scope.Variables["SymbolicExpressionTree"].Value;
    102118        var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue;
    103119        var ds = ProblemDataParameter.ActualValue.Dataset;
    104120        var rows = ProblemDataParameter.ActualValue.TrainingIndices;
     121        var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(tree, ds, rows).ToArray();
    105122
    106         var evaluatedValues = new ItemArray<DoubleArray>(trees.Select(t => new DoubleArray(interpreter.GetSymbolicExpressionTreeValues(t, ds, rows).ToArray())));
    107         EvaluatedValuesParameter.ActualValue = evaluatedValues;
     123        var estimationLimits = EstimationLimitsParameter.ActualValue;
     124
     125        if (applyLinearScaling) {
     126          var linearScalingCalculator = new OnlineLinearScalingParameterCalculator();
     127          var targetValues = ds.GetDoubleValues(ProblemDataParameter.ActualValue.TargetVariable, rows);
     128          int i = 0;
     129          foreach (var target in targetValues) {
     130            var estimated = estimatedValues[i];
     131            if (!double.IsNaN(estimated) && !double.IsInfinity(estimated))
     132              linearScalingCalculator.Add(estimated, target);
     133            i++;
     134          }
     135          if (linearScalingCalculator.ErrorState == OnlineCalculatorError.None) {
     136            var alpha = linearScalingCalculator.Alpha;
     137            var beta = linearScalingCalculator.Beta;
     138            for (i = 0; i < estimatedValues.Length; ++i) {
     139              estimatedValues[i] = estimatedValues[i] * beta + alpha;
     140            }
     141          }
     142        }
     143        // add estimated values to escope
     144        scope.Variables.Add(new Core.Variable("EstimatedValues", new DoubleArray(estimatedValues.LimitToRange(estimationLimits.Lower, estimationLimits.Upper).ToArray())));
    108145      }
    109146      return base.Apply();
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/SymbolicExpressionTreeBottomUpSimilarityCalculator.cs

    r14185 r14353  
    6161    }
    6262
     63    public static double CalculateBottomUpSimilarity(ISymbolicExpressionTree t1, ISymbolicExpressionTree t2) {
     64      return new SymbolicExpressionTreeBottomUpSimilarityCalculator().CalculateSimilarity(t1, t2);
     65    }
     66
    6367    public override double CalculateSolutionSimilarity(IScope leftSolution, IScope rightSolution) {
    6468      if (leftSolution == rightSolution)
     
    7377      var similarity = CalculateSimilarity(t1, t2);
    7478      if (similarity > 1.0)
    75         throw new Exception("Similarity value cannot be greater than 1");
     79        throw new Exception("Similarity value " + similarity + " cannot be greater than 1");
    7680
    7781      return similarity;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/SymbolicExpressionTreePhenotypicSimilarityCalculator.cs

    r14185 r14353  
    9292
    9393      var r2 = error == OnlineCalculatorError.None ? r * r : 0;
    94 
    95       if (r2 > 1.0)
    96         r2 = 1.0;
    97 
    9894      return r2;
    9995    }
  • trunk/sources/HeuristicLab.Problems.GrammaticalEvolution/3.4/HeuristicLab.Problems.GrammaticalEvolution-3.4.csproj

    r12915 r14353  
    252252    </ProjectReference>
    253253  </ItemGroup>
     254  <ItemGroup>
     255    <Content Include="ArtificialAnt\GEArtificialAntEvaluator.cs" />
     256  </ItemGroup>
    254257  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    255258  <PropertyGroup>
  • trunk/sources/HeuristicLab.Tests/HeuristicLab-3.3/ContentViewTests.cs

    r14185 r14353  
    2424using HeuristicLab.Common;
    2525using HeuristicLab.MainForm;
    26 using HeuristicLab.MainForm.WindowsForms;
    2726using HeuristicLab.PluginInfrastructure;
    2827using Microsoft.VisualStudio.TestTools.UnitTesting;
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.BinaryVectorEncoding-3.3/NPointCrossoverTest.cs

    r14185 r14353  
    2020#endregion
    2121
     22using HeuristicLab.Core;
    2223using HeuristicLab.Data;
    2324using HeuristicLab.Tests;
     
    3132  [TestClass()]
    3233  public class NPointCrossoverTest {
     34    /// <summary>
     35    ///A test for Cross
     36    ///</summary>
     37    [TestMethod]
     38    [TestCategory("Encodings.BinaryVector")]
     39    [TestProperty("Time", "short")]
     40    public void NPointCrossoverCrossTest() {
     41      var privateObject = new PrivateObject(typeof(NPointCrossover));
     42      ItemArray<BinaryVector> parents;
     43      TestRandom random = new TestRandom();
     44      bool exceptionFired;
     45      // The following test checks if there is an exception when there are more than 2 parents
     46      random.Reset();
     47      parents = new ItemArray<BinaryVector>(new BinaryVector[] { new BinaryVector(5), new BinaryVector(6), new BinaryVector(4) });
     48      exceptionFired = false;
     49      try {
     50        var actual = (BinaryVector)privateObject.Invoke("Cross", random, parents);
     51      }
     52      catch (System.ArgumentException) {
     53        exceptionFired = true;
     54      }
     55      Assert.IsTrue(exceptionFired);
     56      // The following test checks if there is an exception when there are less than 2 parents
     57      random.Reset();
     58      parents = new ItemArray<BinaryVector>(new BinaryVector[] { new BinaryVector(4) });
     59      exceptionFired = false;
     60      try {
     61        var actual = (BinaryVector)privateObject.Invoke("Cross", random, parents);
     62      }
     63      catch (System.ArgumentException) {
     64        exceptionFired = true;
     65      }
     66      Assert.IsTrue(exceptionFired);
     67    }
     68
    3369    /// <summary>
    3470    ///A test for Apply
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.BinaryVectorEncoding-3.3/SinglePointCrossoverTest.cs

    r13129 r14353  
    3939    [TestProperty("Time", "short")]
    4040    public void SinglePointCrossoverCrossTest() {
    41       SinglePointCrossover_Accessor target = new SinglePointCrossover_Accessor(new PrivateObject(typeof(SinglePointCrossover)));
     41      var privateObject = new PrivateObject(typeof(SinglePointCrossover));
    4242      ItemArray<BinaryVector> parents;
    4343      TestRandom random = new TestRandom();
     
    4848      exceptionFired = false;
    4949      try {
    50         BinaryVector actual;
    51         actual = target.Cross(random, parents);
    52       } catch (ArgumentException) {
     50        var actual = (BinaryVector)privateObject.Invoke("Cross", random, parents);
     51      }
     52      catch (ArgumentException) {
    5353        exceptionFired = true;
    5454      }
     
    5959      exceptionFired = false;
    6060      try {
    61         BinaryVector actual;
    62         actual = target.Cross(random, parents);
    63       } catch (ArgumentException) {
     61        var actual = (BinaryVector)privateObject.Invoke("Cross", random, parents);
     62      }
     63      catch (ArgumentException) {
    6464        exceptionFired = true;
    6565      }
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.BinaryVectorEncoding-3.3/UniformCrossoverTest.cs

    r14185 r14353  
    2020#endregion
    2121
     22using HeuristicLab.Core;
    2223using HeuristicLab.Tests;
    2324using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    3031  [TestClass()]
    3132  public class UniformCrossoverTest {
     33    /// <summary>
     34    ///A test for Cross
     35    ///</summary>
     36    [TestMethod]
     37    [TestCategory("Encodings.BinaryVector")]
     38    [TestProperty("Time", "short")]
     39    public void SinglePointCrossoverCrossTest() {
     40      var target = new PrivateObject(typeof(UniformCrossover));
     41      ItemArray<BinaryVector> parents;
     42      TestRandom random = new TestRandom();
     43      bool exceptionFired;
     44      // The following test checks if there is an exception when there are more than 2 parents
     45      random.Reset();
     46      parents = new ItemArray<BinaryVector>(new BinaryVector[] { new BinaryVector(5), new BinaryVector(6), new BinaryVector(4) });
     47      exceptionFired = false;
     48      try {
     49        BinaryVector actual;
     50        actual = (BinaryVector)target.Invoke("Cross", random, parents);
     51      }
     52      catch (System.ArgumentException) {
     53        exceptionFired = true;
     54      }
     55      Assert.IsTrue(exceptionFired);
     56      // The following test checks if there is an exception when there are less than 2 parents
     57      random.Reset();
     58      parents = new ItemArray<BinaryVector>(new BinaryVector[] { new BinaryVector(4) });
     59      exceptionFired = false;
     60      try {
     61        BinaryVector actual;
     62        actual = (BinaryVector)target.Invoke("Cross", random, parents);
     63      }
     64      catch (System.ArgumentException) {
     65        exceptionFired = true;
     66      }
     67      Assert.IsTrue(exceptionFired);
     68    }
     69
    3270    /// <summary>
    3371    ///A test for Apply
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.IntegerVectorEncoding-3.3/DiscreteCrossoverTest.cs

    r14185 r14353  
    3131  [TestClass()]
    3232  public class DiscreteCrossoverTest {
     33    /// <summary>
     34    ///A test for Cross
     35    ///</summary>
     36    [TestMethod]
     37    [TestCategory("Encodings.IntegerVector")]
     38    [TestProperty("Time", "short")]
     39    public void DiscreteCrossoverCrossTest() {
     40      var privateObject = new PrivateObject(typeof(DiscreteCrossover));
     41      ItemArray<IntegerVector> parents;
     42      TestRandom random = new TestRandom();
     43      bool exceptionFired;
     44      // The following test checks if there is an exception when there are less than 2 parents
     45      random.Reset();
     46      parents = new ItemArray<IntegerVector>(new IntegerVector[] { new IntegerVector(4) });
     47      exceptionFired = false;
     48      try {
     49        var actual = (IntegerVector)privateObject.Invoke("Cross", random, parents);
     50      }
     51      catch (System.ArgumentException) {
     52        exceptionFired = true;
     53      }
     54      Assert.IsTrue(exceptionFired);
     55    }
     56
    3357    /// <summary>
    3458    ///A test for Apply
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.IntegerVectorEncoding-3.3/SinglePointCrossoverTest.cs

    r14185 r14353  
    3838    [TestProperty("Time", "short")]
    3939    public void SinglePointCrossoverCrossTest() {
    40       var target = new PrivateObject(typeof(SinglePointCrossover));
     40      var privateObject = new PrivateObject(typeof(SinglePointCrossover));
    4141      ItemArray<IntegerVector> parents;
    4242      TestRandom random = new TestRandom();
     
    4747      exceptionFired = false;
    4848      try {
    49         IntegerVector actual;
    50         actual = (IntegerVector)target.Invoke("Cross", random, parents);
     49        var actual = (IntegerVector)privateObject.Invoke("Cross", random, parents);
    5150      }
    5251      catch (System.ArgumentException) {
     
    5958      exceptionFired = false;
    6059      try {
    61         IntegerVector actual;
    62         actual = (IntegerVector)target.Invoke("Cross", random, parents);
     60        var actual = (IntegerVector)privateObject.Invoke("Cross", random, parents);
    6361      }
    6462      catch (System.ArgumentException) {
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.PermutationEncoding-3.3/CosaCrossoverTest.cs

    r14185 r14353  
    2020#endregion
    2121
     22using HeuristicLab.Core;
    2223using HeuristicLab.Tests;
    2324using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    3031  [TestClass()]
    3132  public class CosaCrossoverTest {
     33    /// <summary>
     34    ///A test for Cross
     35    ///</summary>
     36    [TestMethod]
     37    [TestCategory("Encodings.Permutation")]
     38    [TestProperty("Time", "short")]
     39    public void CosaCrossoverCrossTest() {
     40      TestRandom random = new TestRandom();
     41      var privateObject = new PrivateObject(typeof(CosaCrossover));
     42      // perform a test with more than two parents
     43      random.Reset();
     44      bool exceptionFired = false;
     45      try {
     46        privateObject.Invoke("Cross", random, new ItemArray<Permutation>(new Permutation[] {
     47          new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4)}));
     48      }
     49      catch (System.InvalidOperationException) {
     50        exceptionFired = true;
     51      }
     52      Assert.IsTrue(exceptionFired);
     53    }
     54
    3255    /// <summary>
    3356    ///A test for Apply
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.PermutationEncoding-3.3/CyclicCrossover2Test.cs

    r14185 r14353  
    2020#endregion
    2121
     22using HeuristicLab.Core;
    2223using HeuristicLab.Tests;
    2324using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    3031  [TestClass()]
    3132  public class CyclicCrossover2Test {
     33    /// <summary>
     34    ///A test for Cross
     35    ///</summary>
     36    [TestMethod]
     37    [TestCategory("Encodings.Permutation")]
     38    [TestProperty("Time", "short")]
     39    public void CyclicCrossover2CrossTest() {
     40      TestRandom random = new TestRandom();
     41      var privateObject = new PrivateObject(typeof(CyclicCrossover2));
     42      // perform a test with more than two parents
     43      random.Reset();
     44      bool exceptionFired = false;
     45      try {
     46        privateObject.Invoke("Cross", random, new ItemArray<Permutation>(new Permutation[] {
     47          new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4)}));
     48      }
     49      catch (System.InvalidOperationException) {
     50        exceptionFired = true;
     51      }
     52      Assert.IsTrue(exceptionFired);
     53    }
     54
    3255    /// <summary>
    3356    ///A test for Apply
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.PermutationEncoding-3.3/CyclicCrossoverTest.cs

    r14185 r14353  
    2020#endregion
    2121
     22using HeuristicLab.Core;
    2223using HeuristicLab.Tests;
    2324using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    3031  [TestClass()]
    3132  public class CyclicCrossoverTest {
     33    /// <summary>
     34    ///A test for Cross
     35    ///</summary>
     36    [TestMethod]
     37    [TestCategory("Encodings.Permutation")]
     38    [TestProperty("Time", "short")]
     39    public void CyclicCrossoverCrossTest() {
     40      TestRandom random = new TestRandom();
     41      var privateObject = new PrivateObject(typeof(CyclicCrossover));
     42      // perform a test with more than two parents
     43      random.Reset();
     44      bool exceptionFired = false;
     45      try {
     46        privateObject.Invoke("Cross", random, new ItemArray<Permutation>(new Permutation[] {
     47          new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4)}));
     48      }
     49      catch (System.InvalidOperationException) {
     50        exceptionFired = true;
     51      }
     52      Assert.IsTrue(exceptionFired);
     53    }
     54
    3255    /// <summary>
    3356    ///A test for Apply
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.PermutationEncoding-3.3/EdgeRecombinationCrossoverTest.cs

    r14185 r14353  
    2020#endregion
    2121
     22using HeuristicLab.Core;
    2223using HeuristicLab.Tests;
    2324using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    3031  [TestClass()]
    3132  public class EdgeRecombinationCrossoverTest {
     33    /// <summary>
     34    ///A test for Cross
     35    ///</summary>
     36    [TestMethod]
     37    [TestCategory("Encodings.Permutation")]
     38    [TestProperty("Time", "short")]
     39    public void EdgeRecombinationCrossoverCrossoverCrossTest() {
     40      TestRandom random = new TestRandom();
     41      var privateObject = new PrivateObject(typeof(EdgeRecombinationCrossover));
     42      // perform a test with more than two parents
     43      random.Reset();
     44      bool exceptionFired = false;
     45      try {
     46        privateObject.Invoke("Cross", random, new ItemArray<Permutation>(new Permutation[] {
     47          new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4)}));
     48      }
     49      catch (System.InvalidOperationException) {
     50        exceptionFired = true;
     51      }
     52      Assert.IsTrue(exceptionFired);
     53    }
     54
    3255    /// <summary>
    3356    ///A test for Apply
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.PermutationEncoding-3.3/MaximalPreservativeCrossoverTest.cs

    r14185 r14353  
    2020#endregion
    2121
     22using HeuristicLab.Core;
    2223using HeuristicLab.Tests;
    2324using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    3031  [TestClass()]
    3132  public class MaximalPreservativeCrossoverTest {
     33    /// <summary>
     34    ///A test for Cross
     35    ///</summary>
     36    [TestMethod]
     37    [TestCategory("Encodings.Permutation")]
     38    [TestProperty("Time", "short")]
     39    public void MaximalPreservativeCrossoverCrossTest() {
     40      TestRandom random = new TestRandom();
     41      var privateObject = new PrivateObject(typeof(MaximalPreservativeCrossover));
     42      // perform a test with more than two parents
     43      random.Reset();
     44      bool exceptionFired = false;
     45      try {
     46        privateObject.Invoke("Cross", random, new ItemArray<Permutation>(new Permutation[] {
     47          new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4)}));
     48      }
     49      catch (System.InvalidOperationException) {
     50        exceptionFired = true;
     51      }
     52      Assert.IsTrue(exceptionFired);
     53    }
     54
    3255    /// <summary>
    3356    ///A test for Apply
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.PermutationEncoding-3.3/OrderBasedCrossoverTest.cs

    r14185 r14353  
    2020#endregion
    2121
     22using HeuristicLab.Core;
    2223using HeuristicLab.Tests;
    2324using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    3031  [TestClass()]
    3132  public class OrderBasedCrossoverTest {
     33    /// <summary>
     34    ///A test for Cross
     35    ///</summary>
     36    [TestMethod]
     37    [TestCategory("Encodings.Permutation")]
     38    [TestProperty("Time", "short")]
     39    public void OrderBasedCrossoverCrossTest() {
     40      TestRandom random = new TestRandom();
     41      var privateObject = new PrivateObject(typeof(OrderBasedCrossover));
     42      // perform a test with more than two parents
     43      random.Reset();
     44      bool exceptionFired = false;
     45      try {
     46        privateObject.Invoke("Cross", random, new ItemArray<Permutation>(new Permutation[] {
     47          new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4)}));
     48      }
     49      catch (System.InvalidOperationException) {
     50        exceptionFired = true;
     51      }
     52      Assert.IsTrue(exceptionFired);
     53    }
     54
    3255    /// <summary>
    3356    ///A test for Apply
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.PermutationEncoding-3.3/OrderCrossover2Test.cs

    r14185 r14353  
    2020#endregion
    2121
     22using HeuristicLab.Core;
    2223using HeuristicLab.Tests;
    2324using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    3031  [TestClass()]
    3132  public class OrderCrossover2Test {
     33    /// <summary>
     34    ///A test for Cross
     35    ///</summary>
     36    [TestMethod]
     37    [TestCategory("Encodings.Permutation")]
     38    [TestProperty("Time", "short")]
     39    public void OrderCrossover2CrossTest() {
     40      TestRandom random = new TestRandom();
     41      var privateObject = new PrivateObject(typeof(OrderCrossover2));
     42      random.Reset();
     43      bool exceptionFired = false;
     44      try {
     45        privateObject.Invoke("Cross", random, new ItemArray<Permutation>(new Permutation[] {
     46          new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4)}));
     47      }
     48      catch (System.InvalidOperationException) {
     49        exceptionFired = true;
     50      }
     51      Assert.IsTrue(exceptionFired);
     52    }
     53
    3254    /// <summary>
    3355    ///A test for Apply
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.PermutationEncoding-3.3/OrderCrossoverTest.cs

    r14185 r14353  
    2020#endregion
    2121
     22using HeuristicLab.Core;
    2223using HeuristicLab.Tests;
    2324using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    3031  [TestClass()]
    3132  public class OrderCrossoverTest {
     33    /// <summary>
     34    ///A test for Cross
     35    ///</summary>
     36    [TestMethod]
     37    [TestCategory("Encodings.Permutation")]
     38    [TestProperty("Time", "short")]
     39    public void OrderCrossoverCrossTest() {
     40      TestRandom random = new TestRandom();
     41      var privateObject = new PrivateObject(typeof(OrderCrossover));
     42      // perform a test with more than two parents
     43      random.Reset();
     44      bool exceptionFired = false;
     45      try {
     46        privateObject.Invoke("Cross", random, new ItemArray<Permutation>(new Permutation[] {
     47          new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4)}));
     48      }
     49      catch (System.InvalidOperationException) {
     50        exceptionFired = true;
     51      }
     52      Assert.IsTrue(exceptionFired);
     53    }
     54
    3255    /// <summary>
    3356    ///A test for Apply
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.PermutationEncoding-3.3/PartiallyMatchedCrossoverTest.cs

    r14185 r14353  
    2020#endregion
    2121
     22using HeuristicLab.Core;
    2223using HeuristicLab.Tests;
    2324using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    3031  [TestClass()]
    3132  public class PartiallyMatchedCrossoverTest {
     33    /// <summary>
     34    ///A test for Cross
     35    ///</summary>
     36    [TestMethod]
     37    [TestCategory("Encodings.Permutation")]
     38    [TestProperty("Time", "short")]
     39    public void PartiallyMatchedCrossTest() {
     40      TestRandom random = new TestRandom();
     41      var privateObject = new PrivateObject(typeof(PartiallyMatchedCrossover));
     42      // perform a test with more than two parents
     43      random.Reset();
     44      bool exceptionFired = false;
     45      try {
     46        privateObject.Invoke("Cross", random, new ItemArray<Permutation>(new Permutation[] {
     47          new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4)}));
     48      }
     49      catch (System.InvalidOperationException) {
     50        exceptionFired = true;
     51      }
     52      Assert.IsTrue(exceptionFired);
     53    }
     54
    3255    /// <summary>
    3356    ///A test for Apply
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.PermutationEncoding-3.3/PositionBasedCrossoverTest.cs

    r14185 r14353  
    2020#endregion
    2121
     22using HeuristicLab.Core;
    2223using HeuristicLab.Tests;
    2324using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    3031  [TestClass()]
    3132  public class PositionBasedCrossoverTest {
     33    /// <summary>
     34    ///A test for Cross
     35    ///</summary>
     36    [TestMethod]
     37    [TestCategory("Encodings.Permutation")]
     38    [TestProperty("Time", "short")]
     39    public void PositionBasedCrossoverCrossTest() {
     40      TestRandom random = new TestRandom();
     41      var privateObject = new PrivateObject(typeof(PositionBasedCrossover));
     42
     43      // perform a test with more than two parents
     44      random.Reset();
     45      bool exceptionFired = false;
     46      try {
     47        privateObject.Invoke("Cross", random, new ItemArray<Permutation>(new Permutation[] {
     48          new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4) }));
     49      }
     50      catch (System.InvalidOperationException) {
     51        exceptionFired = true;
     52      }
     53      Assert.IsTrue(exceptionFired);
     54    }
     55
    3256    /// <summary>
    3357    ///A test for Apply
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.PermutationEncoding-3.3/UniformLikeCrossoverTest.cs

    r14185 r14353  
    5454      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, actual));
    5555    }
     56
     57    /// <summary>
     58    ///A test for Cross
     59    ///</summary>
     60    [TestMethod]
     61    [TestCategory("Encodings.Permutation")]
     62    [TestProperty("Time", "short")]
     63    public void UniformLikeCrossoverCrossTest() {
     64      var privateObject = new PrivateObject(typeof(UniformLikeCrossover));
     65      IRandom random = new TestRandom(new int[] { }, new double[] { 0.1, 0.2, 0.3, 0.4 });
     66      random.Reset();
     67      bool exceptionFired = false;
     68      try {
     69        privateObject.Invoke("Cross", random, new ItemArray<Permutation>(new Permutation[] {
     70
     71          new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4), new Permutation(PermutationTypes.RelativeUndirected, 4)}));
     72      }
     73      catch (System.InvalidOperationException) {
     74        exceptionFired = true;
     75      }
     76      Assert.IsTrue(exceptionFired);
     77    }
    5678  }
    5779}
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.RealVectorEncoding-3.3/BlendAlphaBetaCrossoverTest.cs

    r14185 r14353  
    2020#endregion
    2121
     22using HeuristicLab.Core;
    2223using HeuristicLab.Data;
    2324using HeuristicLab.Tests;
     
    3132  [TestClass()]
    3233  public class BlendAlphaBetaCrossoverTest {
     34    /// <summary>
     35    ///A test for Cross
     36    ///</summary>
     37    [TestMethod()]
     38    [TestCategory("Encodings.RealVector")]
     39    [TestProperty("Time", "short")]
     40    public void BlendAlphaBetaCrossoverCrossTest() {
     41      var privateObject = new PrivateObject(typeof(BlendAlphaBetaCrossover));
     42      ItemArray<RealVector> parents;
     43      TestRandom random = new TestRandom();
     44      bool exceptionFired;
     45      // The following test checks if there is an exception when there are more than 2 parents
     46      random.Reset();
     47      parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(5), new RealVector(6), new RealVector(4) });
     48      exceptionFired = false;
     49      try {
     50        var actual = (RealVector)privateObject.Invoke("Cross", random, parents);
     51      }
     52      catch (System.ArgumentException) {
     53        exceptionFired = true;
     54      }
     55      Assert.IsTrue(exceptionFired);
     56      // The following test checks if there is an exception when there are less than 2 parents
     57      random.Reset();
     58      parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(4) });
     59      exceptionFired = false;
     60      try {
     61        var actual = (RealVector)privateObject.Invoke("Cross", random, parents);
     62      }
     63      catch (System.ArgumentException) {
     64        exceptionFired = true;
     65      }
     66      Assert.IsTrue(exceptionFired);
     67    }
     68
    3369    /// <summary>
    3470    ///A test for Apply
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.RealVectorEncoding-3.3/BlendAlphaCrossoverTest.cs

    r14185 r14353  
    2020#endregion
    2121
     22using HeuristicLab.Core;
    2223using HeuristicLab.Data;
    2324using HeuristicLab.Tests;
     
    3132  [TestClass()]
    3233  public class BlendAlphaCrossoverTest {
     34    /// <summary>
     35    ///A test for Cross
     36    ///</summary>
     37    [TestMethod()]
     38    [TestCategory("Encodings.RealVector")]
     39    [TestProperty("Time", "short")]
     40    public void BlendAlphaCrossoverCrossTest() {
     41      var privateObject = new PrivateObject(typeof(BlendAlphaCrossover));
     42      ItemArray<RealVector> parents;
     43      TestRandom random = new TestRandom();
     44      bool exceptionFired;
     45      // The following test checks if there is an exception when there are more than 2 parents
     46      random.Reset();
     47      parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(5), new RealVector(6), new RealVector(4) });
     48      exceptionFired = false;
     49      try {
     50        var actual = (RealVector)privateObject.Invoke("Cross", random, parents);
     51      }
     52      catch (System.ArgumentException) {
     53        exceptionFired = true;
     54      }
     55      Assert.IsTrue(exceptionFired);
     56      // The following test checks if there is an exception when there are less than 2 parents
     57      random.Reset();
     58      parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(4) });
     59      exceptionFired = false;
     60      try {
     61        var actual = (RealVector)privateObject.Invoke("Cross", random, parents);
     62      }
     63      catch (System.ArgumentException) {
     64        exceptionFired = true;
     65      }
     66      Assert.IsTrue(exceptionFired);
     67    }
     68
    3369    /// <summary>
    3470    ///A test for Apply
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.RealVectorEncoding-3.3/DiscreteCrossoverTest.cs

    r14185 r14353  
    3131  [TestClass()]
    3232  public class DiscreteCrossoverTest {
     33    /// <summary>
     34    ///A test for Cross
     35    ///</summary>
     36    [TestMethod()]
     37    [TestCategory("Encodings.RealVector")]
     38    [TestProperty("Time", "short")]
     39    public void DiscreteCrossoverCrossTest() {
     40      var privateObject = new PrivateObject(typeof(DiscreteCrossover));
     41      ItemArray<RealVector> parents;
     42      TestRandom random = new TestRandom();
     43      bool exceptionFired;
     44      // The following test checks if there is an exception when there are less than 2 parents
     45      random.Reset();
     46      parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(4) });
     47      exceptionFired = false;
     48      try {
     49        var actual = (RealVector)privateObject.Invoke("Cross", random, parents);
     50      }
     51      catch (System.ArgumentException) {
     52        exceptionFired = true;
     53      }
     54      Assert.IsTrue(exceptionFired);
     55    }
     56
    3357    /// <summary>
    3458    ///A test for Apply
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.RealVectorEncoding-3.3/HeuristicCrossoverTest.cs

    r14185 r14353  
    2020#endregion
    2121
     22using HeuristicLab.Core;
    2223using HeuristicLab.Tests;
    2324using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    3031  [TestClass()]
    3132  public class HeuristicCrossoverTest {
     33    /// <summary>
     34    ///A test for Cross
     35    ///</summary>
     36    [TestMethod()]
     37    [TestCategory("Encodings.RealVector")]
     38    [TestProperty("Time", "short")]
     39    public void HeuristicCrossoverCrossTest() {
     40      var privateObject = new PrivateObject(typeof(HeuristicCrossover));
     41      ItemArray<RealVector> parents;
     42      TestRandom random = new TestRandom();
     43      bool exceptionFired;
     44      // The following test checks if there is an exception when there are more than 2 parents
     45      random.Reset();
     46      parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(5), new RealVector(6), new RealVector(4) });
     47      exceptionFired = false;
     48      try {
     49        var actual = (RealVector)privateObject.Invoke("Cross", random, parents);
     50      }
     51      catch (System.ArgumentException) {
     52        exceptionFired = true;
     53      }
     54      Assert.IsTrue(exceptionFired);
     55      // The following test checks if there is an exception when there are less than 2 parents
     56      random.Reset();
     57      parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(4) });
     58      exceptionFired = false;
     59      try {
     60        var actual = (RealVector)privateObject.Invoke("Cross", random, parents);
     61      }
     62      catch (System.ArgumentException) {
     63        exceptionFired = true;
     64      }
     65      Assert.IsTrue(exceptionFired);
     66    }
     67
    3268    /// <summary>
    3369    ///A test for Apply
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.RealVectorEncoding-3.3/LocalCrossoverTest.cs

    r14185 r14353  
    2020#endregion
    2121
     22using HeuristicLab.Core;
    2223using HeuristicLab.Tests;
    2324using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    3031  [TestClass()]
    3132  public class LocalCrossoverTest {
     33    /// <summary>
     34    ///A test for Cross
     35    ///</summary>
     36    [TestMethod()]
     37    [TestCategory("Encodings.RealVector")]
     38    [TestProperty("Time", "short")]
     39    public void LocalCrossoverCrossTest() {
     40      var privateObject = new PrivateObject(typeof(LocalCrossover));
     41      ItemArray<RealVector> parents;
     42      TestRandom random = new TestRandom();
     43      bool exceptionFired;
     44      // The following test checks if there is an exception when there are more than 2 parents
     45      random.Reset();
     46      parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(5), new RealVector(6), new RealVector(4) });
     47      exceptionFired = false;
     48      try {
     49        var actual = (RealVector)privateObject.Invoke("Cross", random, parents);
     50      }
     51      catch (System.ArgumentException) {
     52        exceptionFired = true;
     53      }
     54      Assert.IsTrue(exceptionFired);
     55      // The following test checks if there is an exception when there are less than 2 parents
     56      random.Reset();
     57      parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(4) });
     58      exceptionFired = false;
     59      try {
     60        var actual = (RealVector)privateObject.Invoke("Cross", random, parents);
     61      }
     62      catch (System.ArgumentException) {
     63        exceptionFired = true;
     64      }
     65      Assert.IsTrue(exceptionFired);
     66    }
     67
    3268    /// <summary>
    3369    ///A test for Apply
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.RealVectorEncoding-3.3/RandomConvexCrossoverTest.cs

    r14185 r14353  
    2020#endregion
    2121
     22using HeuristicLab.Core;
    2223using HeuristicLab.Tests;
    2324using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    3031  [TestClass()]
    3132  public class RandomConvexCrossoverTest {
     33    /// <summary>
     34    ///A test for Cross
     35    ///</summary>
     36    [TestMethod()]
     37    [TestCategory("Encodings.RealVector")]
     38    [TestProperty("Time", "short")]
     39    public void RandomConvexCrossoverCrossTest() {
     40      var privateObject = new PrivateObject(typeof(RandomConvexCrossover));
     41      ItemArray<RealVector> parents;
     42      TestRandom random = new TestRandom();
     43      bool exceptionFired;
     44      // The following test checks if there is an exception when there are more than 2 parents
     45      random.Reset();
     46      parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(5), new RealVector(6), new RealVector(4) });
     47      exceptionFired = false;
     48      try {
     49        var actual = (RealVector)privateObject.Invoke("Cross", random, parents);
     50      }
     51      catch (System.ArgumentException) {
     52        exceptionFired = true;
     53      }
     54      Assert.IsTrue(exceptionFired);
     55      // The following test checks if there is an exception when there are less than 2 parents
     56      random.Reset();
     57      parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(4) });
     58      exceptionFired = false;
     59      try {
     60        var actual = (RealVector)privateObject.Invoke("Cross", random, parents);
     61      }
     62      catch (System.ArgumentException) {
     63        exceptionFired = true;
     64      }
     65      Assert.IsTrue(exceptionFired);
     66    }
     67
    3268    /// <summary>
    3369    ///A test for Apply
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.RealVectorEncoding-3.3/SimulatedBinaryCrossoverTest.cs

    r14185 r14353  
    2020#endregion
    2121
     22using HeuristicLab.Core;
    2223using HeuristicLab.Data;
    2324using HeuristicLab.Tests;
     
    3132  [TestClass()]
    3233  public class SimulatedBinaryCrossoverTest {
     34    /// <summary>
     35    ///A test for Cross
     36    ///</summary>
     37    [TestMethod()]
     38    [TestCategory("Encodings.RealVector")]
     39    [TestProperty("Time", "short")]
     40    public void SimulatedBinaryCrossoverCrossTest() {
     41      var privateObject = new PrivateObject(typeof(SimulatedBinaryCrossover));
     42      ItemArray<RealVector> parents;
     43      TestRandom random = new TestRandom();
     44      bool exceptionFired;
     45      // The following test checks if there is an exception when there are more than 2 parents
     46      random.Reset();
     47      parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(5), new RealVector(6), new RealVector(4) });
     48      exceptionFired = false;
     49      try {
     50        RealVector actual = (RealVector)privateObject.Invoke("Cross", random, parents);
     51      }
     52      catch (System.ArgumentException) {
     53        exceptionFired = true;
     54      }
     55      Assert.IsTrue(exceptionFired);
     56      // The following test checks if there is an exception when there are less than 2 parents
     57      random.Reset();
     58      parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(4) });
     59      exceptionFired = false;
     60      try {
     61        RealVector actual = (RealVector)privateObject.Invoke("Cross", random, parents);
     62      }
     63      catch (System.ArgumentException) {
     64        exceptionFired = true;
     65      }
     66      Assert.IsTrue(exceptionFired);
     67    }
     68
    3369    /// <summary>
    3470    ///A test for Apply
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.RealVectorEncoding-3.3/SinglePointCrossoverTest.cs

    r14185 r14353  
    2020#endregion
    2121
     22using HeuristicLab.Core;
    2223using HeuristicLab.Tests;
    2324using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    3031  [TestClass()]
    3132  public class SinglePointCrossoverTest {
     33    /// <summary>
     34    ///A test for Cross
     35    ///</summary>
     36    [TestMethod()]
     37    [TestCategory("Encodings.RealVector")]
     38    [TestProperty("Time", "short")]
     39    public void SinglePointCrossoverCrossTest() {
     40      var privateObject = new PrivateObject(typeof(SinglePointCrossover));
     41      ItemArray<RealVector> parents;
     42      TestRandom random = new TestRandom();
     43      bool exceptionFired;
     44      // The following test checks if there is an exception when there are more than 2 parents
     45      random.Reset();
     46      parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(5), new RealVector(6), new RealVector(4) });
     47      exceptionFired = false;
     48      try {
     49        var actual = (RealVector)privateObject.Invoke("Cross", random, parents);
     50      }
     51      catch (System.ArgumentException) {
     52        exceptionFired = true;
     53      }
     54      Assert.IsTrue(exceptionFired);
     55      // The following test checks if there is an exception when there are less than 2 parents
     56      random.Reset();
     57      parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(4) });
     58      exceptionFired = false;
     59      try {
     60        var actual = (RealVector)privateObject.Invoke("Cross", random, parents);
     61      }
     62      catch (System.ArgumentException) {
     63        exceptionFired = true;
     64      }
     65      Assert.IsTrue(exceptionFired);
     66      // The following test checks if there is an exception when the vector has just one dimension
     67      random.Reset();
     68      parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(1) });
     69      exceptionFired = false;
     70      try {
     71        var actual = (RealVector)privateObject.Invoke("Cross", random, parents);
     72      }
     73      catch (System.ArgumentException) {
     74        exceptionFired = true;
     75      }
     76      Assert.IsTrue(exceptionFired);
     77    }
     78
    3279    /// <summary>
    3380    ///A test for Apply
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4/GrammarsTest.cs

    r14352 r14353  
    8787        Assert.AreEqual(2, grammar.GetMinimumExpressionLength(y));
    8888      }
     89
     90      {
     91        var grammar = CreateTestGrammar6();
     92        var prs = grammar.ProgramRootSymbol;
     93        var ss = grammar.StartSymbol;
     94        var x = grammar.Symbols.First(s => s.Name == "<x>");
     95        var s_ = grammar.Symbols.First(s => s.Name == "<s>");
     96        var a = grammar.Symbols.First(s => s.Name == "<a>");
     97        var b = grammar.Symbols.First(s => s.Name == "<b>");
     98        var c = grammar.Symbols.First(s => s.Name == "<c>");
     99        var d = grammar.Symbols.First(s => s.Name == "<d>");
     100        Assert.AreEqual(4, grammar.GetMinimumExpressionLength(prs));
     101        Assert.AreEqual(3, grammar.GetMinimumExpressionLength(ss));
     102        Assert.AreEqual(2, grammar.GetMinimumExpressionLength(x));
     103        Assert.AreEqual(5, grammar.GetMinimumExpressionLength(s_));
     104        Assert.AreEqual(4, grammar.GetMinimumExpressionLength(a));
     105        Assert.AreEqual(3, grammar.GetMinimumExpressionLength(b));
     106        Assert.AreEqual(4, grammar.GetMinimumExpressionLength(c));
     107        Assert.AreEqual(3, grammar.GetMinimumExpressionLength(d));
     108      }
    89109    }
    90110
     
    170190        Assert.AreEqual(2, grammar.GetMinimumExpressionDepth(y));
    171191      }
     192
     193      {
     194        var grammar = CreateTestGrammar6();
     195        var prs = grammar.ProgramRootSymbol;
     196        var ss = grammar.StartSymbol;
     197        var x = grammar.Symbols.First(s => s.Name == "<x>");
     198        var s_ = grammar.Symbols.First(s => s.Name == "<s>");
     199        var a = grammar.Symbols.First(s => s.Name == "<a>");
     200        var b = grammar.Symbols.First(s => s.Name == "<b>");
     201        var c = grammar.Symbols.First(s => s.Name == "<c>");
     202        var d = grammar.Symbols.First(s => s.Name == "<d>");
     203        Assert.AreEqual(4, grammar.GetMinimumExpressionDepth(prs));
     204        Assert.AreEqual(3, grammar.GetMinimumExpressionDepth(ss));
     205        Assert.AreEqual(2, grammar.GetMinimumExpressionDepth(x));
     206        Assert.AreEqual(5, grammar.GetMinimumExpressionDepth(s_));
     207        Assert.AreEqual(4, grammar.GetMinimumExpressionDepth(a));
     208        Assert.AreEqual(3, grammar.GetMinimumExpressionDepth(b));
     209        Assert.AreEqual(4, grammar.GetMinimumExpressionDepth(c));
     210        Assert.AreEqual(3, grammar.GetMinimumExpressionDepth(d));
     211      }
    172212    }
    173213
     
    286326      return grammar;
    287327    }
     328
     329    private static ISymbolicExpressionGrammar CreateTestGrammar6() {
     330      var grammar = new SimpleSymbolicExpressionGrammar();
     331      var x = new SimpleSymbol("<x>", 1);
     332      var s = new SimpleSymbol("<s>", 1);
     333      var a = new SimpleSymbol("<a>", 1);
     334      var b = new SimpleSymbol("<b>", 1);
     335      var c = new SimpleSymbol("<c>", 1);
     336      var d = new SimpleSymbol("<d>", 1);
     337      var e = new SimpleSymbol("<e>", 1);
     338
     339      var _x = new SimpleSymbol("x", 0);
     340      var _y = new SimpleSymbol("y", 0);
     341
     342      grammar.AddSymbol(x);
     343      grammar.AddSymbol(s);
     344      grammar.AddSymbol(a);
     345      grammar.AddSymbol(b);
     346      grammar.AddSymbol(c);
     347      grammar.AddSymbol(d);
     348      grammar.AddSymbol(e);
     349      grammar.AddSymbol(_x);
     350      grammar.AddSymbol(_y);
     351
     352      grammar.AddAllowedChildSymbol(grammar.StartSymbol, x);
     353      grammar.AddAllowedChildSymbol(x, s);
     354      grammar.AddAllowedChildSymbol(x, _x);
     355      grammar.AddAllowedChildSymbol(s, a);
     356      grammar.AddAllowedChildSymbol(a, b);
     357      grammar.AddAllowedChildSymbol(a, c);
     358      grammar.AddAllowedChildSymbol(b, x);
     359      grammar.AddAllowedChildSymbol(c, d);
     360      grammar.AddAllowedChildSymbol(d, e);
     361      grammar.AddAllowedChildSymbol(e, _y);
     362
     363      return grammar;
     364    }
    288365  }
    289366}
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicDataAnalysisExpressionTreeInterpreterTest.cs

    r14185 r14353  
    3333  public class SymbolicDataAnalysisExpressionTreeInterpreterTest {
    3434    private const int N = 1000;
    35     private const int Rows = 1000;
     35    private const int Rows = 5000;
    3636    private const int Columns = 50;
    3737
     
    7373    [TestCategory("Problems.DataAnalysis.Symbolic")]
    7474    [TestProperty("Time", "long")]
    75     public void CompiledInterpreterTestTypeCoherentGrammarPerformance() {
    76       TestTypeCoherentGrammarPerformance(new SymbolicDataAnalysisExpressionCompiledTreeInterpreter(), 12.5e6);
    77     }
    78     [TestMethod]
    79     [TestCategory("Problems.DataAnalysis.Symbolic")]
    80     [TestProperty("Time", "long")]
    81     public void CompiledInterpreterTestFullGrammarPerformance() {
    82       TestFullGrammarPerformance(new SymbolicDataAnalysisExpressionCompiledTreeInterpreter(), 12.5e6);
    83     }
    84     [TestMethod]
    85     [TestCategory("Problems.DataAnalysis.Symbolic")]
    86     [TestProperty("Time", "long")]
    87     public void CompiledInterpreterTestArithmeticGrammarPerformance() {
    88       TestArithmeticGrammarPerformance(new SymbolicDataAnalysisExpressionCompiledTreeInterpreter(), 12.5e6);
    89     }
    90 
    91     [TestMethod]
    92     [TestCategory("Problems.DataAnalysis.Symbolic")]
    93     [TestProperty("Time", "long")]
    9475    public void ILEmittingInterpreterTestTypeCoherentGrammarPerformance() {
    9576      TestTypeCoherentGrammarPerformance(new SymbolicDataAnalysisExpressionTreeILEmittingInterpreter(), 7.5e6);
     
    185166    [TestCategory("Problems.DataAnalysis.Symbolic")]
    186167    [TestProperty("Time", "short")]
    187     public void CompiledInterpreterTestEvaluation() {
    188       var interpreter = new SymbolicDataAnalysisExpressionCompiledTreeInterpreter();
    189       // ADFs are not supported by the compiled tree interpreter
    190       EvaluateTerminals(interpreter, ds);
    191       EvaluateOperations(interpreter, ds);
    192       EvaluateSpecialFunctions(interpreter, ds);
    193     }
    194 
    195     [TestMethod]
    196     [TestCategory("Problems.DataAnalysis.Symbolic")]
    197     [TestProperty("Time", "short")]
    198168    public void LinearInterpreterTestEvaluation() {
    199169      var interpreter = new SymbolicDataAnalysisExpressionTreeLinearInterpreter();
     
    269239
    270240      var interpreters = new ISymbolicDataAnalysisExpressionTreeInterpreter[] {
    271         new SymbolicDataAnalysisExpressionCompiledTreeInterpreter(),
    272241        new SymbolicDataAnalysisExpressionTreeInterpreter(),
    273242        new SymbolicDataAnalysisExpressionTreeLinearInterpreter(),
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicExpressionTreeBottomUpSimilarityCalculatorTest.cs

    r11978 r14353  
    1515
    1616    public BottomUpSimilarityCalculatorTest() {
    17       busCalculator = new SymbolicExpressionTreeBottomUpSimilarityCalculator();
     17      busCalculator = new SymbolicExpressionTreeBottomUpSimilarityCalculator {
     18        //        MatchConstantValues = true,
     19        //        MatchVariableWeights = true
     20      };
    1821      importer = new SymbolicExpressionImporter();
    1922    }
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.TestFunctions-3.3/AckleyEvaluatorTest.cs

    r14185 r14353  
    3737    [TestProperty("Time", "short")]
    3838    public void AckleyEvaluateFunctionTest() {
    39       AckleyEvaluator target = new AckleyEvaluator();
     39      var privateObject = new PrivateObject(typeof(AckleyEvaluator));
    4040      RealVector point = null;
    41       double expected = target.BestKnownQuality;
     41      double expected = (double)privateObject.GetProperty("BestKnownQuality");
    4242      double actual;
    43       for (int dimension = target.MinimumProblemSize; dimension <= System.Math.Min(10, target.MaximumProblemSize); dimension++) {
    44         point = target.GetBestKnownSolution(dimension);
    45         actual = target.Evaluate(point);
     43      int minimumProblemSize = (int)privateObject.GetProperty("MinimumProblemSize");
     44      int maximumProblemSize = (int)privateObject.GetProperty("MaximumProblemSize");
     45      for (int dimension = minimumProblemSize; dimension <= System.Math.Min(10, maximumProblemSize); dimension++) {
     46        point = (RealVector)privateObject.Invoke("GetBestKnownSolution", dimension);
     47        actual = (double)privateObject.Invoke("Evaluate", point);
    4648        Assert.AreEqual(expected, actual);
    4749      }
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.TestFunctions-3.3/BealeEvaluatorTest.cs

    r14185 r14353  
    3737    [TestProperty("Time", "short")]
    3838    public void BealeEvaluateFunctionTest() {
    39       BealeEvaluator target = new BealeEvaluator();
     39      var privateObject = new PrivateObject(typeof(BealeEvaluator));
    4040      RealVector point = null;
    41       double expected = target.BestKnownQuality;
     41      double expected = (double)privateObject.GetProperty("BestKnownQuality");
    4242      double actual;
    43       for (int dimension = target.MinimumProblemSize; dimension <= System.Math.Min(10, target.MaximumProblemSize); dimension++) {
    44         point = target.GetBestKnownSolution(dimension);
    45         actual = target.Evaluate(point);
     43      int minimumProblemSize = (int)privateObject.GetProperty("MinimumProblemSize");
     44      int maximumProblemSize = (int)privateObject.GetProperty("MaximumProblemSize");
     45      for (int dimension = minimumProblemSize; dimension <= System.Math.Min(10, maximumProblemSize); dimension++) {
     46        point = (RealVector)privateObject.Invoke("GetBestKnownSolution", dimension);
     47        actual = (double)privateObject.Invoke("Evaluate", point);
    4648        Assert.AreEqual(expected, actual);
    4749      }
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.TestFunctions-3.3/BoothEvaluatorTest.cs

    r14185 r14353  
    3737    [TestProperty("Time", "short")]
    3838    public void BoothEvaluateFunctionTest() {
    39       BoothEvaluator target = new BoothEvaluator();
     39      var privateObject = new PrivateObject(typeof(BoothEvaluator));
    4040      RealVector point = null;
    41       double expected = target.BestKnownQuality;
     41      double expected = (double)privateObject.GetProperty("BestKnownQuality");
    4242      double actual;
    43       for (int dimension = target.MinimumProblemSize; dimension <= System.Math.Min(10, target.MaximumProblemSize); dimension++) {
    44         point = target.GetBestKnownSolution(dimension);
    45         actual = target.Evaluate(point);
     43      int minimumProblemSize = (int)privateObject.GetProperty("MinimumProblemSize");
     44      int maximumProblemSize = (int)privateObject.GetProperty("MaximumProblemSize");
     45      for (int dimension = minimumProblemSize; dimension <= System.Math.Min(10, maximumProblemSize); dimension++) {
     46        point = (RealVector)privateObject.Invoke("GetBestKnownSolution", dimension);
     47        actual = (double)privateObject.Invoke("Evaluate", point);
    4648        Assert.AreEqual(expected, actual);
    4749      }
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.TestFunctions-3.3/GriewankEvaluatorTest.cs

    r14185 r14353  
    3737    [TestProperty("Time", "short")]
    3838    public void GriewankEvaluateFunctionTest() {
    39       GriewankEvaluator target = new GriewankEvaluator();
     39      var privateObject = new PrivateObject(typeof(GriewankEvaluator));
    4040      RealVector point = null;
    41       double expected = target.BestKnownQuality;
     41      double expected = (double)privateObject.GetProperty("BestKnownQuality");
    4242      double actual;
    43       for (int dimension = target.MinimumProblemSize; dimension <= System.Math.Min(10, target.MaximumProblemSize); dimension++) {
    44         point = target.GetBestKnownSolution(dimension);
    45         actual = target.Evaluate(point);
     43      int minimumProblemSize = (int)privateObject.GetProperty("MinimumProblemSize");
     44      int maximumProblemSize = (int)privateObject.GetProperty("MaximumProblemSize");
     45      for (int dimension = minimumProblemSize; dimension <= System.Math.Min(10, maximumProblemSize); dimension++) {
     46        point = (RealVector)privateObject.Invoke("GetBestKnownSolution", dimension);
     47        actual = (double)privateObject.Invoke("Evaluate", point);
    4648        Assert.AreEqual(expected, actual);
    4749      }
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.TestFunctions-3.3/LevyEvaluatorTest.cs

    r14185 r14353  
    3737    [TestProperty("Time", "short")]
    3838    public void LevyEvaluateFunctionTest() {
    39       LevyEvaluator target = new LevyEvaluator();
     39      var privateObject = new PrivateObject(typeof(LevyEvaluator));
    4040      RealVector point = null;
    41       double expected = target.BestKnownQuality;
     41      double expected = (double)privateObject.GetProperty("BestKnownQuality");
    4242      double actual;
    43       for (int dimension = target.MinimumProblemSize; dimension <= System.Math.Min(10, target.MaximumProblemSize); dimension++) {
    44         point = target.GetBestKnownSolution(dimension);
    45         actual = target.Evaluate(point);
     43      int minimumProblemSize = (int)privateObject.GetProperty("MinimumProblemSize");
     44      int maximumProblemSize = (int)privateObject.GetProperty("MaximumProblemSize");
     45      for (int dimension = minimumProblemSize; dimension <= System.Math.Min(10, maximumProblemSize); dimension++) {
     46        point = (RealVector)privateObject.Invoke("GetBestKnownSolution", dimension);
     47        actual = (double)privateObject.Invoke("Evaluate", point);
    4648        Assert.AreEqual(expected, actual);
    4749      }
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.TestFunctions-3.3/MatyasEvaluatorTest.cs

    r14185 r14353  
    3737    [TestProperty("Time", "short")]
    3838    public void MatyasEvaluateFunctionTest() {
    39       MatyasEvaluator target = new MatyasEvaluator();
     39      var privateObject = new PrivateObject(typeof(MatyasEvaluator));
    4040      RealVector point = null;
    41       double expected = target.BestKnownQuality;
     41      double expected = (double)privateObject.GetProperty("BestKnownQuality");
    4242      double actual;
    43       for (int dimension = target.MinimumProblemSize; dimension <= System.Math.Min(10, target.MaximumProblemSize); dimension++) {
    44         point = target.GetBestKnownSolution(dimension);
    45         actual = target.Evaluate(point);
     43      int minimumProblemSize = (int)privateObject.GetProperty("MinimumProblemSize");
     44      int maximumProblemSize = (int)privateObject.GetProperty("MaximumProblemSize");
     45      for (int dimension = minimumProblemSize; dimension <= System.Math.Min(10, maximumProblemSize); dimension++) {
     46        point = (RealVector)privateObject.Invoke("GetBestKnownSolution", dimension);
     47        actual = (double)privateObject.Invoke("Evaluate", point);
    4648        Assert.AreEqual(expected, actual);
    4749      }
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.TestFunctions-3.3/RastriginEvaluatorTest.cs

    r14185 r14353  
    3737    [TestProperty("Time", "short")]
    3838    public void RastriginEvaluateFunctionTest() {
    39       RastriginEvaluator target = new RastriginEvaluator();
     39      var privateObject = new PrivateObject(typeof(RastriginEvaluator));
    4040      RealVector point = null;
    41       double expected = target.BestKnownQuality;
     41      double expected = (double)privateObject.GetProperty("BestKnownQuality");
    4242      double actual;
    43       for (int dimension = target.MinimumProblemSize; dimension <= System.Math.Min(10, target.MaximumProblemSize); dimension++) {
    44         point = target.GetBestKnownSolution(dimension);
    45         actual = target.Evaluate(point);
     43      int minimumProblemSize = (int)privateObject.GetProperty("MinimumProblemSize");
     44      int maximumProblemSize = (int)privateObject.GetProperty("MaximumProblemSize");
     45      for (int dimension = minimumProblemSize; dimension <= System.Math.Min(10, maximumProblemSize); dimension++) {
     46        point = (RealVector)privateObject.Invoke("GetBestKnownSolution", dimension);
     47        actual = (double)privateObject.Invoke("Evaluate", point);
    4648        Assert.AreEqual(expected, actual);
    4749      }
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.TestFunctions-3.3/RosenbrockEvaluatorTest.cs

    r14185 r14353  
    3737    [TestProperty("Time", "short")]
    3838    public void RosenbrockEvaluateFunctionTest() {
    39       RosenbrockEvaluator target = new RosenbrockEvaluator();
     39      var privateObject = new PrivateObject(typeof(RosenbrockEvaluator));
    4040      RealVector point = null;
    41       double expected = target.BestKnownQuality;
     41      double expected = (double)privateObject.GetProperty("BestKnownQuality");
    4242      double actual;
    43       for (int dimension = target.MinimumProblemSize; dimension <= System.Math.Min(10, target.MaximumProblemSize); dimension++) {
    44         point = target.GetBestKnownSolution(dimension);
    45         actual = target.Evaluate(point);
     43      int minimumProblemSize = (int)privateObject.GetProperty("MinimumProblemSize");
     44      int maximumProblemSize = (int)privateObject.GetProperty("MaximumProblemSize");
     45      for (int dimension = minimumProblemSize; dimension <= System.Math.Min(10, maximumProblemSize); dimension++) {
     46        point = (RealVector)privateObject.Invoke("GetBestKnownSolution", dimension);
     47        actual = (double)privateObject.Invoke("Evaluate", point);
    4648        Assert.AreEqual(expected, actual);
    4749      }
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.TestFunctions-3.3/SphereEvaluatorTest.cs

    r14185 r14353  
    3737    [TestProperty("Time", "short")]
    3838    public void SphereEvaluateFunctionTest() {
    39       SphereEvaluator target = new SphereEvaluator();
     39      var privateObject = new PrivateObject(typeof(SphereEvaluator));
    4040      RealVector point = null;
    41       double expected = target.BestKnownQuality;
     41      double expected = (double)privateObject.GetProperty("BestKnownQuality");
    4242      double actual;
    43       for (int dimension = target.MinimumProblemSize; dimension <= System.Math.Min(10, target.MaximumProblemSize); dimension++) {
    44         point = target.GetBestKnownSolution(dimension);
    45         actual = target.Evaluate(point);
     43      int minimumProblemSize = (int)privateObject.GetProperty("MinimumProblemSize");
     44      int maximumProblemSize = (int)privateObject.GetProperty("MaximumProblemSize");
     45      for (int dimension = minimumProblemSize; dimension <= System.Math.Min(10, maximumProblemSize); dimension++) {
     46        point = (RealVector)privateObject.Invoke("GetBestKnownSolution", dimension);
     47        actual = (double)privateObject.Invoke("Evaluate", point);
    4648        Assert.AreEqual(expected, actual);
    4749      }
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.TestFunctions-3.3/SumSquaresEvaluatorTest.cs

    r14185 r14353  
    3737    [TestProperty("Time", "short")]
    3838    public void SumSquaresEvaluateFunctionTest() {
    39       SumSquaresEvaluator target = new SumSquaresEvaluator();
     39      var privateObject = new PrivateObject(typeof(SumSquaresEvaluator));
    4040      RealVector point = null;
    41       double expected = target.BestKnownQuality;
     41      double expected = (double)privateObject.GetProperty("BestKnownQuality");
    4242      double actual;
    43       for (int dimension = target.MinimumProblemSize; dimension <= System.Math.Min(10, target.MaximumProblemSize); dimension++) {
    44         point = target.GetBestKnownSolution(dimension);
    45         actual = target.Evaluate(point);
     43      int minimumProblemSize = (int)privateObject.GetProperty("MinimumProblemSize");
     44      int maximumProblemSize = (int)privateObject.GetProperty("MaximumProblemSize");
     45      for (int dimension = minimumProblemSize; dimension <= System.Math.Min(10, maximumProblemSize); dimension++) {
     46        point = (RealVector)privateObject.Invoke("GetBestKnownSolution", dimension);
     47        actual = (double)privateObject.Invoke("Evaluate", point);
    4648        Assert.AreEqual(expected, actual);
    4749      }
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.TestFunctions-3.3/ZakharovEvaluatorTest.cs

    r14185 r14353  
    3737    [TestProperty("Time", "short")]
    3838    public void ZakharovEvaluateFunctionTest() {
    39       ZakharovEvaluator target = new ZakharovEvaluator();
     39      var privateObject = new PrivateObject(typeof(ZakharovEvaluator));
    4040      RealVector point = null;
    41       double expected = target.BestKnownQuality;
     41      double expected = (double)privateObject.GetProperty("BestKnownQuality");
    4242      double actual;
    43       for (int dimension = target.MinimumProblemSize; dimension <= System.Math.Min(10, target.MaximumProblemSize); dimension++) {
    44         point = target.GetBestKnownSolution(dimension);
    45         actual = target.Evaluate(point);
     43      int minimumProblemSize = (int)privateObject.GetProperty("MinimumProblemSize");
     44      int maximumProblemSize = (int)privateObject.GetProperty("MaximumProblemSize");
     45      for (int dimension = minimumProblemSize; dimension <= System.Math.Min(10, maximumProblemSize); dimension++) {
     46        point = (RealVector)privateObject.Invoke("GetBestKnownSolution", dimension);
     47        actual = (double)privateObject.Invoke("Evaluate", point);
    4648        Assert.AreEqual(expected, actual);
    4749      }
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Tests.csproj

    r14341 r14353  
    500500    <Compile Include="HeuristicLab.Collections-3.3\BidirectionalLookupTest.cs" />
    501501    <Compile Include="HeuristicLab.Collections-3.3\ObservableKeyedListTest.cs" />
    502     <Compile Include="HeuristicLab.Common-3.3\EnumerableStatisticExtensions.cs" />
    503502    <Compile Include="HeuristicLab.Encodings.BinaryVectorEncoding-3.3\Auxiliary.cs" />
    504503    <Compile Include="HeuristicLab.Encodings.BinaryVectorEncoding-3.3\NPointCrossoverTest.cs" />
     
    574573    <Compile Include="HeuristicLab.Problems.DataAnalysis-3.4\OnlineCalculatorPerformanceTest.cs" />
    575574    <Compile Include="HeuristicLab.Problems.DataAnalysis-3.4\StatisticCalculatorsTest.cs" />
    576     <Compile Include="HeuristicLab.Problems.DataAnalysis.Symbolic-3.4\InfixExpressionParserTest.cs" />
     575    <Compile Include="HeuristicLab.Problems.DataAnalysis.Symbolic-3.4\DoubleConverter.cs" />
    577576    <Compile Include="HeuristicLab.Problems.DataAnalysis.Symbolic-3.4\SymbolicExpressionTreeBottomUpSimilarityCalculatorTest.cs" />
    578577    <Compile Include="HeuristicLab.Problems.DataAnalysis.Symbolic-3.4\SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculatorTest.cs" />
     
    685684    </EmbeddedResource>
    686685  </ItemGroup>
    687   <ItemGroup />
    688   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
     686  <ItemGroup>
     687    <Folder Include="Test References\" />
     688  </ItemGroup>  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
    689689  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
    690690       Other similar extension points exist, see Microsoft.Common.targets.
  • trunk/sources/HeuristicLab.Visualization.ChartControlsExtensions/3.3/ChartUtil.cs

    r14160 r14353  
    3737
    3838      // if one of the interval ends is a multiple of 5 or 10, change the other interval end to be a multiple as well
    39       if ((aMin.Mod(5).IsAlmost(0) || aMin.Mod(10).IsAlmost(0)) && Math.Abs(aMax) >= 5 && !(aMax.Mod(5).IsAlmost(0) || aMax.Mod(10).IsAlmost(0))) {
     39      if (Math.Abs(aMax) >= 5 && aMin.Mod(5).IsAlmost(0) && !(aMax.Mod(5).IsAlmost(0) || aMax.Mod(10).IsAlmost(0))) {
    4040        aMax = Math.Min(aMax + 5 - aMax.Mod(5), aMax + 10 - aMax.Mod(10));
    41       } else if ((aMax.Mod(5).IsAlmost(0) || aMax.Mod(10).IsAlmost(0)) && Math.Abs(aMin) >= 5 && !(aMin.Mod(5).IsAlmost(0) || aMin.Mod(10).IsAlmost(0))) {
     41      } else if (Math.Abs(aMin) >= 5 && aMax.Mod(5).IsAlmost(0) && !(aMin.Mod(5).IsAlmost(0) || aMin.Mod(10).IsAlmost(0))) {
    4242        aMin = Math.Max(aMin - aMin.Mod(5), aMin - aMin.Mod(10));
    4343      }
Note: See TracChangeset for help on using the changeset viewer.