Free cookie consent management tool by TermsFeed Policy Generator

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

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

Location:
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Analyzers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Analyzers/BestGQAPSolutionAnalyzer.cs

    r7807 r7970  
    2929using HeuristicLab.Parameters;
    3030using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    31 using HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common;
    3231
    3332namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment {
     
    4039    IQualitiesAwareGQAPOperator, IDistancesAwareGQAPOperator, IWeightsAwareGQAPOperator, IInstallationCostsAwareGQAPOperator,
    4140    IDemandsAwareGQAPOperator, ICapacitiesAwareGQAPOperator, ITransportationCostsAwareGQAPOperator,
    42     IOverbookedCapacityPenaltyAwareGQAPOperator, IEquipmentNamesAwareGQAPOperator, ILocationNamesAwareGQAPOperator,
    43     IBestKnownQualityAwareGQAPOperator, IBestKnownSolutionAwareGQAPOperator, IAnalyzer {
     41    IExpectedRandomQualityAwareGQAPOperator, IEquipmentNamesAwareGQAPOperator, ILocationNamesAwareGQAPOperator,
     42    IBestKnownQualityAwareGQAPOperator, IBestKnownSolutionAwareGQAPOperator,
     43    IEvaluatorAwareGQAPOperator, IAnalyzer {
    4444
    4545    public bool EnabledByDefault {
     
    8484      get { return (IValueLookupParameter<DoubleValue>)Parameters["TransportationCosts"]; }
    8585    }
    86     public IValueLookupParameter<DoubleValue> OverbookedCapacityPenaltyParameter {
    87       get { return (IValueLookupParameter<DoubleValue>)Parameters["OverbookedCapacityPenalty"]; }
     86    public IValueLookupParameter<DoubleValue> ExpectedRandomQualityParameter {
     87      get { return (IValueLookupParameter<DoubleValue>)Parameters["ExpectedRandomQuality"]; }
    8888    }
    8989    public ILookupParameter<StringArray> EquipmentNamesParameter {
     
    104104    public IValueLookupParameter<ResultCollection> ResultsParameter {
    105105      get { return (IValueLookupParameter<ResultCollection>)Parameters["Results"]; }
     106    }
     107    public IValueLookupParameter<IGQAPEvaluator> EvaluatorParameter {
     108      get { return (IValueLookupParameter<IGQAPEvaluator>)Parameters["Evaluator"]; }
    106109    }
    107110    #endregion
     
    122125      Parameters.Add(new LookupParameter<DoubleArray>("Capacities", GeneralizedQuadraticAssignmentProblem.CapacitiesDescription));
    123126      Parameters.Add(new ValueLookupParameter<DoubleValue>("TransportationCosts", GeneralizedQuadraticAssignmentProblem.TransportationCostsDescription));
    124       Parameters.Add(new ValueLookupParameter<DoubleValue>("OverbookedCapacityPenalty", GeneralizedQuadraticAssignmentProblem.OverbookedCapacityPenaltyDescription));
     127      Parameters.Add(new ValueLookupParameter<DoubleValue>("ExpectedRandomQuality", GeneralizedQuadraticAssignmentProblem.ExpectedRandomQualityDescription));
    125128      Parameters.Add(new ScopeTreeLookupParameter<IntegerVector>("Assignment", GQAPSolutionCreator.AssignmentDescription));
    126129      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", GQAPEvaluator.QualityDescription));
     
    134137      Parameters.Add(new LookupParameter<GQAPAssignment>("BestSolution", "The best GQAP solution found so far."));
    135138      Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best GQAP solution should be stored."));
     139      Parameters.Add(new ValueLookupParameter<IGQAPEvaluator>("Evaluator", "The evaluator that is used to evaluate GQAP solutions."));
    136140    }
    137141
    138142    public override IOperation Apply() {
     143      var evaluator = EvaluatorParameter.ActualValue;
    139144      var assignments = AssignmentParameter.ActualValue;
    140145      var qualities = QualityParameter.ActualValue;
     
    150155      var capacities = CapacitiesParameter.ActualValue;
    151156      var transportationCosts = TransportationCostsParameter.ActualValue;
    152       var overbookedCapacityPenalty = OverbookedCapacityPenaltyParameter.ActualValue;
     157      var expectedRandomQuality = ExpectedRandomQualityParameter.ActualValue;
    153158      var results = ResultsParameter.ActualValue;
    154159      var maximization = MaximizationParameter.ActualValue.Value;
     
    162167      if (bestKnownQuality == null || HasSolutionImproved(bestKnownQuality.Value, qualities[bestIndex].Value, maximization)) {
    163168        BestKnownQualityParameter.ActualValue = new DoubleValue(qualities[bestIndex].Value);
    164         BestKnownSolutionParameter.ActualValue = new GQAPAssignment((IntegerVector)assignments[bestIndex].Clone(), (DoubleValue)qualities[bestIndex].Clone(), flowDistanceQualities[bestIndex], installationQualities[bestIndex], overbookedCapacities[bestIndex], equipmentNames, locationNames, distances, weights, installationCosts, demands, capacities, transportationCosts, overbookedCapacityPenalty);
     169        BestKnownSolutionParameter.ActualValue = new GQAPAssignment((IntegerVector)assignments[bestIndex].Clone(), (DoubleValue)qualities[bestIndex].Clone(), flowDistanceQualities[bestIndex], installationQualities[bestIndex], overbookedCapacities[bestIndex], equipmentNames, locationNames, distances, weights, installationCosts, demands, capacities, transportationCosts, expectedRandomQuality, evaluator);
    165170      }
    166171
    167172      var assignment = BestSolutionParameter.ActualValue;
    168173      if (assignment == null) {
    169         assignment = new GQAPAssignment((IntegerVector)assignments[bestIndex].Clone(), (DoubleValue)qualities[bestIndex].Clone(), flowDistanceQualities[bestIndex], installationQualities[bestIndex], overbookedCapacities[bestIndex], equipmentNames, locationNames, distances, weights, installationCosts, demands, capacities, transportationCosts, overbookedCapacityPenalty);
     174        assignment = new GQAPAssignment((IntegerVector)assignments[bestIndex].Clone(), (DoubleValue)qualities[bestIndex].Clone(), flowDistanceQualities[bestIndex], installationQualities[bestIndex], overbookedCapacities[bestIndex], equipmentNames, locationNames, distances, weights, installationCosts, demands, capacities, transportationCosts, expectedRandomQuality, evaluator);
    170175        assignment.Distances = distances;
    171176        BestSolutionParameter.ActualValue = assignment;
     
    185190          assignment.Capacities = capacities;
    186191          assignment.TransportationCosts = transportationCosts;
    187           assignment.OverbookedCapacityPenalty = overbookedCapacityPenalty;
     192          assignment.ExpectedRandomQuality = expectedRandomQuality;
     193          assignment.Evaluator = evaluator;
    188194        }
    189195      }
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Analyzers/GQAPSolutionArchiveAnalyzer.cs

    r7470 r7970  
    3939    IQualitiesAwareGQAPOperator, IDistancesAwareGQAPOperator, IWeightsAwareGQAPOperator, IInstallationCostsAwareGQAPOperator,
    4040    IDemandsAwareGQAPOperator, ICapacitiesAwareGQAPOperator, ITransportationCostsAwareGQAPOperator,
    41     IOverbookedCapacityPenaltyAwareGQAPOperator, IEquipmentNamesAwareGQAPOperator, ILocationNamesAwareGQAPOperator,
    42     IBestKnownSolutionsAwareGQAPOperator, IAnalyzer {
     41    IExpectedRandomQualityAwareGQAPOperator, IEquipmentNamesAwareGQAPOperator, ILocationNamesAwareGQAPOperator,
     42    IBestKnownSolutionsAwareGQAPOperator, IEvaluatorAwareGQAPOperator, IAnalyzer {
    4343
    4444    public bool EnabledByDefault {
     
    8282      get { return (IValueLookupParameter<DoubleValue>)Parameters["TransportationCosts"]; }
    8383    }
    84     public IValueLookupParameter<DoubleValue> OverbookedCapacityPenaltyParameter {
    85       get { return (IValueLookupParameter<DoubleValue>)Parameters["OverbookedCapacityPenalty"]; }
     84    public IValueLookupParameter<DoubleValue> ExpectedRandomQualityParameter {
     85      get { return (IValueLookupParameter<DoubleValue>)Parameters["ExpectedRandomQuality"]; }
    8686    }
    8787    public ILookupParameter<StringArray> EquipmentNamesParameter {
     
    9696    public ILookupParameter<GQAPAssignmentArchive> BestKnownSolutionsParameter {
    9797      get { return (ILookupParameter<GQAPAssignmentArchive>)Parameters["BestKnownSolutions"]; }
     98    }
     99    public IValueLookupParameter<IGQAPEvaluator> EvaluatorParameter {
     100      get { return (IValueLookupParameter<IGQAPEvaluator>)Parameters["Evaluator"]; }
    98101    }
    99102
     
    113116      Parameters.Add(new LookupParameter<DoubleArray>("Capacities", GeneralizedQuadraticAssignmentProblem.CapacitiesDescription));
    114117      Parameters.Add(new ValueLookupParameter<DoubleValue>("TransportationCosts", GeneralizedQuadraticAssignmentProblem.TransportationCostsDescription));
    115       Parameters.Add(new ValueLookupParameter<DoubleValue>("OverbookedCapacityPenalty", GeneralizedQuadraticAssignmentProblem.OverbookedCapacityPenaltyDescription));
     118      Parameters.Add(new ValueLookupParameter<DoubleValue>("ExpectedRandomQuality", GeneralizedQuadraticAssignmentProblem.ExpectedRandomQualityDescription));
    116119      Parameters.Add(new ScopeTreeLookupParameter<IntegerVector>("Assignment", GQAPSolutionCreator.AssignmentDescription));
    117120      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", GQAPEvaluator.QualityDescription));
     
    123126      Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best GQAP solution should be stored."));
    124127      Parameters.Add(new LookupParameter<GQAPAssignmentArchive>("BestKnownSolutions", GeneralizedQuadraticAssignmentProblem.BestKnownSolutionsDescription));
     128      Parameters.Add(new ValueLookupParameter<IGQAPEvaluator>("Evaluator", "The evaluator that is used to evaluate GQAP solutions."));
    125129    }
    126130
    127131    public override IOperation Apply() {
     132      var evaluator = EvaluatorParameter.ActualValue;
    128133      var assignments = AssignmentParameter.ActualValue;
    129134      var qualities = QualityParameter.ActualValue;
     
    139144      var capacities = CapacitiesParameter.ActualValue;
    140145      var transportationCosts = TransportationCostsParameter.ActualValue;
    141       var overbookedCapacityPenalty = OverbookedCapacityPenaltyParameter.ActualValue;
     146      var expectedRandomQuality = ExpectedRandomQualityParameter.ActualValue;
    142147      var results = ResultsParameter.ActualValue;
    143148      var maximization = MaximizationParameter.ActualValue.Value;
     
    145150      GQAPAssignmentArchive archive = results.ContainsKey("Solution Archive") ? results["Solution Archive"].Value as GQAPAssignmentArchive : null;
    146151      if (archive == null) {
    147         archive = new GQAPAssignmentArchive(equipmentNames, locationNames, distances, weights, installationCosts, demands, capacities, transportationCosts, overbookedCapacityPenalty);
     152        archive = new GQAPAssignmentArchive(equipmentNames, locationNames, distances, weights, installationCosts, demands, capacities, transportationCosts, expectedRandomQuality, evaluator);
    148153        results.Add(new Result("Solution Archive", archive));
    149154      } else {
     
    156161        archive.Capacities = capacities;
    157162        archive.TransportationCosts = transportationCosts;
    158         archive.OverbookedCapacityPenalty = overbookedCapacityPenalty;
     163        archive.ExpectedRandomQuality = expectedRandomQuality;
     164        archive.Evaluator = evaluator;
    159165      }
    160166
Note: See TracChangeset for help on using the changeset viewer.