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/PermutationWithRepetition
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Crossovers/PWRCrossover.cs

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

    r8603 r8887  
    3131  [StorableClass]
    3232  public class PWRGOXCrossover : PWRCrossover {
     33
    3334    [StorableConstructor]
    3435    protected PWRGOXCrossover(bool deserializing) : base(deserializing) { }
    35     protected PWRGOXCrossover(PWRGOXCrossover original, Cloner cloner)
    36       : base(original, cloner) {
    37     }
     36    protected PWRGOXCrossover(PWRGOXCrossover original, Cloner cloner) : base(original, cloner) { }
     37    public PWRGOXCrossover() : base() { }
     38
    3839    public override IDeepCloneable Clone(Cloner cloner) {
    3940      return new PWRGOXCrossover(this, cloner);
    4041    }
    41     public PWRGOXCrossover() : base() { }
    4242
    4343    private static int[] GetLookUpForIndividual(List<int> p) {
    44       int[] result = new int[p.Count];
    45       Dictionary<int, int> lookUpTable = new Dictionary<int, int>();
     44      var result = new int[p.Count];
     45      var lookUpTable = new Dictionary<int, int>();
    4646
    4747      for (int i = 0; i < p.Count; i++) {
     
    5454      return result;
    5555    }
     56
    5657    public static PWREncoding Apply(IRandom random, PWREncoding parent1, PWREncoding parent2) {
    57       PWREncoding result = new PWREncoding();
     58      var result = new PWREncoding();
    5859
    59       List<int> p1 = ((IntegerVector)(parent1.PermutationWithRepetition.Clone())).ToList<int>();
    60       List<int> p2 = ((IntegerVector)(parent2.PermutationWithRepetition.Clone())).ToList<int>();
    61       List<int> child = new List<int>();
     60      var p1 = ((IntegerVector)(parent1.PermutationWithRepetition.Clone())).ToList();
     61      var p2 = ((IntegerVector)(parent2.PermutationWithRepetition.Clone())).ToList();
     62      var child = new List<int>();
    6263
    6364      int[] lookUpArrayP1 = GetLookUpForIndividual(p1);
     
    9091    }
    9192
    92 
    93 
    94 
    9593  }
    9694}
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Crossovers/PWRPPXCrossover.cs

    r8603 r8887  
    3131  [StorableClass]
    3232  public class PWRPPXCrossover : PWRCrossover {
     33
    3334    [StorableConstructor]
    3435    protected PWRPPXCrossover(bool deserializing) : base(deserializing) { }
    35     protected PWRPPXCrossover(PWRPPXCrossover original, Cloner cloner)
    36       : base(original, cloner) {
    37     }
     36    protected PWRPPXCrossover(PWRPPXCrossover original, Cloner cloner) : base(original, cloner) { }
     37    public PWRPPXCrossover() : base() { }
     38
    3839    public override IDeepCloneable Clone(Cloner cloner) {
    3940      return new PWRPPXCrossover(this, cloner);
    4041    }
    41     public PWRPPXCrossover() : base() { }
    4242
    4343    public static PWREncoding Apply(IRandom random, PWREncoding parent1, PWREncoding parent2) {
    44       PWREncoding result = new PWREncoding();
    45       List<int> p1 = ((IntegerVector)(parent1.PermutationWithRepetition.Clone())).ToList<int>();
    46       List<int> p2 = ((IntegerVector)(parent2.PermutationWithRepetition.Clone())).ToList<int>();
    47       List<int> child = new List<int>();
     44      var result = new PWREncoding();
     45      var p1 = ((IntegerVector)(parent1.PermutationWithRepetition.Clone())).ToList();
     46      var p2 = ((IntegerVector)(parent2.PermutationWithRepetition.Clone())).ToList();
     47      var child = new List<int>();
    4848
    49       bool[] lookUpTable = new bool[parent1.PermutationWithRepetition.Length];
     49      var lookUpTable = new bool[parent1.PermutationWithRepetition.Length];
    5050      for (int i = 0; i < lookUpTable.Length; i++) {
    5151        lookUpTable[i] = random.Next(2) == 1;
     
    7373    }
    7474
    75 
    7675  }
    7776}
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Manipulators/PWRInsertionManipulator.cs

    r8603 r8887  
    2828
    2929namespace HeuristicLab.Encodings.ScheduleEncoding.PermutationWithRepetition {
    30 
    3130  [Item("PWRInsertionManipulator", "Represents a manipulation operation inserting parts of the individual at another position.")]
    3231  [StorableClass]
     
    3433    [StorableConstructor]
    3534    protected PWRInsertionManipulator(bool deserializing) : base(deserializing) { }
    36     protected PWRInsertionManipulator(PWRInsertionManipulator original, Cloner cloner)
    37       : base(original, cloner) {
    38     }
     35    protected PWRInsertionManipulator(PWRInsertionManipulator original, Cloner cloner) : base(original, cloner) { }
     36    public PWRInsertionManipulator() : base() { }
     37
    3938    public override IDeepCloneable Clone(Cloner cloner) {
    4039      return new PWRInsertionManipulator(this, cloner);
    4140    }
    42     public PWRInsertionManipulator() : base() { }
    4341
    4442    public static void Apply(IRandom random, PWREncoding individual) {
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Manipulators/PWRManipulator.cs

    r8603 r8887  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    2728  [Item("PWRManipulator", "An operator which manipulates a PWR representation.")]
    2829  [StorableClass]
    29   public abstract class PWRManipulator : ScheduleManipulator<PWREncoding>, IPWROperator {
     30  public abstract class PWRManipulator : ScheduleManipulator, IPWROperator {
     31
    3032    [StorableConstructor]
    3133    protected PWRManipulator(bool deserializing) : base(deserializing) { }
     
    3840    protected abstract void Manipulate(IRandom random, PWREncoding individual);
    3941
    40 
    4142    public override IOperation Apply() {
    42       PWREncoding solution = ScheduleEncodingParameter.ActualValue;
     43      var solution = ScheduleEncodingParameter.ActualValue as PWREncoding;
     44      if (solution == null) throw new InvalidOperationException("ScheduleEncoding was not found or is not of type PWREncoding.");
    4345      Manipulate(RandomParameter.ActualValue, solution);
    4446      return base.Apply();
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/PWREncoding.cs

    r8603 r8887  
    3030  [StorableClass]
    3131  public class PWREncoding : Item, IScheduleEncoding {
     32
    3233    [Storable]
    3334    public IntegerVector PermutationWithRepetition { get; set; }
    34 
    3535
    3636    [StorableConstructor]
     
    4040      this.PermutationWithRepetition = cloner.Clone(original.PermutationWithRepetition);
    4141    }
    42     public override IDeepCloneable Clone(Cloner cloner) {
    43       return new PWREncoding(this, cloner);
    44     }
    4542    public PWREncoding()
    4643      : base() {
    4744      PermutationWithRepetition = new IntegerVector();
     45    }
     46
     47    public override IDeepCloneable Clone(Cloner cloner) {
     48      return new PWREncoding(this, cloner);
    4849    }
    4950
     
    8182        return base.Equals(obj);
    8283    }
     84
    8385    public override int GetHashCode() {
    8486      if (PermutationWithRepetition.Length == 1)
     
    8890      return 0;
    8991    }
     92
    9093    private bool AreEqual(PWREncoding pWREncoding1, PWREncoding pWREncoding2) {
    9194      if (pWREncoding1.PermutationWithRepetition.Length != pWREncoding2.PermutationWithRepetition.Length)
     
    97100      return true;
    98101    }
    99 
    100 
    101102  }
    102103}
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/PWRRandomCreator.cs

    r8603 r8887  
    3030  [Item("PermutationWithRepetitionRandomCreator", "Creates PWR-individuals at random.")]
    3131  [StorableClass]
    32   public class PWRRandomCreator : ScheduleCreator<PWREncoding>, IStochasticOperator {
    33     public IRandom Random {
    34       get { return RandomParameter.ActualValue; }
    35     }
     32  public class PWRRandomCreator : ScheduleCreator, IStochasticOperator {
    3633
    3734    public ILookupParameter<IRandom> RandomParameter {
     
    4744    [StorableConstructor]
    4845    protected PWRRandomCreator(bool deserializing) : base(deserializing) { }
    49     protected PWRRandomCreator(PWRRandomCreator original, Cloner cloner)
    50       : base(original, cloner) {
    51     }
    52     public override IDeepCloneable Clone(Cloner cloner) {
    53       return new PWRRandomCreator(this, cloner);
    54     }
    55 
     46    protected PWRRandomCreator(PWRRandomCreator original, Cloner cloner) : base(original, cloner) { }
    5647    public PWRRandomCreator()
    5748      : base() {
     
    6354    }
    6455
     56    public override IDeepCloneable Clone(Cloner cloner) {
     57      return new PWRRandomCreator(this, cloner);
     58    }
     59
    6560    public static PWREncoding Apply(int jobs, int resources, IRandom random) {
    6661      return new PWREncoding(jobs, resources, random);
    6762    }
    6863
    69 
    70     protected override PWREncoding CreateSolution() {
    71       return Apply(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, Random);
     64    protected override IScheduleEncoding CreateSolution() {
     65      return Apply(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue);
    7266    }
    7367  }
Note: See TracChangeset for help on using the changeset viewer.