Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13435


Ignore:
Timestamp:
12/04/15 10:35:04 (9 years ago)
Author:
mkommend
Message:

#2521: Intermediate version of schedule encoding refactoring.

Location:
branches/ProblemRefactoring
Files:
31 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding.Views/3.3/ScheduleView.cs

    r12012 r13435  
    6767    private void RedrawGanttChart(Schedule content) {
    6868      ResetGanttChart();
    69       int resCount = 0;
    70       Random random = new Random(1);
    71       foreach (Resource r in content.Resources) {
    72         foreach (ScheduledTask t in content.Resources[resCount].Tasks) {
    73           int categoryNr = 0;
    74           string toolTip = "Task#" + t.TaskNr;
    75           string categoryName = "ScheduleTasks";
    76           if (t is ScheduledTask) {
    77             categoryNr = ((ScheduledTask)t).JobNr;
    78             categoryName = "Job" + categoryNr;
    79             toolTip = categoryName + " - " + toolTip;
    80           }
    81           ganttChart.AddData("Resource" + r.Index,
     69      foreach (Resource resource in content.Resources) {
     70        foreach (ScheduledTask task in resource.Tasks) {
     71          int categoryNr = task.JobNr;
     72          string categoryName = "Job" + categoryNr;
     73          string toolTip = categoryName + " - " + "Task#" + task.TaskNr;
     74
     75          ganttChart.AddData("Resource" + resource.Index,
    8276            categoryNr,
    83             t.TaskNr,
    84             t.StartTime,
    85             t.EndTime,
     77            task.TaskNr,
     78            task.StartTime,
     79            task.EndTime,
    8680            toolTip);
    8781        }
    88         resCount++;
    8982      }
    90     }
    91 
    92     private void RefreshChartInformations(Schedule content) {
    93 
    9483    }
    9584
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/HeuristicLab.Encodings.ScheduleEncoding-3.3.csproj

    r11623 r13435  
    122122    <Compile Include="Interfaces\IScheduleCreator.cs" />
    123123    <Compile Include="Interfaces\IScheduleCrossover.cs" />
    124     <Compile Include="Interfaces\IScheduleEncoding.cs" />
     124    <Compile Include="Interfaces\ISchedule.cs" />
    125125    <Compile Include="Interfaces\IScheduleManipulator.cs" />
    126126    <Compile Include="Interfaces\IScheduleOperator.cs" />
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/ISchedule.cs

    r13434 r13435  
    2323
    2424namespace HeuristicLab.Encodings.ScheduleEncoding {
    25   public interface IScheduleEncoding : IItem {
     25  public interface ISchedule : IItem {
    2626  }
    2727}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IScheduleCreator.cs

    r12012 r13435  
    2525namespace HeuristicLab.Encodings.ScheduleEncoding {
    2626  public interface IScheduleCreator : ISolutionCreator, IScheduleOperator {
    27     ILookupParameter<IScheduleEncoding> ScheduleEncodingParameter { get; }
     27    ILookupParameter<ISchedule> ScheduleParameter { get; }
    2828  }
    2929}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IScheduleCrossover.cs

    r12012 r13435  
    2525namespace HeuristicLab.Encodings.ScheduleEncoding {
    2626  public interface IScheduleCrossover : ICrossover, IScheduleOperator {
    27     ILookupParameter<IScheduleEncoding> ChildParameter { get; }
    28     IScopeTreeLookupParameter<IScheduleEncoding> ParentsParameter { get; }
     27    ILookupParameter<ISchedule> ChildParameter { get; }
     28    IScopeTreeLookupParameter<ISchedule> ParentsParameter { get; }
    2929  }
    3030}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IScheduleManipulator.cs

    r12012 r13435  
    2525namespace HeuristicLab.Encodings.ScheduleEncoding {
    2626  public interface IScheduleManipulator : IManipulator, IScheduleOperator {
    27     ILookupParameter<IScheduleEncoding> ScheduleEncodingParameter { get; }
     27    ILookupParameter<ISchedule> ScheduleParameter { get; }
    2828  }
    2929}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/JSMEncoding.cs

    r12012 r13435  
    3030  [Item("JobSequenceMatrixEncoding", "Represents an encoding for a scheduling Problem using a list of job sequences to deliver scheduleinformation.")]
    3131  [StorableClass]
    32   public class JSMEncoding : Item, IScheduleEncoding {
     32  public class JSMEncoding : Item, ISchedule {
    3333
    3434    [Storable]
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/JSMRandomCreator.cs

    r12012 r13435  
    5252      Parameters.Add(new ValueLookupParameter<IntValue>("Resources", "The number of resources used in this problem instance."));
    5353
    54       ScheduleEncodingParameter.ActualName = "JobSequenceMatrix";
     54      ScheduleParameter.ActualName = "JobSequenceMatrix";
    5555    }
    5656
     
    6767    }
    6868
    69     protected override IScheduleEncoding CreateSolution() {
     69    protected override ISchedule CreateSolution() {
    7070      return Apply(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue);
    7171    }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Manipulators/JSMManipulator.cs

    r12012 r13435  
    3434    public JSMManipulator()
    3535      : base() {
    36       ScheduleEncodingParameter.ActualName = "JobSequenceMatrix";
     36      ScheduleParameter.ActualName = "JobSequenceMatrix";
    3737    }
    3838
    39     protected abstract void Manipulate(IRandom random, IScheduleEncoding individual);
     39    protected abstract void Manipulate(IRandom random, ISchedule individual);
    4040
    4141    public override IOperation InstrumentedApply() {
    42       var solution = ScheduleEncodingParameter.ActualValue as JSMEncoding;
     42      var solution = ScheduleParameter.ActualValue as JSMEncoding;
    4343      if (solution == null) throw new InvalidOperationException("ScheduleEncoding was not found or is not of type JSMEncoding.");
    4444      Manipulate(RandomParameter.ActualValue, solution);
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Manipulators/JSMShiftChangeManipulator.cs

    r12012 r13435  
    6363    }
    6464
    65     protected override void Manipulate(IRandom random, IScheduleEncoding encoding) {
     65    protected override void Manipulate(IRandom random, ISchedule encoding) {
    6666      var solution = encoding as JSMEncoding;
    6767      if (solution == null) throw new InvalidOperationException("Encoding is not of type JSMEncoding");
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Manipulators/JSMSwapManipulator.cs

    r12012 r13435  
    5050    }
    5151
    52     protected override void Manipulate(IRandom random, IScheduleEncoding individual) {
     52    protected override void Manipulate(IRandom random, ISchedule individual) {
    5353      var solution = individual as JSMEncoding;
    5454      if (solution == null) throw new InvalidOperationException("Encoding is not of type JSMEncoding");
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Manipulators/PWRManipulator.cs

    r12012 r13435  
    3535    public PWRManipulator()
    3636      : base() {
    37       ScheduleEncodingParameter.ActualName = "PermutationWithRepetition";
     37      ScheduleParameter.ActualName = "PermutationWithRepetition";
    3838    }
    3939
     
    4141
    4242    public override IOperation InstrumentedApply() {
    43       var solution = ScheduleEncodingParameter.ActualValue as PWREncoding;
     43      var solution = ScheduleParameter.ActualValue as PWREncoding;
    4444      if (solution == null) throw new InvalidOperationException("ScheduleEncoding was not found or is not of type PWREncoding.");
    4545      Manipulate(RandomParameter.ActualValue, solution);
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/PWREncoding.cs

    r12012 r13435  
    2929  [Item("PermutationWithRepetitionEncoding", "Represents a encoding for a standard JobShop Scheduling Problem.")]
    3030  [StorableClass]
    31   public class PWREncoding : Item, IScheduleEncoding {
     31  public class PWREncoding : Item, ISchedule {
    3232
    3333    [Storable]
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/PWRRandomCreator.cs

    r12012 r13435  
    5151      Parameters.Add(new ValueLookupParameter<IntValue>("Resources", "The number of resources used in this problem instance."));
    5252
    53       ScheduleEncodingParameter.ActualName = "PermutationWithRepetition";
     53      ScheduleParameter.ActualName = "PermutationWithRepetition";
    5454    }
    5555
     
    6262    }
    6363
    64     protected override IScheduleEncoding CreateSolution() {
     64    protected override ISchedule CreateSolution() {
    6565      return Apply(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue);
    6666    }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Manipulators/PRVManipulator.cs

    r12012 r13435  
    3434    public PRVManipulator()
    3535      : base() {
    36       ScheduleEncodingParameter.ActualName = "PriorityRulesVector";
     36      ScheduleParameter.ActualName = "PriorityRulesVector";
    3737    }
    3838
     
    4040
    4141    public override IOperation InstrumentedApply() {
    42       var solution = ScheduleEncodingParameter.ActualValue as PRVEncoding;
     42      var solution = ScheduleParameter.ActualValue as PRVEncoding;
    4343      if (solution == null) throw new InvalidOperationException("ScheduleEncoding was not found or is not of type PRVEncoding.");
    4444      Manipulate(RandomParameter.ActualValue, solution);
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/PRVEncoding.cs

    r12012 r13435  
    3030  [Item("PriorityRulesVectorEncoding", "Represents an encoding for a Scheduling Problem.")]
    3131  [StorableClass]
    32   public class PRVEncoding : Item, IScheduleEncoding {
     32  public class PRVEncoding : Item, ISchedule {
    3333    [Storable]
    3434    public IntegerVector PriorityRulesVector { get; set; }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/PRVRandomCreator.cs

    r12012 r13435  
    5757      Parameters.Add(new ValueLookupParameter<IntValue>("Jobs", "The number of jobs handled in this problem instance."));
    5858      Parameters.Add(new ValueLookupParameter<IntValue>("Resources", "The number of resources used in this problem instance."));
    59       ScheduleEncodingParameter.ActualName = "PriorityRulesVector";
     59      ScheduleParameter.ActualName = "PriorityRulesVector";
    6060    }
    6161
     
    6868    }
    6969
    70     protected override IScheduleEncoding CreateSolution() {
     70    protected override ISchedule CreateSolution() {
    7171      return Apply(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue, NrOfRules);
    7272    }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleCreator.cs

    r12012 r13435  
    3131  public abstract class ScheduleCreator : InstrumentedOperator, IScheduleCreator {
    3232
    33     public ILookupParameter<IScheduleEncoding> ScheduleEncodingParameter {
    34       get { return (ILookupParameter<IScheduleEncoding>)Parameters["ScheduleEncoding"]; }
     33    public ILookupParameter<ISchedule> ScheduleParameter {
     34      get { return (ILookupParameter<ISchedule>)Parameters["Schedule"]; }
    3535    }
    3636
     
    4040    public ScheduleCreator()
    4141      : base() {
    42       Parameters.Add(new LookupParameter<IScheduleEncoding>("ScheduleEncoding", "The new scheduling solutioncandidate."));
     42      Parameters.Add(new LookupParameter<ISchedule>("Schedule", "The new scheduling solutioncandidate."));
    4343    }
    4444
    4545    public override IOperation InstrumentedApply() {
    46       ScheduleEncodingParameter.ActualValue = CreateSolution();
     46      ScheduleParameter.ActualValue = CreateSolution();
    4747      return base.InstrumentedApply();
    4848    }
    4949
    50     protected abstract IScheduleEncoding CreateSolution();
     50    protected abstract ISchedule CreateSolution();
    5151  }
    5252}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleCrossover.cs

    r12012 r13435  
    3232  public abstract class ScheduleCrossover : InstrumentedOperator, IScheduleCrossover, IStochasticOperator {
    3333
    34     public ILookupParameter<IScheduleEncoding> ChildParameter {
    35       get { return (ILookupParameter<IScheduleEncoding>)Parameters["Child"]; }
     34    public ILookupParameter<ISchedule> ChildParameter {
     35      get { return (ILookupParameter<ISchedule>)Parameters["Child"]; }
    3636    }
    37     public IScopeTreeLookupParameter<IScheduleEncoding> ParentsParameter {
    38       get { return (IScopeTreeLookupParameter<IScheduleEncoding>)Parameters["Parents"]; }
     37    public IScopeTreeLookupParameter<ISchedule> ParentsParameter {
     38      get { return (IScopeTreeLookupParameter<ISchedule>)Parameters["Parents"]; }
    3939    }
    4040    public ILookupParameter<IRandom> RandomParameter {
     
    4848      : base() {
    4949      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
    50       Parameters.Add(new LookupParameter<IScheduleEncoding>("Child", "The child solution resulting from the crossover."));
    51       ChildParameter.ActualName = "SchedulingSolution";
    52       Parameters.Add(new ScopeTreeLookupParameter<IScheduleEncoding>("Parents", "The parent solution which should be crossed."));
    53       ParentsParameter.ActualName = "SchedulingSolution";
     50      Parameters.Add(new LookupParameter<ISchedule>("Child", "The child solution resulting from the crossover."));
     51      ChildParameter.ActualName = "Schedule";
     52      Parameters.Add(new ScopeTreeLookupParameter<ISchedule>("Parents", "The parent solution which should be crossed."));
     53      ParentsParameter.ActualName = "Schedule";
    5454    }
    5555  }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/DirectScheduleRandomCreator.cs

    r12012 r13435  
    6363      Parameters.Add(new ValueLookupParameter<IntValue>("Resources", "The number of resources used in this problem instance."));
    6464      Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Job data taken from the JSSP - Instance."));
    65       ScheduleEncodingParameter.ActualName = "Schedule";
     65      ScheduleParameter.ActualName = "Schedule";
    6666    }
    6767
     
    8282
    8383
    84     protected override IScheduleEncoding CreateSolution() {
     84    protected override ISchedule CreateSolution() {
    8585      try {
    8686        var jobData = (ItemList<Job>)JobDataParameter.ActualValue.Clone();
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Job.cs

    r12012 r13435  
    3131  [Item("Job", "Represents a composition of tasks that require processing in a scheduling problem.")]
    3232  [StorableClass]
    33   public class Job : Item, INotifyPropertyChanged {
     33  public sealed class Job : Item, INotifyPropertyChanged {
    3434
    3535    [Storable(Name = "DueDate")]
     
    3838      get { return dueDate; }
    3939      set {
    40         bool changed = dueDate != value;
     40        if (dueDate == value) return;
    4141        dueDate = value;
    42         if (changed) {
    43           OnPropertyChanged("DueDate");
    44           OnToStringChanged();
    45         }
     42        OnPropertyChanged("DueDate");
     43        OnToStringChanged();
    4644      }
    4745    }
     
    5250      get { return index; }
    5351      set {
    54         bool changed = index != value;
     52        if (index == value) return;
    5553        index = value;
    56         if (changed) {
    57           OnPropertyChanged("Index");
    58           OnToStringChanged();
    59         }
     54        OnPropertyChanged("Index");
     55        OnToStringChanged();
    6056      }
    6157    }
     
    6561    public ItemList<Task> Tasks {
    6662      get { return tasks; }
    67       set {
    68         bool changed = tasks != value;
     63      private set {
    6964        tasks = value;
    70         if (changed) OnPropertyChanged("Tasks");
     65        OnPropertyChanged("Tasks");
    7166      }
    7267    }
    7368
    7469    [StorableConstructor]
    75     protected Job(bool deserializing) : base(deserializing) { }
    76     protected Job(Job original, Cloner cloner)
     70    private Job(bool deserializing) : base(deserializing) { }
     71    private Job(Job original, Cloner cloner)
    7772      : base(original, cloner) {
    7873      this.dueDate = original.DueDate;
     
    151146    }
    152147
    153     internal Task GetPreviousTask(Task t) {
    154       if (t.TaskNr == 0) return null;
    155       return Tasks[t.TaskNr - 1];
    156     }
    157 
    158148    public event EventHandler TasksChanged;
    159     protected virtual void OnTasksChanged() {
     149    private void OnTasksChanged() {
    160150      var handler = TasksChanged;
    161151      if (handler != null) handler(this, EventArgs.Empty);
     
    163153
    164154    public event PropertyChangedEventHandler PropertyChanged;
    165     protected virtual void OnPropertyChanged(string propertyName) {
     155    private void OnPropertyChanged(string propertyName) {
    166156      var handler = PropertyChanged;
    167157      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Manipulators/DirectScheduleManipulator.cs

    r12012 r13435  
    3535    public DirectScheduleManipulator()
    3636      : base() {
    37       ScheduleEncodingParameter.ActualName = "Schedule";
     37      ScheduleParameter.ActualName = "Schedule";
    3838    }
    3939
     
    4141
    4242    public override IOperation InstrumentedApply() {
    43       var schedule = ScheduleEncodingParameter.ActualValue as Schedule;
     43      var schedule = ScheduleParameter.ActualValue as Schedule;
    4444      if (schedule == null) throw new InvalidOperationException("ScheduleEncoding was not found or is not of type Schedule.");
    4545      Manipulate(RandomParameter.ActualValue, schedule);
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Resource.cs

    r12012 r13435  
    2020#endregion
    2121
     22using System.Linq;
    2223using System.Text;
    2324using HeuristicLab.Common;
     
    2829  [Item("ResourceClass", "Represents a resource used in scheduling problems.")]
    2930  [StorableClass]
    30   public class Resource : Item {
     31  public sealed class Resource : Item {
    3132
    3233    [Storable]
    33     public int Index {
    34       get;
    35       set;
    36     }
     34    public int Index { get; private set; }
    3735    [Storable]
    38     public ItemList<ScheduledTask> Tasks {
    39       get;
    40       set;
     36    public ItemList<ScheduledTask> Tasks { get; private set; }
     37
     38    //TODO why does a Ressource has a duration?
     39    public double TotalDuration {
     40      get {
     41        if (Tasks.Count == 0) return 0.0;
     42        return Tasks.Max(t => t.EndTime);
     43      }
    4144    }
    4245
    4346    [StorableConstructor]
    44     protected Resource(bool deserializing) : base(deserializing) { }
    45     protected Resource(Resource original, Cloner cloner)
     47    private Resource(bool deserializing) : base(deserializing) { }
     48    private Resource(Resource original, Cloner cloner)
    4649      : base(original, cloner) {
    4750      this.Index = original.Index;
     
    5861    }
    5962
    60     public double TotalDuration {
    61       get {
    62         double result = 0;
    63         foreach (ScheduledTask t in Tasks) {
    64           if (t.EndTime > result)
    65             result = t.EndTime;
    66         }
    67         return result;
    68       }
    69     }
    70 
    7163    public override string ToString() {
    7264      StringBuilder sb = new StringBuilder();
    7365      sb.Append("Resource#" + Index + " [ ");
    7466      foreach (ScheduledTask t in Tasks) {
    75         sb.Append(t+ " ");
     67        sb.Append(t + " ");
    7668      }
    7769      sb.Append("]");
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Schedule.cs

    r12012 r13435  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
    27 using HeuristicLab.Data;
    2827using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2928
     
    3130  [Item("Schedule", "Represents the general solution for scheduling problems.")]
    3231  [StorableClass]
    33   public class Schedule : NamedItem, IScheduleEncoding {
     32  public class Schedule : NamedItem, ISchedule {
    3433
    3534    #region Properties
     
    3837    public ItemList<Resource> Resources {
    3938      get { return resources; }
    40       set {
    41         if (resources != null) DeregisterResourcesEvents();
    42         resources = value;
    43         if (resources != null) RegisterResourcesEvents();
    44         OnResourcesChanged();
    45       }
    4639    }
    4740    [Storable]
    48     private DoubleValue quality;
    49     public DoubleValue Quality {
     41    private double quality;
     42    public double Quality {
    5043      get { return quality; }
    5144      set {
    52         if (quality != value) {
    53           if (quality != null) DeregisterQualityEvents();
    54           quality = value;
    55           if (quality != null) RegisterQualityEvents();
    56           OnQualityChanged();
    57         }
     45        if (quality == value) return;
     46        quality = value;
     47        OnQualityChanged();
    5848      }
    5949    }
     
    6656    protected Schedule(Schedule original, Cloner cloner)
    6757      : base(original, cloner) {
    68       this.Resources = cloner.Clone(original.Resources);
    69       this.Quality = cloner.Clone(original.Quality);
     58      this.resources = cloner.Clone(original.Resources);
     59      this.quality = original.Quality;
     60      //TODO clone
    7061      this.lastScheduledTaskOfJob = new Dictionary<int, ScheduledTask>(original.lastScheduledTaskOfJob);
     62
     63      RegisterResourcesEvents();
    7164    }
    7265    public Schedule(int nrOfResources) {
    73       Resources = new ItemList<Resource>();
     66      resources = new ItemList<Resource>();
    7467      for (int i = 0; i < nrOfResources; i++) {
    7568        Resources.Add(new Resource(i));
    7669      }
    7770      lastScheduledTaskOfJob = new Dictionary<int, ScheduledTask>();
     71
     72      RegisterResourcesEvents();
    7873    }
    7974
     
    8984        changed(this, EventArgs.Empty);
    9085    }
    91     private void RegisterQualityEvents() {
    92       Quality.ValueChanged += new EventHandler(Quality_ValueChanged);
    93     }
    94     private void DeregisterQualityEvents() {
    95       Quality.ValueChanged -= new EventHandler(Quality_ValueChanged);
    96     }
    97     private void Quality_ValueChanged(object sender, EventArgs e) {
    98       OnQualityChanged();
    99     }
    10086
    10187    public event EventHandler ResourcesChanged;
     
    10793    private void RegisterResourcesEvents() {
    10894      Resources.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(Resources_PropertyChanged);
    109     }
    110     private void DeregisterResourcesEvents() {
    111       Resources.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(Resources_PropertyChanged);
    11295    }
    11396    private void Resources_PropertyChanged(object sender, EventArgs e) {
     
    154137      return sb.ToString();
    155138    }
    156 
    157     public double CalculateMakespan() {
    158       double quality = 0;
    159       foreach (Resource r in Resources) {
    160         if (r.TotalDuration > quality) {
    161           quality = r.TotalDuration;
    162         }
    163       }
    164       return quality;
    165     }
    166139  }
    167140}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleManipulator.cs

    r12012 r13435  
    3232  public abstract class ScheduleManipulator : InstrumentedOperator, IScheduleManipulator, IStochasticOperator {
    3333
    34     public ILookupParameter<IScheduleEncoding> ScheduleEncodingParameter {
    35       get { return (ILookupParameter<IScheduleEncoding>)Parameters["ScheduleEncoding"]; }
     34    public ILookupParameter<ISchedule> ScheduleParameter {
     35      get { return (ILookupParameter<ISchedule>)Parameters["Schedule"]; }
    3636    }
    3737
     
    4545    public ScheduleManipulator()
    4646      : base() {
    47       Parameters.Add(new LookupParameter<IScheduleEncoding>("ScheduleEncoding", "The scheduling solution to be manipulated."));
     47      Parameters.Add(new LookupParameter<ISchedule>("Schedule", "The scheduling solution to be manipulated."));
    4848      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
    4949    }
  • branches/ProblemRefactoring/HeuristicLab.Problems.Scheduling/3.3/Analyzers/BestSchedulingSolutionAnalyzer.cs

    r12012 r13435  
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using System.Linq;
    2324using HeuristicLab.Common;
     
    7778      if (bestSolution == null) {
    7879        bestSolution = (Schedule)solutions[i].Clone();
    79         bestSolution.Quality = (DoubleValue)qualities[i].Clone();
     80        bestSolution.Quality = qualities[i].Value;
    8081        BestSolutionParameter.ActualValue = bestSolution;
    8182        results.Add(new Result("Best Scheduling Solution", bestSolution));
    8283      } else {
    83         if (max && bestSolution.Quality.Value < qualities[i].Value ||
    84           !max && bestSolution.Quality.Value > qualities[i].Value) {
    85           bestSolution.Quality.Value = qualities[i].Value;
    86           bestSolution.Resources = (ItemList<Resource>)solutions[i].Resources.Clone();
     84        if (max && bestSolution.Quality < qualities[i].Value ||
     85          !max && bestSolution.Quality > qualities[i].Value) {
     86          bestSolution.Quality = qualities[i].Value;
     87          bestSolution.Resources.Clear();
     88          bestSolution.Resources.AddRange((IEnumerable<Resource>)solutions[i].Resources.Clone());
    8789        }
    8890      }
  • branches/ProblemRefactoring/HeuristicLab.Problems.Scheduling/3.3/Decoders/JSMDecoder.cs

    r12012 r13435  
    177177    }
    178178
    179     public override Schedule CreateScheduleFromEncoding(IScheduleEncoding encoding) {
     179    public override Schedule CreateScheduleFromEncoding(ISchedule encoding) {
    180180      var solution = encoding as JSMEncoding;
    181181      if (solution == null) throw new InvalidOperationException("Encoding is not of type JSMEncoding");
  • branches/ProblemRefactoring/HeuristicLab.Problems.Scheduling/3.3/Decoders/PRVDecoder.cs

    r12012 r13435  
    202202    }
    203203
    204     public override Schedule CreateScheduleFromEncoding(IScheduleEncoding encoding) {
     204    public override Schedule CreateScheduleFromEncoding(ISchedule encoding) {
    205205      var solution = encoding as PRVEncoding;
    206       if (solution == null) throw new InvalidOperationException("Encoding is not of type PWREncoding");
     206      if (solution == null) throw new InvalidOperationException("Encoding is not of type PRVEncoding");
    207207
    208208      var jobs = (ItemList<Job>)JobDataParameter.ActualValue.Clone();
  • branches/ProblemRefactoring/HeuristicLab.Problems.Scheduling/3.3/Decoders/PWRDecoder.cs

    r12012 r13435  
    5555    }
    5656
    57     public override Schedule CreateScheduleFromEncoding(IScheduleEncoding encoding) {
     57    public override Schedule CreateScheduleFromEncoding(ISchedule encoding) {
    5858      var solution = encoding as PWREncoding;
    5959      if (solution == null) throw new InvalidOperationException("Encoding is not of type PWREncoding");
  • branches/ProblemRefactoring/HeuristicLab.Problems.Scheduling/3.3/Decoders/ScheduleDecoder.cs

    r12012 r13435  
    3232  public abstract class ScheduleDecoder : SingleSuccessorOperator, IScheduleDecoder {
    3333
    34     public ILookupParameter<IScheduleEncoding> ScheduleEncodingParameter {
    35       get { return (ILookupParameter<IScheduleEncoding>)Parameters["ScheduleEncoding"]; }
     34    public ILookupParameter<ISchedule> ScheduleEncodingParameter {
     35      get { return (ILookupParameter<ISchedule>)Parameters["ScheduleEncoding"]; }
    3636    }
    3737    public ILookupParameter<Schedule> ScheduleParameter {
     
    4444    public ScheduleDecoder()
    4545      : base() {
    46       Parameters.Add(new LookupParameter<IScheduleEncoding>("ScheduleEncoding", "The new scheduling solution represented as encoding."));
     46      Parameters.Add(new LookupParameter<ISchedule>("ScheduleEncoding", "The new scheduling solution represented as encoding."));
    4747      Parameters.Add(new LookupParameter<Schedule>("Schedule", "The decoded scheduling solution represented as generalized schedule."));
    4848    }
    4949
    50     public abstract Schedule CreateScheduleFromEncoding(IScheduleEncoding solution);
     50    public abstract Schedule CreateScheduleFromEncoding(ISchedule solution);
    5151
    5252    public override IOperation Apply() {
  • branches/ProblemRefactoring/HeuristicLab.Problems.Scheduling/3.3/Interfaces/IScheduleDecoder.cs

    r12012 r13435  
    2424namespace HeuristicLab.Encodings.ScheduleEncoding {
    2525  public interface IScheduleDecoder : IOperator {
    26     ILookupParameter<IScheduleEncoding> ScheduleEncodingParameter { get; }
     26    ILookupParameter<ISchedule> ScheduleEncodingParameter { get; }
    2727    ILookupParameter<Schedule> ScheduleParameter { get; }
    2828  }
  • branches/ProblemRefactoring/HeuristicLab.Problems.Scheduling/3.3/JobShopSchedulingProblem.cs

    r13173 r13435  
    164164      ScheduleEvaluatorParameter.ValueChanged += ScheduleEvaluatorParameter_ValueChanged;
    165165      ScheduleEvaluator.QualityParameter.ActualNameChanged += ScheduleEvaluator_QualityParameter_ActualNameChanged;
    166       SolutionCreator.ScheduleEncodingParameter.ActualNameChanged += SolutionCreator_SchedulingEncodingParameter_ActualNameChanged;
     166      SolutionCreator.ScheduleParameter.ActualNameChanged += SolutionCreator_SchedulingEncodingParameter_ActualNameChanged;
    167167      ScheduleDecoderParameter.ValueChanged += ScheduleDecoderParameter_ValueChanged;
    168168      if (ScheduleDecoder != null) ScheduleDecoder.ScheduleParameter.ActualNameChanged += ScheduleDecoder_ScheduleParameter_ActualNameChanged;
     
    171171    #region Events
    172172    protected override void OnSolutionCreatorChanged() {
    173       SolutionCreator.ScheduleEncodingParameter.ActualNameChanged += SolutionCreator_SchedulingEncodingParameter_ActualNameChanged;
     173      SolutionCreator.ScheduleParameter.ActualNameChanged += SolutionCreator_SchedulingEncodingParameter_ActualNameChanged;
    174174      InitializeOperators();
    175175    }
     
    288288
    289289      if (ScheduleDecoder != null)
    290         ScheduleDecoder.ScheduleEncodingParameter.ActualName = SolutionCreator.ScheduleEncodingParameter.ActualName;
     290        ScheduleDecoder.ScheduleEncodingParameter.ActualName = SolutionCreator.ScheduleParameter.ActualName;
    291291
    292292      if (ScheduleDecoder != null) {
     
    295295      } else if (SolutionCreator is DirectScheduleRandomCreator) {
    296296        var directEvaluator = (DirectScheduleRandomCreator)SolutionCreator;
    297         ScheduleEvaluator.ScheduleParameter.ActualName = directEvaluator.ScheduleEncodingParameter.ActualName;
     297        ScheduleEvaluator.ScheduleParameter.ActualName = directEvaluator.ScheduleParameter.ActualName;
    298298        ScheduleEvaluator.ScheduleParameter.Hidden = true;
    299299      } else {
     
    303303
    304304      foreach (var op in Operators.OfType<IScheduleManipulator>()) {
    305         op.ScheduleEncodingParameter.ActualName = SolutionCreator.ScheduleEncodingParameter.ActualName;
    306         op.ScheduleEncodingParameter.Hidden = true;
     305        op.ScheduleParameter.ActualName = SolutionCreator.ScheduleParameter.ActualName;
     306        op.ScheduleParameter.Hidden = true;
    307307      }
    308308
    309309      foreach (var op in Operators.OfType<IScheduleCrossover>()) {
    310         op.ChildParameter.ActualName = SolutionCreator.ScheduleEncodingParameter.ActualName;
     310        op.ChildParameter.ActualName = SolutionCreator.ScheduleParameter.ActualName;
    311311        op.ChildParameter.Hidden = true;
    312         op.ParentsParameter.ActualName = SolutionCreator.ScheduleEncodingParameter.ActualName;
     312        op.ParentsParameter.ActualName = SolutionCreator.ScheduleParameter.ActualName;
    313313        op.ParentsParameter.Hidden = true;
    314314      }
     
    320320          op.ScheduleParameter.Hidden = true;
    321321        } else if (SolutionCreator is DirectScheduleRandomCreator) {
    322           op.ScheduleParameter.ActualName = ((DirectScheduleRandomCreator)SolutionCreator).ScheduleEncodingParameter.ActualName;
     322          op.ScheduleParameter.ActualName = ((DirectScheduleRandomCreator)SolutionCreator).ScheduleParameter.ActualName;
    323323          op.ScheduleParameter.Hidden = true;
    324324        } else {
Note: See TracChangeset for help on using the changeset viewer.