Changeset 15704 for branches/1614_GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms
- Timestamp:
- 02/01/18 10:25:57 (7 years ago)
- Location:
- branches/1614_GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3
- Files:
-
- 2 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 } -
branches/1614_GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/Infrastructure/Algorithms/ContextAlgorithm.cs
r15703 r15704 193 193 elapsed += stopwatch.Elapsed; 194 194 stopwatch.Reset(); 195 firstHitGraph.Values[firstHitGraph.Values.Count - 1] = Tuple.Create(elapsed.TotalSeconds, Context.BestQuality); 195 if (firstHitGraph.Values.Count > 0) 196 firstHitGraph.Values[firstHitGraph.Values.Count - 1] = Tuple.Create(elapsed.TotalSeconds, Context.BestQuality); 196 197 base.OnPaused(); 197 198 } … … 201 202 elapsed += stopwatch.Elapsed; 202 203 stopwatch.Reset(); 203 firstHitGraph.Values[firstHitGraph.Values.Count - 1] = Tuple.Create(elapsed.TotalSeconds, Context.BestQuality); 204 if (firstHitGraph.Values.Count > 0) 205 firstHitGraph.Values[firstHitGraph.Values.Count - 1] = Tuple.Create(elapsed.TotalSeconds, Context.BestQuality); 204 206 } 205 207 // base call must be done last as the results will be cloned and a run is created
Note: See TracChangeset
for help on using the changeset viewer.