Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/14/19 22:33:44 (6 years ago)
Author:
abeham
Message:

#2521: reverted r14429

Location:
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Knapsack/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Knapsack/3.3/Analyzers/BestKnapsackSolutionAnalyzer.cs

    r14429 r16532  
    6060    }
    6161    public ILookupParameter<KnapsackSolution> BestSolutionParameter {
    62       get { return (ILookupParameter<KnapsackSolution>)Parameters["BestKnapsackSolution"]; }
     62      get { return (ILookupParameter<KnapsackSolution>)Parameters["BestSolution"]; }
    6363    }
    6464    public IValueLookupParameter<ResultCollection> ResultsParameter {
     
    8484
    8585      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the Knapsack solutions which should be visualized."));
    86       Parameters.Add(new LookupParameter<KnapsackSolution>("BestKnapsackSolution", "The best Knapsack solution."));
     86      Parameters.Add(new LookupParameter<KnapsackSolution>("BestSolution", "The best Knapsack solution."));
    8787      Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the knapsack solution should be stored."));
    8888      Parameters.Add(new LookupParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution."));
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Knapsack/3.3/KnapsackProblem.cs

    r14429 r16532  
    9191
    9292      InitializeRandomKnapsackInstance();
    93       Encoding.Length = Weights.Length;
    9493
    9594      InitializeOperators();
     
    9897
    9998    public override double Evaluate(BinaryVector solution, IRandom random) {
    100       var weights = Weights;
    101       var values = Values;
    10299      var totalWeight = 0.0;
    103100      var totalValue = 0.0;
    104101      for (var i = 0; i < solution.Length; i++) {
    105102        if (!solution[i]) continue;
    106         totalWeight += weights[i];
    107         totalValue += values[i];
     103        totalWeight += Weights[i];
     104        totalValue += Values[i];
    108105      }
    109106      return totalWeight > KnapsackCapacity ? KnapsackCapacity - totalWeight : totalValue;
     
    256253      var sysrand = new System.Random();
    257254
    258       var power = sysrand.Next(5, 11);
    259       var itemCount = (int)Math.Pow(2, power);
     255      var itemCount = sysrand.Next(10, 100);
    260256      Weights = new IntArray(itemCount);
    261257      Values = new IntArray(itemCount);
     
    264260
    265261      for (int i = 0; i < itemCount; i++) {
    266         var value = sysrand.Next(1, 30);
    267         var weight = sysrand.Next(1, 30);
     262        var value = sysrand.Next(1, 10);
     263        var weight = sysrand.Next(1, 10);
    268264
    269265        Values[i] = value;
     
    272268      }
    273269
    274       KnapsackCapacity = (int)Math.Round(0.5 * totalWeight);
     270      KnapsackCapacity = (int)Math.Round(0.7 * totalWeight);
    275271    }
    276272  }
Note: See TracChangeset for help on using the changeset viewer.