#3136: Improved item name and description of structured symreg problem.
[heuristiclab.git] / HeuristicLab.Tests / HeuristicLab.Problems.LinearAssignment-3.3 / LinearAssignmentProblemSolverTest.cs
blob04131ce97fefa9dfe8560e01e56a6b81da21f716
1 #region License Information
2 /* HeuristicLab
3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
5 * This file is part of HeuristicLab.
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.
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.
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/>.
20 #endregion
22 using HeuristicLab.Data;
23 using HeuristicLab.Encodings.PermutationEncoding;
24 using Microsoft.VisualStudio.TestTools.UnitTesting;
26 namespace HeuristicLab.Problems.LinearAssignment.Tests {
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>
36 [TestMethod]
37 [TestCategory("Problems.Assignment")]
38 [TestProperty("Time", "short")]
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());
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 }};
58 p = new Permutation(PermutationTypes.Absolute, LinearAssignmentProblemSolver.Solve(new DoubleMatrix(costs), out quality));
59 Assert.AreEqual(51, quality);
60 Assert.IsTrue(p.Validate());
62 costs = new double[,] {
63 { 3, 1, 1, 4 },
64 { 4, 2, 2, 5 },
65 { 5, 3, 4, 8 },
66 { 4, 2, 5, 9 }};
68 p = new Permutation(PermutationTypes.Absolute, LinearAssignmentProblemSolver.Solve(new DoubleMatrix(costs), out quality));
69 Assert.AreEqual(13, quality);
70 Assert.IsTrue(p.Validate());