Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/11/17 22:10:01 (5 years ago)
Author:
abeham
Message:

#1614:

  • Fixed bugs in view
  • Made Evaluation object immutable
  • Fixed bug in Analyze
  • Fixed operators
Location:
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3
Files:
2 edited

Legend:

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

    • Property svn:ignore
      •  

        old new  
         1*.user
        12Plugin.cs
         3bin
        24obj
        3 bin
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Evaluation/GQAPNMoveEvaluator.cs

    r15507 r15510  
    8585    public static Evaluation Evaluate(NMove move, IntegerVector assignment, Evaluation evaluation, GQAPInstance problemInstance) {
    8686      int moves = move.N;
    87       var newEvaluation = new Evaluation() {
    88         ExcessDemand = evaluation.ExcessDemand,
    89         FlowCosts = evaluation.FlowCosts,
    90         InstallationCosts = evaluation.InstallationCosts,
    91         Slack = evaluation.Slack.ToArray()
    92       };
     87      var excessDemand = evaluation.ExcessDemand;
     88      var flowCosts = evaluation.FlowCosts;
     89      var installationCosts = evaluation.InstallationCosts;
     90      var slack = evaluation.Slack.ToArray();
     91
    9392      foreach (var kvp in move.NewAssignments) {
    9493        int equip = kvp.Key;
     
    9695        int oldLoc = assignment[equip];
    9796        var equipDemand = problemInstance.Demands[equip];
    98         newEvaluation.InstallationCosts -= problemInstance.InstallationCosts[equip, oldLoc];
    99         newEvaluation.InstallationCosts += problemInstance.InstallationCosts[equip, newLoc];
     97        installationCosts -= problemInstance.InstallationCosts[equip, oldLoc];
     98        installationCosts += problemInstance.InstallationCosts[equip, newLoc];
    10099        for (int j = 0; j < assignment.Length; j++) {
    101100          if (!move.NewAssignments.ContainsKey(j)) {
    102             newEvaluation.FlowCosts += problemInstance.Weights[equip, j] * problemInstance.Distances[newLoc, assignment[j]];
    103             newEvaluation.FlowCosts -= problemInstance.Weights[equip, j] * problemInstance.Distances[oldLoc, assignment[j]];
    104             newEvaluation.FlowCosts += problemInstance.Weights[j, equip] * problemInstance.Distances[assignment[j], newLoc];
    105             newEvaluation.FlowCosts -= problemInstance.Weights[j, equip] * problemInstance.Distances[assignment[j], oldLoc];
     101            flowCosts += problemInstance.Weights[equip, j] * problemInstance.Distances[newLoc, assignment[j]];
     102            flowCosts -= problemInstance.Weights[equip, j] * problemInstance.Distances[oldLoc, assignment[j]];
     103            flowCosts += problemInstance.Weights[j, equip] * problemInstance.Distances[assignment[j], newLoc];
     104            flowCosts -= problemInstance.Weights[j, equip] * problemInstance.Distances[assignment[j], oldLoc];
    106105          } else {
    107             newEvaluation.FlowCosts += problemInstance.Weights[equip, j] * problemInstance.Distances[newLoc, move.NewAssignments[j]];
    108             newEvaluation.FlowCosts -= problemInstance.Weights[equip, j] * problemInstance.Distances[oldLoc, assignment[j]];
     106            flowCosts += problemInstance.Weights[equip, j] * problemInstance.Distances[newLoc, move.NewAssignments[j]];
     107            flowCosts -= problemInstance.Weights[equip, j] * problemInstance.Distances[oldLoc, assignment[j]];
    109108          }
    110109        }
    111         newEvaluation.Slack[oldLoc] += equipDemand;
    112         if (newEvaluation.Slack[oldLoc] < equipDemand)
    113           newEvaluation.ExcessDemand -= Math.Min(equipDemand, equipDemand - newEvaluation.Slack[oldLoc]);
    114         newEvaluation.Slack[newLoc] -= equipDemand;
    115         if (newEvaluation.Slack[newLoc] < 0)
    116           newEvaluation.ExcessDemand += Math.Min(equipDemand, -newEvaluation.Slack[newLoc]);
     110        slack[oldLoc] += equipDemand;
     111        if (slack[oldLoc] < equipDemand)
     112          excessDemand -= Math.Min(equipDemand, equipDemand - slack[oldLoc]);
     113        slack[newLoc] -= equipDemand;
     114        if (slack[newLoc] < 0)
     115          excessDemand += Math.Min(equipDemand, -slack[newLoc]);
    117116      }
    118117
    119       return newEvaluation;
     118      return new Evaluation(flowCosts, installationCosts, excessDemand, slack);
    120119    }
    121120
Note: See TracChangeset for help on using the changeset viewer.