[7873] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[16453] | 3 | * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[7873] | 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using HeuristicLab.Data;
|
---|
| 23 | using HeuristicLab.Encodings.PermutationEncoding;
|
---|
| 24 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
---|
| 25 |
|
---|
[9782] | 26 | namespace HeuristicLab.Problems.LinearAssignment.Tests {
|
---|
[7873] | 27 | /// <summary>
|
---|
| 28 | ///This is a test class for LinearAssignmentProblemSolverTest and is intended
|
---|
| 29 | ///to contain all LinearAssignmentProblemSolverTest Unit Tests
|
---|
| 30 | ///</summary>
|
---|
| 31 | [TestClass()]
|
---|
| 32 | public class LinearAssignmentProblemSolverTest {
|
---|
| 33 | /// <summary>
|
---|
| 34 | ///A test for Solve
|
---|
| 35 | ///</summary>
|
---|
[9774] | 36 | [TestMethod]
|
---|
[9782] | 37 | [TestCategory("Problems.Assignment")]
|
---|
| 38 | [TestProperty("Time", "short")]
|
---|
[7873] | 39 | public void SolveTest() {
|
---|
| 40 | double[,] costs = new double[,] {
|
---|
| 41 | { 5, 9, 3, 6 },
|
---|
| 42 | { 8, 7, 8, 2 },
|
---|
| 43 | { 6, 10, 12, 7 },
|
---|
| 44 | { 3, 10, 8, 6 }};
|
---|
| 45 | double quality;
|
---|
| 46 | Permutation p;
|
---|
| 47 | p = new Permutation(PermutationTypes.Absolute, LinearAssignmentProblemSolver.Solve(new DoubleMatrix(costs), out quality));
|
---|
| 48 | Assert.AreEqual(18, quality);
|
---|
| 49 | Assert.IsTrue(p.Validate());
|
---|
| 50 |
|
---|
| 51 | costs = new double[,] {
|
---|
| 52 | { 11, 7, 10, 17, 10 },
|
---|
| 53 | { 13, 21, 7, 11, 13 },
|
---|
| 54 | { 13, 13, 15, 13, 14 },
|
---|
| 55 | { 18, 10, 13, 16, 14 },
|
---|
| 56 | { 12, 8, 16, 19, 10 }};
|
---|
| 57 |
|
---|
| 58 | p = new Permutation(PermutationTypes.Absolute, LinearAssignmentProblemSolver.Solve(new DoubleMatrix(costs), out quality));
|
---|
| 59 | Assert.AreEqual(51, quality);
|
---|
| 60 | Assert.IsTrue(p.Validate());
|
---|
| 61 |
|
---|
| 62 | costs = new double[,] {
|
---|
| 63 | { 3, 1, 1, 4 },
|
---|
| 64 | { 4, 2, 2, 5 },
|
---|
| 65 | { 5, 3, 4, 8 },
|
---|
| 66 | { 4, 2, 5, 9 }};
|
---|
| 67 |
|
---|
| 68 | p = new Permutation(PermutationTypes.Absolute, LinearAssignmentProblemSolver.Solve(new DoubleMatrix(costs), out quality));
|
---|
| 69 | Assert.AreEqual(13, quality);
|
---|
| 70 | Assert.IsTrue(p.Validate());
|
---|
| 71 | }
|
---|
| 72 | }
|
---|
| 73 | }
|
---|