Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/11/12 22:57:09 (12 years ago)
Author:
abeham
Message:

#1329:

  • Moved decoders and evaluators from encoding to problem
  • Removed unnecessary state variables in operators
  • Introduced parameters in interfaces and added wiring code
  • Removed ConcreteScheduleManipulator as it does not perform any manipulation
  • Made ErrorPolicy and ForcingStrategy configurable and added views for them
  • Renamed the SchedulingEvaluationAlgorithm and also converted the AlgorithmOperator to a SingleSuccessorOperator
  • Fixed Plugin- and AssemblyFileVersion
  • Added missing license headers
Location:
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMCrossover.cs

    r8603 r8887  
    2727  [Item("JSMCrossover", "An operator which crosses two JSM representations.")]
    2828  [StorableClass]
    29   public abstract class JSMCrossover : ScheduleCrossover<JSMEncoding>, IJSMOperator {
     29  public abstract class JSMCrossover : ScheduleCrossover, IJSMOperator {
    3030
    3131    [StorableConstructor]
     
    4141
    4242    public override IOperation Apply() {
    43       ItemArray<JSMEncoding> parents = ParentsParameter.ActualValue;
     43      var parents = ParentsParameter.ActualValue;
    4444
    4545      ChildParameter.ActualValue =
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMJOXCrossover.cs

    r8603 r8887  
    3030  [StorableClass]
    3131  public class JSMJOXCrossover : JSMCrossover {
     32
    3233    [StorableConstructor]
    3334    protected JSMJOXCrossover(bool deserializing) : base(deserializing) { }
    34     protected JSMJOXCrossover(JSMJOXCrossover original, Cloner cloner)
    35       : base(original, cloner) {
    36     }
     35    protected JSMJOXCrossover(JSMJOXCrossover original, Cloner cloner) : base(original, cloner) { }
     36    public JSMJOXCrossover() : base() { }
     37
    3738    public override IDeepCloneable Clone(Cloner cloner) {
    3839      return new JSMJOXCrossover(this, cloner);
    3940    }
    40     public JSMJOXCrossover() : base() { }
    41 
    4241
    4342    public static JSMEncoding Apply(IRandom random, JSMEncoding p1, JSMEncoding p2) {
    44       JSMEncoding result = new JSMEncoding();
     43      var result = new JSMEncoding();
    4544
    4645      int nrOfResources = p1.JobSequenceMatrix.Count;
     
    4847
    4948      //Determine randomly which jobindexes persist
    50       BoolArray persist = new BoolArray(nrOfJobs);
     49      var persist = new BoolArray(nrOfJobs);
    5150      for (int i = 0; i < persist.Length; i++) {
    5251        persist[i] = random.Next(2) == 1;
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMOXCrossover.cs

    r8603 r8887  
    2828  [StorableClass]
    2929  public class JSMOXCrossover : JSMCrossover {
     30
    3031    [StorableConstructor]
    3132    protected JSMOXCrossover(bool deserializing) : base(deserializing) { }
    32     protected JSMOXCrossover(JSMOXCrossover original, Cloner cloner)
    33       : base(original, cloner) {
    34     }
     33    protected JSMOXCrossover(JSMOXCrossover original, Cloner cloner) : base(original, cloner) { }
     34    public JSMOXCrossover() : base() { }
     35
    3536    public override IDeepCloneable Clone(Cloner cloner) {
    3637      return new JSMOXCrossover(this, cloner);
    3738    }
    38     public JSMOXCrossover() : base() { }
    39 
    4039
    4140    public static JSMEncoding Apply(IRandom random, JSMEncoding parent1, JSMEncoding parent2) {
    42       JSMEncoding result = new JSMEncoding();
     41      var result = new JSMEncoding();
    4342
    4443      for (int i = 0; i < parent1.JobSequenceMatrix.Count; i++) {
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMSXXCrossover.cs

    r8603 r8887  
    2929  [StorableClass]
    3030  public class JSMSXXCrossover : JSMCrossover {
     31
    3132    [StorableConstructor]
    3233    protected JSMSXXCrossover(bool deserializing) : base(deserializing) { }
    33     protected JSMSXXCrossover(JSMSXXCrossover original, Cloner cloner)
    34       : base(original, cloner) {
    35     }
     34    protected JSMSXXCrossover(JSMSXXCrossover original, Cloner cloner) : base(original, cloner) { }
     35    public JSMSXXCrossover() : base() { }
     36
    3637    public override IDeepCloneable Clone(Cloner cloner) {
    3738      return new JSMSXXCrossover(this, cloner);
    3839    }
    39     public JSMSXXCrossover() : base() { }
    40 
    4140
    4241    public static JSMEncoding Apply(IRandom random, JSMEncoding parent1, JSMEncoding parent2) {
    43       JSMEncoding result = new JSMEncoding();
     42      var result = new JSMEncoding();
    4443      int subSequenceLength = random.Next(parent1.JobSequenceMatrix[0].Length);
    4544      for (int i = 0; i < parent1.JobSequenceMatrix.Count; i++) {
    46         Permutation p1 = (Permutation)parent1.JobSequenceMatrix[i].Clone();
    47         Permutation p2 = (Permutation)parent2.JobSequenceMatrix[i].Clone();
     45        var p1 = (Permutation)parent1.JobSequenceMatrix[i].Clone();
     46        var p2 = (Permutation)parent2.JobSequenceMatrix[i].Clone();
    4847        FindAndExchangeSubsequences(p1, p2, subSequenceLength);
    4948        result.JobSequenceMatrix.Add(p1);
     
    5150      return result;
    5251    }
     52
    5353    private static void FindAndExchangeSubsequences(Permutation p1, Permutation p2, int subSequenceLength) {
    5454      for (int i = 0; i <= p1.Length - subSequenceLength; i++) {
     
    6363      }
    6464    }
     65
    6566    private static void ExchangeSubsequences(Permutation p1, int index1, Permutation p2, int index2, int subSequenceLength) {
    66       Permutation aux = (Permutation)p1.Clone();
     67      var aux = (Permutation)p1.Clone();
    6768      for (int i = 0; i < subSequenceLength; i++) {
    6869        p1[i + index1] = p2[i + index2];
     
    7071      }
    7172    }
     73
    7274    private static bool AreEqualSubsequences(int[] ss1, int[] ss2) {
    7375      int counter = 0;
     
    8082      return counter == ss1.Length;
    8183    }
     84
    8285    private static int[] GetSubSequenceAtPosition(Permutation p1, int index, int subSequenceLength) {
    83       int[] result = new int[subSequenceLength];
     86      var result = new int[subSequenceLength];
    8487      for (int i = 0; i < subSequenceLength; i++)
    8588        result[i] = p1[i + index];
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/JSMEncoding.cs

    r8603 r8887  
    3030  [StorableClass]
    3131  public class JSMEncoding : Item, IScheduleEncoding {
     32
    3233    [Storable]
    3334    public ItemList<Permutation> JobSequenceMatrix { get; set; }
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/JSMRandomCreator.cs

    r8603 r8887  
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2929
    30 
    3130namespace HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix {
    3231  [Item("JobSequenceMatrixCreator", "Creator class used to create Job Sequence Matrix solutions for standard JobShop scheduling problems.")]
    3332  [StorableClass]
    34   public class JSMRandomCreator : ScheduleCreator<JSMEncoding>, IStochasticOperator {
    35     #region Parameter Properties
     33  public class JSMRandomCreator : ScheduleCreator, IStochasticOperator {
     34
    3635    public ILookupParameter<IRandom> RandomParameter {
    3736      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
     
    4342      get { return (IValueLookupParameter<IntValue>)Parameters["Resources"]; }
    4443    }
    45     #endregion
    46 
    4744
    4845    [StorableConstructor]
    4946    protected JSMRandomCreator(bool deserializing) : base(deserializing) { }
    50     protected JSMRandomCreator(JSMRandomCreator original, Cloner cloner)
    51       : base(original, cloner) {
    52     }
    53     public override IDeepCloneable Clone(Cloner cloner) {
    54       return new JSMRandomCreator(this, cloner);
    55     }
     47    protected JSMRandomCreator(JSMRandomCreator original, Cloner cloner) : base(original, cloner) { }
    5648    public JSMRandomCreator()
    5749      : base() {
     
    6355    }
    6456
     57    public override IDeepCloneable Clone(Cloner cloner) {
     58      return new JSMRandomCreator(this, cloner);
     59    }
    6560
    6661    public static JSMEncoding Apply(int jobs, int resources, IRandom random) {
    67       JSMEncoding solution = new JSMEncoding();
    68 
     62      var solution = new JSMEncoding();
    6963      for (int i = 0; i < resources; i++) {
    7064        solution.JobSequenceMatrix.Add(new Permutation(PermutationTypes.Absolute, jobs, random));
    7165      }
    72 
    7366      return solution;
    7467    }
    7568
    76 
    77     protected override JSMEncoding CreateSolution() {
     69    protected override IScheduleEncoding CreateSolution() {
    7870      return Apply(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue);
    7971    }
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Manipulators/JSMManipulator.cs

    r8603 r8887  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    2728  [Item("JSMManipulator", "An operator which manipulates a JSM representation.")]
    2829  [StorableClass]
    29   public abstract class JSMManipulator : ScheduleManipulator<JSMEncoding>, IJSMOperator {
     30  public abstract class JSMManipulator : ScheduleManipulator, IJSMOperator {
    3031    [StorableConstructor]
    3132    protected JSMManipulator(bool deserializing) : base(deserializing) { }
     
    3637    }
    3738
    38     protected abstract void Manipulate(IRandom random, JSMEncoding individual);
    39 
     39    protected abstract void Manipulate(IRandom random, IScheduleEncoding individual);
    4040
    4141    public override IOperation Apply() {
    42       JSMEncoding solution = ScheduleEncodingParameter.ActualValue;
     42      var solution = ScheduleEncodingParameter.ActualValue as JSMEncoding;
     43      if (solution == null) throw new InvalidOperationException("ScheduleEncoding was not found or is not of type JSMEncoding.");
    4344      Manipulate(RandomParameter.ActualValue, solution);
    4445      return base.Apply();
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Manipulators/JSMShiftChangeManipulator.cs

    r8603 r8887  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Linq;
     
    2829
    2930namespace HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix {
    30 
    3131  [Item("JSMShiftChangeManipulator", "Represents a manipulation operation where the operations of a randomly determined job are shifted in one direction for all resources.")]
    3232  [StorableClass]
    3333  public class JSMShiftChangeManipulator : JSMManipulator {
     34
    3435    [StorableConstructor]
    3536    protected JSMShiftChangeManipulator(bool deserializing) : base(deserializing) { }
    36     protected JSMShiftChangeManipulator(JSMShiftChangeManipulator original, Cloner cloner)
    37       : base(original, cloner) {
    38     }
     37    protected JSMShiftChangeManipulator(JSMShiftChangeManipulator original, Cloner cloner) : base(original, cloner) { }
     38    public JSMShiftChangeManipulator() : base() { }
     39
    3940    public override IDeepCloneable Clone(Cloner cloner) {
    4041      return new JSMShiftChangeManipulator(this, cloner);
    4142    }
    42 
    43     public JSMShiftChangeManipulator() : base() { }
    44 
    4543
    4644    public static void Apply(IRandom random, JSMEncoding individual) {
     
    6563    }
    6664
    67     protected override void Manipulate(IRandom random, JSMEncoding individual) {
    68       Apply(random, individual);
     65    protected override void Manipulate(IRandom random, IScheduleEncoding encoding) {
     66      var solution = encoding as JSMEncoding;
     67      if (solution == null) throw new InvalidOperationException("Encoding is not of type JSMEncoding");
     68      Apply(random, solution);
    6969    }
    7070  }
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Manipulators/JSMSwapManipulator.cs

    r8603 r8887  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    2627
    2728namespace HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix {
    28 
    2929  [Item("JSMSwapManipulator", "Represents a manipulation operation swapping parts of the individual.")]
    3030  [StorableClass]
    3131  public class JSMSwapManipulator : JSMManipulator {
     32
    3233    [StorableConstructor]
    3334    protected JSMSwapManipulator(bool deserializing) : base(deserializing) { }
    34     protected JSMSwapManipulator(JSMSwapManipulator original, Cloner cloner)
    35       : base(original, cloner) {
    36     }
     35    protected JSMSwapManipulator(JSMSwapManipulator original, Cloner cloner) : base(original, cloner) { }
     36    public JSMSwapManipulator() : base() { }
     37
    3738    public override IDeepCloneable Clone(Cloner cloner) {
    3839      return new JSMSwapManipulator(this, cloner);
    3940    }
    40 
    41     public JSMSwapManipulator() : base() { }
    42 
    4341
    4442    public static void Apply(IRandom random, JSMEncoding individual) {
     
    5250    }
    5351
    54     protected override void Manipulate(IRandom random, JSMEncoding individual) {
    55       Apply(random, individual);
     52    protected override void Manipulate(IRandom random, IScheduleEncoding individual) {
     53      var solution = individual as JSMEncoding;
     54      if (solution == null) throw new InvalidOperationException("Encoding is not of type JSMEncoding");
     55      Apply(random, solution);
    5656    }
    5757  }
Note: See TracChangeset for help on using the changeset viewer.