Changeset 15704 for branches/1614_GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/GRASP
- Timestamp:
- 02/01/18 10:25:57 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1614_GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/GRASP/GRASP.cs
r15700 r15704 170 170 IntegerVector pi_prime_vec = null; 171 171 try { 172 pi_prime_vec = GreedyRandomizedSolutionCreator.CreateSolution(Context.Random, Problem.ProblemInstance, 10 00, false, cancellationToken);172 pi_prime_vec = GreedyRandomizedSolutionCreator.CreateSolution(Context.Random, Problem.ProblemInstance, 10, true, cancellationToken); 173 173 } catch (OperationCanceledException) { break; } 174 174 … … 204 204 .OrderByDescending(x => similarities[x.Index]) // line 14 in Algorithm 1 205 205 .FirstOrDefault(); 206 if (replacement != null) { 206 if (replacement != null) { 207 207 Context.ReplaceAtPopulation(replacement.Index, Context.ToScope(pi_prime, fitness)); // line 14 in Algorithm 1 208 208 } … … 223 223 Context.BestQuality = fitness; 224 224 Context.BestSolution = (GQAPSolution)pi_prime.Clone(); 225 } 226 } else if (Context.PopulationCount == 0) { 227 // Book-keeping 228 // pi_prime_vec is not feasible, but no other feasible solution has been found so far 229 var eval = Problem.ProblemInstance.Evaluate(pi_prime_vec); 230 Context.EvaluatedSolutions++; 231 var fit = Problem.ProblemInstance.ToSingleObjective(eval); 232 if (double.IsNaN(Context.BestQuality) || fit < Context.BestQuality) { 233 Context.BestQuality = fit; 234 Context.BestSolution = new GQAPSolution(pi_prime_vec, eval); 225 235 } 226 236 }
Note: See TracChangeset
for help on using the changeset viewer.