Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/24/11 14:23:19 (13 years ago)
Author:
jhelm
Message:

#1329: Added DirectSchedule-Classes for optimization with the direct-schedule encoding.

Location:
branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding
Files:
10 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Resource.cs

    r6412 r6475  
    7575      return sb.ToString();
    7676    }
     77
     78
     79    public override bool Equals(object obj) {
     80      if (obj.GetType() == typeof(Resource))
     81        return AreEqual(this, obj as Resource);
     82      else
     83        return false;
     84    }
     85
     86    private static bool AreEqual(Resource res1, Resource res2) {
     87      if (res1.Tasks.Count != res2.Tasks.Count)
     88        return false;
     89      for (int i = 0; i < res1.Tasks.Count; i++) {
     90        if (!res1.Tasks[i].Equals(res2.Tasks[i]))
     91          return false;
     92      }
     93
     94      return true;
     95    }
    7796  }
    7897}
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Schedule.cs

    r6412 r6475  
    3131  [Item("Schedule", "Represents the general solution for scheduling problems.")]
    3232  [StorableClass]
    33   public class Schedule : NamedItem {
     33  public class Schedule : NamedItem, IScheduleEncoding {
    3434    #region Properties
    3535    [Storable]
     
    7979      lastScheduledTaskOfJob = new Dictionary<int, ScheduledTask>();
    8080    }
     81
    8182
    8283
     
    159160      return quality;
    160161    }
     162
     163    public override bool Equals(object obj) {
     164      if (obj.GetType() == typeof(Schedule))
     165        return AreEqual(this, obj as Schedule);
     166      else
     167        return false;
     168    }
     169
     170    private static bool AreEqual(Schedule schedule1, Schedule schedule2) {
     171      if (schedule1.Resources.Count != schedule2.Resources.Count)
     172        return false;
     173      for (int i = 0; i < schedule1.Resources.Count; i++) {
     174        if (!schedule1.Resources[i].Equals(schedule2.Resources[i]))
     175          return false;
     176      }
     177
     178      return true;
     179    }
     180
    161181  }
    162182}
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/ScheduledTask.cs

    r6414 r6475  
    7171      return sb.ToString();
    7272    }
     73
     74
     75    public override bool Equals(object obj) {
     76      if (obj.GetType() == typeof(ScheduledTask))
     77        return AreEqual(this, obj as ScheduledTask);
     78      else
     79        return false;
     80    }
     81
     82    public static bool AreEqual(ScheduledTask task1, ScheduledTask task2) {
     83      return (task1.Duration == task2.Duration &&
     84        task1.JobNr == task2.JobNr &&
     85        task1.ResourceNr == task2.ResourceNr &&
     86        task1.StartTime == task2.StartTime &&
     87        task1.EndTime == task2.EndTime);
     88    }
    7389  }
    7490}
Note: See TracChangeset for help on using the changeset viewer.