- Timestamp:
- 11/15/10 09:41:51 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ParameterBinding/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs
r4787 r4790 33 33 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 34 34 using HeuristicLab.PluginInfrastructure; 35 using System.Linq.Expressions; 35 36 36 37 namespace HeuristicLab.Problems.TravelingSalesman { … … 148 149 } 149 150 public override IDeepCloneable Clone(Cloner cloner) { 150 return new TravelingSalesmanProblem(this, cloner); 151 TravelingSalesmanProblem clone = new TravelingSalesmanProblem(this, cloner); 152 clone.parameterBindingList = this.parameterBindingList.Select(x => cloner.Clone(x)).ToList(); 153 return clone; 151 154 } 152 155 public TravelingSalesmanProblem() … … 178 181 InitializeOperators(); 179 182 AttachEventHandlers(); 180 183 CreateBindings(); 184 } 185 186 private void CreateBindings() { 187 #region Analyzers 181 188 AddBinding("BestTSPSolutionAnalyzer.QualityParameter.ActualName", "Evaluator.QualityParameter.ActualName"); 182 189 AddBinding("BestTSPSolutionAnalyzer.CoordinatesParameter.ActualName", "CoordinatesParameter.Name"); … … 185 192 AddBinding("BestTSPSolutionAnalyzer.BestKnownSolutionParameter.ActualName", "BestKnownSolutionParameter.Name"); 186 193 AddBinding("BestTSPSolutionAnalyzer.MaximizationParameter.ActualName", "MaximizationParameter.Name"); 187 BestTSPSolutionAnalyzer.ResultsParameter.ActualName = "Results"; 194 AddBinding("TSPAlleleFrequencyAnalyzer.MaximizationParameter.ActualName", "MaximizationParameter.Name"); 195 AddBinding("TSPAlleleFrequencyAnalyzer.CoordinatesParameter.ActualName", "CoordinatesParameter.Name"); 196 AddBinding("TSPAlleleFrequencyAnalyzer.SolutionParameter.ActualName", "SolutionCreator.PermutationParameter.ActualName"); 197 AddBinding("TSPAlleleFrequencyAnalyzer.QualityParameter.ActualName", "Evaluator.QualityParameter.ActualName"); 198 AddBinding("TSPAlleleFrequencyAnalyzer.BestKnownSolutionParameter.ActualName", "BestKnownSolutionParameter.Name"); 199 AddBinding("TSPPopulationDiversityAnalyzer.MaximizationParameter.ActualName", "MaximizationParameter.Name"); 200 AddBinding("TSPPopulationDiversityAnalyzer.SolutionParameter.ActualName", "SolutionCreator.PermutationParameter.ActualName"); 201 AddBinding("TSPPopulationDiversityAnalyzer.QualityParameter.ActualName", "Evaluator.QualityParameter.ActualName"); 202 #endregion 203 Expression<Func<IEnumerable<string>,IntValue>> tmp = (x) => new IntValue(x.Count()); 204 AddBinding("SolutionCreator.LengthParameter.Value", "Coordinates.RowNames", tmp); 205 Expression<Func<IPermutationCreator, PermutationType>> tmp2 = (x) => new PermutationType(PermutationTypes.RelativeUndirected); 206 AddBinding("SolutionCreator.PermutationTypeParameter.Value", "SolutionCreator", tmp2); 188 207 } 189 208 … … 227 246 ParameterizeSolutionCreator(); 228 247 ParameterizeEvaluator(); 229 ParameterizeAnalyzers();230 248 ParameterizeOperators(); 231 249 OnSolutionCreatorChanged(); … … 233 251 private void SolutionCreator_PermutationParameter_ActualNameChanged(object sender, EventArgs e) { 234 252 ParameterizeEvaluator(); 235 ParameterizeAnalyzers();236 253 ParameterizeOperators(); 237 254 } 238 255 private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) { 239 Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);240 256 ParameterizeEvaluator(); 241 257 UpdateMoveEvaluators(); 242 ParameterizeAnalyzers();243 258 ClearDistanceMatrix(); 244 259 OnEvaluatorChanged(); 245 }246 private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {247 ParameterizeAnalyzers();248 260 } 249 261 private void MoveGenerator_InversionMoveParameter_ActualNameChanged(object sender, EventArgs e) { … … 278 290 SolutionCreator.PermutationParameter.ActualNameChanged += new EventHandler(SolutionCreator_PermutationParameter_ActualNameChanged); 279 291 EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged); 280 Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);281 292 } 282 293 … … 286 297 operators.Add(new TSPAlleleFrequencyAnalyzer()); 287 298 operators.Add(new TSPPopulationDiversityAnalyzer()); 288 ParameterizeAnalyzers(); 299 BestTSPSolutionAnalyzer.ResultsParameter.ActualName = "Results"; 300 TSPAlleleFrequencyAnalyzer.ResultsParameter.ActualName = "Results"; 301 TSPPopulationDiversityAnalyzer.ResultsParameter.ActualName = "Results"; 289 302 operators.AddRange(ApplicationManager.Manager.GetInstances<IPermutationOperator>().Cast<IOperator>()); 290 303 ParameterizeOperators(); … … 314 327 } 315 328 private void ParameterizeSolutionCreator() { 316 SolutionCreator.LengthParameter.Value = new IntValue(Coordinates.Rows);317 SolutionCreator.PermutationTypeParameter.Value = new PermutationType(PermutationTypes.RelativeUndirected);329 //SolutionCreator.LengthParameter.Value = new IntValue(Coordinates.Rows); 330 //SolutionCreator.PermutationTypeParameter.Value = new PermutationType(PermutationTypes.RelativeUndirected); 318 331 } 319 332 private void ParameterizeEvaluator() { … … 325 338 evaluator.DistanceMatrixParameter.ActualName = DistanceMatrixParameter.Name; 326 339 evaluator.UseDistanceMatrixParameter.ActualName = UseDistanceMatrixParameter.Name; 327 }328 }329 private void ParameterizeAnalyzers() {330 /*if (BestTSPSolutionAnalyzer != null) {331 BestTSPSolutionAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;332 BestTSPSolutionAnalyzer.CoordinatesParameter.ActualName = CoordinatesParameter.Name;333 BestTSPSolutionAnalyzer.PermutationParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;334 BestTSPSolutionAnalyzer.ResultsParameter.ActualName = "Results";335 BestTSPSolutionAnalyzer.BestKnownQualityParameter.ActualName = BestKnownQualityParameter.Name;336 BestTSPSolutionAnalyzer.BestKnownSolutionParameter.ActualName = BestKnownSolutionParameter.Name;337 BestTSPSolutionAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;338 }*/339 340 if (TSPAlleleFrequencyAnalyzer != null) {341 TSPAlleleFrequencyAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;342 TSPAlleleFrequencyAnalyzer.CoordinatesParameter.ActualName = CoordinatesParameter.Name;343 TSPAlleleFrequencyAnalyzer.SolutionParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;344 TSPAlleleFrequencyAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;345 TSPAlleleFrequencyAnalyzer.BestKnownSolutionParameter.ActualName = BestKnownSolutionParameter.Name;346 TSPAlleleFrequencyAnalyzer.ResultsParameter.ActualName = "Results";347 }348 349 if (TSPPopulationDiversityAnalyzer != null) {350 TSPPopulationDiversityAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;351 TSPPopulationDiversityAnalyzer.SolutionParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;352 TSPPopulationDiversityAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;353 TSPPopulationDiversityAnalyzer.ResultsParameter.ActualName = "Results";354 340 } 355 341 }
Note: See TracChangeset
for help on using the changeset viewer.