Changeset 15558 for branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/LocalImprovers
- Timestamp:
- 12/22/17 01:32:13 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/LocalImprovers/ApproximateLocalSearch.cs
r15555 r15558 76 76 get { return (ILookupParameter<ResultCollection>)Parameters["Results"]; } 77 77 } 78 public IValueLookupParameter<BoolValue> GreedyParameter { 79 get { return (IValueLookupParameter<BoolValue>)Parameters["Greedy"]; } 80 } 78 81 79 82 [StorableConstructor] … … 92 95 Parameters.Add(new ValueLookupParameter<PercentValue>("OneMoveProbability", "The probability for performing a 1-move, which is the opposite of performing a 2-move.", new PercentValue(.5))); 93 96 Parameters.Add(new LookupParameter<ResultCollection>("Results", "The result collection that stores the results.")); 97 Parameters.Add(new ValueLookupParameter<BoolValue>("Greedy", "Whether to use a greedy selection strategy or a probabilistic one.", new BoolValue(true))); 94 98 } 95 99 … … 100 104 public static void Apply(IRandom random, GQAPSolution sol, int maxCLS, 101 105 double oneMoveProbability, int maximumIterations, 102 GQAPInstance problemInstance, out int evaluatedSolutions ) {106 GQAPInstance problemInstance, out int evaluatedSolutions, bool greedy = true) { 103 107 var fit = problemInstance.ToSingleObjective(sol.Evaluation); 104 108 var eval = sol.Evaluation; 105 109 Apply(random, sol.Assignment, ref fit, ref eval, maxCLS, oneMoveProbability, maximumIterations, problemInstance, 106 out evaluatedSolutions );110 out evaluatedSolutions, greedy); 107 111 sol.Evaluation = eval; 108 112 } 109 113 110 /// <summary> 111 /// </summary> 112 /// <param name="random">The random number generator to use.</param> 113 /// <param name="assignment">The equipment-location assignment vector.</param> 114 /// <param name="quality">The solution quality.</param> 115 /// <param name="evaluation">The evaluation result of the solution.</param> 116 /// <param name="maxCLS">The maximum number of candidates that should be found in each step.</param> 117 /// <param name="oneMoveProbability">The probability for performing a 1-move, which is the opposite of performing a 2-move.</param> 118 /// <param name="maximumIterations">The maximum number of iterations that should be performed each time the candidate list is generated.</param> 119 /// <param name="problemInstance">The problem instance that contains the data.</param> 120 /// <param name="evaluatedSolutions">The number of evaluated solutions.</param> 121 public static void Apply(IRandom random, IntegerVector assignment, 114 /// <summary> 115 /// </summary> 116 /// <param name="random">The random number generator to use.</param> 117 /// <param name="assignment">The equipment-location assignment vector.</param> 118 /// <param name="quality">The solution quality.</param> 119 /// <param name="evaluation">The evaluation result of the solution.</param> 120 /// <param name="maxCLS">The maximum number of candidates that should be found in each step.</param> 121 /// <param name="oneMoveProbability">The probability for performing a 1-move, which is the opposite of performing a 2-move.</param> 122 /// <param name="maximumIterations">The maximum number of iterations that should be performed each time the candidate list is generated.</param> 123 /// <param name="problemInstance">The problem instance that contains the data.</param> 124 /// <param name="evaluatedSolutions">The number of evaluated solutions.</param> 125 /// <param name="greedy">Greedy selection performed better in 5 of 8 instances according to the paper</param> 126 public static void Apply(IRandom random, IntegerVector assignment, 122 127 ref double quality, ref Evaluation evaluation, int maxCLS, 123 128 double oneMoveProbability, int maximumIterations, 124 GQAPInstance problemInstance, out int evaluatedSolutions ) {129 GQAPInstance problemInstance, out int evaluatedSolutions, bool greedy = true) { 125 130 evaluatedSolutions = 0; 126 131 var capacities = problemInstance.Capacities; … … 128 133 var evaluations = 0.0; 129 134 var deltaEvaluationFactor = 1.0 / assignment.Length; 130 var greedy = true; // greedy selection performed better in 5 of 8 instances according to the paper131 135 while (true) { // line 1 of Algorithm 3 132 136 var count = 0; // line 2 of Algorithm 3 … … 183 187 MaximumIterationsParameter.ActualValue.Value, 184 188 ProblemInstanceParameter.ActualValue, 185 out evaluatedSolutions); 189 out evaluatedSolutions, 190 GreedyParameter.ActualValue.Value); 186 191 187 192 EvaluationParameter.ActualValue = evaluation;
Note: See TracChangeset
for help on using the changeset viewer.