Changeset 4365 for branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4
- Timestamp:
- 09/06/10 17:05:13 (14 years ago)
- Location:
- branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4
- Files:
-
- 23 added
- 1 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Creators/DefaultRepresentationCreator.cs
r4363 r4365 42 42 public override IOperation Apply() { 43 43 //choose default encoding here 44 //VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(CreateSolution());44 VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(CreateSolution(), ProblemInstance); 45 45 46 46 return base.Apply(); -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/VRPOperator.cs
r4362 r4365 34 34 [StorableClass] 35 35 public abstract class VRPOperator : SingleSuccessorOperator, IVRPOperator { 36 p rotectedLookupParameter<IVRPProblemInstance> ProblemInstanceParameter {36 public ILookupParameter<IVRPProblemInstance> ProblemInstanceParameter { 37 37 get { return (LookupParameter<IVRPProblemInstance>)Parameters["ProblemInstance"]; } 38 38 } 39 39 40 p rotectedIVRPProblemInstance ProblemInstance {40 public IVRPProblemInstance ProblemInstance { 41 41 get { return ProblemInstanceParameter.ActualValue; } 42 42 } -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/HeuristicLab.Problems.VehicleRouting-3.4.csproj
r4363 r4365 106 106 </ItemGroup> 107 107 <ItemGroup> 108 <Compile Include="Encodings\Alba\AlbaEncoding.cs" /> 108 109 <Compile Include="Encodings\Alba\Creators\DefaultRepresentationCreator.cs" /> 110 <Compile Include="Encodings\Alba\Creators\PushForwardInsertionCreator.cs" /> 109 111 <Compile Include="Encodings\Alba\Creators\RandomCreator.cs" /> 110 112 <Compile Include="Encodings\Alba\Creators\AlbaCreator.cs" /> 111 113 <Compile Include="Encodings\Alba\AlbaOperator.cs" /> 114 <Compile Include="Encodings\Alba\Crossovers\AlbaCrossover.cs" /> 115 <Compile Include="Encodings\Alba\Crossovers\AlbaPermutationCrossover.cs" /> 116 <Compile Include="Encodings\Alba\Manipulators\AlbaCustomerInsertionManipulator.cs" /> 117 <Compile Include="Encodings\Alba\Manipulators\AlbaCustomerInversionManipulator.cs" /> 118 <Compile Include="Encodings\Alba\Manipulators\AlbaCustomerSwapManipulator.cs" /> 119 <Compile Include="Encodings\Alba\Manipulators\AlbaIntraRouteInversionManipulator.cs" /> 120 <Compile Include="Encodings\Alba\Manipulators\AlbaLambdaInterchangeManipulator.cs" /> 121 <Compile Include="Encodings\Alba\Manipulators\AlbaManipulator.cs" /> 122 <Compile Include="Encodings\Alba\Manipulators\AlbaPermutationManipulator.cs" /> 123 <Compile Include="Encodings\General\Creators\MultiVRPSolutionCreator.cs" /> 124 <Compile Include="Encodings\General\Crossovers\MultiVRPSolutionCrossover.cs" /> 125 <Compile Include="Encodings\General\Crossovers\RandomParentCloneCrossover.cs" /> 126 <Compile Include="Encodings\General\Manipulators\MultiVRPSolutionManipulator.cs" /> 127 <Compile Include="Encodings\General\PermutationEncoding.cs" /> 128 <Compile Include="Encodings\General\TourEncoding.cs" /> 112 129 <Compile Include="Encodings\VRPOperator.cs" /> 113 <Compile Include="Encodings\VRPEncoding.cs" /> 130 <Compile Include="Interfaces\IMultiVRPOperator.cs" /> 131 <Compile Include="Interfaces\IVRPManipulator.cs" /> 132 <Compile Include="Interfaces\IVRPCrossover.cs" /> 114 133 <Compile Include="Interfaces\IVRPEvaluator.cs" /> 115 134 <Compile Include="Interfaces\IVRPCreator.cs" /> … … 123 142 <Compile Include="Variants\Capacitated\Homogenous\ICapacitatedOperator.cs" /> 124 143 <Compile Include="Variants\Capacitated\Homogenous\ICapacitatedProblemInstance.cs" /> 144 <Compile Include="Variants\General\IGeneralVRPOperator.cs" /> 125 145 <Compile Include="Variants\SingleDepot\ISingleDepotOperator.cs" /> 126 146 <Compile Include="Variants\SingleDepot\ISingleDepotEncoding.cs" /> -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/HeuristicLabProblemsVehicleRoutingPlugin.cs
r4363 r4365 26 26 /// Plugin class for HeuristicLab.Problems.VehicleRouting plugin 27 27 /// </summary> 28 [Plugin("HeuristicLab.Problems.VehicleRouting", "3.4.0.436 2")]28 [Plugin("HeuristicLab.Problems.VehicleRouting", "3.4.0.4363")] 29 29 [PluginFile("HeuristicLab.Problems.VehicleRouting-3.4.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Analysis", "3.3")] -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPOperator.cs
r4362 r4365 28 28 namespace HeuristicLab.Problems.VehicleRouting.Interfaces { 29 29 public interface IVRPOperator: IItem { 30 ILookupParameter<IVRPProblemInstance> ProblemInstanceParameter { get; } 30 31 } 31 32 } -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRP/SingleDepotVRPProblemInstance.cs
r4363 r4365 43 43 } 44 44 45 public override IntValue Cities { 46 get { 47 return new IntValue(Demand.Length - 1); 48 } 49 } 50 45 51 protected override IVRPEvaluator Evaluator { 46 52 get { -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPEvaluator.cs
r4363 r4365 124 124 125 125 public override IOperation Apply() { 126 double quality = 0; 126 127 InitResultParameters(); 127 128 128 129 foreach (Tour tour in VRPToursParameter.ActualValue.GetTours()) { 129 130 VRPEvaluation tourEvaluation = EvaluateTour(ProblemInstance, tour); 131 quality += tourEvaluation.Quality; 130 132 131 133 UpdateResultParameters(tourEvaluation); 132 134 } 135 136 QualityParameter.ActualValue = new DoubleValue(quality); 133 137 134 138 return base.Apply(); -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPProblemInstance.cs
r4363 r4365 89 89 set { DemandParameter.Value = value; } 90 90 } 91 public IntValue Cities {91 public virtual IntValue Cities { 92 92 get { return new IntValue(Demand.Length); } 93 93 } -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs
r4362 r4365 35 35 using HeuristicLab.Problems.VehicleRouting.Parsers; 36 36 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; 37 using HeuristicLab.Problems.VehicleRouting.Variants; 37 38 38 39 namespace HeuristicLab.Problems.VehicleRouting { … … 61 62 get { return BestKnownQualityParameter; } 62 63 } 63 public IParameter SolutionCreatorParameter { 64 get { 65 if (ProblemInstance != null) 66 return ProblemInstance.SolutionCreatorParameter; 67 else 68 return null; 69 } 70 } 71 public IParameter EvaluatorParameter { 72 get { 73 if (ProblemInstance != null) 74 return ProblemInstance.EvaluatorParameter; 75 else 76 return null; 77 } 64 public IValueParameter<IVRPCreator> SolutionCreatorParameter { 65 get { return (IValueParameter<IVRPCreator>)Parameters["SolutionCreator"]; } 66 } 67 IParameter IProblem.SolutionCreatorParameter { 68 get { return SolutionCreatorParameter; } 69 } 70 public IValueParameter<IVRPEvaluator> EvaluatorParameter { 71 get { return (IValueParameter<IVRPEvaluator>)Parameters["Evaluator"]; } 72 } 73 IParameter IProblem.EvaluatorParameter { 74 get { return EvaluatorParameter; } 78 75 } 79 76 #endregion … … 86 83 87 84 public ISingleObjectiveEvaluator Evaluator { 88 get { 89 if (ProblemInstance != null) 90 return ProblemInstance.EvaluatorParameter.Value; 91 else 92 return null; 93 } 85 get { return ProblemInstance.EvaluatorParameter.Value; } 94 86 } 95 87 … … 99 91 100 92 public ISolutionCreator SolutionCreator { 101 get { 102 if (ProblemInstance != null) 103 return ProblemInstance.SolutionCreatorParameter.Value; 104 else 105 return null; 106 } 107 } 93 get { return ProblemInstance.SolutionCreatorParameter.Value; } 94 } 95 96 [Storable] 97 private List<IOperator> operators; 108 98 109 99 public IEnumerable<IOperator> Operators { 110 get { 111 if (ProblemInstance != null) 112 return ProblemInstance.Operators.OrderBy(op => op.Name); 113 else 114 return null; 115 } 100 get { return operators; } 116 101 } 117 102 #endregion … … 124 109 Parameters.Add(new ValueParameter<IVRPProblemInstance>("ProblemInstance", "The VRP problem instance")); 125 110 Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this VRP instance.")); 126 111 112 operators = new List<IOperator>(); 113 127 114 InitializeRandomVRPInstance(); 115 InitializeOperators(); 128 116 129 117 AttachEventHandlers(); … … 133 121 public override IDeepCloneable Clone(Cloner cloner) { 134 122 VehicleRoutingProblem clone = (VehicleRoutingProblem)base.Clone(cloner); 123 clone.operators = operators.Select(x => (IOperator)cloner.Clone(x)).ToList(); 135 124 clone.AttachEventHandlers(); 136 125 return clone; … … 172 161 173 162 private void AttachProblemInstanceEventHandlers() { 163 if (Parameters.ContainsKey("Evaluator")) 164 Parameters.Remove("Evaluator"); 165 166 if (Parameters.ContainsKey("SolutionCreator")) 167 Parameters.Remove("SolutionCreator"); 168 174 169 if (ProblemInstance != null) { 175 170 ProblemInstance.SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged); 176 171 ProblemInstance.EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged); 172 Parameters.Add(ProblemInstance.EvaluatorParameter); 173 Parameters.Add(ProblemInstance.SolutionCreatorParameter); 177 174 } 178 175 } … … 180 177 void ProblemInstanceParameter_ValueChanged(object sender, EventArgs e) { 181 178 AttachProblemInstanceEventHandlers(); 182 } 183 179 InitializeOperators(); 180 181 OnSolutionCreatorChanged(); 182 OnEvaluatorChanged(); 183 OnOperatorsChanged(); 184 } 184 185 private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) { 186 ParameterizeSolutionCreator(); 187 185 188 OnSolutionCreatorChanged(); 186 189 } 187 190 private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) { 188 191 OnEvaluatorChanged(); 192 } 193 194 private void InitializeOperators() { 195 operators = new List<IOperator>(); 196 197 if (ProblemInstance != null) { 198 operators.AddRange( 199 ProblemInstance.Operators.Concat( 200 ApplicationManager.Manager.GetInstances<IGeneralVRPOperator>().Cast<IOperator>()).OrderBy(op => op.Name)); 201 } 202 203 ParameterizeOperators(); 204 } 205 206 private void ParameterizeSolutionCreator() { 207 if (SolutionCreator is IMultiVRPOperator) { 208 (SolutionCreator as IMultiVRPOperator).SetOperators(Operators); 209 } 210 } 211 212 private void ParameterizeOperators() { 213 foreach (IOperator op in Operators) { 214 if (op is IMultiVRPOperator) { 215 (op as IMultiVRPOperator).SetOperators(Operators); 216 } 217 } 189 218 } 190 219 #endregion
Note: See TracChangeset
for help on using the changeset viewer.