Advertisement
claukiller

Untitled

Apr 27th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. public class BranchAndBoundExt extends BranchAndBound {
  2. private ExtNode node;
  3.  
  4. public BranchAndBoundExt (int[] v, int n, int k, int c) {
  5. super();
  6. this.node = new ExtNode(v, n, k, c);
  7. node.calculateHeuristicValue();
  8. rootNode = this.vNode;
  9. branchAndBound(rootNode);
  10. }
  11. }
  12. ----------------------------------------
  13.  
  14. public class ExtNode extends Node {
  15. static int n;
  16. static int[] v;
  17. static int k; // how many items we choose
  18. static int c; // the quantity we want
  19. static boolean[] mark; //whether you get or not an element
  20. static int sum; //cumulative sum in a state
  21.  
  22. public ExtNode(int[] v, int n, int k, int c) {
  23. super();
  24. NumberVector.n = n;
  25. NumberVector.k = k;
  26. NumberVector.c = c;
  27. NumberVector.v = v;
  28.  
  29. mark = new boolean[n];
  30. sum = 0;
  31. }
  32.  
  33. @Override
  34. public boolean isSolution() {
  35. return depth == k && sum == c;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement