#region License Information /* HeuristicLab * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System.Linq; using System.Threading; using HeuristicLab.Data; using HeuristicLab.Problems.GeneralizedQuadraticAssignment; using HeuristicLab.Problems.Instances.CordeauGQAP; using HeuristicLab.Random; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace UnitTests { [TestClass] public class CordeauCrossoverTest { [TestMethod] public void CordeauCrossoverFunctionalityTest() { var provider = new CordeauGQAPInstanceProvider(); var instance = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name == "20-15-75")); var gqap = new GQAP(); gqap.Load(instance); var evaluator = gqap.Evaluator; for (int i = 0; i < 100; i++) { var random = new MersenneTwister((uint)i); var parent1 = GreedyRandomizedSolutionCreator.CreateSolution(random, gqap.ProblemInstance, 100, true, CancellationToken.None); var parent2 = GreedyRandomizedSolutionCreator.CreateSolution(random, gqap.ProblemInstance, 100, true, CancellationToken.None); try { CordeauCrossover.Apply(random, parent1, new DoubleValue(gqap.Evaluate(parent1)), parent2, new DoubleValue(gqap.Evaluate(parent2)), gqap.ProblemInstance, new IntValue(0)); } catch { Assert.Fail("Error during crossover"); } } } } }