Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/03/18 00:28:51 (6 years ago)
Author:
abeham
Message:

#1614:

  • fixed a bug in GRASP where solutions in the elite set would be mutated
  • introduced termination criteria when reaching best-known quality
  • tweaked generating random numbers in StochasticNMoveSingleMoveGenerator
  • changed DiscreteLocationCrossover to use an allele from one of the parents instead of introducing a mutation in case no feasible insert location is found
  • changed OSGA maxselpress to 500
  • slight change to contexts, introduced single-objectiveness much earlier in the class hierachy
    • limited ContextAlgorithm to SingleObjectiveBasicProblems (doesn't matter here)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/Crossovers/DiscreteLocationCrossover.cs

    r15564 r15572  
    8383      }
    8484
    85       var order = Enumerable.Range(0, takenEquip.Length).Shuffle(random); // avoid bias
     85      var order = Enumerable.Range(0, takenEquip.Length)
     86        .Where(x => !takenEquip[x])
     87        .Shuffle(random); // avoid bias
    8688      foreach (var e in order) {
    87         if (takenEquip[e]) continue;
    8889        var assigned = false;
    8990        // try 1: find a parent where equipment can be assigned feasibly
    90         foreach (var p in Enumerable.Range(0, parents.Length).Shuffle(random)) {
    91           if (slack[parents[p][e]] >= demands[e]) {
    92             child[e] = parents[p][e];
     91        var fallback = -1;
     92        var count = 1;
     93        foreach (var p in parents.Shuffle(random)) {
     94          if (slack[p[e]] >= demands[e]) {
     95            child[e] = p[e];
    9396            slack[child[e]] -= demands[e];
    9497            assigned = true;
    9598            break;
     99          } else if (random.NextDouble() < 1.0 / count) {
     100            fallback = p[e];
    96101          }
     102          count++;
    97103        }
    98104        // try 2: find a random feasible location
     
    103109            child[e] = loc;
    104110            slack[loc] -= demands[e];
    105             assigned = true;
     111          } else {
     112            // otherwise: fallback
     113            child[e] = fallback;
     114            slack[child[e]] -= demands[e];
    106115          }
    107         }
    108         // try 3: insert in a random location (no feasible insert found)
    109         if (!assigned) {
    110           child[e] = random.Next(locations);
    111           slack[child[e]] -= demands[e];
    112116        }
    113117      }
Note: See TracChangeset for help on using the changeset viewer.