Examples of TIntArrayList


Examples of gnu.trove.list.array.TIntArrayList

    // METHODS
    //***********************************************************************************

    @Override
    public void propagate(int evtmask) throws ContradictionException {
        TIntArrayList fixedVar = new TIntArrayList();
        for (int i = 0; i < n; i++) {
            vars[i].removeValue(i + offset, aCause);
            vars[i].updateLowerBound(offset, aCause);
            vars[i].updateUpperBound(n - 1 + offset, aCause);
            if (vars[i].isInstantiated()) {
                fixedVar.add(i);
            }
        }
        for (int i = 0; i < fixedVar.size(); i++) {
            varInstantiated(fixedVar.get(i), vars[fixedVar.get(i)].getValue() - offset);
        }
    }
View Full Code Here

Examples of gnu.trove.list.array.TIntArrayList

  public static TIntArrayList[] generateKingTourInstance_LightMemory(int size) {
    int n = size * size;
    int node, next, a, b;
    TIntArrayList[] matrix = new TIntArrayList[n];
    for (int i = 0; i < n; i++) {
      matrix[i] = new TIntArrayList(8);
    }
    for (int i = 0; i < size; i++) {
      for (int j = 0; j < size; j++) {
        node = i * size + j;
        // move
View Full Code Here

Examples of gnu.trove.list.array.TIntArrayList

//                graph[i][j] = true;
//                i = j;
//            }
//        } while (j != -1);
//        graph[i][start] = true;
        TIntArrayList nodes = new TIntArrayList(size);
        for (int i = 0; i < size; i++) {
            nodes.add(i);
        }
        nodes.shuffle(rand);
        for (int i = 0; i < size - 1; i++) {
            graph[nodes.get(i)][nodes.get(i + 1)] = true;
        }
        graph[nodes.get(size - 1)][nodes.get(0)] = true;
    }
View Full Code Here

Examples of gnu.trove.list.array.TIntArrayList

     * @param VARS    collection of variables
     * @param NVALUES limit variable
     * @param AC      additional filtering algorithm, domain filtering algorithm derivated from (Soft)AllDifferent
     */
    public static Constraint atleast_nvalues(IntVar[] VARS, IntVar NVALUES, boolean AC) {
        TIntArrayList vals = getDomainUnion(VARS);
        if (AC) {
            return new Constraint("AtLeastNValues", new PropAtLeastNValues(VARS, vals, NVALUES), new PropAtLeastNValues_AC(VARS, NVALUES));
        } else {
            return new Constraint("AtLeastNValues", new PropAtLeastNValues(VARS, vals, NVALUES));
        }
View Full Code Here

Examples of gnu.trove.list.array.TIntArrayList

     *                (see Fages and Lap&egrave;gue, CP'13 or Artificial Intelligence journal)
     *                automatically detects disequalities and alldifferent constraints.
     *                Presumably useful when NVALUES must be minimized.
     */
    public static Constraint atmost_nvalues(IntVar[] VARS, IntVar NVALUES, boolean GREEDY) {
        TIntArrayList vals = getDomainUnion(VARS);
        if (GREEDY) {
            Gci gci = new Gci(VARS, new AutoDiffDetection(VARS));
            R[] rules = new R[]{new R1(), new R3(VARS.length, NVALUES.getSolver())};
            return new Constraint("AtMostNValues", new PropAtMostNValues(VARS, vals, NVALUES),
                    new PropAMNV(VARS, NVALUES, gci, new MDRk(gci), rules));
View Full Code Here

Examples of gnu.trove.list.array.TIntArrayList

    public static Constraint global_cardinality(IntVar[] VARS, int[] VALUES, IntVar[] OCCURRENCES, boolean CLOSED) {
        assert VALUES.length == OCCURRENCES.length;
        if (!CLOSED) {
            return new GlobalCardinality(VARS, VALUES, OCCURRENCES);
        } else {
            TIntArrayList toAdd = new TIntArrayList();
            TIntSet givenValues = new TIntHashSet();
            for (int i : VALUES) {
                assert !givenValues.contains(i);
                givenValues.add(i);
            }
            for (IntVar var : VARS) {
                int ub = var.getUB();
                for (int k = var.getLB(); k <= ub; k = var.nextValue(k)) {
                    if (!givenValues.contains(k)) {
                        if (!toAdd.contains(k)) {
                            toAdd.add(k);
                        }
                    }
                }
            }
            if (toAdd.size() > 0) {
                int n2 = VALUES.length + toAdd.size();
                int[] values = new int[n2];
                IntVar[] cards = new IntVar[n2];
                System.arraycopy(VALUES, 0, values, 0, VALUES.length);
                System.arraycopy(OCCURRENCES, 0, cards, 0, VALUES.length);
                for (int i = VALUES.length; i < n2; i++) {
                    values[i] = toAdd.get(i - VALUES.length);
                    cards[i] = VariableFactory.fixed(0, VARS[0].getSolver());
                }
                return new GlobalCardinality(VARS, values, cards);
            } else {
                return new GlobalCardinality(VARS, VALUES, OCCURRENCES);
View Full Code Here

Examples of gnu.trove.list.array.TIntArrayList

        model[n + 1] = circuit(SUCCS, 0);
        return model;
    }

    public static TIntArrayList getDomainUnion(IntVar[] vars) {
        TIntArrayList values = new TIntArrayList();
        for (IntVar v : vars) {
            int ub = v.getUB();
            for (int i = v.getLB(); i <= ub; i = v.nextValue(i)) {
                if (!values.contains(i)) {
                    values.add(i);
                }
            }
        }
        return values;
    }
View Full Code Here

Examples of gnu.trove.list.array.TIntArrayList

        for (int idx = 0; idx < n2; idx++) {
            mandatories[idx] = SetFactory.makeStoredSet(SetType.BITSET, n, solver);
            possibles[idx] = SetFactory.makeStoredSet(SetType.BITSET, n, solver);
        }
        this.valueToCompute = SetFactory.makeStoredSet(SetType.BITSET, n2, solver);
        this.boundVar = new TIntArrayList();
        for (int i = 0; i < n; i++) {
            if (!vars[i].hasEnumeratedDomain()) {
                boundVar.add(i);
            }
        }
View Full Code Here

Examples of gnu.trove.list.array.TIntArrayList

    }

    public void watch(IntVar var, Nogood ng, int idxInNG) {
        TIntList nogoods = vars2nogood.get(var.getId());
        if (nogoods == null) {
            nogoods = new TIntArrayList();
            vars2nogood.put(var.getId(), nogoods);
        }
        nogoods.add(ng.getIdx());
        TIntList indices = vars2idxinng.get(var.getId());
        if (indices == null) {
            indices = new TIntArrayList();
            vars2idxinng.put(var.getId(), indices);
        }
        indices.add(idxInNG);
    }
View Full Code Here

Examples of gnu.trove.list.array.TIntArrayList

    protected Filler filler;

    public ViewDeltaMonitor(IIntDeltaMonitor deltamonitor, ICause propagator) {
        this.deltamonitor = deltamonitor;
        this.propagator = propagator;
        values = new TIntArrayList(8);
        filler = new Filler();
    }
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.