Package gnu.trove.list.array

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


//                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

     * @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

     *                (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

    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

        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

        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

    }

    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

    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

            minVal = Math.min(minVal, vars[i].getLB());
            maxVal = Math.max(maxVal, vars[i].getUB());
        }
        valSet = new BitSet(maxVal - minVal + 1);
        instVals = new int[n];
        dVar = new TIntArrayList();
    }
View Full Code Here

TOP

Related Classes of gnu.trove.list.array.TIntArrayList

Copyright © 2018 www.massapicom. 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.