#region License Information /* HeuristicLab * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System.Text; using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.Encodings.ScheduleEncoding { [Item("ScheduledTask", "Represents a task that has been scheduled already.")] [StorableClass] public class ScheduledTask : Item { #region Properties [Storable] public int TaskNr { get; set; } [Storable] public int ResourceNr { get; set; } [Storable] public double Duration { get; set; } [Storable] public double StartTime { get; set; } public double EndTime { get { return Duration + StartTime; } } [Storable] public int JobNr { get; set; } #endregion [StorableConstructor] protected ScheduledTask(bool deserializing) : base(deserializing) { } protected ScheduledTask(ScheduledTask original, Cloner cloner) : base(original, cloner) { this.TaskNr = original.TaskNr; this.ResourceNr = original.ResourceNr; this.Duration = original.Duration; this.StartTime = original.StartTime; this.JobNr = original.JobNr; } public override IDeepCloneable Clone(Cloner cloner) { return new ScheduledTask(this, cloner); } public ScheduledTask(int resNr, double startTime, double duration, int jobNr) : base() { Duration = duration; ResourceNr = resNr; StartTime = startTime; JobNr = jobNr; } public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("[" + JobNr + "," + ResourceNr + "]"); return sb.ToString(); } public override bool Equals(object obj) { if (obj.GetType() == typeof(ScheduledTask)) return AreEqual(this, obj as ScheduledTask); else return false; } public override int GetHashCode() { return TaskNr ^ JobNr; } public static bool AreEqual(ScheduledTask task1, ScheduledTask task2) { return ( task1.TaskNr == task2.TaskNr && task1.Duration == task2.Duration && task1.JobNr == task2.JobNr && task1.ResourceNr == task2.ResourceNr && task1.StartTime == task2.StartTime && task1.EndTime == task2.EndTime); } } }