Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BranchAndBoundExt extends BranchAndBound {
- private ExtNode node;
- public BranchAndBoundExt (int[] v, int n, int k, int c) {
- super();
- this.node = new ExtNode(v, n, k, c);
- node.calculateHeuristicValue();
- rootNode = this.vNode;
- branchAndBound(rootNode);
- }
- }
- ----------------------------------------
- public class ExtNode extends Node {
- static int n;
- static int[] v;
- static int k; // how many items we choose
- static int c; // the quantity we want
- static boolean[] mark; //whether you get or not an element
- static int sum; //cumulative sum in a state
- public ExtNode(int[] v, int n, int k, int c) {
- super();
- NumberVector.n = n;
- NumberVector.k = k;
- NumberVector.c = c;
- NumberVector.v = v;
- mark = new boolean[n];
- sum = 0;
- }
- @Override
- public boolean isSolution() {
- return depth == k && sum == c;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement