Ignore:
Timestamp:
02/02/18 16:31:42 (22 months ago)
Author:
abeham
Message:

#1614:

  • added additional constraint to benchmark data generator and updated one instance that was affected by this
  • added fitness landscape characteristics for the GQAP
  • fixed RLD analysis view to compensate for empty convergence graphs
  • fixed CPLEX solvers not using the obj value when the solver terminates (callback is not called if proven optimal solution is found)
  • added code for local solver to also check on final quality
Location:
branches/1614_GeneralizedQAP/HeuristicLab.Analysis.FitnessLandscape/3.3/ProblemCharacteristicAnalysis/GQAP
Files:
1 added
1 copied

Legend:

Unmodified
Added
Removed
  • branches/1614_GeneralizedQAP/HeuristicLab.Analysis.FitnessLandscape/3.3/ProblemCharacteristicAnalysis/GQAP/GQAPCharacteristicCalculator.cs

    r15702 r15713  
    2020#endregion
    2121
     22using System;
     23using System.Collections.Generic;
     24using System.Linq;
    2225using HeuristicLab.Common;
    2326using HeuristicLab.Core;
     
    2528using HeuristicLab.Optimization;
    2629using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    27 using HeuristicLab.Problems.QuadraticAssignment;
    28 using System;
    29 using System.Collections.Generic;
    30 using System.Linq;
     30using HeuristicLab.Problems.GeneralizedQuadraticAssignment;
    3131
    3232namespace HeuristicLab.Analysis.FitnessLandscape {
    33   [Item("QAP Characteristic Calculator", "")]
     33  [Item("GQAP Characteristic Calculator", "")]
    3434  [StorableClass]
    35   public sealed class QAPCharacteristicCalculator : CharacteristicCalculator {
     35  public sealed class GQAPCharacteristicCalculator : CharacteristicCalculator {
    3636
    3737    [StorableConstructor]
    38     private QAPCharacteristicCalculator(bool deserializing) : base(deserializing) { }
    39     private QAPCharacteristicCalculator(QAPCharacteristicCalculator original, Cloner cloner) : base(original, cloner) { }
    40     public QAPCharacteristicCalculator() {
    41       characteristics.AddRange(new[] { "Dimension",
     38    private GQAPCharacteristicCalculator(bool deserializing) : base(deserializing) { }
     39    private GQAPCharacteristicCalculator(GQAPCharacteristicCalculator original, Cloner cloner) : base(original, cloner) { }
     40    public GQAPCharacteristicCalculator() {
     41      characteristics.AddRange(new[] {
     42        "Dimension", "MNRatio",
    4243        "FlowDominance", "DistanceDominance",
    43         "FlowAsymmetry", "DistanceAsymmetry",
    4444        "FlowSparsity", "DistanceSparsity",
    45         "FlowSkewness", "DistanceSkewness",
    46         "FlowDisparity", "DistanceDisparity" }.Select(x => new StringValue(x)).ToList());
     45        "DemandDominance", "CapacityDominance",
     46        "Utilization", "BasicFeasibility",
     47      }.Select(x => new StringValue(x)).ToList());
    4748    }
    4849
    4950    public override IDeepCloneable Clone(Cloner cloner) {
    50       return new QAPCharacteristicCalculator(this, cloner);
     51      return new GQAPCharacteristicCalculator(this, cloner);
    5152    }
    5253
    5354    public override bool CanCalculate() {
    54       return Problem is QuadraticAssignmentProblem;
     55      return Problem is GQAP;
    5556    }
    5657
    5758    public override IEnumerable<IResult> Calculate() {
    58       var qap = Problem as QuadraticAssignmentProblem;
    59       if (qap == null) throw new ArgumentException("Instance is not of type QuadraticAssignmentProblem");
     59      var gqap = Problem as GQAP;
     60      if (gqap == null) throw new ArgumentException("Instance is not of type GQAP");
     61      var inst = gqap.ProblemInstance;
    6062      foreach (var chara in characteristics.CheckedItems.Select(x => x.Value.Value)) {
    6163        if (chara == "Dimension")
    62           yield return new Result(chara, new IntValue(qap.Weights.Rows));
     64          yield return new Result(chara, new IntValue(inst.Demands.Length));
     65        if (chara == "MNRatio")
     66          yield return new Result(chara, new DoubleValue(inst.Capacities.Length / (double)inst.Demands.Length));
    6367        if (chara == "FlowDominance")
    64           yield return new Result(chara, new DoubleValue(DoubleMatrixCharacteristicCalculator.CoeffVariation(qap.Weights)));
     68          yield return new Result(chara, new DoubleValue(DoubleMatrixCharacteristicCalculator.CoeffVariation(inst.Weights)));
    6569        if (chara == "DistanceDominance")
    66           yield return new Result(chara, new DoubleValue(DoubleMatrixCharacteristicCalculator.CoeffVariation(qap.Distances)));
    67         if (chara == "FlowAsymmetry")
    68           yield return new Result(chara, new DoubleValue(DoubleMatrixCharacteristicCalculator.Asymmetry(qap.Weights)));
    69         if (chara == "DistanceAsymmetry")
    70           yield return new Result(chara, new DoubleValue(DoubleMatrixCharacteristicCalculator.Asymmetry(qap.Distances)));
     70          yield return new Result(chara, new DoubleValue(DoubleMatrixCharacteristicCalculator.CoeffVariation(inst.Distances)));
    7171        if (chara == "FlowSparsity")
    72           yield return new Result(chara, new DoubleValue(DoubleMatrixCharacteristicCalculator.Sparsity(qap.Weights)));
     72          yield return new Result(chara, new DoubleValue(DoubleMatrixCharacteristicCalculator.Sparsity(inst.Weights)));
    7373        if (chara == "DistanceSparsity")
    74           yield return new Result(chara, new DoubleValue(DoubleMatrixCharacteristicCalculator.Sparsity(qap.Distances)));
    75         if (chara == "FlowSkewness")
    76           yield return new Result(chara, new DoubleValue(DoubleMatrixCharacteristicCalculator.Skewness(qap.Weights)));
    77         if (chara == "DistanceSkewness")
    78           yield return new Result(chara, new DoubleValue(DoubleMatrixCharacteristicCalculator.Skewness(qap.Distances)));
    79         if (chara == "FlowDisparity")
    80           yield return new Result(chara, new DoubleValue(DoubleMatrixCharacteristicCalculator.Disparity(qap.Weights)));
    81         if (chara == "DistanceDisparity")
    82           yield return new Result(chara, new DoubleValue(DoubleMatrixCharacteristicCalculator.Disparity(qap.Distances)));
     74          yield return new Result(chara, new DoubleValue(DoubleMatrixCharacteristicCalculator.Sparsity(inst.Distances)));
     75        if (chara == "DemandDominance")
     76          yield return new Result(chara, new DoubleValue(inst.Demands.StandardDeviation() / inst.Demands.Average()));
     77        if (chara == "CapacityDominance")
     78          yield return new Result(chara, new DoubleValue(inst.Capacities.StandardDeviation() / inst.Capacities.Average()));
     79        if (chara == "Utilization")
     80          yield return new Result(chara, new DoubleValue(inst.Demands.Sum() / inst.Capacities.Sum()));
     81        if (chara == "BasicFeasibility")
     82          yield return new Result(chara, new DoubleValue(inst.Demands.Select(d => inst.Capacities.Count(c => d <= c)).Average() / inst.Capacities.Length));
    8383      }
    8484    }
Note: See TracChangeset for help on using the changeset viewer.