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
Files:
4 added
1 deleted
15 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
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Evaluators/GQAPEvaluator.cs

    r7593 r7970  
    3131
    3232namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment {
    33   [Item("GQAPEvaluator", "Evaluates solutions to the generalized quadratic assignment problem.")]
     33  [Item("GQAPEvaluator", "Base class for solution evaluators for the generalized quadratic assignment problem.")]
    3434  [StorableClass]
    35   public class GQAPEvaluator : SingleSuccessorOperator, IGQAPEvaluator,
     35  public abstract class GQAPEvaluator : SingleSuccessorOperator, IGQAPEvaluator,
    3636  IWeightsAwareGQAPOperator, IDistancesAwareGQAPOperator, IInstallationCostsAwareGQAPOperator,
    37   IDemandsAwareGQAPOperator, ICapacitiesAwareGQAPOperator, IAssignmentAwareGQAPOperator {
     37  IDemandsAwareGQAPOperator, ICapacitiesAwareGQAPOperator, IAssignmentAwareGQAPOperator,
     38  IExpectedRandomQualityAwareGQAPOperator {
    3839
    3940    #region Parameter Descriptions
     
    6263      get { return (IValueLookupParameter<DoubleValue>)Parameters["TransportationCosts"]; }
    6364    }
    64     public IValueLookupParameter<DoubleValue> OverbookedCapacityPenaltyParameter {
    65       get { return (IValueLookupParameter<DoubleValue>)Parameters["OverbookedCapacityPenalty"]; }
     65    public IValueLookupParameter<DoubleValue> ExpectedRandomQualityParameter {
     66      get { return (IValueLookupParameter<DoubleValue>)Parameters["ExpectedRandomQuality"]; }
    6667    }
    6768    public ILookupParameter<DoubleMatrix> WeightsParameter {
     
    8788    protected GQAPEvaluator(bool deserializing) : base(deserializing) { }
    8889    protected GQAPEvaluator(GQAPEvaluator original, Cloner cloner) : base(original, cloner) { }
    89     public GQAPEvaluator()
    90       : base() {
     90    public GQAPEvaluator() : base() {
    9191      Parameters.Add(new LookupParameter<BoolValue>("Maximization", GeneralizedQuadraticAssignmentProblem.MaximizationDescription));
    9292      Parameters.Add(new LookupParameter<DoubleValue>("Quality", QualityDescription));
     
    9595      Parameters.Add(new LookupParameter<DoubleValue>("OverbookedCapacity", OverbookedCapacityDescription));
    9696      Parameters.Add(new ValueLookupParameter<DoubleValue>("TransportationCosts", GeneralizedQuadraticAssignmentProblem.TransportationCostsDescription));
    97       Parameters.Add(new ValueLookupParameter<DoubleValue>("OverbookedCapacityPenalty", GeneralizedQuadraticAssignmentProblem.OverbookedCapacityPenaltyDescription));
     97      Parameters.Add(new ValueLookupParameter<DoubleValue>("ExpectedRandomQuality", GeneralizedQuadraticAssignmentProblem.ExpectedRandomQualityDescription));
    9898      Parameters.Add(new LookupParameter<DoubleMatrix>("Weights", GeneralizedQuadraticAssignmentProblem.WeightsDescription));
    9999      Parameters.Add(new LookupParameter<DoubleMatrix>("Distances", GeneralizedQuadraticAssignmentProblem.DistancesDescription));
     
    104104    }
    105105
    106     public override IDeepCloneable Clone(Cloner cloner) {
    107       return new GQAPEvaluator(this, cloner);
    108     }
    109 
    110     public static double Evaluate(IntegerVector assignment, DoubleMatrix weights, DoubleMatrix distances,
    111                                   DoubleMatrix installCosts, DoubleArray demands, DoubleArray capacities,
    112                                   DoubleValue transportationCosts, DoubleValue overbookedCapacityPenalty) {
     106    public virtual double Evaluate(IntegerVector assignment, DoubleMatrix weights,
     107      DoubleMatrix distances, DoubleMatrix installCosts, DoubleArray demands,
     108      DoubleArray capacities, double transportationCosts, double expectedRandomQuality) {
    113109      double flowDistanceQuality, installationQuality, overbookedCapacity;
    114110      Evaluate(assignment, weights, distances, installCosts, demands, capacities,
    115111        out flowDistanceQuality, out installationQuality, out overbookedCapacity);
    116       return GetCombinedQuality(flowDistanceQuality, installationQuality, overbookedCapacity,
    117         transportationCosts.Value, overbookedCapacityPenalty.Value);
     112      return GetFitness(flowDistanceQuality, installationQuality, overbookedCapacity,
     113        transportationCosts, expectedRandomQuality);
    118114    }
    119115
    120     public static void Evaluate(IntegerVector assignment, DoubleMatrix weights, DoubleMatrix distances,
    121                                 DoubleMatrix installCosts, DoubleArray demands, DoubleArray capacities,
    122                                 out double flowDistanceQuality, out double installationQuality, out double overbookedCapacity) {
     116    public virtual void Evaluate(IntegerVector assignment, DoubleMatrix weights, DoubleMatrix distances,
     117      DoubleMatrix installCosts, DoubleArray demands, DoubleArray capacities,
     118      out double flowDistanceQuality, out double installationQuality,
     119      out double overbookedCapacity) {
    123120      flowDistanceQuality = 0;
    124121      installationQuality = 0;
     
    135132    }
    136133
    137     public static double EvaluateOverbooking(DoubleArray slack, DoubleArray capacities) {
    138       return slack.Select((v, i) => new { V = v, Index = i }).Where(x => x.V < 0.0).Select(x => -x.V / capacities[x.Index]).Sum();
     134    public virtual double EvaluateOverbooking(DoubleArray slack, DoubleArray capacities) {
     135      return slack.Select((v, i) => new { V = v, Index = i }).Where(x => x.V < 0.0).Select(x => -100.0 * x.V / capacities[x.Index]).Sum();
    139136    }
    140137
    141     public static double GetCombinedQuality(double flowDistanceQuality, double installationQuality, double overbookedCapacity,
    142       double transportationCosts, double overbookedCapacityPenalty) {
    143       return installationQuality
    144         + transportationCosts * flowDistanceQuality
    145         + overbookedCapacityPenalty * overbookedCapacity;
    146     }
     138    public abstract double GetFitness(double flowDistanceQuality,
     139      double installationQuality, double overbookedCapacity,
     140      double transportationCosts, double expectedRandomQuality);
    147141
    148142    public override IOperation Apply() {
     
    154148      var capacities = CapacitiesParameter.ActualValue;
    155149      var transportCosts = TransportationCostsParameter.ActualValue.Value;
    156       double penalty = OverbookedCapacityPenaltyParameter.ActualValue.Value;
     150      var expectedRandomQuality = ExpectedRandomQualityParameter.ActualValue.Value;
    157151
    158152      if (weights.Rows != weights.Columns || distances.Rows != distances.Columns
     
    169163      OverbookedCapacityParameter.ActualValue = new DoubleValue(overbookedCapacity);
    170164
    171       QualityParameter.ActualValue = new DoubleValue(GetCombinedQuality(flowDistanceQuality, installationQuality, overbookedCapacity, transportCosts, penalty));
     165      QualityParameter.ActualValue = new DoubleValue(GetFitness(flowDistanceQuality, installationQuality, overbookedCapacity, transportCosts, expectedRandomQuality));
    172166      return base.Apply();
    173167    }
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Evaluators/GQAPNMoveEvaluator.cs

    r7505 r7970  
    2020#endregion
    2121
    22 using System.Linq;
    2322using HeuristicLab.Common;
    2423using HeuristicLab.Core;
     
    3534  public class GQAPNMoveEvaluator : SingleSuccessorOperator, IGQAPNMoveEvaluator, IAssignmentAwareGQAPOperator,
    3635  IQualityAwareGQAPOperator, ITransportationCostsAwareGQAPOperator,
    37   IOverbookedCapacityPenaltyAwareGQAPOperator, IWeightsAwareGQAPOperator, IDistancesAwareGQAPOperator,
    38   IInstallationCostsAwareGQAPOperator, IDemandsAwareGQAPOperator, ICapacitiesAwareGQAPOperator {
     36  IExpectedRandomQualityAwareGQAPOperator, IWeightsAwareGQAPOperator, IDistancesAwareGQAPOperator,
     37  IInstallationCostsAwareGQAPOperator, IDemandsAwareGQAPOperator, ICapacitiesAwareGQAPOperator,
     38  IEvaluatorAwareGQAPOperator {
    3939
    4040    #region Parameter Descriptions
     
    9494      get { return (IValueLookupParameter<DoubleValue>)Parameters["TransportationCosts"]; }
    9595    }
    96     public IValueLookupParameter<DoubleValue> OverbookedCapacityPenaltyParameter {
    97       get { return (IValueLookupParameter<DoubleValue>)Parameters["OverbookedCapacityPenalty"]; }
     96    public IValueLookupParameter<DoubleValue> ExpectedRandomQualityParameter {
     97      get { return (IValueLookupParameter<DoubleValue>)Parameters["ExpectedRandomQuality"]; }
    9898    }
    9999    public ILookupParameter<DoubleMatrix> WeightsParameter {
     
    111111    public ILookupParameter<DoubleArray> CapacitiesParameter {
    112112      get { return (ILookupParameter<DoubleArray>)Parameters["Capacities"]; }
     113    }
     114    public IValueLookupParameter<IGQAPEvaluator> EvaluatorParameter {
     115      get { return (IValueLookupParameter<IGQAPEvaluator>)Parameters["Evaluator"]; }
    113116    }
    114117    #endregion
     
    130133      Parameters.Add(new LookupParameter<DoubleValue>("MoveInstallationQuality", MoveInstallationQualityDescription));
    131134      Parameters.Add(new LookupParameter<DoubleValue>("MoveOverbookedCapacity", MoveOverbookedCapacityDescription));
    132       Parameters.Add(new ValueLookupParameter<DoubleValue>("OverbookedCapacityPenalty", GeneralizedQuadraticAssignmentProblem.OverbookedCapacityPenaltyDescription));
     135      Parameters.Add(new ValueLookupParameter<DoubleValue>("ExpectedRandomQuality", GeneralizedQuadraticAssignmentProblem.ExpectedRandomQualityDescription));
    133136      Parameters.Add(new ValueLookupParameter<DoubleValue>("TransportationCosts", GeneralizedQuadraticAssignmentProblem.TransportationCostsDescription));
    134137      Parameters.Add(new LookupParameter<DoubleMatrix>("Weights", GeneralizedQuadraticAssignmentProblem.WeightsDescription));
     
    137140      Parameters.Add(new LookupParameter<DoubleArray>("Demands", GeneralizedQuadraticAssignmentProblem.DemandsDescription));
    138141      Parameters.Add(new LookupParameter<DoubleArray>("Capacities", GeneralizedQuadraticAssignmentProblem.CapacitiesDescription));
     142      Parameters.Add(new ValueLookupParameter<IGQAPEvaluator>("Evaluator", "The evaluator that is used to evaluate GQAP solutions."));
    139143    }
    140144
     
    144148
    145149    public static double Evaluate(NMove move, IntegerVector assignment, DoubleMatrix weights, DoubleMatrix distances, DoubleMatrix installationCosts,
    146       DoubleArray demands, DoubleArray capacities, DoubleValue transportationCosts, DoubleValue overbookedCapacityPenalty) {
     150      DoubleArray demands, DoubleArray capacities, double transportationCosts, double expectedRandomQuality, IGQAPEvaluator evaluator) {
    147151      double moveFlowDistanceQuality, moveInstallationQuality, moveOverbookedCapacity;
    148       Evaluate(move, assignment, weights, distances, installationCosts, demands, capacities,
     152      Evaluate(move, assignment, weights, distances, installationCosts, demands, capacities, evaluator,
    149153        out moveFlowDistanceQuality, out moveInstallationQuality, out moveOverbookedCapacity);
    150       return GQAPEvaluator.GetCombinedQuality(moveFlowDistanceQuality, moveInstallationQuality, moveOverbookedCapacity,
    151         transportationCosts.Value, overbookedCapacityPenalty.Value);
     154      return evaluator.GetFitness(moveFlowDistanceQuality, moveInstallationQuality, moveOverbookedCapacity,
     155        transportationCosts, expectedRandomQuality);
    152156    }
    153157
    154158    public static void Evaluate(NMove move, IntegerVector assignment, DoubleMatrix weights, DoubleMatrix distances, DoubleMatrix installationCosts,
    155       DoubleArray demands, DoubleArray capacities, out double moveFlowDistanceQuality, out double moveInstallationQuality, out double moveOverbookedCapacity) {
     159      DoubleArray demands, DoubleArray capacities, IGQAPEvaluator evaluator, out double moveFlowDistanceQuality, out double moveInstallationQuality, out double moveOverbookedCapacity) {
    156160      moveFlowDistanceQuality = moveInstallationQuality = moveOverbookedCapacity = 0.0;
    157161      int moves = move.N;
     
    184188      }
    185189
    186       moveOverbookedCapacity = slack.Select((v, i) => new { V = v, Index = i }).Where(x => x.V < 0.0).Select(x => -x.V / capacities[x.Index]).Sum()
    187                                - oldSlack.Select((v, i) => new { V = v, Index = i }).Where(x => x.V < 0.0).Select(x => -x.V / capacities[x.Index]).Sum();
     190      moveOverbookedCapacity = evaluator.EvaluateOverbooking(slack, capacities) - evaluator.EvaluateOverbooking(oldSlack, capacities);
    188191    }
    189192
    190193    public override IOperation Apply() {
     194      var evaluator = EvaluatorParameter.ActualValue;
    191195      double moveFlowDistanceQuality, moveInstallationQuality, moveOverbookedCapacity;
    192196      double quality = QualityParameter.ActualValue.Value;
    193197      double transportationCosts = TransportationCostsParameter.ActualValue.Value;
    194       double overbookedCapacityPenalty = OverbookedCapacityPenaltyParameter.ActualValue.Value;
     198      double expectedRandomQuality = ExpectedRandomQualityParameter.ActualValue.Value;
    195199
    196200      double flowDistanceQuality = FlowDistanceQualityParameter.ActualValue.Value;
     
    203207               InstallationCostsParameter.ActualValue,
    204208               DemandsParameter.ActualValue, CapacitiesParameter.ActualValue,
     209               evaluator,
    205210               out moveFlowDistanceQuality, out moveInstallationQuality, out moveOverbookedCapacity);
    206211
     
    209214      MoveOverbookedCapacityParameter.ActualValue = new DoubleValue(overbookedCapacity + moveOverbookedCapacity);
    210215
    211       MoveQualityParameter.ActualValue = new DoubleValue(GQAPEvaluator.GetCombinedQuality(
     216      MoveQualityParameter.ActualValue = new DoubleValue(evaluator.GetFitness(
    212217        flowDistanceQuality + moveFlowDistanceQuality,
    213218        installationQuality + moveInstallationQuality,
    214219        overbookedCapacity + moveOverbookedCapacity,
    215         transportationCosts,
    216         overbookedCapacityPenalty));
     220        transportationCosts, expectedRandomQuality));
    217221      return base.Apply();
    218222    }
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/GQAPAssignment.cs

    r7470 r7970  
    176176
    177177    [Storable]
    178     private DoubleValue overbookedCapacityPenalty;
    179     public DoubleValue OverbookedCapacityPenalty {
    180       get { return overbookedCapacityPenalty; }
    181       set {
    182         bool changed = (overbookedCapacityPenalty != value);
    183         overbookedCapacityPenalty = value;
    184         if (changed) OnPropertyChanged("OverbookedCapacityPenalty");
     178    private DoubleValue expectedRandomQuality;
     179    public DoubleValue ExpectedRandomQuality {
     180      get { return expectedRandomQuality; }
     181      set {
     182        bool changed = (expectedRandomQuality != value);
     183        expectedRandomQuality = value;
     184        if (changed) OnPropertyChanged("ExpectedRandomQuality");
     185      }
     186    }
     187
     188    [Storable]
     189    private IGQAPEvaluator evaluator;
     190    public IGQAPEvaluator Evaluator {
     191      get { return evaluator; }
     192      set {
     193        bool changed = (evaluator != value);
     194        evaluator = value;
     195        if (changed) OnPropertyChanged("Evaluator");
    185196      }
    186197    }
     
    203214      capacities = cloner.Clone(original.capacities);
    204215      transportationCosts = cloner.Clone(original.transportationCosts);
    205       overbookedCapacityPenalty = cloner.Clone(original.overbookedCapacityPenalty);
    206     }
    207     public GQAPAssignment(IntegerVector assignment, DoubleValue quality, DoubleValue flowDistanceQuality, DoubleValue installationQuality, DoubleValue overbookedCapacity, StringArray equipmentNames, StringArray locationNames, DoubleMatrix distances, DoubleMatrix weights, DoubleMatrix installationCosts, DoubleArray demands, DoubleArray capacities, DoubleValue transportationCosts, DoubleValue overbookedCapacityPenalty)
     216      expectedRandomQuality = cloner.Clone(original.expectedRandomQuality);
     217      evaluator = cloner.Clone(original.evaluator);
     218    }
     219    public GQAPAssignment(IntegerVector assignment, DoubleValue quality, DoubleValue flowDistanceQuality, DoubleValue installationQuality, DoubleValue overbookedCapacity, StringArray equipmentNames, StringArray locationNames, DoubleMatrix distances, DoubleMatrix weights, DoubleMatrix installationCosts, DoubleArray demands, DoubleArray capacities, DoubleValue transportationCosts, DoubleValue expectedRandomQuality, IGQAPEvaluator evaluator)
    208220      : base() {
    209221      this.assignment = assignment;
     
    220232      this.capacities = capacities;
    221233      this.transportationCosts = transportationCosts;
    222       this.overbookedCapacityPenalty = overbookedCapacityPenalty;
     234      this.expectedRandomQuality = expectedRandomQuality;
     235      this.evaluator = evaluator;
    223236    }
    224237
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/GQAPAssignmentArchive.cs

    r7935 r7970  
    131131
    132132    [Storable]
    133     private DoubleValue overbookedCapacityPenalty;
    134     public DoubleValue OverbookedCapacityPenalty {
    135       get { return overbookedCapacityPenalty; }
     133    private DoubleValue expectedRandomQuality;
     134    public DoubleValue ExpectedRandomQuality {
     135      get { return expectedRandomQuality; }
    136136      set {
    137         bool changed = (overbookedCapacityPenalty != value);
    138         overbookedCapacityPenalty = value;
    139         if (changed) OnPropertyChanged("OverbookedCapacityPenalty");
     137        bool changed = (expectedRandomQuality != value);
     138        expectedRandomQuality = value;
     139        if (changed) OnPropertyChanged("ExpectedRandomQuality");
     140      }
     141    }
     142
     143    [Storable]
     144    private IGQAPEvaluator evaluator;
     145    public IGQAPEvaluator Evaluator {
     146      get { return evaluator; }
     147      set {
     148        bool changed = (evaluator != value);
     149        evaluator = value;
     150        if (changed) OnPropertyChanged("Evaluator");
    140151      }
    141152    }
     
    154165      capacities = cloner.Clone(original.capacities);
    155166      transportationCosts = cloner.Clone(original.transportationCosts);
    156       overbookedCapacityPenalty = cloner.Clone(original.overbookedCapacityPenalty);
     167      expectedRandomQuality = cloner.Clone(original.expectedRandomQuality);
     168      evaluator = cloner.Clone(original.evaluator);
    157169    }
    158170    public GQAPAssignmentArchive()
     
    160172      this.solutions = new ItemList<GQAPSolution>();
    161173    }
    162     public GQAPAssignmentArchive(StringArray equipmentNames, StringArray locationNames, DoubleMatrix distances, DoubleMatrix weights, DoubleMatrix installationCosts, DoubleArray demands, DoubleArray capacities, DoubleValue transportationCosts, DoubleValue overbookedCapacityPenalty)
     174    public GQAPAssignmentArchive(StringArray equipmentNames, StringArray locationNames, DoubleMatrix distances, DoubleMatrix weights, DoubleMatrix installationCosts, DoubleArray demands, DoubleArray capacities, DoubleValue transportationCosts, DoubleValue expectedRandomQuality, IGQAPEvaluator evaluator)
    163175      : this() {
    164176      this.distances = distances;
     
    168180      this.capacities = capacities;
    169181      this.transportationCosts = transportationCosts;
    170       this.overbookedCapacityPenalty = overbookedCapacityPenalty;
     182      this.expectedRandomQuality = expectedRandomQuality;
     183      this.evaluator = evaluator;
    171184    }
    172185
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/GeneralizedQuadraticAssignmentProblem.cs

    r7548 r7970  
    2323using System.Drawing;
    2424using System.Linq;
     25using HeuristicLab.Analysis.QualityAnalysis;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    3132using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3233using HeuristicLab.PluginInfrastructure;
    33 using HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common;
    3434using HeuristicLab.Problems.Instances;
    3535
     
    5959    public static readonly string CapacitiesDescription = "The capacities vector describes the available space at the locations.";
    6060    public static readonly string TransportationCostsDescription = "The transportation cost represents the flow-unit per distance-unit cost factor. This value can also be set to 1 if these costs are factored into the weights matrix already.";
    61     public static readonly string OverbookedCapacityPenaltyDescription = "The multiplier for the constraint violation when added to the quality.";
    6261    public static readonly string BestKnownQualityDescription = "The best known quality (if available).";
    6362    public static readonly string BestKnownSolutionDescription = "The best known solution (if available).";
     
    6564    public static readonly string EquipmentNamesDescription = "Optional: A list of names that describes the equipments.";
    6665    public static readonly string LocationNamesDescription = "Optional: A list of names that describes the locations.";
     66    public static readonly string ExpectedRandomQualityDescription = "The expected quality value of a random solution.";
    6767    #endregion
    6868
     
    8686      get { return (FixedValueParameter<DoubleValue>)Parameters["TransportationCosts"]; }
    8787    }
    88     public FixedValueParameter<DoubleValue> OverbookedCapacityPenaltyParameter {
    89       get { return (FixedValueParameter<DoubleValue>)Parameters["OverbookedCapacityPenalty"]; }
     88    public FixedValueParameter<DoubleValue> ExpectedRandomQualityParameter {
     89      get { return (FixedValueParameter<DoubleValue>)Parameters["ExpectedRandomQuality"]; }
    9090    }
    9191    public OptionalValueParameter<GQAPAssignment> BestKnownSolutionParameter {
     
    124124      set { CapacitiesParameter.Value = value; }
    125125    }
    126     public DoubleValue TransportationCosts {
    127       get { return TransportationCostsParameter.Value; }
    128       set { TransportationCostsParameter.Value = value; }
    129     }
    130     public DoubleValue OverbookedCapacityPenalty {
    131       get { return TransportationCostsParameter.Value; }
    132       set { TransportationCostsParameter.Value = value; }
     126    public double TransportationCosts {
     127      get { return TransportationCostsParameter.Value.Value; }
     128      set { TransportationCostsParameter.Value.Value = value; }
     129    }
     130    public double ExpectedRandomQuality {
     131      get { return ExpectedRandomQualityParameter.Value.Value; }
     132      set { ExpectedRandomQualityParameter.Value.Value = value; }
    133133    }
    134134    public StringArray EquipmentNames {
     
    164164    }
    165165    public GeneralizedQuadraticAssignmentProblem()
    166       : base(new GQAPEvaluator(), new RandomSolutionCreator()) {
     166      : base(new GQAPAdditivePenaltyEvaluator(), new RandomSolutionCreator()) {
    167167      Parameters.Add(new ValueParameter<DoubleMatrix>("Weights", WeightsDescription, new DoubleMatrix(), false));
    168168      Parameters.Add(new ValueParameter<DoubleMatrix>("Distances", DistancesDescription, new DoubleMatrix(), false));
    169169      Parameters.Add(new ValueParameter<DoubleMatrix>("InstallationCosts", InstallationCostsDescription, new DoubleMatrix(), false));
    170170      Parameters.Add(new FixedValueParameter<DoubleValue>("TransportationCosts", TransportationCostsDescription, new DoubleValue(1)));
    171       Parameters.Add(new FixedValueParameter<DoubleValue>("OverbookedCapacityPenalty", OverbookedCapacityPenaltyDescription, new DoubleValue(100000)));
     171      Parameters.Add(new FixedValueParameter<DoubleValue>("ExpectedRandomQuality", ExpectedRandomQualityDescription, new DoubleValue(0), true));
    172172      Parameters.Add(new ValueParameter<DoubleArray>("Demands", DemandsDescription, new DoubleArray(), false));
    173173      Parameters.Add(new ValueParameter<DoubleArray>("Capacities", CapacitiesDescription, new DoubleArray(), false));
     
    310310    public void Load(DoubleArray demands, DoubleArray capacities,
    311311      DoubleMatrix weights, DoubleMatrix distances, DoubleMatrix installationCosts,
    312       DoubleValue transportationCosts, DoubleValue overbookedCapacityPenalty = null) {
     312      DoubleValue transportationCosts) {
    313313      if (weights == null || weights.Rows == 0)
    314314        throw new System.IO.InvalidDataException(
     
    316316      if (weights.Rows != weights.Columns)
    317317        throw new System.IO.InvalidDataException(
    318 @"The weights matrix of the given instance contains an unequal number of rows
    319 and columns.");
     318@"The weights matrix of the given instance contains
     319an unequal number of rows and columns.");
    320320      Weights = weights;
    321321
     
    325325      if (distances.Rows != distances.Columns)
    326326        throw new System.IO.InvalidDataException(
    327 @"The distances matrix of the given instance contains an unequal number of rows
    328 and columns.");
     327@"The distances matrix of the given instance contains
     328an unequal number of rows and columns.");
    329329      Distances = distances;
    330330
     
    335335        || installationCosts.Columns != distances.Columns)
    336336        throw new System.IO.InvalidDataException(
    337 @"The installation costs matrix of the given instance contains different number
    338 of rows than given in the weights matrix and a different number of columns than
     337@"The installation costs matrix of the given instance
     338contains different number of rows than given in the
     339weights matrix and a different number of columns than
    339340given in the distances matrix.");
    340341      InstallationCosts = installationCosts;
     
    345346      if (capacities.Length != distances.Rows)
    346347        throw new System.IO.InvalidDataException(
    347 @"The given instance contains a different number of capacities than rows given in
    348 the distances matrix.");
     348@"The given instance contains a different number of
     349capacities than rows given in the distances matrix.");
    349350      Capacities = capacities;
    350351
     
    354355      if (demands.Length != weights.Rows)
    355356        throw new System.IO.InvalidDataException(
    356 @"The given instance contains a different number of demands than rows given in
    357 the weights matrix.");
     357@"The given instance contains a different number of
     358demands than rows given in the weights matrix.");
    358359      Demands = demands;
    359360
     
    361362        throw new System.IO.InvalidDataException(
    362363@"The given instance does not contain transportation costs.");
    363       TransportationCosts.Value = transportationCosts.Value;
    364 
    365       if (overbookedCapacityPenalty != null)
    366         OverbookedCapacityPenalty.Value = overbookedCapacityPenalty.Value;
     364      TransportationCosts = transportationCosts.Value;
    367365
    368366      BestKnownQuality = null;
    369367      BestKnownSolution = null;
    370368      BestKnownSolutions = null;
    371     }
    372 
     369      CalculateExpectedRandomQuality();
     370    }
     371
     372    private void CalculateExpectedRandomQuality() {
     373      if (IsConfigurationValid()) {
     374        double[] avgDistances = new double[Capacities.Length];
     375        for (int i = 0; i < Capacities.Length; i++) {
     376          for (int j = 0; j < Capacities.Length; j++)
     377            avgDistances[i] += Distances[i, j];
     378          avgDistances[i] /= Capacities.Length;
     379        }
     380        double[] avgWeight = new double[Demands.Length];
     381        for (int i = 0; i < Demands.Length; i++) {
     382          for (int j = 0; j < Demands.Length; j++)
     383            avgWeight[i] += Weights[i, j];
     384          avgWeight[i] /= Demands.Length;
     385        }
     386        double avgCosts = InstallationCosts.Average();
     387        double quality = 0;
     388        for (int i = 0; i < Demands.Length; i++) {
     389          double equipmentInfluence = 0;
     390          for (int j = 0; j < Capacities.Length; j++)
     391            equipmentInfluence += avgWeight[i] * avgDistances[j];
     392          quality += equipmentInfluence * Demands.Length / (double)Capacities.Length;
     393        }
     394        quality *= TransportationCosts;
     395        quality += avgCosts * Demands.Length;
     396
     397        ExpectedRandomQuality = quality;
     398      }
     399    }
    373400    private void EvaluateAndLoadAssignment(int[] vector) {
    374401      if (vector == null || vector.Length == 0) return;
     
    382409      }
    383410      double flowDistanceQuality, installationQuality, overbookedCapacity;
    384       GQAPEvaluator.Evaluate(assignment, Weights, Distances, InstallationCosts, Demands, Capacities,
     411      Evaluator.Evaluate(assignment, Weights, Distances, InstallationCosts, Demands, Capacities,
    385412        out flowDistanceQuality, out installationQuality, out overbookedCapacity);
    386       double quality = GQAPEvaluator.GetCombinedQuality(flowDistanceQuality, installationQuality, overbookedCapacity, TransportationCosts.Value, OverbookedCapacityPenalty.Value);
     413      double quality = Evaluator.GetFitness(flowDistanceQuality, installationQuality, overbookedCapacity, TransportationCosts, ExpectedRandomQuality);
    387414      BestKnownSolution = new GQAPAssignment((IntegerVector)assignment.Clone(), new DoubleValue(quality),
    388415        new DoubleValue(flowDistanceQuality), new DoubleValue(installationQuality),
    389416        new DoubleValue(overbookedCapacity), EquipmentNames, LocationNames, Distances, Weights, InstallationCosts,
    390         Demands, Capacities, TransportationCosts, OverbookedCapacityPenalty);
     417        Demands, Capacities, new DoubleValue(TransportationCosts), new DoubleValue(ExpectedRandomQuality), Evaluator);
    391418      BestKnownQuality = new DoubleValue(quality);
    392       BestKnownSolutions = new GQAPAssignmentArchive(EquipmentNames, LocationNames, Distances, Weights, InstallationCosts, Demands, Capacities, TransportationCosts, OverbookedCapacityPenalty);
     419      BestKnownSolutions = new GQAPAssignmentArchive(EquipmentNames, LocationNames, Distances, Weights, InstallationCosts, Demands, Capacities, new DoubleValue(TransportationCosts), new DoubleValue(ExpectedRandomQuality), Evaluator);
    393420      BestKnownSolutions.Solutions.Add(new GQAPSolution((IntegerVector)assignment.Clone(), new DoubleValue(quality), new DoubleValue(flowDistanceQuality), new DoubleValue(installationQuality), new DoubleValue(overbookedCapacity)));
    394421    }
     
    403430      base.OnEvaluatorChanged();
    404431      Parameterize();
     432      if (BestKnownSolution != null) EvaluateAndLoadAssignment(BestKnownSolution.Assignment);
    405433      Evaluator.QualityParameter.ActualNameChanged += new System.EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    406434    }
     
    436464      Operators.RemoveAll(x => x is ISingleObjectiveMoveEvaluator);
    437465      Operators.AddRange(ApplicationManager.Manager.GetInstances<IGQAPMoveEvaluator>());
     466      Operators.Add(new ScaledQualityDifferenceAnalyzer());
    438467      Parameterize();
    439468    }
     
    445474      foreach (var op in operators.OfType<IAssignmentAwareGQAPOperator>()) {
    446475        op.AssignmentParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
    447       }
    448       foreach (var op in operators.OfType<IAssignmentsAwareGQAPOperator>()) {
    449         op.AssignmentParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
     476        op.AssignmentParameter.Hidden = true;
    450477      }
    451478      foreach (var op in operators.OfType<IBestKnownQualityAwareGQAPOperator>()) {
    452479        op.BestKnownQualityParameter.ActualName = BestKnownQualityParameter.Name;
     480        op.BestKnownQualityParameter.Hidden = true;
    453481      }
    454482      foreach (var op in operators.OfType<IBestKnownSolutionAwareGQAPOperator>()) {
    455483        op.BestKnownSolutionParameter.ActualName = BestKnownSolutionParameter.Name;
     484        op.BestKnownSolutionParameter.Hidden = true;
    456485      }
    457486      foreach (var op in operators.OfType<IBestKnownSolutionsAwareGQAPOperator>()) {
    458487        op.BestKnownSolutionsParameter.ActualName = BestKnownSolutionsParameter.Name;
     488        op.BestKnownSolutionsParameter.Hidden = true;
    459489      }
    460490      foreach (var op in operators.OfType<ICapacitiesAwareGQAPOperator>()) {
    461491        op.CapacitiesParameter.ActualName = CapacitiesParameter.Name;
     492        op.CapacitiesParameter.Hidden = true;
    462493      }
    463494      foreach (var op in operators.OfType<IDemandsAwareGQAPOperator>()) {
    464495        op.DemandsParameter.ActualName = DemandsParameter.Name;
     496        op.DemandsParameter.Hidden = true;
    465497      }
    466498      foreach (var op in operators.OfType<IDistancesAwareGQAPOperator>()) {
    467499        op.DistancesParameter.ActualName = DistancesParameter.Name;
     500        op.DistancesParameter.Hidden = true;
    468501      }
    469502      foreach (var op in operators.OfType<IEquipmentNamesAwareGQAPOperator>()) {
    470503        op.EquipmentNamesParameter.ActualName = EquipmentNamesParameter.Name;
     504        op.EquipmentNamesParameter.Hidden = true;
    471505      }
    472506      foreach (var op in operators.OfType<IGQAPCrossover>()) {
    473507        op.ParentsParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
     508        op.ParentsParameter.Hidden = true;
    474509        op.ChildParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
     510        op.ChildParameter.Hidden = true;
    475511      }
    476512      foreach (var op in operators.OfType<IInstallationCostsAwareGQAPOperator>()) {
    477513        op.InstallationCostsParameter.ActualName = InstallationCostsParameter.Name;
     514        op.InstallationCostsParameter.Hidden = true;
    478515      }
    479516      foreach (var op in operators.OfType<ILocationNamesAwareGQAPOperator>()) {
    480517        op.LocationNamesParameter.ActualName = LocationNamesParameter.Name;
     518        op.LocationNamesParameter.Hidden = true;
    481519      }
    482520      var moveEvaluator = operators.OfType<IGQAPMoveEvaluator>().FirstOrDefault();
     
    484522        if (moveEvaluator != null) {
    485523          op.MoveQualityParameter.ActualName = moveEvaluator.MoveQualityParameter.ActualName;
     524          op.MoveQualityParameter.Hidden = true;
    486525          op.MoveFlowDistanceQualityParameter.ActualName = moveEvaluator.MoveFlowDistanceQualityParameter.ActualName;
     526          op.MoveFlowDistanceQualityParameter.Hidden = true;
    487527          op.MoveInstallationQualityParameter.ActualName = moveEvaluator.MoveInstallationQualityParameter.ActualName;
     528          op.MoveInstallationQualityParameter.Hidden = true;
    488529          op.MoveOverbookedCapacityParameter.ActualName = moveEvaluator.MoveOverbookedCapacityParameter.ActualName;
     530          op.MoveOverbookedCapacityParameter.Hidden = true;
    489531        }
    490532      }
     
    492534        if (moveEvaluator != null) {
    493535          op.MoveQualityParameter.ActualName = moveEvaluator.MoveQualityParameter.ActualName;
     536          op.MoveQualityParameter.Hidden = true;
    494537          op.MoveFlowDistanceQualityParameter.ActualName = moveEvaluator.MoveFlowDistanceQualityParameter.ActualName;
     538          op.MoveFlowDistanceQualityParameter.Hidden = true;
    495539          op.MoveInstallationQualityParameter.ActualName = moveEvaluator.MoveInstallationQualityParameter.ActualName;
     540          op.MoveInstallationQualityParameter.Hidden = true;
    496541          op.MoveOverbookedCapacityParameter.ActualName = moveEvaluator.MoveOverbookedCapacityParameter.ActualName;
     542          op.MoveOverbookedCapacityParameter.Hidden = true;
    497543        }
    498544        op.MaximizationParameter.ActualName = MaximizationParameter.Name;
    499       }
    500       foreach (var op in operators.OfType<IOverbookedCapacityPenaltyAwareGQAPOperator>()) {
    501         op.OverbookedCapacityPenaltyParameter.ActualName = OverbookedCapacityPenaltyParameter.Name;
     545        op.MaximizationParameter.Hidden = true;
     546      }
     547      foreach (var op in operators.OfType<IExpectedRandomQualityAwareGQAPOperator>()) {
     548        op.ExpectedRandomQualityParameter.ActualName = ExpectedRandomQualityParameter.Name;
     549        op.ExpectedRandomQualityParameter.Hidden = true;
    502550      }
    503551      foreach (var op in operators.OfType<IQualitiesAwareGQAPOperator>()) {
    504552        op.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
     553        op.QualityParameter.Hidden = true;
    505554        op.FlowDistanceQualityParameter.ActualName = Evaluator.FlowDistanceQualityParameter.ActualName;
     555        op.FlowDistanceQualityParameter.Hidden = true;
    506556        op.InstallationQualityParameter.ActualName = Evaluator.InstallationQualityParameter.ActualName;
     557        op.InstallationQualityParameter.Hidden = true;
    507558        op.OverbookedCapacityParameter.ActualName = Evaluator.OverbookedCapacityParameter.ActualName;
     559        op.OverbookedCapacityParameter.Hidden = true;
    508560        op.MaximizationParameter.ActualName = MaximizationParameter.Name;
     561        op.MaximizationParameter.Hidden = true;
    509562      }
    510563      foreach (var op in operators.OfType<IQualityAwareGQAPOperator>()) {
    511564        op.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
     565        op.QualityParameter.Hidden = true;
    512566        op.FlowDistanceQualityParameter.ActualName = Evaluator.FlowDistanceQualityParameter.ActualName;
     567        op.FlowDistanceQualityParameter.Hidden = true;
    513568        op.InstallationQualityParameter.ActualName = Evaluator.InstallationQualityParameter.ActualName;
     569        op.InstallationQualityParameter.Hidden = true;
    514570        op.OverbookedCapacityParameter.ActualName = Evaluator.OverbookedCapacityParameter.ActualName;
     571        op.OverbookedCapacityParameter.Hidden = true;
    515572        op.MaximizationParameter.ActualName = MaximizationParameter.Name;
     573        op.MaximizationParameter.Hidden = true;
    516574      }
    517575      foreach (var op in operators.OfType<ITransportationCostsAwareGQAPOperator>()) {
    518576        op.TransportationCostsParameter.ActualName = TransportationCostsParameter.Name;
     577        op.TransportationCostsParameter.Hidden = true;
    519578      }
    520579      foreach (var op in operators.OfType<IWeightsAwareGQAPOperator>()) {
    521580        op.WeightsParameter.ActualName = WeightsParameter.Name;
     581        op.WeightsParameter.Hidden = true;
     582      }
     583      foreach (var op in operators.OfType<IEvaluatorAwareGQAPOperator>()) {
     584        op.EvaluatorParameter.ActualName = EvaluatorParameter.Name;
     585        op.EvaluatorParameter.Hidden = true;
    522586      }
    523587
    524588      foreach (var op in operators.OfType<IIntegerVectorCrossover>()) {
    525589        op.ParentsParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
     590        op.ParentsParameter.Hidden = true;
    526591        op.ChildParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
     592        op.ChildParameter.Hidden = true;
    527593      }
    528594      foreach (var op in operators.OfType<IIntegerVectorManipulator>()) {
    529595        op.IntegerVectorParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
     596        op.IntegerVectorParameter.Hidden = true;
     597      }
     598
     599      foreach (var op in operators.OfType<ScaledQualityDifferenceAnalyzer>()) {
     600        op.MinimumQualityParameter.ActualName = BestKnownQualityParameter.Name;
     601        op.MinimumQualityParameter.Hidden = true;
     602        op.MaximumQualityParameter.ActualName = ExpectedRandomQualityParameter.Name;
     603        op.MaximumQualityParameter.Hidden = true;
     604        op.QualityParameter.ActualName = "BestQuality";
     605        op.QualityParameter.Hidden = true;
    530606      }
    531607    }
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/HeuristicLab.Problems.GeneralizedQuadraticAssignment-3.3.csproj

    r7813 r7970  
    105105    <Compile Include="Analyzers\GQAPPopulationDiversityAnalyzer.cs" />
    106106    <Compile Include="Analyzers\GQAPSolutionArchiveAnalyzer.cs" />
     107    <Compile Include="Evaluators\GQAPPenaltyLevelEvaluator.cs" />
     108    <Compile Include="Evaluators\GQAPEvaluator.cs" />
    107109    <Compile Include="Evaluators\GQAPNMoveEvaluator.cs" />
    108110    <Compile Include="GQAPAssignment.cs" />
     111    <Compile Include="Interfaces\IEvaluatorAwareGQAPOperator.cs" />
    109112    <Compile Include="Operators\Crossovers\CordeauCrossover.cs" />
    110113    <Compile Include="SolutionCreators\SlackMinimizationSolutionCreator.cs" />
     
    115118    <Compile Include="SolutionCreators\RandomSolutionCreator.cs" />
    116119    <None Include="Plugin.cs.frame" />
    117     <Compile Include="Evaluators\GQAPEvaluator.cs" />
     120    <Compile Include="Evaluators\GQAPAdditivePenaltyEvaluator.cs" />
    118121    <Compile Include="GeneralizedQuadraticAssignmentProblem.cs" />
    119122    <Compile Include="GQAPAssignmentArchive.cs" />
     
    130133    <Compile Include="Interfaces\IGQAPEvaluator.cs" />
    131134    <Compile Include="Interfaces\IQualityAwareGQAPOperator.cs" />
    132     <Compile Include="Interfaces\IOverbookedCapacityPenaltyAwareGQAPOperator.cs" />
     135    <Compile Include="Interfaces\IExpectedRandomQualityAwareGQAPOperator.cs" />
    133136    <Compile Include="Interfaces\ITransportationCostsAwareGQAPOperator.cs" />
    134137    <Compile Include="Interfaces\IInstallationCostsAwareGQAPOperator.cs" />
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Interfaces/IGQAPEvaluator.cs

    r7419 r7970  
    2222using HeuristicLab.Core;
    2323using HeuristicLab.Data;
     24using HeuristicLab.Encodings.IntegerVectorEncoding;
    2425using HeuristicLab.Optimization;
    2526
     
    3031    ILookupParameter<DoubleValue> InstallationQualityParameter { get; }
    3132    ILookupParameter<DoubleValue> OverbookedCapacityParameter { get; }
     33
     34    double Evaluate(IntegerVector assignment, DoubleMatrix weights, DoubleMatrix distances,
     35                    DoubleMatrix installCosts, DoubleArray demands, DoubleArray capacities,
     36                    double transportationCosts, double expectedRandomQuality);
     37
     38    void Evaluate(IntegerVector assignment, DoubleMatrix weights, DoubleMatrix distances,
     39                  DoubleMatrix installCosts, DoubleArray demands, DoubleArray capacities,
     40                  out double flowDistanceQuality, out double installationQuality,
     41                  out double overbookedCapacity);
     42
     43    double EvaluateOverbooking(DoubleArray slack, DoubleArray capacities);
     44
     45    double GetFitness(double flowDistanceQuality, double installationQuality,
     46                      double overbookedCapacity, double transportationCosts,
     47                      double expectedRandomQuality);
    3248  }
    3349}
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/Crossovers/CordeauCrossover.cs

    r7523 r7970  
    3434    IQualitiesAwareGQAPOperator, IWeightsAwareGQAPOperator, IDistancesAwareGQAPOperator, IInstallationCostsAwareGQAPOperator,
    3535    IDemandsAwareGQAPOperator, ICapacitiesAwareGQAPOperator, ITransportationCostsAwareGQAPOperator,
    36     IOverbookedCapacityPenaltyAwareGQAPOperator {
     36    IExpectedRandomQualityAwareGQAPOperator {
    3737
    3838    public ILookupParameter<BoolValue> MaximizationParameter {
     
    6969      get { return (IValueLookupParameter<DoubleValue>)Parameters["TransportationCosts"]; }
    7070    }
    71     public IValueLookupParameter<DoubleValue> OverbookedCapacityPenaltyParameter {
    72       get { return (IValueLookupParameter<DoubleValue>)Parameters["OverbookedCapacityPenalty"]; }
     71    public IValueLookupParameter<DoubleValue> ExpectedRandomQualityParameter {
     72      get { return (IValueLookupParameter<DoubleValue>)Parameters["ExpectedRandomQuality"]; }
     73    }
     74    public IValueLookupParameter<IGQAPEvaluator> EvaluatorParameter {
     75      get { return (IValueLookupParameter<IGQAPEvaluator>)Parameters["Evaluator"]; }
    7376    }
    7477
     
    9194      Parameters.Add(new LookupParameter<DoubleArray>("Capacities", GeneralizedQuadraticAssignmentProblem.CapacitiesDescription));
    9295      Parameters.Add(new ValueLookupParameter<DoubleValue>("TransportationCosts", GeneralizedQuadraticAssignmentProblem.TransportationCostsDescription));
    93       Parameters.Add(new ValueLookupParameter<DoubleValue>("OverbookedCapacityPenalty", GeneralizedQuadraticAssignmentProblem.OverbookedCapacityPenaltyDescription));
     96      Parameters.Add(new ValueLookupParameter<DoubleValue>("ExpectedRandomQuality", GeneralizedQuadraticAssignmentProblem.ExpectedRandomQualityDescription));
     97      Parameters.Add(new ValueLookupParameter<IGQAPEvaluator>("Evaluator", "The evaluator used to evaluate solutions."));
    9498    }
    9599
     
    103107      DoubleMatrix weights, DoubleMatrix distances, DoubleMatrix installationCosts,
    104108      DoubleArray demands, DoubleArray capacities,
    105       DoubleValue transportationCosts, DoubleValue overbookedCapacityPenalty) {
     109      double transportationCosts, double expectedRandomQuality, IGQAPEvaluator evaluator) {
    106110      var mediana = Inizialize(distances);
    107111      int m = capacities.Length;
     
    158162        }
    159163        if (!nofound) {
    160           double sonQual = GQAPEvaluator.Evaluate(son, weights, distances, installationCosts, demands, capacities, transportationCosts, overbookedCapacityPenalty);
     164          double sonQual = evaluator.Evaluate(son, weights, distances, installationCosts, demands, capacities, transportationCosts, expectedRandomQuality);
    161165          if (sonQual < fbest) {
    162166            fbest = sonQual;
     
    197201          onefound = true;
    198202        } else {
    199           double sonQual = GQAPEvaluator.Evaluate(son, weights, distances, installationCosts, demands, capacities, transportationCosts, overbookedCapacityPenalty);
     203          double sonQual = evaluator.Evaluate(son, weights, distances, installationCosts, demands, capacities, transportationCosts, expectedRandomQuality);
    200204          if (sonQual < fbest) {
    201205            fbest = sonQual;
     
    227231        WeightsParameter.ActualValue, DistancesParameter.ActualValue, InstallationCostsParameter.ActualValue,
    228232        DemandsParameter.ActualValue, CapacitiesParameter.ActualValue,
    229         TransportationCostsParameter.ActualValue, OverbookedCapacityPenaltyParameter.ActualValue);
     233        TransportationCostsParameter.ActualValue.Value, ExpectedRandomQualityParameter.ActualValue.Value,
     234        EvaluatorParameter.ActualValue);
    230235    }
    231236
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/Crossovers/GQAPPathRelinking.cs

    r7813 r7970  
    3737  public class GQAPPathRelinking : GQAPCrossover, IQualitiesAwareGQAPOperator, IDemandsAwareGQAPOperator, ICapacitiesAwareGQAPOperator,
    3838  IWeightsAwareGQAPOperator, IDistancesAwareGQAPOperator, IInstallationCostsAwareGQAPOperator, ITransportationCostsAwareGQAPOperator,
    39   IOverbookedCapacityPenaltyAwareGQAPOperator {
     39  IExpectedRandomQualityAwareGQAPOperator, IEvaluatorAwareGQAPOperator {
    4040
    4141    public ILookupParameter<BoolValue> MaximizationParameter {
     
    7272      get { return (IValueLookupParameter<DoubleValue>)Parameters["TransportationCosts"]; }
    7373    }
    74     public IValueLookupParameter<DoubleValue> OverbookedCapacityPenaltyParameter {
    75       get { return (IValueLookupParameter<DoubleValue>)Parameters["OverbookedCapacityPenalty"]; }
     74    public IValueLookupParameter<DoubleValue> ExpectedRandomQualityParameter {
     75      get { return (IValueLookupParameter<DoubleValue>)Parameters["ExpectedRandomQuality"]; }
     76    }
     77    public IValueLookupParameter<IGQAPEvaluator> EvaluatorParameter {
     78      get { return (IValueLookupParameter<IGQAPEvaluator>)Parameters["Evaluator"]; }
    7679    }
    7780
     
    9699      Parameters.Add(new LookupParameter<DoubleMatrix>("InstallationCosts", GeneralizedQuadraticAssignmentProblem.InstallationCostsDescription));
    97100      Parameters.Add(new ValueLookupParameter<DoubleValue>("TransportationCosts", GeneralizedQuadraticAssignmentProblem.TransportationCostsDescription));
    98       Parameters.Add(new ValueLookupParameter<DoubleValue>("OverbookedCapacityPenalty", GeneralizedQuadraticAssignmentProblem.OverbookedCapacityPenaltyDescription));
     101      Parameters.Add(new ValueLookupParameter<DoubleValue>("ExpectedRandomQuality", GeneralizedQuadraticAssignmentProblem.ExpectedRandomQualityDescription));
     102      Parameters.Add(new ValueLookupParameter<IGQAPEvaluator>("Evaluator", "The evaluator that is used to evaluate GQAP solutions."));
    99103      Parameters.Add(new ValueParameter<PercentValue>("CandidateSizeFactor", "(η) Determines the size of the set of feasible moves in each path-relinking step relative to the maximum size. A value of 50% means that only half of all possible moves are considered each step.", new PercentValue(0.5)));
    100104    }
     
    107111      ItemArray<DoubleValue> flowDistanceQualities, ItemArray<DoubleValue> installationQualities, ItemArray<DoubleValue> overbookedCapacities,
    108112      DoubleArray demands, DoubleArray capacities, DoubleMatrix weights, DoubleMatrix distances, DoubleMatrix installationCosts,
    109       DoubleValue transportationCosts, DoubleValue overbookedCapacityPenalty, DoubleValue candidateSizeFactor) {
     113      DoubleValue transportationCosts, DoubleValue expectedRandomQuality, DoubleValue candidateSizeFactor, IGQAPEvaluator evaluator) {
    110114      if (random == null) throw new ArgumentNullException("random", "No IRandom provider is given.");
    111115      if (parents == null || !parents.Any()) throw new ArgumentException("No parents given for path relinking.", "parents");
     
    145149
    146150          double currentFDQ, currentIQ, currentOC;
    147           GQAPEvaluator.Evaluate(pi2, weights, distances, installationCosts, demands, capacities,
     151          evaluator.Evaluate(pi2, weights, distances, installationCosts, demands, capacities,
    148152            out currentFDQ, out currentIQ, out currentOC);
    149153
    150154          if (currentOC <= 0.0) {
    151             var quality = GQAPEvaluator.GetCombinedQuality(currentFDQ, currentIQ, currentOC,
    152                 transportationCosts.Value, overbookedCapacityPenalty.Value);
     155            var quality = evaluator.GetFitness(currentFDQ, currentIQ, currentOC,
     156              transportationCosts.Value, expectedRandomQuality.Value);
    153157            var solution = new GQAPSolution(pi2, new DoubleValue(quality), new DoubleValue(currentFDQ),
    154158              new DoubleValue(currentIQ), new DoubleValue(currentOC));
     
    211215        CapacitiesParameter.ActualValue, WeightsParameter.ActualValue, DistancesParameter.ActualValue,
    212216        InstallationCostsParameter.ActualValue, TransportationCostsParameter.ActualValue,
    213         OverbookedCapacityPenaltyParameter.ActualValue, CandidateSizeFactorParameter.Value);
     217        ExpectedRandomQualityParameter.ActualValue, CandidateSizeFactorParameter.Value,
     218        EvaluatorParameter.ActualValue);
    214219    }
    215220
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/LocalImprovers/ApproximateLocalSearch.cs

    r7523 r7970  
    3737  public class ApproximateLocalSearch : SingleSuccessorOperator, IDemandsAwareGQAPOperator, ICapacitiesAwareGQAPOperator,
    3838    IWeightsAwareGQAPOperator, IDistancesAwareGQAPOperator, IInstallationCostsAwareGQAPOperator,
    39     ITransportationCostsAwareGQAPOperator, IOverbookedCapacityPenaltyAwareGQAPOperator,
    40     IAssignmentAwareGQAPOperator, IQualityAwareGQAPOperator, IGQAPLocalImprovementOperator, IStochasticOperator {
     39    ITransportationCostsAwareGQAPOperator, IExpectedRandomQualityAwareGQAPOperator,
     40    IAssignmentAwareGQAPOperator, IQualityAwareGQAPOperator, IGQAPLocalImprovementOperator,
     41    IEvaluatorAwareGQAPOperator, IStochasticOperator {
    4142    public IProblem Problem { get; set; }
    4243    public Type ProblemType {
     
    6263      get { return (IValueLookupParameter<DoubleValue>)Parameters["TransportationCosts"]; }
    6364    }
    64     public IValueLookupParameter<DoubleValue> OverbookedCapacityPenaltyParameter {
    65       get { return (IValueLookupParameter<DoubleValue>)Parameters["OverbookedCapacityPenalty"]; }
     65    public IValueLookupParameter<DoubleValue> ExpectedRandomQualityParameter {
     66      get { return (IValueLookupParameter<DoubleValue>)Parameters["ExpectedRandomQuality"]; }
    6667    }
    6768    public ILookupParameter<IntegerVector> AssignmentParameter {
     
    100101    public ILookupParameter<ResultCollection> ResultsParameter {
    101102      get { return (ILookupParameter<ResultCollection>)Parameters["Results"]; }
     103    }
     104    public IValueLookupParameter<IGQAPEvaluator> EvaluatorParameter {
     105      get { return (IValueLookupParameter<IGQAPEvaluator>)Parameters["Evaluator"]; }
    102106    }
    103107
     
    113117      Parameters.Add(new LookupParameter<DoubleMatrix>("InstallationCosts", GeneralizedQuadraticAssignmentProblem.InstallationCostsDescription));
    114118      Parameters.Add(new ValueLookupParameter<DoubleValue>("TransportationCosts", GeneralizedQuadraticAssignmentProblem.TransportationCostsDescription));
    115       Parameters.Add(new ValueLookupParameter<DoubleValue>("OverbookedCapacityPenalty", GeneralizedQuadraticAssignmentProblem.OverbookedCapacityPenaltyDescription));
     119      Parameters.Add(new ValueLookupParameter<DoubleValue>("ExpectedRandomQuality", GeneralizedQuadraticAssignmentProblem.ExpectedRandomQualityDescription));
    116120      Parameters.Add(new LookupParameter<IntegerVector>("Assignment", GQAPSolutionCreator.AssignmentDescription));
    117121      Parameters.Add(new LookupParameter<BoolValue>("Maximization", GeneralizedQuadraticAssignmentProblem.MaximizationDescription));
     
    126130      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)));
    127131      Parameters.Add(new LookupParameter<ResultCollection>("Results", "The result collection that stores the results."));
     132      Parameters.Add(new ValueLookupParameter<IGQAPEvaluator>("Evaluator", "The evaluator that is used to evaluate GQAP solutions."));
    128133    }
    129134
     
    157162      IntValue maxCLS, IntValue maximumIterations,
    158163      DoubleMatrix weights, DoubleMatrix distances, DoubleMatrix installationCosts, DoubleArray demands, DoubleArray capacities,
    159       DoubleValue transportationCosts, DoubleValue overbookedCapacityPenalty, PercentValue oneMoveProbability) {
     164      DoubleValue transportationCosts, DoubleValue expectedRandomQuality, PercentValue oneMoveProbability,
     165      IGQAPEvaluator evaluator) {
    160166
    161167      while (true) {
     
    171177          double moveFlowDistanceQuality, moveInstallationQuality, moveOverbookedCapacity;
    172178          GQAPNMoveEvaluator.Evaluate(move, assignment, weights, distances, installationCosts,
    173             demands, capacities, out moveFlowDistanceQuality, out moveInstallationQuality, out moveOverbookedCapacity);
    174           double moveQuality = GQAPEvaluator.GetCombinedQuality(moveFlowDistanceQuality, moveInstallationQuality, moveOverbookedCapacity,
    175             transportationCosts.Value, overbookedCapacityPenalty.Value);
     179            demands, capacities, evaluator, out moveFlowDistanceQuality, out moveInstallationQuality, out moveOverbookedCapacity);
     180          double moveQuality = evaluator.GetFitness(moveFlowDistanceQuality, moveInstallationQuality, moveOverbookedCapacity,
     181            transportationCosts.Value, expectedRandomQuality.Value);
    176182
    177183          if (moveOverbookedCapacity <= 0.0 && moveQuality < 0.0) {
     
    216222        DemandsParameter.ActualValue, CapacitiesParameter.ActualValue,
    217223        TransportationCostsParameter.ActualValue,
    218         OverbookedCapacityPenaltyParameter.ActualValue,
    219         OneMoveProbabilityParameter.ActualValue);
     224        ExpectedRandomQualityParameter.ActualValue,
     225        OneMoveProbabilityParameter.ActualValue,
     226        EvaluatorParameter.ActualValue);
    220227      return base.Apply();
    221228    }
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/SolutionCreators/GreedyRandomizedSolutionCreator.cs

    r7833 r7970  
    3535  [Item("GreedyRandomizedSolutionCreator", "Creates a solution according to the procedure described in Mateus, G., Resende, M., and Silva, R. 2011. GRASP with path-relinking for the generalized quadratic assignment problem. Journal of Heuristics 17, Springer Netherlands, pp. 527-565.")]
    3636  [StorableClass]
    37   public class GreedyRandomizedSolutionCreator : GQAPStochasticSolutionCreator {
     37  public class GreedyRandomizedSolutionCreator : 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
     
    5256      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)));
    5357      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)));
     58      Parameters.Add(new ValueLookupParameter<IGQAPEvaluator>("Evaluator", "The evaluator that is used to evaluate GQAP solutions."));
    5459    }
    5560
     
    5863    }
    5964
    60     public static IntegerVector CreateSolution(IRandom random, DoubleArray demands, DoubleArray capacities, int maximumTries, bool createMostFeasibleSolution, CancellationToken cancelToken) {
     65    public static IntegerVector CreateSolution(IRandom random, DoubleArray demands, DoubleArray capacities,
     66      IGQAPEvaluator evaluator,
     67      int maximumTries, bool createMostFeasibleSolution, CancellationToken cancelToken) {
    6168      int tries = 0;
    6269      var assignment = new Dictionary<int, int>(demands.Length);
     
    118125            slack[l] -= demands[f];
    119126          }
    120           double violation = GQAPEvaluator.EvaluateOverbooking(slack, capacities);
     127          double violation = evaluator.EvaluateOverbooking(slack, capacities);
    121128          if (violation < minViolation) {
    122129            bestAssignment = assignment;
     
    134141    protected override IntegerVector CreateRandomSolution(IRandom random, DoubleArray demands, DoubleArray capacities) {
    135142      return CreateSolution(random, demands, capacities,
     143        EvaluatorParameter.ActualValue,
    136144        MaximumTriesParameter.ActualValue.Value,
    137145        CreateMostFeasibleSolutionParameter.ActualValue.Value,
  • 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,
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/SolutionCreators/SlackMinimizationSolutionCreator.cs

    r7813 r7970  
    3535  [Item("SlackMinimizationSolutionCreator", "A heuristic that creates a solution to the Generalized Quadratic Assignment Problem by minimizing the amount of slack.")]
    3636  [StorableClass]
    37   public class SlackMinimizationSolutionCreator : GQAPStochasticSolutionCreator {
     37  public class SlackMinimizationSolutionCreator : GQAPStochasticSolutionCreator,
     38    IEvaluatorAwareGQAPOperator {
    3839
    3940    public IValueLookupParameter<IntValue> MaximumTriesParameter {
     
    4950      get { return (IValueLookupParameter<IntValue>)Parameters["RandomWalkLength"]; }
    5051    }
     52    public IValueLookupParameter<IGQAPEvaluator> EvaluatorParameter {
     53      get { return (IValueLookupParameter<IGQAPEvaluator>)Parameters["Evaluator"]; }
     54    }
    5155
    5256    [StorableConstructor]
     
    5963      Parameters.Add(new ValueLookupParameter<IntValue>("Depth", "How deep the algorithm should look forward.", new IntValue(3)));
    6064      Parameters.Add(new ValueLookupParameter<IntValue>("RandomWalkLength", "The length of the random walk in the feasible region that is used to diversify the found assignments.", new IntValue(10)));
     65      Parameters.Add(new ValueLookupParameter<IGQAPEvaluator>("Evaluator", "The evaluator that is used to evaluate GQAP solutions."));
    6166    }
    6267
     
    7580    }
    7681
    77     public static IntegerVector CreateSolution(IRandom random, DoubleArray demands, DoubleArray capacities, int depth, int maximumTries, bool createMostFeasibleSolution, int randomWalkLength, CancellationToken cancel) {
     82    public static IntegerVector CreateSolution(IRandom random, DoubleArray demands,
     83      DoubleArray capacities, IGQAPEvaluator evaluator,
     84      int depth, int maximumTries, bool createMostFeasibleSolution, int randomWalkLength, CancellationToken cancel) {
    7885      IntegerVector result = null;
    7986      bool isFeasible = false;
     
    118125          }
    119126        } else RandomFeasibleWalk(random, assignment, demands, slack, randomWalkLength);
    120         double violation = GQAPEvaluator.EvaluateOverbooking(slack, capacities);
     127        double violation = evaluator.EvaluateOverbooking(slack, capacities);
    121128        isFeasible = violation == 0;
    122129        if (isFeasible || violation < minViolation) {
     
    177184    protected override IntegerVector CreateRandomSolution(IRandom random, DoubleArray demands, DoubleArray capacities) {
    178185      return CreateSolution(random, demands, capacities,
     186        EvaluatorParameter.ActualValue,
    179187        DepthParameter.ActualValue.Value,
    180188        MaximumTriesParameter.ActualValue.Value,
Note: See TracChangeset for help on using the changeset viewer.