public void OperateTest() { double percent = 50.0; Selection_PercentAboveAverage target = new Selection_PercentAboveAverage(percent); DoublePoint p1 = new DoublePoint(10); DoublePoint p2 = new DoublePoint(1); DoublePoint p3 = new DoublePoint(15); DoublePoint p4 = new DoublePoint(17); DoublePoint p5 = new DoublePoint(12); p1.Value = 2; p2.Value = 5; p3.Value = 324; p4.Value = 4; p5.Value = 6; PointSet ps = new PointSet(new HashSet <Point>() { p1, p2, p3, p4, p5 }); PointSet ps1 = new PointSet(new HashSet <Point>() { p1, p2, p3, p4, p5 }); PointSet actual; actual = target.Operate(ps); Assert.IsTrue(actual.Set.Count <= ps1.Set.Count); }
public void Selection_PercentAboveAverageConstructorTest() { double percent = 50.0; Selection_PercentAboveAverage target = new Selection_PercentAboveAverage(percent); Assert.AreEqual(target.Type, OperatorType.Both); }
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 OperationsTest() { EvaluationIF e = new DoubleEvaluation_Logarithmic(); GeneticAlgorithm target = new GeneticAlgorithm(e); IList <Operator> expected = new List <Operator>(); SelectionIF S = new Selection_PercentAboveAverage(50); CrossoverIF C2 = new DoubleCrossover_Random(); MutationIF M = new DoubleMutation_ValuePercent(5.0); expected.Add(S); expected.Add(C2); expected.Add(M); IList <Operator> actual; target.Operations = expected; actual = target.Operations; Assert.AreEqual(expected, actual); }
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); }