Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/06/12 04:29:56 (12 years ago)
Author:
abeham
Message:

#1614: restructured architecture to allow for different evaluator with different penalty strategies

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/SolutionCreators/RandomButFeasibleSolutionCreator.cs

    r7813 r7970  
    3535  [Item("RandomButFeasibleSolutionCreator", "Creates a random, but feasible solution to the Generalized Quadratic Assignment Problem.")]
    3636  [StorableClass]
    37   public class RandomFeasibleSolutionCreator : GQAPStochasticSolutionCreator {
     37  public class RandomFeasibleSolutionCreator : GQAPStochasticSolutionCreator,
     38    IEvaluatorAwareGQAPOperator {
    3839
    3940    public IValueLookupParameter<IntValue> MaximumTriesParameter {
     
    4243    public IValueLookupParameter<BoolValue> CreateMostFeasibleSolutionParameter {
    4344      get { return (IValueLookupParameter<BoolValue>)Parameters["CreateMostFeasibleSolution"]; }
     45    }
     46    public IValueLookupParameter<IGQAPEvaluator> EvaluatorParameter {
     47      get { return (IValueLookupParameter<IGQAPEvaluator>)Parameters["Evaluator"]; }
    4448    }
    4549
     
    5155      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)));
    5256      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."));
    5358    }
    5459
     
    5762    }
    5863
    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) {
    6067      IntegerVector result = null;
    6168      bool isFeasible = false;
     
    8087          slack[assignment[equipment]] -= demands[equipment];
    8188        }
    82         double violation = GQAPEvaluator.EvaluateOverbooking(slack, capacities);
     89        double violation = evaluator.EvaluateOverbooking(slack, capacities);
    8390        isFeasible = violation == 0;
    8491        if (isFeasible || violation < minViolation) {
     
    9299    protected override IntegerVector CreateRandomSolution(IRandom random, DoubleArray demands, DoubleArray capacities) {
    93100      return CreateSolution(random, demands, capacities,
     101        EvaluatorParameter.ActualValue,
    94102        MaximumTriesParameter.ActualValue.Value,
    95103        CreateMostFeasibleSolutionParameter.ActualValue.Value,
Note: See TracChangeset for help on using the changeset viewer.