public SimulatedAnnealingTests() { Algorithm = new SimulatedAnnealing( _graphFactory.ProvideValid(), _problemProvider.ProvideSubstitute(), _coolingSetupFactory.ProvideValid()); }
public void ISelectionStrategy_Set_ThrowsOnNullPopulation() { Assert.Throws <ArgumentException>(() => { Strategy.Set(null); }); Strategy.Set(IndividualProvider.ProvideValid()); }
public EdgeTests() { _graph = _graphProvider.ProvideValid(); _validNode1 = _graph.AddNode("1"); _validNode2 = _graph.AddNode("2"); _validNode3 = _graph.AddNode("3"); _otherGraphNode = _graphProvider.ProvideValid().AddNode("1"); _notAddedNode = new Node("5", _graph); }
public void ISelectionStrategy_Set_ThrowsOnProblemMismatch() { Assert.Throws <AlgorithmException>(() => { var graph = GraphDataProvider.ProvideValid(); var problem = ProblemProvider.ProvideSubstitute(); var individuals = new List <Individual> { new Individual(graph, problem), new Individual(graph, ProblemProvider.ProvideSubstitute()) }; Strategy.Set(individuals); }); }
public void IMutationStrategy_Mutate_ThrowsOnNullIndividual() { Assert.Throws <ArgumentException>(() => { Strategy.Mutate(null); }); Strategy.Mutate(IndividualProvider.ProvideValid().FirstOrDefault()); }
private void NextCoupleSetup(ISelectionStrategy strategy) { var testIndividuals = IndividualProvider.ProvideValid().ToList(); if (testIndividuals.Count < 2) { throw new InvalidOperationException(); } strategy.NextCouple().Returns(new Tuple <Individual, Individual>(testIndividuals[0], testIndividuals[1])); }
/// <summary> /// Provides valid instance of declared type. /// </summary> /// <returns></returns> public ICollection <Individual> ProvideValid() { var graph = _graphProvider.ProvideValid(); var problem = _problemProvider.ProvideSubstitute(); return(new List <Individual> { new Individual(graph, problem), new Individual(graph, problem), new Individual(graph, problem) }); }
public GeneticAlgorithmTests() { Algorithm = new GeneticAlgorithm(_graphFactory.ProvideValid(), _problemProvider.ProvideSubstitute(), _operatorsProvider.ProvideSubstitute(), _settingsProvider.ProvideValid()); _geneticAlgorithmThatAlwaysCrossoversAndMutates = new GeneticAlgorithm(_graphFactory.ProvideValid(), _problemProvider.ProvideSubstitute(), _operatorsProvider.ProvideSubstitute(), new GeneticAlgorithmSettings(generationsToCome: 1, crossoverProbability: 1d, mutationProbability: 1d)); _geneticAlgorithmThatHasLotsOfGenerations = new GeneticAlgorithm(_graphFactory.ProvideValid(), _problemProvider.ProvideSubstitute(), _operatorsProvider.ProvideSubstitute(), new GeneticAlgorithmSettings(generationsToCome: 20, initialPopulationSize: 4)); _geneticAlgorithmThatAlwaysCrossoversAndMutatesAndPerformsElitism = new GeneticAlgorithm(_graphFactory.ProvideValid(), _problemProvider.ProvideSubstitute(), _operatorsProvider.ProvideSubstitute(), new GeneticAlgorithmSettings(generationsToCome: 1, crossoverProbability: 1d, mutationProbability: 1d, withElitistSelection: true)); }
public NodeGeneratorTests() { _generator = new NodeGenerator(); _graph = _graphProvider.ProvideValid(); }
public NodeTests() { _graph = _graphProvider.ProvideValid(); _validNode = _graph.AddNode("1"); _validNeighbour = _graph.AddNode("2"); }
protected ICrossoverStrategyTests() { ValidGraph = GraphProvider.ProvideValid(); ValidProblem = ProblemProvider.ProvideSubstitute(); }