- Timestamp:
- 08/05/20 05:46:07 (4 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Collections/3.3/ObservableCollection.cs
r17461 r17718 103 103 if (list.Capacity != capacity) 104 104 OnPropertyChanged("Capacity"); 105 OnPropertyChanged("Item[]"); 106 OnPropertyChanged("Count"); 107 } 105 OnPropertyChanged("Count"); 106 } 107 } 108 109 /// <summary> 110 /// Performs a Clear and an AddRange, but does not fire separate events for those operations 111 /// </summary> 112 /// <param name="collection"></param> 113 public void Replace(IEnumerable<T> collection) { 114 List<T> oldItems = null; 115 if (list.Any()) oldItems = new List<T>(list); 116 else oldItems = new List<T>(); 117 118 int oldCapacity = list.Capacity; 119 list.Clear(); 120 list.AddRange(collection); 121 122 List<T> items = null; 123 if (list.Any()) items = new List<T>(list); 124 else items = new List<T>(); 125 126 OnCollectionReset(items, oldItems); 127 if (oldCapacity != list.Capacity) OnPropertyChanged("Capacity"); 128 if (oldItems.Count != items.Count) OnPropertyChanged("Count"); 108 129 } 109 130 -
branches/2521_ProblemRefactoring/HeuristicLab.Collections/3.3/ObservableSet.cs
r17226 r17718 128 128 OnItemsRemoved(items); 129 129 } 130 } 131 132 /// <summary> 133 /// Performs a Clear and an Add, but does not fire separate events for those operations 134 /// </summary> 135 /// <param name="other"></param> 136 public void Replace(IEnumerable<T> other) { 137 List<T> oldItems = null; 138 if (set.Any()) oldItems = new List<T>(set); 139 else oldItems = new List<T>(); 140 141 set.Clear(); 142 set.UnionWith(other); 143 144 List<T> items = null; 145 if (set.Any()) items = new List<T>(set); 146 else items = new List<T>(); 147 148 OnCollectionReset(items, oldItems); 149 if (oldItems.Count != items.Count) OnPropertyChanged("Count"); 130 150 } 131 151 -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Encoding.cs
r17699 r17718 82 82 } 83 83 84 protected void ReplaceOperators(IEnumerable<IOperator> operators) { 85 encodingOperators.Replace(operators); 86 } 87 84 88 public void ConfigureOperator(IItem @operator) { ConfigureOperators(new[] { @operator }); } 85 89 public virtual void ConfigureOperators(IEnumerable<IItem> operators) { -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Results/ResultParameter.cs
r17715 r17718 121 121 if (result.Value != null && resultValue == null) 122 122 throw new InvalidOperationException(string.Format("Type mismatch. Result \"{0}\" does not contain a \"{1}\".", ActualName, typeof(T).GetPrettyName())); 123 123 else if (result.Value == null && DefaultValue != null) { 124 result.Value = resultValue = (T)DefaultValue.Clone(); 125 } 124 126 return resultValue; 125 127 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/AlbaEncoding.cs
r17714 r17718 27 27 using HeuristicLab.Core; 28 28 using HeuristicLab.PluginInfrastructure; 29 using HeuristicLab.Problems.VehicleRouting.Encodings.General; 29 30 using HeuristicLab.Problems.VehicleRouting.Interfaces; 30 31 … … 56 57 typeof (IAlbaOperator), 57 58 typeof (IVRPCreator), 58 typeof (IMultiVRPOperator) 59 typeof (IMultiVRPOperator), 60 typeof (IMultiVRPMoveOperator) 59 61 }; 60 62 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/GVR/GVREncoding.cs
r17714 r17718 27 27 using HeuristicLab.Core; 28 28 using HeuristicLab.PluginInfrastructure; 29 using HeuristicLab.Problems.VehicleRouting.Encodings.General; 29 30 using HeuristicLab.Problems.VehicleRouting.Interfaces; 30 31 … … 56 57 typeof (IGVROperator), 57 58 typeof (IVRPCreator), 58 typeof (IMultiVRPOperator) 59 typeof (IMultiVRPOperator), 60 typeof (IMultiVRPMoveOperator) 59 61 }; 60 62 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/PotvinEncoding.cs
r17714 r17718 27 27 using HeuristicLab.Core; 28 28 using HeuristicLab.PluginInfrastructure; 29 using HeuristicLab.Problems.VehicleRouting.Encodings.General; 29 30 using HeuristicLab.Problems.VehicleRouting.Interfaces; 30 31 … … 56 57 typeof (IPotvinOperator), 57 58 typeof (IVRPCreator), 58 typeof (IMultiVRPOperator) 59 typeof (IMultiVRPOperator), 60 typeof (IMultiVRPMoveOperator) 59 61 }; 60 62 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Prins/PrinsEncoding.cs
r17714 r17718 27 27 using HeuristicLab.Core; 28 28 using HeuristicLab.PluginInfrastructure; 29 using HeuristicLab.Problems.VehicleRouting.Encodings.General; 29 30 using HeuristicLab.Problems.VehicleRouting.Interfaces; 30 31 … … 56 57 typeof (IPrinsOperator), 57 58 typeof (IVRPCreator), 58 typeof (IMultiVRPOperator) 59 typeof (IMultiVRPOperator), 60 typeof (IMultiVRPMoveOperator) 59 61 }; 60 62 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/VRPEncoding.cs
r17711 r17718 39 39 public void FilterOperators(IVRPProblemInstance instance) { 40 40 DiscoverOperators(); 41 var operators = instance.FilterOperators(Operators); 42 foreach (var op in Operators.Except(operators).ToList()) { 43 RemoveOperator(op); 41 var operators = instance.FilterOperators(Operators).ToList(); 42 foreach (var op in operators.OfType<IMultiVRPOperator>().ToList()) { 43 var subOps = instance.FilterOperators(op.Operators).ToList(); 44 if (subOps.Count == 0) operators.Remove(op); 45 else { 46 foreach (var dm in op.Operators.Except(subOps).ToList()) 47 op.RemoveOperator(dm); 48 } 44 49 } 50 ReplaceOperators(operators); 45 51 } 46 52 -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/ZhuEncoding.cs
r17714 r17718 27 27 using HeuristicLab.Core; 28 28 using HeuristicLab.PluginInfrastructure; 29 using HeuristicLab.Problems.VehicleRouting.Encodings.General; 29 30 using HeuristicLab.Problems.VehicleRouting.Interfaces; 30 31 … … 56 57 typeof (IZhuOperator), 57 58 typeof (IVRPCreator), 58 typeof (IMultiVRPOperator) 59 typeof (IMultiVRPOperator), 60 typeof (IMultiVRPMoveOperator) 59 61 }; 60 62 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs
r17717 r17718 204 204 Encoding.FilterOperators(ProblemInstance); 205 205 206 var newOps = new List<IItem>(); 207 var operatorTypes = new HashSet<Type>(Operators.Select(x => x.GetType())); 206 var newOps = ProblemInstance.FilterOperators(Operators.OfType<IOperator>()) 207 .Union(Operators.Where(x => !(x is IOperator) || x.GetType().Namespace.StartsWith("HeuristicLab.Optimization"))) 208 .ToList(); 209 var operatorTypes = new HashSet<Type>(newOps.Select(x => x.GetType())); 208 210 if (operatorTypes.Add(typeof(VRPSimilarityCalculator))) 209 211 newOps.Add(new VRPSimilarityCalculator()); … … 214 216 215 217 var assembly = typeof(VehicleRoutingProblem).Assembly; 216 var operators = ApplicationManager.Manager.GetTypes(new[] { typeof(IAnalyzer) }, assembly, true, false, false)218 var analyzers = ApplicationManager.Manager.GetTypes(new[] { typeof(IAnalyzer) }, assembly, true, false, false) 217 219 .Where(x => operatorTypes.Add(x)).Select(t => (IOperator)Activator.CreateInstance(t)).ToList(); 218 newOps.AddRange(ProblemInstance.FilterOperators( operators));219 220 Operators. AddRange(newOps);220 newOps.AddRange(ProblemInstance.FilterOperators(analyzers)); 221 222 Operators.Replace(newOps); 221 223 } 222 224
Note: See TracChangeset
for help on using the changeset viewer.