Changeset 7970 for branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/SolutionCreators/RandomButFeasibleSolutionCreator.cs
- Timestamp:
- 06/06/12 04:29:56 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/SolutionCreators/RandomButFeasibleSolutionCreator.cs
r7813 r7970 35 35 [Item("RandomButFeasibleSolutionCreator", "Creates a random, but feasible solution to the Generalized Quadratic Assignment Problem.")] 36 36 [StorableClass] 37 public class RandomFeasibleSolutionCreator : GQAPStochasticSolutionCreator { 37 public class RandomFeasibleSolutionCreator : GQAPStochasticSolutionCreator, 38 IEvaluatorAwareGQAPOperator { 38 39 39 40 public IValueLookupParameter<IntValue> MaximumTriesParameter { … … 42 43 public IValueLookupParameter<BoolValue> CreateMostFeasibleSolutionParameter { 43 44 get { return (IValueLookupParameter<BoolValue>)Parameters["CreateMostFeasibleSolution"]; } 45 } 46 public IValueLookupParameter<IGQAPEvaluator> EvaluatorParameter { 47 get { return (IValueLookupParameter<IGQAPEvaluator>)Parameters["Evaluator"]; } 44 48 } 45 49 … … 51 55 Parameters.Add(new ValueLookupParameter<IntValue>("MaximumTries", "The maximum number of tries to create a feasible solution after which an exception is thrown. If it is set to 0 or a negative value there will be an infinite number of attempts.", new IntValue(100000))); 52 56 Parameters.Add(new ValueLookupParameter<BoolValue>("CreateMostFeasibleSolution", "If this is set to true the operator will always succeed, and outputs the solution with the least violation instead of throwing an exception.", new BoolValue(false))); 57 Parameters.Add(new ValueLookupParameter<IGQAPEvaluator>("Evaluator", "The evaluator that is used to evaluate GQAP solutions.")); 53 58 } 54 59 … … 57 62 } 58 63 59 public static IntegerVector CreateSolution(IRandom random, DoubleArray demands, DoubleArray capacities, int maximumTries, bool createMostFeasibleSolution, CancellationToken cancel) { 64 public static IntegerVector CreateSolution(IRandom random, DoubleArray demands, 65 DoubleArray capacities, IGQAPEvaluator evaluator, 66 int maximumTries, bool createMostFeasibleSolution, CancellationToken cancel) { 60 67 IntegerVector result = null; 61 68 bool isFeasible = false; … … 80 87 slack[assignment[equipment]] -= demands[equipment]; 81 88 } 82 double violation = GQAPEvaluator.EvaluateOverbooking(slack, capacities);89 double violation = evaluator.EvaluateOverbooking(slack, capacities); 83 90 isFeasible = violation == 0; 84 91 if (isFeasible || violation < minViolation) { … … 92 99 protected override IntegerVector CreateRandomSolution(IRandom random, DoubleArray demands, DoubleArray capacities) { 93 100 return CreateSolution(random, demands, capacities, 101 EvaluatorParameter.ActualValue, 94 102 MaximumTriesParameter.ActualValue.Value, 95 103 CreateMostFeasibleSolutionParameter.ActualValue.Value,
Note: See TracChangeset
for help on using the changeset viewer.