Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/26/15 09:30:43 (9 years ago)
Author:
abeham
Message:

#2521:

  • Adapted Knapsack problem to new problem infrastructure
  • Introduced additional interfaces in binary vector encoding
  • Improved KnapsackImprovementOperator which requires less evaluated solutions in case of an infeasible start solution

Loosely related change:

  • All LookupParameters are now shown by default
  • Wiring code should make sure that wired parameters are hidden
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ProblemRefactoring/HeuristicLab.Problems.Knapsack/3.3/Improvers/KnapsackImprovementOperator.cs

    r12012 r13404  
    125125      int evaluatedSolutions = 0;
    126126      int j = sol.Length - 1;
    127       while (KnapsackEvaluator.Apply(sol, KnapsackCapacity, Penalty, Weights, Values)
    128                               .SumWeights.Value > KnapsackCapacity.Value && j >= 0) {
     127      var totalWeight = 0.0;
     128      for (var i = 0; i < sol.Length; i++) {
     129        if (sol[i]) totalWeight += Weights[i];
     130      }
     131      evaluatedSolutions++;
     132
     133      while (totalWeight > KnapsackCapacity.Value && j >= 0) {
     134        totalWeight -= Weights[order[j]];
    129135        sol[order[j--]] = false;
    130         evaluatedSolutions++;
    131136      }
    132137
Note: See TracChangeset for help on using the changeset viewer.