public void TestClosed() { var problem = SequenceProblemHelper.Create(new Tour(new int[] { 0, 1, 2, 3 }, 0), 4, 60, 360); var solver = new ConstructionSolver(); var result = solver.Solve(problem, new SequenceDirectedObjective()); Assert.IsNotNull(result); var arr = result.ToArray(); Assert.AreEqual(arr.Length, 4); Assert.AreEqual(0, DirectedHelper.ExtractId(arr[0])); Assert.AreEqual(1, DirectedHelper.ExtractId(arr[1])); Assert.AreEqual(2, DirectedHelper.ExtractId(arr[2])); Assert.AreEqual(3, DirectedHelper.ExtractId(arr[3])); }
public void TestFixed() { var problem = SequenceProblemHelper.Create(new Tour(new int[] { 0, 1, 2, 3 }, 3), 4, 60, 360); var tour = new Tour(new int[] { 0, 4, 8, 12 }, 12); var op = new Itinero.Optimization.Sequence.Directed.Solver.Operators.DirectionLocalSearchOperator(); float delta; Assert.IsFalse(op.Apply(problem, new Optimization.Sequence.Directed.SequenceDirectedObjective(), tour, out delta)); Assert.AreEqual(0, delta); tour = new Tour(new int[] { 0, 5, 8, 12 }, 12); Assert.IsTrue(op.Apply(problem, new Optimization.Sequence.Directed.SequenceDirectedObjective(), tour, out delta)); Assert.AreEqual(96, delta); tour = new Tour(new int[] { 0, 4, 9, 12 }, 12); Assert.IsTrue(op.Apply(problem, new Optimization.Sequence.Directed.SequenceDirectedObjective(), tour, out delta)); Assert.AreEqual(96, delta); tour = new Tour(new int[] { 0, 4, 8, 14 }, 14); Assert.IsTrue(op.Apply(problem, new Optimization.Sequence.Directed.SequenceDirectedObjective(), tour, out delta)); Assert.AreEqual(96, delta); }