Package java.util

Examples of java.util.BitSet.cardinality()


                    return ESat.FALSE;
                }
                visited.set(x);
                x = vars[x].getValue() - offset;
            } while (x != first);
            if (visited.cardinality() != n) {
                return ESat.FALSE;
            }
            return ESat.TRUE;
        } else {
            return ESat.UNDEFINED;
View Full Code Here


        // on bouche jusqu'a la limite pour creer les contraintes 1
        while (nbPrec > 0) {
            //Pair p = precs.get(rand.nextInt(precs.size()));
            int ij = precs.nextSetBit(0);
            int index = rand.nextInt(precs.cardinality());
            while (index > 0) {
                ij = precs.nextSetBit(ij + 1);
                index--;
            }
            assert (ij > -1);
View Full Code Here

        }

        // on bouche jusqu'a la limite pour creer les contraintes 2
        BitSet neqs = new BitSet();
        neqs.or(precs);
        while (nbNeq > 0 && neqs.cardinality() > 0) {
            int ij = neqs.nextSetBit(0);
            int index = rand.nextInt(neqs.cardinality());
            while (index > 0) {
                ij = neqs.nextSetBit(ij + 1);
                index--;
View Full Code Here

        // on bouche jusqu'a la limite pour creer les contraintes 2
        BitSet neqs = new BitSet();
        neqs.or(precs);
        while (nbNeq > 0 && neqs.cardinality() > 0) {
            int ij = neqs.nextSetBit(0);
            int index = rand.nextInt(neqs.cardinality());
            while (index > 0) {
                ij = neqs.nextSetBit(ij + 1);
                index--;
            }
            assert (ij > -1);
View Full Code Here

            }
        }

        for (int i = 0; i < alldiffLayers.length; i++) {
            BitSet disjoint = alldiffLayers[i];
            IntVar[] tvars = new IntVar[disjoint.cardinality()];
            for (int k = 0, j = disjoint.nextSetBit(0); j >= 0; j = disjoint.nextSetBit(j + 1), k++) {
                tvars[k] = vars[j];
            }
            solver.post(IntConstraintFactory.alldifferent(tvars, "BC"));
        }
View Full Code Here

        allDiffLayers = new BitSet[nbAd];
        BitSet activeLayers = new BitSet(nbC);
        activeLayers.set(1, nbC - 1, true);
        for (int i = 0; i < nbAd; i++) {
            allDiffLayers[i] = new BitSet(nbS);
            int k = rand.nextInt(activeLayers.cardinality());
            int v = activeLayers.nextSetBit(0);
            while (k > 0) {
                v = activeLayers.nextSetBit(v + 1);
                k--;
            }
View Full Code Here

        }
    }

    private void activity(ICause cause) throws ContradictionException {
        BitSet selected = new BitSet(vars.length);
        while (selected.cardinality() < nbFixedVars) {
            double a = Integer.MIN_VALUE;
            int idx = -1;
            for (int k = 0; k < nbFixedVars; k++) {
                double ao = abs.getActivity(vars[k]);
                if (!selected.get(k) && ao > a) {
View Full Code Here

            }
            for (int j = v.getLB(); j <= ub; j++) {
                values.set(map.get(j));
            }
        }
        if (mandatoryValues.cardinality() >= vars[n].getUB()) {
            return ESat.TRUE;
        }
        if (values.cardinality() < vars[n].getLB()) {
            return ESat.FALSE;
        }
View Full Code Here

            }
        }
        List<BoolVar> lbvars = new ArrayList<BoolVar>();
        for (int i = 0; i < alldiffLayers.length; i++) {
            BitSet disjoint = alldiffLayers[i];
            IntVar[] _vars = new IntVar[disjoint.cardinality()];
            int[] _durs = new int[disjoint.cardinality()];
            for (int k = 0, j = disjoint.nextSetBit(0); j >= 0; j = disjoint.nextSetBit(j + 1), k++) {
                _vars[k] = vars[j];
                _durs[k] = 1;
            }
View Full Code Here

        }
        List<BoolVar> lbvars = new ArrayList<BoolVar>();
        for (int i = 0; i < alldiffLayers.length; i++) {
            BitSet disjoint = alldiffLayers[i];
            IntVar[] _vars = new IntVar[disjoint.cardinality()];
            int[] _durs = new int[disjoint.cardinality()];
            for (int k = 0, j = disjoint.nextSetBit(0); j >= 0; j = disjoint.nextSetBit(j + 1), k++) {
                _vars[k] = vars[j];
                _durs[k] = 1;
            }
            for (int l = 0; l < _vars.length - 1; l++) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.