Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/15/12 19:24:54 (12 years ago)
Author:
abeham
Message:

#1614

  • Added a button to recalculate the quality
File:
1 edited

Legend:

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

    r7470 r7471  
    175175      DistancesParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false;
    176176      InstallationCostsParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false;
     177      DemandsParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false;
     178      CapacitiesParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false;
    177179
    178180      Weights = new DoubleMatrix(5, 5);
     
    330332
    331333    private void EvaluateAndLoadAssignment(int[] vector) {
    332       var assignment = new IntegerVector(vector);
     334      EvaluateAndLoadAssignment(new IntegerVector(vector));
     335    }
     336    private void EvaluateAndLoadAssignment(IntegerVector assignment) {
     337      if (!IsConfigurationValid()) return;
    333338      double flowDistanceQuality, installationQuality, overbookedCapacity;
    334339      GQAPEvaluator.Evaluate(assignment, Weights, Distances, InstallationCosts, Demands, Capacities,
    335340        out flowDistanceQuality, out installationQuality, out overbookedCapacity);
    336341      double quality = GQAPEvaluator.GetCombinedQuality(flowDistanceQuality, installationQuality, overbookedCapacity, TransportationCosts.Value, OverbookedCapacityPenalty.Value);
    337       BestKnownSolution = new GQAPAssignment(assignment, new DoubleValue(quality),
     342      BestKnownSolution = new GQAPAssignment((IntegerVector)assignment.Clone(), new DoubleValue(quality),
    338343        new DoubleValue(flowDistanceQuality), new DoubleValue(installationQuality),
    339344        new DoubleValue(overbookedCapacity), EquipmentNames, LocationNames, Distances, Weights, InstallationCosts,
     
    341346      BestKnownQuality = new DoubleValue(quality);
    342347      BestKnownSolutions = new GQAPAssignmentArchive(EquipmentNames, LocationNames, Distances, Weights, InstallationCosts, Demands, Capacities, TransportationCosts, OverbookedCapacityPenalty);
    343       BestKnownSolutions.Solutions.Add(BestKnownSolution);
     348      BestKnownSolutions.Solutions.Add(new GQAPSolution((IntegerVector)assignment.Clone(), new DoubleValue(quality), new DoubleValue(flowDistanceQuality), new DoubleValue(installationQuality), new DoubleValue(overbookedCapacity)));
    344349    }
    345350
     
    480485    }
    481486    #endregion
     487
     488    private bool IsConfigurationValid() {
     489      return Weights != null && Distances != null && Demands != null && Capacities != null && InstallationCosts != null
     490        && Weights.Rows == Weights.Columns && Weights.Rows == InstallationCosts.Rows
     491        && Distances.Rows == Distances.Columns && Distances.Rows == InstallationCosts.Columns
     492        && Demands.Length == Weights.Rows && Capacities.Length == Distances.Rows;
     493    }
    482494  }
    483495}
Note: See TracChangeset for help on using the changeset viewer.