- Timestamp:
- 08/01/08 21:35:35 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.CEDMA.Core/AgentList.cs
r403 r420 30 30 using System.Runtime.Serialization; 31 31 using System.IO; 32 using HeuristicLab.Operators; 32 33 33 34 namespace HeuristicLab.CEDMA.Core { … … 50 51 newAgent.Status = a.Status; 51 52 IOperatorGraph opGraph = (IOperatorGraph)PersistenceManager.RestoreFromGZip(a.RawData); 52 foreach(IOperator op in opGraph.Operators) newAgent.OperatorGraph.AddOperator(op); 53 54 DownloadOperators(opGraph, new Dictionary<long, IOperator>()); 55 56 foreach(IOperator op in opGraph.Operators) { 57 newAgent.OperatorGraph.AddOperator(op); 58 } 53 59 newAgent.OperatorGraph.InitialOperator = opGraph.InitialOperator; 54 60 agentList.Add(newAgent); … … 80 86 } 81 87 88 private void DownloadOperators(IOperatorGraph opGraph, Dictionary<long, IOperator> downloaded) { 89 foreach(IOperator op in opGraph.Operators) { 90 DownloadOperators(op, downloaded); 91 } 92 } 93 94 private void DownloadOperators(IOperator op, Dictionary<long, IOperator> downloaded) { 95 if(op is OperatorLink) { 96 OperatorLink link = op as OperatorLink; 97 if(downloaded.ContainsKey(link.Id)) { 98 link.Operator = downloaded[link.Id]; 99 } else { 100 OperatorEntry targetEntry = database.GetOperator(link.Id); 101 IOperator target = (IOperator)PersistenceManager.RestoreFromGZip(targetEntry.RawData); 102 downloaded.Add(link.Id, target); 103 DownloadOperators(target, downloaded); 104 link.Operator = target; 105 } 106 } else if(op is CombinedOperator) { 107 DownloadOperators(((CombinedOperator)op).OperatorGraph, downloaded); 108 } 109 } 110 82 111 public override IView CreateView() { 83 112 return new AgentListView(this); -
trunk/sources/HeuristicLab.CEDMA.DB.Interfaces/IDatabase.cs
r417 r420 73 73 ICollection<OperatorEntry> GetOperators(); 74 74 75 [OperationContract] 76 OperatorEntry GetOperator(long agentId); 77 75 78 } 76 79 } -
trunk/sources/HeuristicLab.CEDMA.Server/RunScheduler.cs
r419 r420 76 76 IOperatorGraph opGraph = (IOperatorGraph)PersistenceManager.RestoreFromGZip(entry.RawData); 77 77 78 foreach(IOperator op in opGraph.Operators) { 79 PatchLinks(op); 80 } 78 PatchLinks(opGraph, new Dictionary<long, IOperator>()); 81 79 82 80 AtomicOperation operation = new AtomicOperation(opGraph.InitialOperator, scope); … … 99 97 } 100 98 101 private void PatchLinks(IOperator op) { 102 if(op is OperatorLink) { 103 OperatorLink link = op as OperatorLink; 104 OperatorEntry targetEntry = database.GetOperator(link.Id); 105 IOperator target = (IOperator)PersistenceManager.RestoreFromGZip(targetEntry.RawData); 106 ReplaceOperatorInGraph(link, target); 107 } else if(op is CombinedOperator) { 108 CombinedOperator combinedOp = op as CombinedOperator; 109 foreach(IOperator internalOp in combinedOp.OperatorGraph.Operators) { 110 PatchLinks(internalOp); 99 private void PatchLinks(IOperatorGraph opGraph, Dictionary<long, IOperator> patchedOperators) { 100 Dictionary<IOperator, IOperator> patchDictionary = new Dictionary<IOperator, IOperator>(); 101 foreach(IOperator op in opGraph.Operators) { 102 IOperator patched = PatchLinks(op, patchedOperators); 103 patchDictionary.Add(op, patched); 104 } 105 foreach(KeyValuePair<IOperator, IOperator> p in patchDictionary) { 106 IOperator original = p.Key; 107 IOperator patch = p.Value; 108 if(original != patch) { 109 foreach(IOperator subOperator in original.SubOperators) { 110 patch.AddSubOperator(subOperator); 111 } 112 if(opGraph.InitialOperator == original) 113 opGraph.InitialOperator = patch; 114 opGraph.RemoveOperator(original.Guid); 115 opGraph.AddOperator(patch); 111 116 } 112 117 } 113 118 } 114 119 115 private void ReplaceOperatorInGraph(OperatorLink link, IOperator target) { 116 throw new NotImplementedException(); 120 private IOperator PatchLinks(IOperator op, Dictionary<long, IOperator> patchedOperators) { 121 if(op is OperatorLink) { 122 OperatorLink link = op as OperatorLink; 123 if(patchedOperators.ContainsKey(link.Id)) { 124 return patchedOperators[link.Id]; 125 } else { 126 OperatorEntry targetEntry = database.GetOperator(link.Id); 127 IOperator target = (IOperator)PersistenceManager.RestoreFromGZip(targetEntry.RawData); 128 patchedOperators.Add(link.Id, target); 129 PatchLinks(target, patchedOperators); 130 return target; 131 } 132 } else if(op is CombinedOperator) { 133 PatchLinks(((CombinedOperator)op).OperatorGraph, patchedOperators); 134 return op; 135 } 136 return op; 117 137 } 118 138
Note: See TracChangeset
for help on using the changeset viewer.