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/ScheduleEncoding
Files:
1 deleted
9 edited

Legend:

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

    r8603 r8887  
    2828  [Item("DirectScheduleCrossover", "An operator which crosses two schedule representations.")]
    2929  [StorableClass]
    30   public abstract class DirectScheduleCrossover : ScheduleCrossover<Schedule>, IDirectScheduleOperator {
     30  public abstract class DirectScheduleCrossover : ScheduleCrossover, IDirectScheduleOperator {
    3131    [StorableConstructor]
    3232    protected DirectScheduleCrossover(bool deserializing) : base(deserializing) { }
     
    3939    }
    4040
    41 
    4241    public ILookupParameter<ItemList<Job>> JobDataParameter {
    4342      get { return (LookupParameter<ItemList<Job>>)Parameters["JobData"]; }
     
    4746
    4847    public override IOperation Apply() {
    49       ItemArray<Schedule> parents = ParentsParameter.ActualValue;
     48      var parents = ParentsParameter.ActualValue;
    5049      ChildParameter.ActualValue =
    5150        Cross(RandomParameter.ActualValue, parents[0] as Schedule, parents[1] as Schedule);
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Crossovers/DirectScheduleGTCrossover.cs

    r8603 r8887  
    3030  [StorableClass]
    3131  public class DirectScheduleGTCrossover : DirectScheduleCrossover {
     32
     33    public IValueLookupParameter<DoubleValue> MutationProbabilityParameter {
     34      get { return (IValueLookupParameter<DoubleValue>)Parameters["MutationProbability"]; }
     35    }
     36
    3237    [StorableConstructor]
    3338    protected DirectScheduleGTCrossover(bool deserializing) : base(deserializing) { }
    34     protected DirectScheduleGTCrossover(DirectScheduleGTCrossover original, Cloner cloner)
    35       : base(original, cloner) {
     39    protected DirectScheduleGTCrossover(DirectScheduleGTCrossover original, Cloner cloner) : base(original, cloner) { }
     40    public DirectScheduleGTCrossover()
     41      : base() {
     42      Parameters.Add(new ValueLookupParameter<DoubleValue>("MutationProbability", "The probability that a task from the conflict set is chosen randomly instead of from one of the parents."));
    3643    }
     44
    3745    public override IDeepCloneable Clone(Cloner cloner) {
    3846      return new DirectScheduleGTCrossover(this, cloner);
    3947    }
    40     public DirectScheduleGTCrossover()
    41       : base() {
    42       Parameters.Add(new LookupParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution."));
    43     }
    44 
    45 
    46     private LookupParameter<PercentValue> MutationProbabilityParameter {
    47       get { return (LookupParameter<PercentValue>)Parameters["MutationProbability"]; }
    48     }
    49 
    5048
    5149    public static Schedule Apply(IRandom random, Schedule parent1, Schedule parent2, ItemList<Job> jobData, double mutProp) {
    52       Schedule child = new Schedule(parent1.Resources.Count);
    53 
     50      var child = new Schedule(parent1.Resources.Count);
    5451
    5552      //Reset scheduled tasks in result
     
    7572        int progressOnResource = conflictedResource.Tasks.Count;
    7673        Task selectedTask = null;
    77         if (random.Next(100) < mutProp) {
     74        if (random.NextDouble() < mutProp) {
    7875          //Mutation
    7976          selectedTask = conflictSet[random.Next(conflictSet.Count)];
     
    9592    }
    9693
    97 
    9894    private static Task SelectTaskFromConflictSet(ItemList<Task> conflictSet, Schedule usedParent, int conflictedResourceNr, int progressOnResource) {
    9995      //Apply Crossover
     
    109105
    110106    public override Schedule Cross(IRandom random, Schedule parent1, Schedule parent2) {
    111       ItemList<Job> jobData = (ItemList<Job>)JobDataParameter.ActualValue.Clone();
    112       PercentValue mutProp = MutationProbabilityParameter.ActualValue;
     107      var jobData = (ItemList<Job>)JobDataParameter.ActualValue.Clone();
     108      var mutProp = MutationProbabilityParameter.ActualValue;
    113109      return Apply(random, parent1, parent2, jobData, mutProp.Value);
    114110    }
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/DirectScheduleRandomCreator.cs

    r8603 r8887  
    3333  [Item("DirectScheduleRandomCreator", "Creator class used to create schedule encoding objects.")]
    3434  [StorableClass]
    35   public class DirectScheduleRandomCreator : ScheduleCreator<Schedule>, IStochasticOperator {
     35  public class DirectScheduleRandomCreator : ScheduleCreator, IStochasticOperator {
    3636
    3737    public ILookupParameter<IRandom> RandomParameter {
     
    6868
    6969    public static Schedule Apply(int jobs, int resources, PWREncoding pwr, ItemList<Job> jobData) {
    70       Schedule resultingSchedule = new Schedule(jobData[0].Tasks.Count);
     70      var resultingSchedule = new Schedule(jobData[0].Tasks.Count);
    7171      foreach (int jobNr in pwr.PermutationWithRepetition) {
    7272        int i = 0;
     
    8282
    8383
    84     protected override Schedule CreateSolution() {
     84    protected override IScheduleEncoding CreateSolution() {
    8585      try {
    86         ItemList<Job> jobData = (ItemList<Job>)JobDataParameter.ActualValue.Clone();
     86        var jobData = (ItemList<Job>)JobDataParameter.ActualValue.Clone();
    8787        return Apply(JobsParameter.ActualValue.Value,
    8888          ResourcesParameter.ActualValue.Value,
    8989          new PWREncoding(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue),
    9090          jobData);
    91       }
    92       catch {
     91      } catch {
    9392        throw new Exception("ScheduleRandomCreator needs JobData parameter from a JSSP-Instance to create Schedule-Instances!");
    9493      }
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Job.cs

    r8886 r8887  
    3030  [StorableClass]
    3131  public class Job : Item, INotifyPropertyChanged {
    32     [Storable(Name = "DueDate")] private double dueDate;
     32
     33    [Storable(Name = "DueDate")]
     34    private double dueDate;
    3335    public double DueDate {
    3436      get { return dueDate; }
     
    5254
    5355    [Storable(Name = "Tasks")]
    54     private ItemList<Task> tasks; 
     56    private ItemList<Task> tasks;
    5557    public ItemList<Task> Tasks {
    5658      get { return tasks; }
     
    7072      this.Tasks = cloner.Clone(original.Tasks);
    7173    }
    72     public override IDeepCloneable Clone(Cloner cloner) {
    73       return new Job(this, cloner);
    74     }
     74    public Job() : this(-1, double.MaxValue) { }
    7575    public Job(int index, double dueDate)
    7676      : base() {
     
    7878      Index = index;
    7979      Tasks = new ItemList<Task>();
     80    }
     81
     82    public override IDeepCloneable Clone(Cloner cloner) {
     83      return new Job(this, cloner);
    8084    }
    8185
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Manipulators/DirectScheduleManipulator.cs

    r8603 r8887  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    2728  [Item("DirectScheduleManipulator", "An operator which manipulates a direct schedule representation.")]
    2829  [StorableClass]
    29   public abstract class DirectScheduleManipulator : ScheduleManipulator<Schedule>, IDirectScheduleOperator {
     30  public abstract class DirectScheduleManipulator : ScheduleManipulator, IDirectScheduleOperator {
     31
    3032    [StorableConstructor]
    3133    protected DirectScheduleManipulator(bool deserializing) : base(deserializing) { }
     
    3638    }
    3739
     40    protected abstract void Manipulate(IRandom random, Schedule individual);
    3841
    39     protected abstract void Manipulate(IRandom random, Schedule individual);
    4042    public override IOperation Apply() {
    41       Schedule solution = ScheduleEncodingParameter.ActualValue;
    42       Manipulate(RandomParameter.ActualValue, solution);
     43      var schedule = ScheduleEncodingParameter.ActualValue as Schedule;
     44      if (schedule == null) throw new InvalidOperationException("ScheduleEncoding was not found or is not of type Schedule.");
     45      Manipulate(RandomParameter.ActualValue, schedule);
    4346      return base.Apply();
    4447    }
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Resource.cs

    r8603 r8887  
    2929  [StorableClass]
    3030  public class Resource : Item {
    31     public Resource(int index)
    32       : base() {
    33       Index = index;
    34       Tasks = new ItemList<ScheduledTask>();
    35     }
     31
    3632    [Storable]
    3733    public int Index {
     
    4440      set;
    4541    }
     42
     43    [StorableConstructor]
     44    protected Resource(bool deserializing) : base(deserializing) { }
     45    protected Resource(Resource original, Cloner cloner)
     46      : base(original, cloner) {
     47      this.Index = original.Index;
     48      this.Tasks = cloner.Clone(original.Tasks);
     49    }
     50    public Resource(int index)
     51      : base() {
     52      Index = index;
     53      Tasks = new ItemList<ScheduledTask>();
     54    }
     55
     56    public override IDeepCloneable Clone(Cloner cloner) {
     57      return new Resource(this, cloner);
     58    }
     59
    4660    public double TotalDuration {
    4761      get {
     
    5367        return result;
    5468      }
    55     }
    56 
    57     [StorableConstructor]
    58     protected Resource(bool deserializing) : base(deserializing) { }
    59     protected Resource(Resource original, Cloner cloner)
    60       : base(original, cloner) {
    61       this.Index = original.Index;
    62       this.Tasks = cloner.Clone(original.Tasks);
    63     }
    64     public override IDeepCloneable Clone(Cloner cloner) {
    65       return new Resource(this, cloner);
    6669    }
    6770
     
    8386        return false;
    8487    }
     88
    8589    public override int GetHashCode() {
    8690      if (Tasks.Count == 1)
     
    9094      return 0;
    9195    }
     96
    9297    private static bool AreEqual(Resource res1, Resource res2) {
    9398      if (res1.Tasks.Count != res2.Tasks.Count)
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Schedule.cs

    r8603 r8887  
    3232  [StorableClass]
    3333  public class Schedule : NamedItem, IScheduleEncoding {
     34
    3435    #region Properties
    3536    [Storable]
     
    6970      this.lastScheduledTaskOfJob = new Dictionary<int, ScheduledTask>(original.lastScheduledTaskOfJob);
    7071    }
    71     public override IDeepCloneable Clone(Cloner cloner) {
    72       return new Schedule(this, cloner);
    73     }
    7472    public Schedule(int nrOfResources) {
    7573      Resources = new ItemList<Resource>();
     
    8078    }
    8179
    82 
     80    public override IDeepCloneable Clone(Cloner cloner) {
     81      return new Schedule(this, cloner);
     82    }
    8383
    8484    #region Events
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/ScheduledTask.cs

    r8603 r8887  
    2929  [StorableClass]
    3030  public class ScheduledTask : Item {
     31
    3132    #region Properties
    3233    [Storable]
     
    5758      this.JobNr = original.JobNr;
    5859    }
    59     public override IDeepCloneable Clone(Cloner cloner) {
    60       return new ScheduledTask(this, cloner);
    61     }
    62 
    6360    public ScheduledTask(int resNr, double startTime, double duration, int jobNr)
    6461      : base() {
     
    6966    }
    7067
     68    public override IDeepCloneable Clone(Cloner cloner) {
     69      return new ScheduledTask(this, cloner);
     70    }
     71
    7172    public override string ToString() {
    7273      StringBuilder sb = new StringBuilder();
     
    7475      return sb.ToString();
    7576    }
    76 
    7777
    7878    public override bool Equals(object obj) {
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Task.cs

    r8886 r8887  
    3030  [StorableClass]
    3131  public class Task : Item, INotifyPropertyChanged {
     32
    3233    [Storable(Name = "TaskNr")]
    3334    private int taskNr;
     
    9495      this.IsScheduled = original.IsScheduled;
    9596    }
    96     public override IDeepCloneable Clone(Cloner cloner) {
    97       return new Task(this, cloner);
    98     }
    99 
    100 
     97    public Task() : this(-1, -1, -1, 0) { }
    10198    public Task(int taskNr, int resNr, int jobNr, double duration)
    10299      : base() {
     
    106103      TaskNr = taskNr;
    107104      IsScheduled = false;
     105    }
     106
     107    public override IDeepCloneable Clone(Cloner cloner) {
     108      return new Task(this, cloner);
    108109    }
    109110
     
    120121        return false;
    121122    }
     123
    122124    public override int GetHashCode() {
    123125      return TaskNr ^ JobNr;
    124126    }
     127
    125128    public static bool AreEqual(Task task1, Task task2) {
    126129      return (task1.Duration == task2.Duration &&
Note: See TracChangeset for help on using the changeset viewer.