• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Permutation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Permutation的典型用法代码示例。如果您正苦于以下问题:C# Permutation类的具体用法?C# Permutation怎么用?C# Permutation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Permutation类属于命名空间,在下文中一共展示了Permutation类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: EdgeRecombinationCrossoverApplyTest

    public void EdgeRecombinationCrossoverApplyTest() {
      TestRandom random = new TestRandom();
      Permutation parent1, parent2, expected, actual;
      // The following test is based on an example from Eiben, A.E. and Smith, J.E. 2003. Introduction to Evolutionary Computation. Natural Computing Series, Springer-Verlag Berlin Heidelberg, pp. 54-55
      random.Reset();
      random.IntNumbers = new int[] { 0 };
      random.DoubleNumbers = new double[] { 0.5, 0, 0, 0 };
      parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });
      Assert.IsTrue(parent1.Validate());
      parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 8, 2, 6, 7, 1, 5, 4, 0, 3 });
      Assert.IsTrue(parent2.Validate());
      expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 4, 5, 1, 7, 6, 2, 8, 3 });
      Assert.IsTrue(expected.Validate());
      actual = EdgeRecombinationCrossover.Apply(random, parent1, parent2);
      Assert.IsTrue(actual.Validate());
      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, actual));

      // perform a test when the two permutations are of unequal length
      random.Reset();
      bool exceptionFired = false;
      try {
        EdgeRecombinationCrossover.Apply(random, new Permutation(PermutationTypes.RelativeUndirected, 8), new Permutation(PermutationTypes.RelativeUndirected, 6));
      }
      catch (System.ArgumentException) {
        exceptionFired = true;
      }
      Assert.IsTrue(exceptionFired);
    }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:28,代码来源:EdgeRecombinationCrossoverTest.cs


示例2: CyclicCrossoverApplyTest

    public void CyclicCrossoverApplyTest() {
      TestRandom random = new TestRandom();
      Permutation parent1, parent2, expected, actual;
      // The following test is based on an example from Larranaga, P. et al. 1999. Genetic Algorithms for the Travelling Salesman Problem: A Review of Representations and Operators. Artificial Intelligence Review, 13
      random.Reset();
      random.DoubleNumbers = new double[] { 0.9 };
      parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
      Assert.IsTrue(parent1.Validate());
      parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 1, 3, 5, 7, 6, 4, 2, 0 });
      Assert.IsTrue(parent2.Validate());
      expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 5, 3, 6, 4, 2, 7 });
      Assert.IsTrue(expected.Validate());
      actual = CyclicCrossover.Apply(random, parent1, parent2);
      Assert.IsTrue(actual.Validate());
      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, actual));

      // perform a test when the two permutations are of unequal length
      random.Reset();
      bool exceptionFired = false;
      try {
        CyclicCrossover.Apply(random, new Permutation(PermutationTypes.RelativeUndirected, 8), new Permutation(PermutationTypes.RelativeUndirected, 6));
      }
      catch (System.ArgumentException) {
        exceptionFired = true;
      }
      Assert.IsTrue(exceptionFired);
    }
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:27,代码来源:CyclicCrossoverTest.cs


示例3: BruteForce

        static double BruteForce()
        {
            var map = new Dictionary<Permutation, List<double>>();
            double i = 345;
            while (true)
            {
                var value = i*i*i;
                var permutation = new Permutation(value);
                if(!map.ContainsKey(permutation))
                {
                    map.Add(permutation, new List<double>());
                }
                map[permutation].Add(value);
                if(map[permutation].Count == 5)
                {
                    foreach (var num in map[permutation])
                    {
                        Console.Out.WriteLine(num);
                    }
                    return map[permutation].Min();
                }
                i++;
            }

            return 0;
        }
开发者ID:david--liu,项目名称:code_kata,代码行数:26,代码来源:Problem62.cs


示例4: TestPermutationEqualityComparer

    public void TestPermutationEqualityComparer() {
      PermutationEqualityComparer comparer = new PermutationEqualityComparer();
      Permutation p = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 3, 2, 0, 1, 4 });
      Permutation q = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 1, 0, 2, 3, 4 });
      Assert.IsTrue(comparer.Equals(p, q));
      Assert.IsTrue(comparer.GetHashCode(p) == comparer.GetHashCode(q));
      Permutation p2 = new Permutation(PermutationTypes.RelativeDirected, new int[] { 2, 3, 4, 1, 0 });
      Permutation q2 = new Permutation(PermutationTypes.RelativeDirected, new int[] { 1, 0, 2, 3, 4 });
      Assert.IsTrue(comparer.Equals(p2, q2));
      Assert.IsTrue(comparer.GetHashCode(p2) == comparer.GetHashCode(q2));

      Assert.IsFalse(comparer.Equals(p, q2));
      Assert.IsFalse(comparer.Equals(p2, q));

      Permutation p3 = new Permutation(PermutationTypes.Absolute, new int[] { 2, 3, 0, 4, 1 });
      Permutation q3 = new Permutation(PermutationTypes.Absolute, new int[] { 2, 3, 0, 4, 1 });
      Assert.IsTrue(comparer.Equals(p3, q3));
      Assert.IsTrue(comparer.GetHashCode(p3) == comparer.GetHashCode(q3));

      Assert.IsFalse(comparer.Equals(p3, q));
      Assert.IsFalse(comparer.Equals(p2, q3));

      Permutation p4 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 3, 2, 0, 1, 4, 5 });
      Assert.IsFalse(comparer.Equals(p, p4));
      Assert.IsFalse(comparer.Equals(p4, q));
    }
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:26,代码来源:PermutationEqualityComparerTest.cs


示例5: OrderCrossover2ApplyTest

    public void OrderCrossover2ApplyTest() {
      TestRandom random = new TestRandom();
      Permutation parent1, parent2, expected, actual;
      // The following test is based on an example from Affenzeller, M. et al. 2009. Genetic Algorithms and Genetic Programming - Modern Concepts and Practical Applications. CRC Press. p. 135.
      random.Reset();
      random.IntNumbers = new int[] { 5, 7 };
      parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
      Assert.IsTrue(parent1.Validate());
      parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 2, 5, 6, 0, 9, 1, 3, 8, 4, 7 });
      Assert.IsTrue(parent2.Validate());
      expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 2, 0, 9, 1, 3, 5, 6, 7, 8, 4 });
      Assert.IsTrue(expected.Validate());
      actual = OrderCrossover2.Apply(random, parent1, parent2);
      Assert.IsTrue(actual.Validate());
      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, actual));

      // perform a test when the two permutations are of unequal length
      random.Reset();
      bool exceptionFired = false;
      try {
        OrderCrossover.Apply(random, new Permutation(PermutationTypes.RelativeUndirected, 8), new Permutation(PermutationTypes.RelativeUndirected, 6));
      }
      catch (System.ArgumentException) {
        exceptionFired = true;
      }
      Assert.IsTrue(exceptionFired);
    }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:27,代码来源:OrderCrossover2Test.cs


示例6: MaximalPreservativeCrossoverApplyTest

    public void MaximalPreservativeCrossoverApplyTest() {
      TestRandom random = new TestRandom();
      Permutation parent1, parent2, expected, actual;
      // The following test is based on an example from Larranaga, 1999. Genetic Algorithms for the Traveling Salesman Problem.
      random.Reset();
      random.IntNumbers = new int[] { 3, 2 };
      parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
      Assert.IsTrue(parent1.Validate());
      parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 1, 3, 5, 7, 6, 4, 2, 0 });
      Assert.IsTrue(parent2.Validate());
      expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 1, 0, 2, 3, 4, 5, 7, 6 });
      Assert.IsTrue(expected.Validate());
      actual = MaximalPreservativeCrossover.Apply(random, parent1, parent2);
      Assert.IsTrue(actual.Validate());
      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, actual));

      // perform a test when the two permutations are of unequal length
      random.Reset();
      bool exceptionFired = false;
      try {
        MaximalPreservativeCrossover.Apply(random, new Permutation(PermutationTypes.RelativeUndirected, 8), new Permutation(PermutationTypes.RelativeUndirected, 6));
      }
      catch (System.ArgumentException) {
        exceptionFired = true;
      }
      Assert.IsTrue(exceptionFired);
    }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:27,代码来源:MaximalPreservativeCrossoverTest.cs


示例7: Main

  public override void Main() {
    DateTime start = DateTime.UtcNow;

    QuadraticAssignmentProblem qap;
    if (vars.Contains("qap")) qap = vars.qap;
    else {
      var provider = new DreznerQAPInstanceProvider();
      var instance = provider.GetDataDescriptors().Single(x => x.Name == "dre56");
      var data = provider.LoadData(instance);
      qap = new QuadraticAssignmentProblem();
      qap.Load(data);
      vars.qap = qap;
    }

    const uint seed = 0;
    const int popSize = 100;
    const int generations = 1000;
    const double mutationRate = 0.05;

    var random = new MersenneTwister(seed);
    var population = new Permutation[popSize];
    var qualities = new double[popSize];
    var nextGen = new Permutation[popSize];
    var nextQual = new double[popSize];

    var qualityChart = new DataTable("Quality Chart");
    var qualityRow = new DataRow("Best Quality");
    qualityChart.Rows.Add(qualityRow);
    vars.qualityChart = qualityChart;

    for (int i = 0; i < popSize; i++) {
      population[i] = new Permutation(PermutationTypes.Absolute, qap.Weights.Rows, random);
      qualities[i] = QAPEvaluator.Apply(population[i], qap.Weights, qap.Distances);
    }
    var bestQuality = qualities.Min();
    var bestQualityGeneration = 0;

    for (int g = 0; g < generations; g++) {
      var parents = population.SampleProportional(random, 2 * popSize, qualities, windowing: true, inverseProportional: true).ToArray();
      for (int i = 0; i < popSize; i++) {
        nextGen[i] = PartiallyMatchedCrossover.Apply(random, parents[i * 2], parents[i * 2 + 1]);
        if (random.NextDouble() < mutationRate) Swap2Manipulator.Apply(random, nextGen[i]);
        nextQual[i] = QAPEvaluator.Apply(nextGen[i], qap.Weights, qap.Distances);
        if (nextQual[i] < bestQuality) {
          bestQuality = nextQual[i];
          bestQualityGeneration = g;
        }
      }
      qualityRow.Values.Add(bestQuality);
      Array.Copy(nextGen, population, popSize);
      Array.Copy(nextQual, qualities, popSize);
    }

    vars.elapsed = new TimeSpanValue(DateTime.UtcNow - start);
    vars.bestQuality = bestQuality;
    vars.bestQualityFoundAt = bestQualityGeneration;
  }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:57,代码来源:GAQAPScriptSource.cs


示例8: CanCreateInversionsFromPermutation

 public void CanCreateInversionsFromPermutation(int[] inv, int[] idx)
 {
     var q = new Permutation(idx);
     var p = q.ToInversions();
     Assert.AreEqual(inv.Length, p.Length);
     for (var i = 0; i < q.Dimension; i++)
     {
         Assert.AreEqual(inv[i], p[i]);
     }
 }
开发者ID:Jungwon,项目名称:mathnet-numerics,代码行数:10,代码来源:PermutationTest.cs


示例9: BruteForce

        static string BruteForce()
        {
            var map = new Dictionary<Permutation, List<int>>();
            for (var i = 1000; i < 10000; i++)
            {
                if (MathUtils.IsPrime(i))
                {
                    var digits = MathUtils.ConvertToDigits(i);
                    {
                        var permutation = new Permutation(digits);
                        if (!map.ContainsKey(permutation))
                        {
                            map.Add(permutation, new List<int>());
                        }
                        var value = map[permutation];
                        value.Add(i);
                    }
                }
            }

            foreach (var result in map.Where(x => x.Value.Count >= 3))
            {
                var value = result.Value;
                if (value.Count == 3)
                {
                    if (IsArithmeticSequence(value))
                    {
                        Print(value);
                    }
                }
                else
                {
                    for (int i = 0; i < value.Count - 3; i++)
                    {
                        for (int j = i + 1; j < value.Count - 1; j++)
                        {
                            
                            for (int k = j + 1; k < value.Count; k++)
                            {
                                var list = new List<int>();
                                list.Add(value[i]);
                                list.Add(value[j]);
                                list.Add(value[k]);
                                if (IsArithmeticSequence(list))
                                {
                                    Print(list);
                                }
                            }
                        }
                    }
                }
            }

            return "";
        }
开发者ID:david--liu,项目名称:code_kata,代码行数:55,代码来源:Problem49.cs


示例10: CreateVariables

        public override BaseVariable[] CreateVariables()
        {
            BaseVariable[] variables = new BaseVariable[Problema.NumberOfVariables];

            for (int var = 0; var < Problema.NumberOfVariables; var++)
            {
                variables[var] = new Permutation(Problema.GetLength(var));
            }

            return variables;
        }
开发者ID:CRIAAC,项目名称:CSharpMetal,代码行数:11,代码来源:PermutationSolutionType.cs


示例11: CanCreatePermutationFromInversions

        public void CanCreatePermutationFromInversions(int[] inv, int[] idx)
        {
            var p = Permutation.FromInversions(inv);
            var q = new Permutation(idx);

            Assert.AreEqual(q.Dimension, p.Dimension);
            for (int i = 0; i < q.Dimension; i++)
            {
                Assert.AreEqual(q[i], p[i]);
            }
        }
开发者ID:hany-abdelrahman,项目名称:mathnet-numerics,代码行数:11,代码来源:PermutationTest.cs


示例12: PermutationIsEqualByPosition

 public static bool PermutationIsEqualByPosition(Permutation p1, Permutation p2) {
   bool equal = (p1.Length == p2.Length);
   if (equal) {
     for (int i = 0; i < p1.Length; i++) {
       if (p1[i] != p2[i]) {
         equal = false;
         break;
       }
     }
   }
   return equal;
 }
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:12,代码来源:Auxiliary.cs


示例13: CanInvertPermutation

        public void CanInvertPermutation([Values(new[] { 0 }, new[] { 0, 1, 2, 3, 4, 5 }, new[] { 5, 4, 3, 2, 1, 0 }, new[] { 0, 4, 3, 2, 1, 5 }, new[] { 0, 3, 2, 1, 4, 5 })] int[] idx)
        {
            var p = new Permutation(idx);
            var pinv = p.Inverse();

            Assert.AreEqual(p.Dimension, pinv.Dimension);
            for (var i = 0; i < p.Dimension; i++)
            {
                Assert.AreEqual(i, pinv[p[i]]);
                Assert.AreEqual(i, p[pinv[i]]);
            }
        }
开发者ID:larzw,项目名称:mathnet-numerics,代码行数:12,代码来源:PermutationTest.cs


示例14: CanCreateInversionsFromPermutation

 public void CanCreateInversionsFromPermutation(
     [Values(new[] { 0 }, new[] { 0, 1, 2, 3, 4, 5 }, new[] { 5, 4, 3, 3, 4, 5 }, new[] { 0, 4, 3, 3, 4, 5 }, new[] { 0, 3, 2, 3, 4, 5 }, new[] { 2, 2, 2, 4, 4 })] int[] inv, 
     [Values(new[] { 0 }, new[] { 0, 1, 2, 3, 4, 5 }, new[] { 5, 4, 3, 2, 1, 0 }, new[] { 0, 4, 3, 2, 1, 5 }, new[] { 0, 3, 2, 1, 4, 5 }, new[] { 1, 2, 0, 4, 3 })] int[] idx)
 {
     var q = new Permutation(idx);
     var p = q.ToInversions();
     Assert.AreEqual(inv.Length, p.Length);
     for (var i = 0; i < q.Dimension; i++)
     {
         Assert.AreEqual(inv[i], p[i]);
     }
 }
开发者ID:jvangael,项目名称:mathnet-numerics,代码行数:12,代码来源:PermutationTest.cs


示例15: CanCreatePermutationFromInversions

        public void CanCreatePermutationFromInversions(
            [Values(new[] { 0 }, new[] { 0, 1, 2, 3, 4, 5 }, new[] { 5, 4, 3, 3, 4, 5 }, new[] { 0, 4, 3, 3, 4, 5 }, new[] { 0, 3, 2, 3, 4, 5 }, new[] { 2, 2, 2, 4, 4 })] int[] inv, 
            [Values(new[] { 0 }, new[] { 0, 1, 2, 3, 4, 5 }, new[] { 5, 4, 3, 2, 1, 0 }, new[] { 0, 4, 3, 2, 1, 5 }, new[] { 0, 3, 2, 1, 4, 5 }, new[] { 1, 2, 0, 4, 3 })] int[] idx)
        {
            var p = Permutation.FromInversions(inv);
            var q = new Permutation(idx);

            Assert.AreEqual(q.Dimension, p.Dimension);
            for (var i = 0; i < q.Dimension; i++)
            {
                Assert.AreEqual(q[i], p[i]);
            }
        }
开发者ID:jvangael,项目名称:mathnet-numerics,代码行数:13,代码来源:PermutationTest.cs


示例16: CosaCrossoverApplyTest

    public void CosaCrossoverApplyTest() {
      TestRandom random = new TestRandom();
      Permutation parent1, parent2, expected, actual;
      // The following test is based on an example from Wendt, O. 1994. COSA: COoperative Simulated Annealing - Integration von Genetischen Algorithmen und Simulated Annealing am Beispiel der Tourenplanung. Dissertation Thesis. IWI Frankfurt.
      random.Reset();
      random.IntNumbers = new int[] { 1 };
      parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 5, 2, 4, 3 });
      Assert.IsTrue(parent1.Validate());
      parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 3, 0, 2, 1, 4, 5 });
      Assert.IsTrue(parent2.Validate());
      expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 4, 2, 5, 3 });
      Assert.IsTrue(expected.Validate());
      actual = CosaCrossover.Apply(random, parent1, parent2);
      Assert.IsTrue(actual.Validate());
      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, actual));
      // The following test is not based on published examples
      random.Reset();
      random.IntNumbers = new int[] { 4 };
      parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
      Assert.IsTrue(parent1.Validate());
      parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 1, 3, 5, 7, 6, 4, 2, 0 });
      Assert.IsTrue(parent2.Validate());
      expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 7, 6, 5, 3, 4, 2, 1, 0 });
      Assert.IsTrue(expected.Validate());
      actual = CosaCrossover.Apply(random, parent1, parent2);
      Assert.IsTrue(actual.Validate());
      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, actual));
      // The following test is not based on published examples
      random.Reset();
      random.IntNumbers = new int[] { 5 };
      parent1 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
      Assert.IsTrue(parent1.Validate());
      parent2 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 4, 3, 5, 1, 0, 9, 7, 2, 8, 6 });
      Assert.IsTrue(parent2.Validate());
      expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 7, 6, 2, 3, 4, 5, 1, 0, 9, 8 });
      Assert.IsTrue(expected.Validate());
      actual = CosaCrossover.Apply(random, parent1, parent2);
      Assert.IsTrue(actual.Validate());
      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, actual));

      // perform a test when the two permutations are of unequal length
      random.Reset();
      bool exceptionFired = false;
      try {
        CosaCrossover.Apply(random, new Permutation(PermutationTypes.RelativeUndirected, 8), new Permutation(PermutationTypes.RelativeUndirected, 6));
      }
      catch (System.ArgumentException) {
        exceptionFired = true;
      }
      Assert.IsTrue(exceptionFired);
    }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:51,代码来源:CosaCrossoverTest.cs


示例17: InversionManipulatorApplyTest

    public void InversionManipulatorApplyTest() {
      TestRandom random = new TestRandom();
      Permutation parent, expected;
      // The following test is based on an example from Eiben, A.E. and Smith, J.E. 2003. Introduction to Evolutionary Computation. Natural Computing Series, Springer-Verlag Berlin Heidelberg, pp. 46-47
      random.Reset();
      random.IntNumbers = new int[] { 1, 4 };
      parent = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });
      Assert.IsTrue(parent.Validate());

      expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 4, 3, 2, 1, 5, 6, 7, 8 });
      Assert.IsTrue(expected.Validate());
      InversionManipulator.Apply(random, parent);
      Assert.IsTrue(parent.Validate());
      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, parent));
    }
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:15,代码来源:InversionManipulatorTest.cs


示例18: TranslocationManipulatorApplyTest

    public void TranslocationManipulatorApplyTest() {
      TestRandom random = new TestRandom();
      Permutation parent, expected;
      // The following test is based on an example from Larranaga, P. et al. 1999. Genetic Algorithms for the Travelling Salesman Problem: A Review of Representations and Operators. Artificial Intelligence Review, 13, p. 24
      random.Reset();
      random.IntNumbers = new int[] { 2, 4, 4 };
      parent = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7 });
      Assert.IsTrue(parent.Validate());

      expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 5, 6, 2, 3, 4, 7 });
      Assert.IsTrue(expected.Validate());
      TranslocationManipulator.Apply(random, parent);
      Assert.IsTrue(parent.Validate());
      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, parent));
    }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:15,代码来源:TranslocationManipulatorTest.cs


示例19: Swap3ManipulatorApplyTest

    public void Swap3ManipulatorApplyTest() {
      TestRandom random = new TestRandom();
      Permutation parent, expected;
      // Test manipulator
      random.Reset();
      random.IntNumbers = new int[] { 1, 3, 6 };
      random.DoubleNumbers = new double[] { 0 };
      parent = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 });
      Assert.IsTrue(parent.Validate());

      expected = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 0, 3, 2, 6, 4, 5, 1, 7, 8 });
      Assert.IsTrue(expected.Validate());
      Swap3Manipulator.Apply(random, parent);
      Assert.IsTrue(parent.Validate());
      Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, parent));
    }
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:16,代码来源:Swap3ManipulatorTest.cs


示例20: UniformLikeCrossoverApplyTest

 public void UniformLikeCrossoverApplyTest() {
   // test from the paper
   IRandom random = new TestRandom(new int[] { 0 }, new double[] { 0.2, 0.7, 0.2, 0.2 }); // TODO: Initialize to an appropriate value
   Permutation parent1 = new Permutation(PermutationTypes.Absolute,
     new int[] { 3, 2, 0, 7, 5, 4, 1, 6 });
   Assert.IsTrue(parent1.Validate());
   Permutation parent2 = new Permutation(PermutationTypes.Absolute,
     new int[] { 5, 0, 4, 7, 1, 3, 2, 6 });
   Assert.IsTrue(parent2.Validate());
   Permutation expected = new Permutation(PermutationTypes.Absolute,
     new int[] { 3, 0, 4, 7, 5, 2, 1, 6 });
   Assert.IsTrue(expected.Validate());
   Permutation actual;
   actual = UniformLikeCrossover.Apply(random, parent1, parent2);
   Assert.IsTrue(actual.Validate());
   Assert.IsTrue(Auxiliary.PermutationIsEqualByPosition(expected, actual));
 }
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:17,代码来源:UniformLikeCrossoverTest.cs



注:本文中的Permutation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Persistence类代码示例发布时间:2022-05-24
下一篇:
C# Permissions类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap