public void DoubleInitialization_RandomBetweenTwoPointsConstructorTest() { DoublePoint leftPoint = new DoublePoint(0); DoublePoint rightPoint = new DoublePoint(4); int howMany = 3; DoubleInitialization_RandomBetweenTwoPoints target = new DoubleInitialization_RandomBetweenTwoPoints(leftPoint, rightPoint, howMany); Assert.AreEqual(target.Type, OperatorType.Double); }
private void SetDoubleDefaults() { double[] p1 = { 0.0, 0.0 }; double[] p2 = { 5.0, 5.0 }; Initialization = new DoubleInitialization_RandomBetweenTwoPoints( new DoublePoint(p1), new DoublePoint(p2), 10); SelectionIF S = new Selection_PercentAboveAverage(50); CrossoverIF C2 = new DoubleCrossover_Random(); MutationIF M = new DoubleMutation_ValuePercent(5.0); Operations.Add(S); Operations.Add(C2); Operations.Add(M); }
public void CreateTest() { DoublePoint leftPoint = new DoublePoint(0); DoublePoint rightPoint = new DoublePoint(4); int howMany = 3; DoubleInitialization_RandomBetweenTwoPoints target = new DoubleInitialization_RandomBetweenTwoPoints(leftPoint, rightPoint, howMany); PointSet expected = new PointSet(new HashSet <Point>() { new DoublePoint(0), new DoublePoint(2), new DoublePoint(4) }); PointSet actual; actual = target.Create(); Assert.AreEqual(expected.Set.Count, actual.Set.Count); // Assert.AreEqual(expected.Set.); }
public void GeneticAlgorithmConstructorTest() { List <Operator> operators = new List <Operator>(); SelectionIF S = new Selection_PercentAboveAverage(50); CrossoverIF C2 = new DoubleCrossover_Random(); MutationIF M = new DoubleMutation_ValuePercent(5.0); operators.Add(S); operators.Add(C2); operators.Add(M); double[] p1 = { 0.0, 0.0 }; double[] p2 = { 5.0, 5.0 }; InitializationIF initialization = new DoubleInitialization_RandomBetweenTwoPoints( new DoublePoint(p1), new DoublePoint(p2), 10); EvaluationIF evaluation = new DoubleEvaluation_Trigonometric(); GeneticAlgorithm target = new GeneticAlgorithm(operators, initialization, evaluation); Assert.IsNotNull(target.Operations); Assert.IsNotNull(target.Initialization); Assert.IsNotNull(target.Evaluation); }