コード例 #1
0
 public SimulatedAnnealingTests()
 {
     Algorithm =
         new SimulatedAnnealing(
             _graphFactory.ProvideValid(),
             _problemProvider.ProvideSubstitute(),
             _coolingSetupFactory.ProvideValid());
 }
コード例 #2
0
        public void ISelectionStrategy_Set_ThrowsOnNullPopulation()
        {
            Assert.Throws <ArgumentException>(() =>
            {
                Strategy.Set(null);
            });

            Strategy.Set(IndividualProvider.ProvideValid());
        }
コード例 #3
0
ファイル: EdgeTests.cs プロジェクト: m-wilczynski/Graphinder
 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);
 }
コード例 #4
0
 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);
     });
 }
コード例 #5
0
        public void IMutationStrategy_Mutate_ThrowsOnNullIndividual()
        {
            Assert.Throws <ArgumentException>(() =>
            {
                Strategy.Mutate(null);
            });

            Strategy.Mutate(IndividualProvider.ProvideValid().FirstOrDefault());
        }
コード例 #6
0
        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]));
        }
コード例 #7
0
        /// <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)
            });
        }
コード例 #8
0
 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));
 }
コード例 #9
0
 public NodeGeneratorTests()
 {
     _generator = new NodeGenerator();
     _graph     = _graphProvider.ProvideValid();
 }
コード例 #10
0
 public NodeTests()
 {
     _graph          = _graphProvider.ProvideValid();
     _validNode      = _graph.AddNode("1");
     _validNeighbour = _graph.AddNode("2");
 }
コード例 #11
0
 protected ICrossoverStrategyTests()
 {
     ValidGraph   = GraphProvider.ProvideValid();
     ValidProblem = ProblemProvider.ProvideSubstitute();
 }