Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6475


Ignore:
Timestamp:
06/24/11 14:23:19 (14 years ago)
Author:
jhelm
Message:

#1329: Added DirectSchedule-Classes for optimization with the direct-schedule encoding.

Location:
branches/Scheduling
Files:
13 added
3 deleted
23 edited

Legend:

Unmodified
Added
Removed
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3.Tests.csproj

    r6406 r6475  
    5252  </ItemGroup>
    5353  <ItemGroup>
     54    <Compile Include="DirectScheduleGTCrossoverTest.cs" />
    5455    <Compile Include="JSMJOXCrossoverTest.cs" />
    5556    <Compile Include="JSMShiftChangeManipulatorTest.cs" />
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Tests/TestUtils.cs

    r6406 r6475  
    3939      return result;
    4040    }
     41
     42
     43    public static ItemList<Job> CreateJobData() {
     44      Job j1 = new Job(0, 0);
     45      j1.Tasks = new ItemList<Task> {
     46        new Task (0, 0, j1.Index, 1),
     47        new Task (1, 1, j1.Index, 2),
     48        new Task (2, 2, j1.Index, 1)
     49      };
     50
     51      Job j2 = new Job(1, 0);
     52      j2.Tasks = new ItemList<Task> {
     53        new Task (3, 2, j2.Index, 2),
     54        new Task (4, 1, j2.Index, 1),
     55        new Task (5, 0, j2.Index, 2)
     56      };
     57
     58      Job j3 = new Job(2, 0);
     59      j3.Tasks = new ItemList<Task> {
     60        new Task (6, 0, j3.Index, 1),
     61        new Task (7, 2, j3.Index, 2),
     62        new Task (8, 1, j3.Index, 1)
     63      };
     64
     65      return new ItemList<Job> { j1, j2, j3 };
     66    }
     67
     68    public static Schedule CreateTestSchedule1() {
     69      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());
     70      return result;
     71    }
     72
     73    public static Schedule CreateTestSchedule2() {
     74      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());
     75      return result;
     76    }
    4177  }
    4278}
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Views/3.3/Plugin.cs

    r6414 r6475  
    2323
    2424namespace HeuristicLab.Encodings.ScheduleEncoding.Views {
    25   [Plugin("HeuristicLab.Encodings.ScheduleEncoding.Views", "3.3.3.6412")]
     25  [Plugin("HeuristicLab.Encodings.ScheduleEncoding.Views", "3.3.3.6414")]
    2626  [PluginFile("HeuristicLab.Encodings.ScheduleEncoding.Views-3.3.dll", PluginFileType.Assembly)]
    2727  public class HeuristicLabEncodingsScheduleEncodingViewsPlugin : PluginBase {
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Views/3.3/Properties/AssemblyInfo.cs

    r6414 r6475  
    5555// [assembly: AssemblyVersion("1.0.*")]
    5656[assembly: AssemblyVersion("3.3.0.0")]
    57 [assembly: AssemblyFileVersion("3.3.3.6412")]
     57[assembly: AssemblyFileVersion("3.3.3.6414")]
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding/3.3/HeuristicLab.Encodings.ScheduleEncoding-3.3.csproj

    r6406 r6475  
    4747  </ItemGroup>
    4848  <ItemGroup>
     49    <Compile Include="Interfaces\IDirectScheduleOperator.cs" />
    4950    <Compile Include="Interfaces\IScheduleEvaluationAlgorithm.cs" />
    5051    <Compile Include="Interfaces\IJSMOperator.cs" />
     
    7172    <Compile Include="PermutationWithRepetition\Crossovers\PWRPPXCrossover.cs" />
    7273    <Compile Include="PermutationWithRepetition\Manipulators\PWRManipulator.cs" />
    73     <Compile Include="PermutationWithRepetition\Manipulators\PWRUniformOnePositionManipulator.cs" />
     74    <Compile Include="PermutationWithRepetition\Manipulators\PWRInsertionManipulator.cs" />
    7475    <Compile Include="PermutationWithRepetition\PWREncoding.cs" />
    7576    <Compile Include="PermutationWithRepetition\PWRRandomCreator.cs" />
     
    8384    <Compile Include="PriorityRulesVector\PRVRandomCreator.cs" />
    8485    <Compile Include="Properties\AssemblyInfo.cs" />
     86    <Compile Include="ScheduleEncoding\Crossovers\DirectScheduleCrossover.cs" />
     87    <Compile Include="ScheduleEncoding\Crossovers\DirectScheduleGTCrossover.cs" />
     88    <Compile Include="ScheduleEncoding\GTAlgorithmUtils.cs" />
     89    <Compile Include="ScheduleEncoding\Job.cs" />
     90    <Compile Include="ScheduleEncoding\Manipulators\DirectScheduleManipulator.cs" />
     91    <Compile Include="ScheduleEncoding\Manipulators\ConcreteScheduleManipulator.cs" />
     92    <Compile Include="ScheduleEncoding\DirectScheduleRandomCreator.cs" />
    8593    <Compile Include="ScheduleEncoding\Resource.cs" />
    8694    <Compile Include="ScheduleEncoding\Schedule.cs" />
     
    8997    <Compile Include="ScheduleCrossover.cs" />
    9098    <Compile Include="ScheduleDecoder.cs" />
     99    <Compile Include="ScheduleEncoding\Task.cs" />
    91100    <Compile Include="ScheduleManipulator.cs" />
    92101  </ItemGroup>
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/JSMRandomCreator.cs

    r6406 r6475  
    6464
    6565
    66     protected override JSMEncoding CreateSolution() {
     66    public static JSMEncoding Apply(int jobs, int resources, IRandom random) {
    6767      JSMEncoding solution = new JSMEncoding();
    68       IntValue nrOfJobs = new IntValue(JobsParameter.ActualValue.Value);
    69       IntValue nrOfResources = new IntValue(ResourcesParameter.ActualValue.Value);
    7068
    71       for (int i = 0; i < nrOfResources.Value; i++) {
    72         solution.JobSequenceMatrix.Add(new Permutation(PermutationTypes.Absolute, nrOfJobs.Value, RandomParameter.ActualValue));
     69      for (int i = 0; i < resources; i++) {
     70        solution.JobSequenceMatrix.Add(new Permutation(PermutationTypes.Absolute, jobs, random));
    7371      }
    7472
    7573      return solution;
    7674    }
     75
     76
     77    protected override JSMEncoding CreateSolution() {
     78      return Apply(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue);
     79    }
    7780  }
    7881}
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Crossovers/PWRPPXCrossover.cs

    r6406 r6475  
    2828
    2929namespace HeuristicLab.Encodings.ScheduleEncoding.PermutationWithRepetition {
    30   [Item("PWROrderCrossover", "Represents a crossover operation swapping sequences of the parents to generate offspring.")]
     30  [Item("PWRPPXCrossover", "Represents a crossover operation swapping sequences of the parents to generate offspring.")]
    3131  [StorableClass]
    3232  public class PWRPPXCrossover : PWRCrossover {
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/PWREncoding.cs

    r6406 r6475  
    4848    }
    4949
    50     public PWREncoding(int problemDimension, IRandom random)
     50    public PWREncoding(int nrOfJobs, int nrOfResources, IRandom random)
    5151      : base() {
    52       PermutationWithRepetition = new IntegerVector(problemDimension * problemDimension);
    53       int[] lookUpTable = new int[problemDimension];
     52      PermutationWithRepetition = new IntegerVector(nrOfJobs * nrOfResources);
     53      int[] lookUpTable = new int[nrOfJobs];
    5454
    5555      for (int i = 0; i < PermutationWithRepetition.Length; i++) {
    56         int newValue = random.Next(problemDimension);
    57         while (lookUpTable[newValue] >= problemDimension)
    58           newValue = random.Next(problemDimension);
     56        int newValue = random.Next(nrOfJobs);
     57        while (lookUpTable[newValue] >= nrOfResources)
     58          newValue = random.Next(nrOfJobs);
    5959
    6060        PermutationWithRepetition[i] = newValue;
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/PWRRandomCreator.cs

    r6406 r6475  
    6363    }
    6464
     65    public static PWREncoding Apply(int jobs, int resources, IRandom random) {
     66      return new PWREncoding(jobs, resources, random);
     67    }
     68
    6569
    6670    protected override PWREncoding CreateSolution() {
    67       PWREncoding result = new PWREncoding(JobsParameter.ActualValue.Value, Random);
    68       return result;
     71      return Apply(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, Random);
    6972    }
    7073  }
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding/3.3/Plugin.cs

    r6414 r6475  
    2323
    2424namespace HeuristicLab.Encodings.ScheduleEncoding {
    25   [Plugin("HeuristicLab.Encodings.ScheduleEncoding", "3.3.3.6412")]
     25  [Plugin("HeuristicLab.Encodings.ScheduleEncoding", "3.3.3.6414")]
    2626  [PluginFile("HeuristicLab.Encodings.ScheduleEncoding-3.3.dll", PluginFileType.Assembly)]
    2727  public class HeuristicLabEncodingsScheduleEncodingPlugin : PluginBase {
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/PRVRandomCreator.cs

    r6406 r6475  
    6464    }
    6565
     66    public static PRVEncoding Apply(int jobs, int resources, IRandom random, IntValue nrOfRules) {
     67      return new PRVEncoding(jobs * resources, random, 0, nrOfRules.Value, nrOfRules);
     68    }
    6669
    6770    protected override PRVEncoding CreateSolution() {
    68       IntValue nrOfJobs = new IntValue(JobsParameter.ActualValue.Value);
    69       IntValue nrOfResources = new IntValue(ResourcesParameter.ActualValue.Value);
    70       PRVEncoding solution = new PRVEncoding(nrOfJobs.Value * nrOfResources.Value, RandomParameter.ActualValue, 0, NrOfRules.Value, NrOfRules);
    71       return solution;
     71      return Apply(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue, NrOfRules);
    7272    }
     73
     74
    7375  }
    7476}
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding/3.3/Properties/AssemblyInfo.cs

    r6414 r6475  
    5555// [assembly: AssemblyVersion("1.0.*")]
    5656[assembly: AssemblyVersion("3.3.0.0")]
    57 [assembly: AssemblyFileVersion("3.3.3.6412")]
     57[assembly: AssemblyFileVersion("3.3.3.6414")]
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Resource.cs

    r6412 r6475  
    7575      return sb.ToString();
    7676    }
     77
     78
     79    public override bool Equals(object obj) {
     80      if (obj.GetType() == typeof(Resource))
     81        return AreEqual(this, obj as Resource);
     82      else
     83        return false;
     84    }
     85
     86    private static bool AreEqual(Resource res1, Resource res2) {
     87      if (res1.Tasks.Count != res2.Tasks.Count)
     88        return false;
     89      for (int i = 0; i < res1.Tasks.Count; i++) {
     90        if (!res1.Tasks[i].Equals(res2.Tasks[i]))
     91          return false;
     92      }
     93
     94      return true;
     95    }
    7796  }
    7897}
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Schedule.cs

    r6412 r6475  
    3131  [Item("Schedule", "Represents the general solution for scheduling problems.")]
    3232  [StorableClass]
    33   public class Schedule : NamedItem {
     33  public class Schedule : NamedItem, IScheduleEncoding {
    3434    #region Properties
    3535    [Storable]
     
    7979      lastScheduledTaskOfJob = new Dictionary<int, ScheduledTask>();
    8080    }
     81
    8182
    8283
     
    159160      return quality;
    160161    }
     162
     163    public override bool Equals(object obj) {
     164      if (obj.GetType() == typeof(Schedule))
     165        return AreEqual(this, obj as Schedule);
     166      else
     167        return false;
     168    }
     169
     170    private static bool AreEqual(Schedule schedule1, Schedule schedule2) {
     171      if (schedule1.Resources.Count != schedule2.Resources.Count)
     172        return false;
     173      for (int i = 0; i < schedule1.Resources.Count; i++) {
     174        if (!schedule1.Resources[i].Equals(schedule2.Resources[i]))
     175          return false;
     176      }
     177
     178      return true;
     179    }
     180
    161181  }
    162182}
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/ScheduledTask.cs

    r6414 r6475  
    7171      return sb.ToString();
    7272    }
     73
     74
     75    public override bool Equals(object obj) {
     76      if (obj.GetType() == typeof(ScheduledTask))
     77        return AreEqual(this, obj as ScheduledTask);
     78      else
     79        return false;
     80    }
     81
     82    public static bool AreEqual(ScheduledTask task1, ScheduledTask task2) {
     83      return (task1.Duration == task2.Duration &&
     84        task1.JobNr == task2.JobNr &&
     85        task1.ResourceNr == task2.ResourceNr &&
     86        task1.StartTime == task2.StartTime &&
     87        task1.EndTime == task2.EndTime);
     88    }
    7389  }
    7490}
  • branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/JobShopSchedulingProblemView.cs

    r6412 r6475  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Core.Views;
     26using HeuristicLab.Encodings.ScheduleEncoding;
    2627using HeuristicLab.MainForm;
    2728using HeuristicLab.PluginInfrastructure;
  • branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/Plugin.cs

    r6414 r6475  
    2323
    2424namespace HeuristicLab.Problems.Scheduling.Views {
    25   [Plugin("HeuristicLab.Problems.Scheduling.Views", "3.3.3.6412")]
     25  [Plugin("HeuristicLab.Problems.Scheduling.Views", "3.3.3.6414")]
    2626  [PluginFile("HeuristicLab.Problems.Scheduling.Views-3.3.dll", PluginFileType.Assembly)]
    2727  public class HeuristicLabProblemsSchedulingViewsPlugin : PluginBase {
  • branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/Properties/AssemblyInfo.cs

    r6414 r6475  
    5353// by using the '*' as shown below:
    5454[assembly: AssemblyVersion("3.3.0.0")]
    55 [assembly: AssemblyFileVersion("3.3.0.6412")]
     55[assembly: AssemblyFileVersion("3.3.0.6414")]
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Evaluators/SchedulingEvaluationAlgorithm.cs

    r6406 r6475  
    5454    }
    5555
     56    public void InitializeOperatorGraph<T>() where T : Item, IScheduleEncoding {
     57      OperatorGraph.Operators.Clear();
     58      OperatorGraph.InitialOperator = evaluator;
     59    }
     60
    5661    public void InitializeOperatorGraph<T>(ScheduleDecoder<T> decoder) where T : Item, IScheduleEncoding {
    5762      OperatorGraph.Operators.Clear();
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/HeuristicLab.Problems.Scheduling-3.3.csproj

    r6406 r6475  
    5050    <Compile Include="Analyzers\BestSchedulingSolutionAnalyzer.cs" />
    5151    <Compile Include="Analyzers\SchedulingAnalyzer.cs" />
    52     <Compile Include="Decoders\GTAlgorithmUtils.cs" />
    5352    <Compile Include="Decoders\JSMDecoder.cs" />
    5453    <Compile Include="Decoders\JSMDecodingErrorPolicyTypes.cs" />
     
    6059    <Compile Include="Evaluators\SchedulingEvaluator.cs" />
    6160    <Compile Include="Interfaces\IJSSPOperator.cs" />
    62     <Compile Include="Job.cs" />
    6361    <Compile Include="JobShopSchedulingProblem.cs" />
    6462    <Compile Include="Evaluators\SchedulingEvaluationAlgorithm.cs" />
    65     <Compile Include="Task.cs" />
    6663    <Compile Include="SchedulingProblem.cs" />
    6764    <Compile Include="Plugin.cs" />
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Interfaces/IJSSPOperator.cs

    r6406 r6475  
    11using HeuristicLab.Core;
     2using HeuristicLab.Encodings.ScheduleEncoding;
    23
    34namespace HeuristicLab.Problems.Scheduling {
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/JobShopSchedulingProblem.cs

    r6412 r6475  
    173173            PWRDecoder decoder = new PWRDecoder();
    174174            ((SchedulingEvaluationAlgorithm)this.EvaluatorParameter.ActualValue).InitializeOperatorGraph<PWREncoding>(decoder);
     175          } else {
     176            if (SolutionCreator.GetType().Equals(typeof(DirectScheduleRandomCreator))) {
     177              Operators.AddRange(ApplicationManager.Manager.GetInstances<IDirectScheduleOperator>());
     178              ((SchedulingEvaluationAlgorithm)this.EvaluatorParameter.ActualValue).InitializeOperatorGraph<Schedule>();
     179            }
    175180          }
    176181        }
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Plugin.cs

    r6414 r6475  
    2323
    2424namespace HeuristicLab.Problems.Scheduling {
    25   [Plugin("HeuristicLab.Problems.Scheduling", "3.3.3.6412")]
     25  [Plugin("HeuristicLab.Problems.Scheduling", "3.3.3.6414")]
    2626  [PluginFile("HeuristicLab.Problems.Scheduling-3.3.dll", PluginFileType.Assembly)]
    2727  public class HeuristicLabProblemsSchedulingPlugin : PluginBase {
Note: See TracChangeset for help on using the changeset viewer.