source: branches/MemPRAlgorithm/HeuristicLab.Tests/HeuristicLab.Encodings.LinearLinkageEncoding-3.3/MoveTests.cs @ 14477

Last change on this file since 14477 was 14477, checked in by abeham, 4 years ago

#2701:

  • Added TryGetBy(First|Second) method to BidirectionalDictionary
  • Updated linear linkage encoding
    • Added move generator and moves for shift, merge, split, and extract moves
    • Added unit test (Apply/Undo)
  • Updated MemPR (linear linkage)
    • Added basic tabu walk
  • Fixed bug in MemPR (permutation)
  • Updated Tests project
File size: 832 bytes
Line 
1using System;
2using System.Linq;
3using HeuristicLab.Encodings.LinearLinkageEncoding;
4using HeuristicLab.Random;
5using Microsoft.VisualStudio.TestTools.UnitTesting;
6
7namespace HeuristicLab.Tests.HeuristicLab.Encodings.LinearLinkageEncoding {
8  [TestClass]
9  public class LinearLinkageMoveTests {
10    [TestMethod]
11    public void TestApplyUndo() {
12      var random = new MersenneTwister(42);
13      var lle = MaxGroupsLinearLinkageCreator.Apply(random, 32, 8);
14      var before = (LinearLinkage)lle.Clone();
15      var moves = 0;
16      foreach (var move in MoveGenerator.Generate(lle)) {
17        move.Apply(lle);
18        Assert.IsFalse(before.SequenceEqual(lle));
19        move.Undo(lle);
20        Assert.IsTrue(before.SequenceEqual(lle));
21        moves++;
22      }
23      Assert.IsTrue(moves > 0);
24    }
25  }
26}
Note: See TracBrowser for help on using the repository browser.