- Timestamp:
- 12/02/08 21:30:34 (16 years ago)
- Location:
- branches/CloningRefactorBranch/HeuristicLab.Scheduling.JSSP
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CloningRefactorBranch/HeuristicLab.Scheduling.JSSP/JSSPInjector.cs
r120 r888 61 61 } 62 62 63 public JSSPInjector(JSSPInjector original) : this(original, new Dictionary<Guid, object>()) { } 64 protected JSSPInjector(JSSPInjector original, IDictionary<Guid, object> clonedObjects) 65 : base(original, clonedObjects) { 66 this.operations = (ItemList)Auxiliary.Clone(original.operations, clonedObjects); 67 this.jobs = (IntData)Auxiliary.Clone(original.jobs, clonedObjects); 68 this.machines = (IntData)Auxiliary.Clone(original.machines, clonedObjects); 69 } 70 63 71 public override IView CreateView() { 64 72 return new JSSPInjectorView(this); … … 73 81 74 82 public override object Clone(IDictionary<Guid, object> clonedObjects) { 75 JSSPInjector clone = (JSSPInjector)base.Clone(clonedObjects); 76 clone.operations = (ItemList)Auxiliary.Clone(operations, clonedObjects); 77 clone.jobs = (IntData)Auxiliary.Clone(jobs, clonedObjects); 78 clone.machines = (IntData)Auxiliary.Clone(machines, clonedObjects); 79 return clone; 83 return new JSSPInjector(this, clonedObjects); 80 84 } 81 85 -
branches/CloningRefactorBranch/HeuristicLab.Scheduling.JSSP/Operation.cs
r2 r888 99 99 } 100 100 101 public Operation(Operation original) : this(original, new Dictionary<Guid, object>()) { } 102 protected Operation(Operation original, IDictionary<Guid, object> clonedObjects) 103 : base(original, clonedObjects) { 104 this.duration = (IntData)Auxiliary.Clone(original.duration, clonedObjects); 105 this.start = (IntData)Auxiliary.Clone(original.start, clonedObjects); 106 this.operationIndex = (IntData)Auxiliary.Clone(original.operationIndex, clonedObjects); 107 this.job = (IntData)Auxiliary.Clone(original.job, clonedObjects); 108 this.machines = (IntArrayData)Auxiliary.Clone(original.machines, clonedObjects); 109 this.predecessors = (ItemList)Auxiliary.Clone(original.predecessors, clonedObjects); 110 } 111 101 112 public override string ToString() { 102 113 if(this.Job == -1) { … … 128 139 129 140 public override object Clone(IDictionary<Guid, object> clonedObjects) { 130 Operation clone = new Operation(); 131 clonedObjects.Add(Guid, clone); 132 clone.duration = (IntData)Auxiliary.Clone(duration, clonedObjects); 133 clone.start = (IntData)Auxiliary.Clone(start, clonedObjects); 134 clone.operationIndex = (IntData)Auxiliary.Clone(operationIndex, clonedObjects); 135 clone.job = (IntData)Auxiliary.Clone(job, clonedObjects); 136 clone.machines = (IntArrayData)Auxiliary.Clone(machines, clonedObjects); 137 clone.predecessors = (ItemList)Auxiliary.Clone(predecessors, clonedObjects); 138 return clone; 141 return new Operation(this, clonedObjects); 139 142 } 140 143 -
branches/CloningRefactorBranch/HeuristicLab.Scheduling.JSSP/Schedule.cs
r2 r888 41 41 public Schedule() : this(0, 100) { } 42 42 43 public Schedule(Schedule original) : this(original, new Dictionary<Guid, object>()) { } 44 protected Schedule(Schedule original, IDictionary<Guid, object> clonedObjects) 45 : base(original, clonedObjects) { 46 this.schedule = new ScheduleTree[original.Machines]; 47 for (int i = 0; i < original.Machines; i++) { 48 this.schedule[i] = (ScheduleTree)Auxiliary.Clone(original.schedule[i], clonedObjects); 49 } 50 } 51 43 52 public int Machines { 44 53 get { return schedule.Length; } … … 64 73 } 65 74 66 75 #region IStorable Members 67 76 68 77 public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid,IStorable> persistedObjects) { … … 87 96 88 97 public override object Clone(IDictionary<Guid, object> clonedObjects) { 89 int timespan = 0; 90 if ((schedule != null) && (schedule.Length > 0)) { 91 timespan = schedule[0].Timespan; 92 } 93 Schedule clone = new Schedule(this.Machines, timespan); 94 clonedObjects.Add(Guid, clone); 95 clone.schedule = new ScheduleTree[this.Machines]; 96 for(int i = 0; i < this.Machines; i++) { 97 clone.schedule[i] = (ScheduleTree)Auxiliary.Clone(schedule[i], clonedObjects); 98 } 99 return clone; 98 return new Schedule(this, clonedObjects); 100 99 } 101 100 -
branches/CloningRefactorBranch/HeuristicLab.Scheduling.JSSP/ScheduleInjector.cs
r361 r888 47 47 } 48 48 49 public ScheduleInjector(ScheduleInjector original) : this(original, new Dictionary<Guid, object>()) { } 50 protected ScheduleInjector(ScheduleInjector original, IDictionary<Guid, object> clonedObjects) 51 : base(original, clonedObjects) { 52 if (original.schedule != null) { 53 this.schedule = (Schedule)Auxiliary.Clone(original.schedule, clonedObjects); 54 } 55 } 56 49 57 public override IOperation Apply(IScope scope) { 50 58 IntData machines = GetVariableValue<IntData>("Machines", scope, true); … … 56 64 57 65 public override object Clone(IDictionary<Guid, object> clonedObjects) { 58 ScheduleInjector clone = (ScheduleInjector)base.Clone(clonedObjects); 59 if(schedule != null) { 60 clone.schedule = (Schedule)Auxiliary.Clone(schedule, clonedObjects); 61 } 62 return clone; 66 return new ScheduleInjector(this, clonedObjects); 63 67 } 64 68 65 69 #region IStorable Members 66 public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {70 public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) { 67 71 XmlNode node = base.GetXmlNode(name, document, persistedObjects); 68 if (schedule != null) {72 if (schedule != null) { 69 73 node.AppendChild(PersistenceManager.Persist("Schedule", schedule, document, persistedObjects)); 70 74 } 71 75 return node; 72 76 } 73 public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {77 public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) { 74 78 base.Populate(node, restoredObjects); 75 79 XmlNode scheduleNode = node.SelectSingleNode("Schedule"); 76 if (scheduleNode != null) {80 if (scheduleNode != null) { 77 81 schedule = (Schedule)PersistenceManager.Restore(scheduleNode, restoredObjects); 78 82 } -
branches/CloningRefactorBranch/HeuristicLab.Scheduling.JSSP/ScheduleTree.cs
r385 r888 88 88 89 89 public ScheduleTree() : this(10000) { } 90 91 public ScheduleTree(ScheduleTree original) : this(original, new Dictionary<Guid, object>()) {} 92 protected ScheduleTree(ScheduleTree original, IDictionary<Guid, object> clonedObjects) 93 : base(original, clonedObjects) { 94 foreach (ScheduleTreeNode node in original.InOrder) { 95 if (IsLeaf(node) && (node.Data.job > -1)) { 96 this.InsertOperation(node.Data); // interestingly enough node.Data is not cloned! (gkronber Dec. 2nd, 2008) 97 } 98 } 99 } 90 100 91 101 private int InsertOperation(Operation op) { … … 243 253 244 254 public override object Clone(IDictionary<Guid, object> clonedObjects) { 245 ScheduleTree clone = new ScheduleTree(timespan); 246 clonedObjects.Add(Guid, clone); 247 foreach (ScheduleTreeNode node in this.InOrder) { 248 if (IsLeaf(node) && (node.Data.job > -1)) { 249 clone.InsertOperation(node.Data); 250 } 251 } 252 return clone; 255 return new ScheduleTree(this, clonedObjects); 253 256 } 254 257
Note: See TracChangeset
for help on using the changeset viewer.