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

#2521: Intermediate version of schedule encoding refactoring.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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("]");
Note: See TracChangeset for help on using the changeset viewer.