Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/15/15 15:16:24 (9 years ago)
Author:
mkommend
Message:

#2521: Refactored problem base classes and adapted scheduling encoding, scheduling problem and unit tests.

Location:
branches/ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3/DirectScheduleGTCrossoverTest.cs

    r12012 r13469  
    2222using System.Linq;
    2323using HeuristicLab.Core;
    24 using HeuristicLab.Encodings.ScheduleEncoding.PermutationWithRepetition;
    25 using HeuristicLab.Encodings.ScheduleEncoding.ScheduleEncoding;
     24using HeuristicLab.Encodings.ScheduleEncoding;
    2625using HeuristicLab.Tests;
    2726using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    4847      Schedule actual;
    4948      actual = DirectScheduleGTCrossover.Apply(random, parent1, parent2, jobData, mutProp);
    50       Schedule expected = DirectScheduleRandomCreator.Apply(3, 3, new PWREncoding(3, 3, new TestRandom(new int[] { 0, 2, 1, 1, 0, 2, 1, 2, 0 }, null)), TestUtils.CreateJobData());
     49      Schedule expected = DirectScheduleRandomCreator.Apply(new PWREncoding(3, 3, new TestRandom(new int[] { 0, 2, 1, 1, 0, 2, 1, 2, 0 }, null)), TestUtils.CreateJobData());
    5150      Assert.IsTrue(TestUtils.ScheduleEquals(actual, expected));
    5251    }
  • branches/ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3/JSMJOXCrossoverTest.cs

    r12012 r13469  
    2222using HeuristicLab.Core;
    2323using HeuristicLab.Encodings.PermutationEncoding;
    24 using HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix;
    2524using HeuristicLab.Tests;
    2625using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    4039    [TestProperty("Time", "short")]
    4140    public void ApplyTest() {
    42       IRandom random = new TestRandom(new int[] { 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1 }, null);
     41      IRandom random = new TestRandom(new int[] { 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1 }, null);
    4342      JSMEncoding p1 = TestUtils.CreateTestJSM1();
    4443      JSMEncoding p2 = TestUtils.CreateTestJSM2();
    45       JSMEncoding expected = new JSMEncoding();
    46       ItemList<Permutation> jsm = new ItemList<Permutation>();
     44      JSMEncoding expected = new JSMEncoding(0);
     45      ItemList<Permutation> jsm = expected.JobSequenceMatrix;
    4746      for (int i = 0; i < 6; i++) {
    4847        jsm.Add(new Permutation(PermutationTypes.Absolute, new int[] { 5, 4, 3, 0, 1, 2 }));
    4948      }
    50       expected.JobSequenceMatrix = jsm;
     49
    5150
    5251      JSMEncoding actual;
  • branches/ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3/JSMSXXCrossoverTest.cs

    r12012 r13469  
    2222using HeuristicLab.Core;
    2323using HeuristicLab.Encodings.PermutationEncoding;
    24 using HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix;
    2524using HeuristicLab.Tests;
    2625using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    4039    [TestProperty("Time", "short")]
    4140    public void ApplyTest() {
    42       IRandom random = new TestRandom(new int[] { 3 }, null);
     41      IRandom random = new TestRandom(new int[] { 0, 3 }, null);
    4342      JSMEncoding p1 = TestUtils.CreateTestJSM1();
    4443      JSMEncoding p2 = TestUtils.CreateTestJSM2();
    45       JSMEncoding expected = new JSMEncoding();
    46       ItemList<Permutation> jsm = new ItemList<Permutation>();
     44      JSMEncoding expected = new JSMEncoding(0);
     45      ItemList<Permutation> jsm = expected.JobSequenceMatrix;
    4746      for (int i = 0; i < 6; i++) {
    4847        jsm.Add(new Permutation(PermutationTypes.Absolute, new int[] { 2, 1, 0, 3, 4, 5 }));
    4948      }
    50       expected.JobSequenceMatrix = jsm;
    5149
    5250      JSMEncoding actual;
  • branches/ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3/JSMShiftChangeManipulatorTest.cs

    r12012 r13469  
    2222using HeuristicLab.Core;
    2323using HeuristicLab.Encodings.PermutationEncoding;
    24 using HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix;
    2524using HeuristicLab.Tests;
    2625using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    4342      JSMEncoding individual = TestUtils.CreateTestJSM1();
    4443      JSMShiftChangeManipulator.Apply(random, individual);
    45       JSMEncoding expected = new JSMEncoding();
    46       ItemList<Permutation> jsm = new ItemList<Permutation>();
     44      JSMEncoding expected = new JSMEncoding(0);
     45      ItemList<Permutation> jsm = expected.JobSequenceMatrix;
    4746      for (int i = 0; i < 3; i++) {
    4847        jsm.Add(new Permutation(PermutationTypes.Absolute, new int[] { 0, 1, 3, 2, 4, 5 }));
    4948        jsm.Add(new Permutation(PermutationTypes.Absolute, new int[] { 0, 1, 3, 4, 2, 5 }));
    5049      }
    51       expected.JobSequenceMatrix = jsm;
    5250
    5351      Assert.IsTrue(TestUtils.JSMEncodingEquals(expected, individual));
  • branches/ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3/PWRGOXCrossoverTest.cs

    r12012 r13469  
    2222using HeuristicLab.Core;
    2323using HeuristicLab.Encodings.IntegerVectorEncoding;
    24 using HeuristicLab.Encodings.ScheduleEncoding.PermutationWithRepetition;
    2524using HeuristicLab.Tests;
    2625using Microsoft.VisualStudio.TestTools.UnitTesting;
  • branches/ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3/PWRPPXCrossoverTest.cs

    r12012 r13469  
    2222using HeuristicLab.Core;
    2323using HeuristicLab.Encodings.IntegerVectorEncoding;
    24 using HeuristicLab.Encodings.ScheduleEncoding.PermutationWithRepetition;
    2524using HeuristicLab.Tests;
    2625using Microsoft.VisualStudio.TestTools.UnitTesting;
  • branches/ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3/TestUtils.cs

    r12012 r13469  
    2424using HeuristicLab.Encodings.IntegerVectorEncoding;
    2525using HeuristicLab.Encodings.PermutationEncoding;
    26 using HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix;
    27 using HeuristicLab.Encodings.ScheduleEncoding.PermutationWithRepetition;
     26
    2827using HeuristicLab.Tests;
    2928
     
    3130  public class TestUtils {
    3231    public static JSMEncoding CreateTestJSM1() {
    33       JSMEncoding result = new JSMEncoding();
    34       ItemList<Permutation> jsm = new ItemList<Permutation>();
     32      JSMEncoding result = new JSMEncoding(0);
     33      ItemList<Permutation> jsm = result.JobSequenceMatrix;
    3534      for (int i = 0; i < 6; i++)
    3635        jsm.Add(new Permutation(PermutationTypes.Absolute, new int[] { 0, 1, 2, 3, 4, 5 }));
    37       result.JobSequenceMatrix = jsm;
    3836      return result;
    3937    }
    4038
    4139    public static JSMEncoding CreateTestJSM2() {
    42       JSMEncoding result = new JSMEncoding();
    43       ItemList<Permutation> jsm = new ItemList<Permutation>();
     40      JSMEncoding result = new JSMEncoding(0);
     41      ItemList<Permutation> jsm = result.JobSequenceMatrix;
    4442      for (int i = 0; i < 6; i++)
    4543        jsm.Add(new Permutation(PermutationTypes.Absolute, new int[] { 5, 4, 3, 2, 1, 0 }));
    46       result.JobSequenceMatrix = jsm;
    4744      return result;
    4845    }
     
    6663    public static ItemList<Job> CreateJobData() {
    6764      Job j1 = new Job(0, 0);
    68       j1.Tasks = new ItemList<Task> {
     65      j1.Tasks.AddRange(new[]{
    6966        new Task (0, 0, j1.Index, 1),
    7067        new Task (1, 1, j1.Index, 2),
    7168        new Task (2, 2, j1.Index, 1)
    72       };
     69      });
    7370
    7471      Job j2 = new Job(1, 0);
    75       j2.Tasks = new ItemList<Task> {
     72      j2.Tasks.AddRange(new[]{
    7673        new Task (3, 2, j2.Index, 2),
    7774        new Task (4, 1, j2.Index, 1),
    7875        new Task (5, 0, j2.Index, 2)
    79       };
     76      });
    8077
    8178      Job j3 = new Job(2, 0);
    82       j3.Tasks = new ItemList<Task> {
     79      j3.Tasks.AddRange(new[]{
    8380        new Task (6, 0, j3.Index, 1),
    8481        new Task (7, 2, j3.Index, 2),
    8582        new Task (8, 1, j3.Index, 1)
    86       };
     83      });
    8784
    8885      return new ItemList<Job> { j1, j2, j3 };
     
    9087
    9188    public static Schedule CreateTestSchedule1() {
    92       Schedule result = DirectScheduleRandomCreator.Apply(3, 3, new PWREncoding(3, 3, new TestRandom(new int[] { 1, 0, 1, 1, 2, 0, 2, 2, 0 }, null)), CreateJobData());
     89      Schedule result = DirectScheduleRandomCreator.Apply(new PWREncoding(3, 3, new TestRandom(new int[] { 1, 0, 1, 1, 2, 0, 2, 2, 0 }, null)), CreateJobData());
    9390      return result;
    9491    }
    9592
    9693    public static Schedule CreateTestSchedule2() {
    97       Schedule result = DirectScheduleRandomCreator.Apply(3, 3, new PWREncoding(3, 3, new TestRandom(new int[] { 0, 1, 1, 0, 2, 0, 1, 2, 2 }, null)), CreateJobData());
     94      Schedule result = DirectScheduleRandomCreator.Apply(new PWREncoding(3, 3, new TestRandom(new int[] { 0, 1, 1, 0, 2, 0, 1, 2, 2 }, null)), CreateJobData());
    9895      return result;
    9996    }
Note: See TracChangeset for help on using the changeset viewer.