- Timestamp:
- 01/13/17 18:18:37 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/MemPRContext.cs
r14552 r14563 197 197 } 198 198 [Storable] 199 private List<Tuple<double, double, double >> breedingStat;200 public List<Tuple<double, double, double>> BreedingStat {199 private List<Tuple<double, double, double, double>> breedingStat; 200 public IEnumerable<Tuple<double, double, double, double>> BreedingStat { 201 201 get { return breedingStat; } 202 202 } … … 207 207 } 208 208 [Storable] 209 private List<Tuple<double, double, double >> relinkingStat;210 public List<Tuple<double, double, double>> RelinkingStat {209 private List<Tuple<double, double, double, double>> relinkingStat; 210 public IEnumerable<Tuple<double, double, double, double>> RelinkingStat { 211 211 get { return relinkingStat; } 212 212 } … … 217 217 } 218 218 [Storable] 219 private List<Tuple<double, double, double >> delinkingStat;220 public List<Tuple<double, double, double>> DelinkingStat {219 private List<Tuple<double, double, double, double>> delinkingStat; 220 public IEnumerable<Tuple<double, double, double, double>> DelinkingStat { 221 221 get { return delinkingStat; } 222 222 } … … 228 228 [Storable] 229 229 private List<Tuple<double, double>> samplingStat; 230 public List<Tuple<double, double>> SamplingStat {230 public IEnumerable<Tuple<double, double>> SamplingStat { 231 231 get { return samplingStat; } 232 232 } … … 238 238 [Storable] 239 239 private List<Tuple<double, double>> hillclimbingStat; 240 public List<Tuple<double, double>> HillclimbingStat {240 public IEnumerable<Tuple<double, double>> HillclimbingStat { 241 241 get { return hillclimbingStat; } 242 242 } … … 248 248 [Storable] 249 249 private List<Tuple<double, double>> adaptivewalkingStat; 250 public List<Tuple<double, double>> AdaptivewalkingStat {250 public IEnumerable<Tuple<double, double>> AdaptivewalkingStat { 251 251 get { return adaptivewalkingStat; } 252 252 } … … 276 276 random = cloner.Clone(original.random); 277 277 breedingPerformanceModel = cloner.Clone(original.breedingPerformanceModel); 278 breedingStat = original.breedingStat.Select(x => Tuple.Create(x.Item1, x.Item2, x.Item3 )).ToList();278 breedingStat = original.breedingStat.Select(x => Tuple.Create(x.Item1, x.Item2, x.Item3, x.Item4)).ToList(); 279 279 relinkingPerformanceModel = cloner.Clone(original.relinkingPerformanceModel); 280 relinkingStat = original.relinkingStat.Select(x => Tuple.Create(x.Item1, x.Item2, x.Item3 )).ToList();280 relinkingStat = original.relinkingStat.Select(x => Tuple.Create(x.Item1, x.Item2, x.Item3, x.Item4)).ToList(); 281 281 delinkingPerformanceModel = cloner.Clone(original.delinkingPerformanceModel); 282 delinkingStat = original.delinkingStat.Select(x => Tuple.Create(x.Item1, x.Item2, x.Item3 )).ToList();282 delinkingStat = original.delinkingStat.Select(x => Tuple.Create(x.Item1, x.Item2, x.Item3, x.Item4)).ToList(); 283 283 samplingPerformanceModel = cloner.Clone(original.samplingPerformanceModel); 284 284 samplingStat = original.samplingStat.Select(x => Tuple.Create(x.Item1, x.Item2)).ToList(); … … 310 310 Parameters.Add(random = new ValueParameter<IRandom>("Random", new MersenneTwister())); 311 311 312 breedingStat = new List<Tuple<double, double, double >>();313 relinkingStat = new List<Tuple<double, double, double >>();314 delinkingStat = new List<Tuple<double, double, double >>();312 breedingStat = new List<Tuple<double, double, double, double>>(); 313 relinkingStat = new List<Tuple<double, double, double, double>>(); 314 delinkingStat = new List<Tuple<double, double, double, double>>(); 315 315 samplingStat = new List<Tuple<double, double>>(); 316 316 hillclimbingStat = new List<Tuple<double, double>>(); … … 344 344 345 345 public void RelearnBreedingPerformanceModel() { 346 breedingPerformanceModel = RunRegression(PrepareRegression( BreedingStat), breedingPerformanceModel).Model;347 } 348 public bool BreedingSuited(ISingleObjectiveSolutionScope<TSolution> p1, ISingleObjectiveSolutionScope<TSolution> p2 ) {346 breedingPerformanceModel = RunRegression(PrepareRegression(ToListRow(breedingStat)), breedingPerformanceModel).Model; 347 } 348 public bool BreedingSuited(ISingleObjectiveSolutionScope<TSolution> p1, ISingleObjectiveSolutionScope<TSolution> p2, double dist) { 349 349 if (breedingPerformanceModel == null) return true; 350 350 double minI1 = double.MaxValue, minI2 = double.MaxValue, maxI1 = double.MinValue, maxI2 = double.MinValue; … … 355 355 if (d.Item2 > maxI2) maxI2 = d.Item2; 356 356 } 357 if (IsBetter(p1, p2)) { 358 if (p1.Fitness < minI1 || p1.Fitness > maxI1 || p2.Fitness < minI2 || p2.Fitness > maxI2) 359 return true; 360 return Random.NextDouble() < ProbabilityAccept3dModel(p1.Fitness, p2.Fitness, breedingPerformanceModel); 361 } 362 if (p1.Fitness < minI2 || p1.Fitness > maxI2 || p2.Fitness < minI1 || p2.Fitness > maxI1) 357 if (p1.Fitness < minI1 || p1.Fitness > maxI1 || p2.Fitness < minI2 || p2.Fitness > maxI2) 363 358 return true; 364 return Random.NextDouble() < ProbabilityAccept3dModel(p2.Fitness, p1.Fitness, breedingPerformanceModel); 359 360 return Random.NextDouble() < ProbabilityAcceptAbsolutePerformanceModel(new List<double> { p1.Fitness, p2.Fitness, dist }, breedingPerformanceModel); 365 361 } 366 362 367 363 public void RelearnRelinkingPerformanceModel() { 368 relinkingPerformanceModel = RunRegression(PrepareRegression( RelinkingStat), relinkingPerformanceModel).Model;369 } 370 public bool RelinkSuited(ISingleObjectiveSolutionScope<TSolution> p1, ISingleObjectiveSolutionScope<TSolution> p2 ) {364 relinkingPerformanceModel = RunRegression(PrepareRegression(ToListRow(relinkingStat)), relinkingPerformanceModel).Model; 365 } 366 public bool RelinkSuited(ISingleObjectiveSolutionScope<TSolution> p1, ISingleObjectiveSolutionScope<TSolution> p2, double dist) { 371 367 if (relinkingPerformanceModel == null) return true; 372 368 double minI1 = double.MaxValue, minI2 = double.MaxValue, maxI1 = double.MinValue, maxI2 = double.MinValue; … … 377 373 if (d.Item2 > maxI2) maxI2 = d.Item2; 378 374 } 375 if (p1.Fitness < minI1 || p1.Fitness > maxI1 || p2.Fitness < minI2 || p2.Fitness > maxI2) 376 return true; 377 379 378 if (IsBetter(p1, p2)) { 380 if (p1.Fitness < minI1 || p1.Fitness > maxI1 || p2.Fitness < minI2 || p2.Fitness > maxI2) 381 return true; 382 return Random.NextDouble() < ProbabilityAccept3dModel(p1.Fitness, p2.Fitness, relinkingPerformanceModel); 383 } 384 if (p1.Fitness < minI2 || p1.Fitness > maxI2 || p2.Fitness < minI1 || p2.Fitness > maxI1) 385 return true; 386 return Random.NextDouble() < ProbabilityAccept3dModel(p2.Fitness, p1.Fitness, relinkingPerformanceModel); 379 return Random.NextDouble() < ProbabilityAcceptRelativePerformanceModel(p1.Fitness, new List<double> { p1.Fitness, p2.Fitness, dist }, relinkingPerformanceModel); 380 } 381 return Random.NextDouble() < ProbabilityAcceptRelativePerformanceModel(p2.Fitness, new List<double> { p1.Fitness, p2.Fitness, dist }, relinkingPerformanceModel); 387 382 } 388 383 389 384 public void RelearnDelinkingPerformanceModel() { 390 delinkingPerformanceModel = RunRegression(PrepareRegression( DelinkingStat), delinkingPerformanceModel).Model;391 } 392 public bool DelinkSuited(ISingleObjectiveSolutionScope<TSolution> p1, ISingleObjectiveSolutionScope<TSolution> p2 ) {385 delinkingPerformanceModel = RunRegression(PrepareRegression(ToListRow(delinkingStat)), delinkingPerformanceModel).Model; 386 } 387 public bool DelinkSuited(ISingleObjectiveSolutionScope<TSolution> p1, ISingleObjectiveSolutionScope<TSolution> p2, double dist) { 393 388 if (delinkingPerformanceModel == null) return true; 394 389 double minI1 = double.MaxValue, minI2 = double.MaxValue, maxI1 = double.MinValue, maxI2 = double.MinValue; … … 399 394 if (d.Item2 > maxI2) maxI2 = d.Item2; 400 395 } 396 if (p1.Fitness < minI1 || p1.Fitness > maxI1 || p2.Fitness < minI2 || p2.Fitness > maxI2) 397 return true; 401 398 if (IsBetter(p1, p2)) { 402 if (p1.Fitness < minI1 || p1.Fitness > maxI1 || p2.Fitness < minI2 || p2.Fitness > maxI2) 403 return true; 404 return Random.NextDouble() < ProbabilityAccept3dModel(p1.Fitness, p2.Fitness, delinkingPerformanceModel); 405 } 406 if (p1.Fitness < minI2 || p1.Fitness > maxI2 || p2.Fitness < minI1 || p2.Fitness > maxI1) 407 return true; 408 return Random.NextDouble() < ProbabilityAccept3dModel(p2.Fitness, p1.Fitness, delinkingPerformanceModel); 399 return Random.NextDouble() < ProbabilityAcceptRelativePerformanceModel(p1.Fitness, new List<double> { p1.Fitness, p2.Fitness, dist }, delinkingPerformanceModel); 400 } 401 return Random.NextDouble() < ProbabilityAcceptRelativePerformanceModel(p2.Fitness, new List<double> { p1.Fitness, p2.Fitness, dist }, delinkingPerformanceModel); 409 402 } 410 403 411 404 public void RelearnSamplingPerformanceModel() { 412 samplingPerformanceModel = RunRegression(PrepareRegression( SamplingStat), samplingPerformanceModel).Model;413 } 414 public bool SamplingSuited( ) {405 samplingPerformanceModel = RunRegression(PrepareRegression(ToListRow(samplingStat)), samplingPerformanceModel).Model; 406 } 407 public bool SamplingSuited(double avgDist) { 415 408 if (samplingPerformanceModel == null) return true; 416 return Random.NextDouble() < ProbabilityAccept2dModel(Population.Average(x => x.Fitness), samplingPerformanceModel); 409 if (avgDist < samplingStat.Min(x => x.Item1) || avgDist > samplingStat.Max(x => x.Item1)) return true; 410 return Random.NextDouble() < ProbabilityAcceptAbsolutePerformanceModel(new List<double> { avgDist }, samplingPerformanceModel); 417 411 } 418 412 419 413 public void RelearnHillclimbingPerformanceModel() { 420 hillclimbingPerformanceModel = RunRegression(PrepareRegression( HillclimbingStat), hillclimbingPerformanceModel).Model;414 hillclimbingPerformanceModel = RunRegression(PrepareRegression(ToListRow(hillclimbingStat)), hillclimbingPerformanceModel).Model; 421 415 } 422 416 public bool HillclimbingSuited(ISingleObjectiveSolutionScope<TSolution> scope) { 423 if (hillclimbingPerformanceModel == null) return true; 424 if (scope.Fitness < HillclimbingStat.Min(x => x.Item1) || scope.Fitness > HillclimbingStat.Max(x => x.Item1)) 425 return true; 426 return Random.NextDouble() < ProbabilityAccept2dModel(scope.Fitness, hillclimbingPerformanceModel); 417 return HillclimbingSuited(scope.Fitness); 427 418 } 428 419 public bool HillclimbingSuited(double startingFitness) { … … 430 421 if (startingFitness < HillclimbingStat.Min(x => x.Item1) || startingFitness > HillclimbingStat.Max(x => x.Item1)) 431 422 return true; 432 return Random.NextDouble() < ProbabilityAccept 2dModel(startingFitness, hillclimbingPerformanceModel);423 return Random.NextDouble() < ProbabilityAcceptRelativePerformanceModel(startingFitness, new List<double> { startingFitness }, hillclimbingPerformanceModel); 433 424 } 434 425 435 426 public void RelearnAdaptiveWalkPerformanceModel() { 436 adaptiveWalkPerformanceModel = RunRegression(PrepareRegression( AdaptivewalkingStat), adaptiveWalkPerformanceModel).Model;427 adaptiveWalkPerformanceModel = RunRegression(PrepareRegression(ToListRow(adaptivewalkingStat)), adaptiveWalkPerformanceModel).Model; 437 428 } 438 429 public bool AdaptivewalkingSuited(ISingleObjectiveSolutionScope<TSolution> scope) { 439 if (adaptiveWalkPerformanceModel == null) return true; 440 if (scope.Fitness < AdaptivewalkingStat.Min(x => x.Item1) || scope.Fitness > AdaptivewalkingStat.Max(x => x.Item1)) 441 return true; 442 return Random.NextDouble() < ProbabilityAccept2dModel(scope.Fitness, adaptiveWalkPerformanceModel); 430 return AdaptivewalkingSuited(scope.Fitness); 443 431 } 444 432 public bool AdaptivewalkingSuited(double startingFitness) { … … 446 434 if (startingFitness < AdaptivewalkingStat.Min(x => x.Item1) || startingFitness > AdaptivewalkingStat.Max(x => x.Item1)) 447 435 return true; 448 return Random.NextDouble() < ProbabilityAccept2dModel(startingFitness, adaptiveWalkPerformanceModel); 449 } 450 451 public IConfidenceRegressionSolution GetSolution(IConfidenceRegressionModel model, List<Tuple<double, double>> data) { 452 return new ConfidenceRegressionSolution(model, PrepareRegression(data)); 453 } 454 public IConfidenceRegressionSolution GetSolution(IConfidenceRegressionModel model, List<Tuple<double, double, double>> data) { 455 return new ConfidenceRegressionSolution(model, PrepareRegression(data)); 456 } 457 458 protected RegressionProblemData PrepareRegression(List<Tuple<double, double>> sample) { 459 var inCol = new List<double>(); 460 var outCol = new List<double>(); 436 return Random.NextDouble() < ProbabilityAcceptAbsolutePerformanceModel(new List<double> { startingFitness }, adaptiveWalkPerformanceModel); 437 } 438 439 public IConfidenceRegressionSolution GetSolution(IConfidenceRegressionModel model, IEnumerable<Tuple<double, double>> data) { 440 return new ConfidenceRegressionSolution(model, PrepareRegression(ToListRow(data.ToList()))); 441 } 442 public IConfidenceRegressionSolution GetSolution(IConfidenceRegressionModel model, IEnumerable<Tuple<double, double, double>> data) { 443 return new ConfidenceRegressionSolution(model, PrepareRegression(ToListRow(data.ToList()))); 444 } 445 public IConfidenceRegressionSolution GetSolution(IConfidenceRegressionModel model, IEnumerable<Tuple<double, double, double, double>> data) { 446 return new ConfidenceRegressionSolution(model, PrepareRegression(ToListRow(data.ToList()))); 447 } 448 449 protected RegressionProblemData PrepareRegression(List<List<double>> sample) { 450 var columns = sample.First().Select(y => new List<double>()).ToList(); 461 451 foreach (var next in sample.Shuffle(Random)) { 462 inCol.Add(next.Item1); 463 outCol.Add(next.Item2); 464 } 465 var ds = new Dataset(new[] { "in", "out" }, new[] { inCol, outCol }); 466 var regPrb = new RegressionProblemData(ds, new[] { "in" }, "out") { 467 TrainingPartition = { Start = 0, End = Math.Min(50, sample.Count) }, 468 TestPartition = { Start = Math.Min(50, sample.Count), End = sample.Count } 469 }; 470 return regPrb; 471 } 472 473 protected RegressionProblemData PrepareRegression(List<Tuple<double, double, double>> sample) { 474 var in1Col = new List<double>(); 475 var in2Col = new List<double>(); 476 var outCol = new List<double>(); 477 foreach (var next in sample.Shuffle(Random)) { 478 in1Col.Add(next.Item1); 479 in2Col.Add(next.Item2); 480 outCol.Add(next.Item3); 481 } 482 var ds = new Dataset(new[] { "in1", "in2", "out" }, new[] { in1Col, in2Col, outCol }); 483 var regPrb = new RegressionProblemData(ds, new[] { "in1", "in2" }, "out") { 452 for (var i = 0; i < next.Count; i++) { 453 columns[i].Add(next[i]); 454 } 455 } 456 var ds = new Dataset(columns.Select((v, i) => i < columns.Count - 1 ? "in" + i : "out").ToList(), columns); 457 var regPrb = new RegressionProblemData(ds, Enumerable.Range(0, columns.Count - 1).Select(x => "in" + x), "out") { 484 458 TrainingPartition = { Start = 0, End = Math.Min(50, sample.Count) }, 485 459 TestPartition = { Start = Math.Min(50, sample.Count), End = sample.Count } … … 525 499 } 526 500 527 private double ProbabilityAccept2dModel(double a, IConfidenceRegressionModel model) { 528 var ds = new Dataset(new[] { "in", "out" }, new[] { new List<double> { a }, new List<double> { double.NaN } }); 501 private double ProbabilityAcceptAbsolutePerformanceModel(List<double> inputs, IConfidenceRegressionModel model) { 502 var inputVariables = inputs.Select((v, i) => "in" + i); 503 var ds = new Dataset(inputVariables.Concat( new [] { "out" }), inputs.Select(x => new List<double> { x }).Concat(new [] { new List<double> { double.NaN } })); 529 504 var mean = model.GetEstimatedValues(ds, new[] { 0 }).Single(); 530 505 var sdev = Math.Sqrt(model.GetEstimatedVariances(ds, new[] { 0 }).Single()); 531 506 507 // calculate the fitness goal 532 508 var goal = Maximization ? Population.Min(x => x.Fitness) : Population.Max(x => x.Fitness); 533 509 var z = (goal - mean) / sdev; 534 return Maximization ? 1.0 - Phi(z) /* P(X >= z) */ : Phi(z); // P(X <= z) 535 } 536 537 private double ProbabilityAccept3dModel(double a, double b, IConfidenceRegressionModel model) { 538 var ds = new Dataset(new[] { "in1", "in2", "out" }, new[] { new List<double> { a }, new List<double> { b }, new List<double> { double.NaN } }); 510 // return the probability of achieving or surpassing that goal 511 var y = alglib.invnormaldistribution(z); 512 return Maximization ? 1.0 - y /* P(X >= z) */ : y; // P(X <= z) 513 } 514 515 private double ProbabilityAcceptRelativePerformanceModel(double basePerformance, List<double> inputs, IConfidenceRegressionModel model) { 516 var inputVariables = inputs.Select((v, i) => "in" + i); 517 var ds = new Dataset(inputVariables.Concat(new[] { "out" }), inputs.Select(x => new List<double> { x }).Concat(new[] { new List<double> { double.NaN } })); 539 518 var mean = model.GetEstimatedValues(ds, new[] { 0 }).Single(); 540 519 var sdev = Math.Sqrt(model.GetEstimatedVariances(ds, new[] { 0 }).Single()); 541 520 542 var goal = Maximization ? Population.Min(x => x.Fitness) : Population.Max(x => x.Fitness); 521 // calculate the improvement goal 522 var goal = Maximization ? Population.Min(x => x.Fitness) - basePerformance : basePerformance - Population.Max(x => x.Fitness); 543 523 var z = (goal - mean) / sdev; 544 return Maximization ? 1.0 - Phi(z) /* P(X >= z) */ : Phi(z); // P(X <= z) 524 // return the probability of achieving or surpassing that goal 525 return 1.0 - alglib.invnormaldistribution(z); /* P(X >= z) */ 526 } 527 528 private static List<List<double>> ToListRow(List<Tuple<double, double>> rows) { 529 return rows.Select(x => new List<double> { x.Item1, x.Item2 }).ToList(); 530 } 531 private static List<List<double>> ToListRow(List<Tuple<double, double, double>> rows) { 532 return rows.Select(x => new List<double> { x.Item1, x.Item2, x.Item3 }).ToList(); 533 } 534 private static List<List<double>> ToListRow(List<Tuple<double, double, double, double>> rows) { 535 return rows.Select(x => new List<double> { x.Item1, x.Item2, x.Item3, x.Item4 }).ToList(); 545 536 } 546 537 … … 556 547 } 557 548 558 public void AddBreedingResult(ISingleObjectiveSolutionScope<TSolution> a, ISingleObjectiveSolutionScope<TSolution> b, ISingleObjectiveSolutionScope<TSolution> child) {549 public void AddBreedingResult(ISingleObjectiveSolutionScope<TSolution> a, ISingleObjectiveSolutionScope<TSolution> b, double parentDist, ISingleObjectiveSolutionScope<TSolution> child) { 559 550 if (IsBetter(a, b)) 560 BreedingStat.Add(Tuple.Create(a.Fitness, b.Fitness, child.Fitness)); 561 else BreedingStat.Add(Tuple.Create(b.Fitness, a.Fitness, child.Fitness)); 562 } 563 564 public void AddRelinkingResult(ISingleObjectiveSolutionScope<TSolution> a, ISingleObjectiveSolutionScope<TSolution> b, ISingleObjectiveSolutionScope<TSolution> child) { 551 breedingStat.Add(Tuple.Create(a.Fitness, b.Fitness, parentDist, child.Fitness)); 552 else breedingStat.Add(Tuple.Create(b.Fitness, a.Fitness, parentDist, child.Fitness)); 553 if (breedingStat.Count % 10 == 0) RelearnBreedingPerformanceModel(); 554 } 555 556 public void AddRelinkingResult(ISingleObjectiveSolutionScope<TSolution> a, ISingleObjectiveSolutionScope<TSolution> b, double parentDist, ISingleObjectiveSolutionScope<TSolution> child) { 565 557 if (IsBetter(a, b)) 566 RelinkingStat.Add(Tuple.Create(a.Fitness, b.Fitness, child.Fitness)); 567 else RelinkingStat.Add(Tuple.Create(b.Fitness, a.Fitness, child.Fitness)); 568 } 569 570 public void AddDelinkingResult(ISingleObjectiveSolutionScope<TSolution> a, ISingleObjectiveSolutionScope<TSolution> b, ISingleObjectiveSolutionScope<TSolution> child) { 558 relinkingStat.Add(Tuple.Create(a.Fitness, b.Fitness, parentDist, Maximization ? child.Fitness - a.Fitness : a.Fitness - child.Fitness)); 559 else relinkingStat.Add(Tuple.Create(a.Fitness, b.Fitness, parentDist, Maximization ? child.Fitness - b.Fitness : b.Fitness - child.Fitness)); 560 if (relinkingStat.Count % 10 == 0) RelearnRelinkingPerformanceModel(); 561 } 562 563 public void AddDelinkingResult(ISingleObjectiveSolutionScope<TSolution> a, ISingleObjectiveSolutionScope<TSolution> b, double parentDist, ISingleObjectiveSolutionScope<TSolution> child) { 571 564 if (IsBetter(a, b)) 572 DelinkingStat.Add(Tuple.Create(a.Fitness, b.Fitness, child.Fitness)); 573 else DelinkingStat.Add(Tuple.Create(b.Fitness, a.Fitness, child.Fitness)); 574 } 575 576 public void AddSamplingResult(ISingleObjectiveSolutionScope<TSolution> sample) { 577 SamplingStat.Add(Tuple.Create(Population.Average(x => x.Fitness), sample.Fitness)); 565 delinkingStat.Add(Tuple.Create(a.Fitness, b.Fitness, parentDist, Maximization ? child.Fitness - a.Fitness : a.Fitness - child.Fitness)); 566 else delinkingStat.Add(Tuple.Create(a.Fitness, b.Fitness, parentDist, Maximization ? child.Fitness - b.Fitness : b.Fitness - child.Fitness)); 567 if (delinkingStat.Count % 10 == 0) RelearnDelinkingPerformanceModel(); 568 } 569 570 public void AddSamplingResult(ISingleObjectiveSolutionScope<TSolution> sample, double avgDist) { 571 samplingStat.Add(Tuple.Create(avgDist, sample.Fitness)); 572 if (samplingStat.Count % 10 == 0) RelearnSamplingPerformanceModel(); 578 573 } 579 574 580 575 public void AddHillclimbingResult(ISingleObjectiveSolutionScope<TSolution> input, ISingleObjectiveSolutionScope<TSolution> outcome) { 581 HillclimbingStat.Add(Tuple.Create(input.Fitness, outcome.Fitness)); 582 } 583 584 public void AddTabuwalkingResult(ISingleObjectiveSolutionScope<TSolution> input, ISingleObjectiveSolutionScope<TSolution> outcome) { 585 AdaptivewalkingStat.Add(Tuple.Create(input.Fitness, outcome.Fitness)); 576 hillclimbingStat.Add(Tuple.Create(input.Fitness, Maximization ? outcome.Fitness - input.Fitness : input.Fitness - outcome.Fitness)); 577 if (hillclimbingStat.Count % 10 == 0) RelearnHillclimbingPerformanceModel(); 578 } 579 580 public void AddAdaptivewalkingResult(ISingleObjectiveSolutionScope<TSolution> input, ISingleObjectiveSolutionScope<TSolution> outcome) { 581 adaptivewalkingStat.Add(Tuple.Create(input.Fitness, outcome.Fitness)); 582 if (adaptivewalkingStat.Count % 10 == 0) RelearnAdaptiveWalkPerformanceModel(); 586 583 } 587 584 … … 609 606 // license: "This code is in the public domain. Do whatever you want with it, no strings attached." 610 607 // added: 2016-11-19 21:46 CET 611 protected static double Phi(double x) {608 /*protected static double Phi(double x) { 612 609 // constants 613 610 double a1 = 0.254829592; … … 629 626 630 627 return 0.5 * (1.0 + sign * y); 631 } 628 }*/ 632 629 #endregion 633 630
Note: See TracChangeset
for help on using the changeset viewer.