- Timestamp:
- 07/28/20 23:36:25 (4 years ago)
- Location:
- branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/AlbaEncoding.cs
r17699 r17704 28 28 using HeuristicLab.Optimization; 29 29 using HeuristicLab.PluginInfrastructure; 30 using HeuristicLab.Problems.VehicleRouting.Interfaces; 30 31 31 32 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 54 55 static AlbaEncoding() { 55 56 encodingSpecificOperatorTypes = new List<Type>() { 56 typeof (IAlbaOperator) 57 typeof (IAlbaOperator), 58 typeof (IVRPCreator), 59 typeof (IMultiVRPOperator) 57 60 }; 58 61 } … … 63 66 var newOperators = operators.Except(Operators, new TypeEqualityComparer<IOperator>()).ToList(); 64 67 68 foreach (var op in newOperators.OfType<IMultiVRPOperator>().ToList()) { 69 op.SetOperators(Operators.Concat(newOperators)); 70 if (!op.Operators.Any()) newOperators.Remove(op); 71 } 72 foreach (var op in Operators.OfType<IMultiVRPOperator>()) { 73 op.SetOperators(newOperators); 74 } 65 75 ConfigureOperators(newOperators); 66 76 foreach (var @operator in newOperators) -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/LocalImprovement/AlbaLambdaInterchangeLocalImprovementOperator.cs
r17698 r17704 20 20 #endregion 21 21 22 using HEAL.Attic; 23 using HeuristicLab.Common; 24 using HeuristicLab.Core; 25 using HeuristicLab.Data; 22 26 using HeuristicLab.Optimization; 23 using HeuristicLab.Core;24 using HEAL.Attic;25 using HeuristicLab.Data;26 using HeuristicLab.Common;27 27 using HeuristicLab.Parameters; 28 28 using HeuristicLab.Problems.VehicleRouting.Interfaces; … … 31 31 [Item("AlbaLambdaInterchangeLocalImprovementOperator", "Takes a solution and finds the local optimum with respect to the lambda interchange neighborhood by decending along the steepest gradient.")] 32 32 [StorableType("84981F03-B886-4ADD-8DB5-C12628404335")] 33 public class AlbaLambdaInterchangeLocalImprovementOperator : VRPOperator, IStochasticOperator, ILocalImprovementOperator, ISingleObjectiveOperator {33 public class AlbaLambdaInterchangeLocalImprovementOperator : VRPOperator, IStochasticOperator, ILocalImprovementOperator, ISingleObjectiveOperator, IAlbaOperator { 34 34 35 35 public IValueLookupParameter<IntValue> MaximumIterationsParameter { -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IMultiVRPOperator.cs
r17226 r17704 21 21 22 22 using System.Collections.Generic; 23 using HEAL.Attic; 23 24 using HeuristicLab.Core; 24 using HEAL.Attic;25 25 26 26 namespace HeuristicLab.Problems.VehicleRouting.Interfaces { 27 27 [StorableType("4ED07F1F-AC5F-4771-8916-AF7DD576C581")] 28 interface IMultiVRPOperator : IVRPOperator {28 interface IMultiVRPOperator : IVRPOperator, IMultiOperator { 29 29 void SetOperators(IEnumerable<IOperator> operators); 30 30 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs
r17699 r17704 39 39 using HeuristicLab.Problems.VehicleRouting.Interpreters; 40 40 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; 41 using HeuristicLab.Problems.VehicleRouting.Variants;42 41 43 42 namespace HeuristicLab.Problems.VehicleRouting { … … 151 150 152 151 void ProblemInstanceParameter_ValueChanged(object sender, EventArgs e) { 153 InitializeOperators();154 AttachProblemInstanceEventHandlers(); 155 156 OnOperatorsChanged();152 //InitializeOperators(); 153 AttachProblemInstanceEventHandlers(); 154 155 //OnOperatorsChanged(); 157 156 } 158 157 … … 167 166 168 167 private void InitializeOperators() { 169 Operators.Clear(); 170 171 if (ProblemInstance != null) { 172 Operators.AddRange( 173 ProblemInstance.Operators.Concat( 174 ApplicationManager.Manager.GetInstances<IGeneralVRPOperator>().Cast<IOperator>()).OrderBy(op => op.Name)); 175 Operators.Add(new VRPSimilarityCalculator()); 176 Operators.Add(new QualitySimilarityCalculator()); 177 Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>())); 178 179 IVRPCreator defaultCreator = null; 180 /*foreach (IVRPCreator creator in Operators.Where(o => o is IVRPCreator)) { 181 solutionCreatorParameter.ValidValues.Add(creator); 182 if (creator is Encodings.Alba.RandomCreator) 183 defaultCreator = creator; 184 }*/ 185 Operators.Add(new AlbaLambdaInterchangeLocalImprovementOperator()); 186 /*if (defaultCreator != null) 187 solutionCreatorParameter.Value = defaultCreator;*/ 188 } 189 190 Parameterize(); 168 Operators.Add(new VRPSimilarityCalculator()); 169 Operators.Add(new QualitySimilarityCalculator()); 170 Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>())); 191 171 } 192 172 … … 197 177 198 178 private void Parameterize() { 199 foreach (IOperator op in Operators.OfType<IOperator>()) { 200 if (op is IMultiVRPOperator) { 201 (op as IMultiVRPOperator).SetOperators(Operators.OfType<IOperator>()); 202 } 203 } 204 if (Parameters.ContainsKey("ProblemInstance") && ProblemInstance != null) { 205 foreach (ISingleObjectiveImprovementOperator op in Operators.OfType<ISingleObjectiveImprovementOperator>()) { 206 //op.SolutionParameter.ActualName = SolutionCreator.VRPToursParameter.ActualName; 207 op.SolutionParameter.Hidden = true; 208 } 209 foreach (ISingleObjectivePathRelinker op in Operators.OfType<ISingleObjectivePathRelinker>()) { 210 //op.ParentsParameter.ActualName = SolutionCreator.VRPToursParameter.ActualName; 211 op.ParentsParameter.Hidden = true; 212 } 213 foreach (ISolutionSimilarityCalculator op in Operators.OfType<ISolutionSimilarityCalculator>()) { 214 //op.SolutionVariableName = SolutionCreator.VRPToursParameter.ActualName; 215 op.QualityVariableName = ProblemInstance.SolutionEvaluator.QualityParameter.ActualName; 216 var calc = op as VRPSimilarityCalculator; 217 if (calc != null) calc.ProblemInstance = ProblemInstance; 218 } 179 foreach (ISolutionSimilarityCalculator op in Operators.OfType<ISolutionSimilarityCalculator>()) { 180 op.SolutionVariableName = Encoding.Name; 181 op.QualityVariableName = Evaluator.QualityParameter.ActualName; 182 var calc = op as VRPSimilarityCalculator; 183 if (calc != null) calc.ProblemInstance = ProblemInstance; 219 184 } 220 185 }
Note: See TracChangeset
for help on using the changeset viewer.