Examples of IEnvironment


Examples of memory.IEnvironment

            if (!vars[i].hasEnumeratedDomain()) {
                throw new SolverException("GAC2001 can not be used with bound variables");
            } else nbElt += vars[i].getUB() - vars[i].getLB() + 1;
        }
        this.supports = new IStateInt[nbElt * size];
        IEnvironment env = vs[0].getSolver().getEnvironment();
        for (int i = 0; i < supports.length; i++) {
            supports[i] = env.makeInt(Integer.MIN_VALUE);
        }
        if (allboolean)
            valcheck = new FastBooleanValidityChecker(size, vars);
        else
            valcheck = new FastValidityChecker(size, vars);
View Full Code Here

Examples of memory.IEnvironment

     * @param maximumSize of the set (maximum value -1)
     * @param solver    solver providing the backtracking environment
     * @return a new set which can be restored during search, after some backtracks
     */
    public static ISet makeStoredSet(SetType type, int maximumSize, Solver solver) {
    IEnvironment environment = solver.getEnvironment();
        if (HARD_CODED)
            switch (type) {
                case BIPARTITESET:
                    return new Set_Std_Swap_Array(environment, maximumSize);
                case SWAP_HASH:
View Full Code Here

Examples of memory.IEnvironment

        for (int i = 0; i < this.vars.length; i++) {
            idms[i] = this.vars[i].monitorDelta(this);
        }
        this.zIdx = vars.length - 1;
        this.rem_proc = new RemProc(this);
        IEnvironment environment = solver.getEnvironment();
        this.toRemove = new TIntArrayStack();
        this.boundChange = environment.makeBool(false);
        this.graph = graph;
        this.cautomaton = cautomaton;
    }
View Full Code Here

Examples of memory.IEnvironment

   *
   * @param slv associated solver's environment
   */
  public LazyExplanationEngineFromRestart(Solver slv) {
    super(slv);
    IEnvironment env = slv.getEnvironment();
    curChunk = env.makeInt(0);
    nextTop = env.makeInt(0);

    varChunks = new IntVar[1][];
    varChunks[0] = new IntVar[CHUNK_SIZE];

    cauChunks = new ICause[1][];
View Full Code Here

Examples of memory.IEnvironment

    }

    @Override
    public void apply() throws ContradictionException {
        ISearchLoop mSearchLoop = dynamicBacktracking.getSolver().getSearchLoop();
        IEnvironment environment = dynamicBacktracking.getSolver().getEnvironment();
        Decision dec;
        // retrieve the decision applied BEFORE the decision to refute, which is the last one in the decision_path
        Decision dec2ref = decision_path.getLast();

        Decision previous = dec2ref.getPrevious();
        int swi = dec2ref.getWorldIndex();
        //assert swi ==environment.getWorldIndex();

        // simulate open_node and rebuild decisions history
        dec = decision_path.pollFirst();
        dec.setPrevious(previous);
        dec.setWorldIndex(swi++);
        mSearchLoop.setLastDecision(dec);
        dec.buildNext();

        // then simulate down_branch
        dec.apply();
        mSearchLoop.getSMList().afterDownLeftBranch();
        previous = dec;

        // iterate over decisions
        while (!decision_path.isEmpty()) {

            // simulate open_node and rebuild decisions history
            dec = decision_path.pollFirst();
            dec.setPrevious(previous);
            dec.setWorldIndex(swi++);
            mSearchLoop.setLastDecision(dec);
            dec.buildNext();

            // then simulate down_branch
            mSearchLoop.getSMList().beforeDownLeftBranch();
            environment.worldPush();
            dec.apply();
            mSearchLoop.getSMList().afterDownLeftBranch();

            previous = dec;
        }
View Full Code Here

Examples of memory.IEnvironment

    int[] ubs;

    private DisposableValueIterator _viterator;

    public AntiDomInterval(IntVar A) {
        IEnvironment env = A.getSolver().getEnvironment();

        lbidx = env.makeInt(-1);
        ubidx = env.makeInt(-1);
        initLB = A.getLB();
        initUB = A.getUB();
        lbs = new int[16];
        ubs = new int[16];
    }
View Full Code Here

Examples of memory.IEnvironment

        random = new java.util.Random(seed);
    }

    @Override
    public void init() throws ContradictionException {
        IEnvironment env = vars[0].getSolver().getEnvironment();
        for (int i = 0; i < variables.length; i++) {
            variables[i].addMonitor(this);
            Propagator[] props = variables[i].getPropagators();
            for (int j = 0; j < props.length; j++) {
                pid2ari.putIfAbsent(props[j].getId(), env.makeInt(props[j].arity()));
            }
        }
    }
View Full Code Here

Examples of memory.IEnvironment

    //////////////////////////////////////////////////////////////////////////////////////

    public BitsetArrayIntVarImpl(String name, int[] sortedValues, Solver solver) {
        super(name, solver);
        IEnvironment env = solver.getEnvironment();
        this.LENGTH = sortedValues.length;
        this.values = sortedValues.clone();
        this.indexes = env.makeBitSet(LENGTH);
        this.indexes.set(0, LENGTH);
        this.LB = env.makeInt(0);
        this.UB = env.makeInt(LENGTH - 1);
        this.SIZE = env.makeInt(LENGTH);
    }
View Full Code Here

Examples of memory.IEnvironment

     * @param enumerated
     */
    public static void test(boolean enumerated) {
        // initialize
        Solver s = new Solver();
        IEnvironment env = s.getEnvironment();
        // set varriables
        IntVar[] vars = new IntVar[3];
        for (int i = 0; i < vars.length; i++) {
            vars[i] = enumerated ? VariableFactory.enumerated("x" + i, 1, vars.length, s)
                    : VariableFactory.bounded("x" + i, 1, vars.length + 1, s);
View Full Code Here

Examples of memory.IEnvironment

    @Test(groups = "1s")
    public void AssignmentTest() {
        int n = 100;

        Solver s = new Solver();
        IEnvironment env = s.getEnvironment();

        IntVar[] variables = new IntVar[n];
        for (int i = 0; i < n; i++) {
            variables[i] = VariableFactory.enumerated("V" + i, i, n + i, s);
        }
        AbstractStrategy asg = IntStrategyFactory.lexico_LB(variables);

        s.set(asg);

        env.worldPush();
        Decision decision = asg.getDecision();
        for (int i = 0; i < n; i++) {
            decision.buildNext();
            try {
                decision.apply();
            } catch (ContradictionException e) {
                e.printStackTrace();
            }
            Assert.assertTrue(variables[i].isInstantiated());
            Assert.assertEquals(variables[i].getValue(), i);
            Decision tmp = decision;
            decision = asg.getDecision();
            if (decision != null) {
                decision.setPrevious(tmp);
            } else {
                decision = tmp;
            }
            env.worldPush();
        }
        env.worldPop();
        for (int i = n - 1; i >= 0; i--) {
            env.worldPop();
            decision.buildNext();
            try {
                decision.apply();
            } catch (ContradictionException e) {
                e.printStackTrace();
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.