Package solver.explanations.antidom

Examples of solver.explanations.antidom.AntiDomain


        super(slv);
    }

    @Override
    public Deduction explain(IntVar var, int val) {
        AntiDomain ad = getRemovedValues(var);
        return flatten(getValueRemoval(var, ad.getKeyValue(val)));
    }
View Full Code Here


        }
    }

    @Override
    public Explanation flatten(IntVar var, int val) {
        AntiDomain ad = getRemovedValues(var);
        return flatten(getValueRemoval(var, ad.getKeyValue(val)));
    }
View Full Code Here

    /**
     * Iterate over removed values to explain the objective variable state
     */
    private void readAntiDomain() {
        AntiDomain adObj = mExplanationEngine.getRemovedValues(objective);
        DisposableValueIterator it = adObj.getValueIterator();
        clusters.add(0);
        // 2'. compute bounds to avoid explaining the whole domain
        boolean ismax = om.getPolicy() == ResolutionPolicy.MAXIMIZE;
        int far, near;
        if (ismax) {
View Full Code Here

        return new AntiDomBitset(this);
    }

    @Override
    public void explain(VariableState what, Explanation to) {
        AntiDomain invdom = solver.getExplainer().getRemovedValues(this);
        DisposableValueIterator it = invdom.getValueIterator();
        while (it.hasNext()) {
            int val = it.next();
            if ((what == VariableState.LB && val < this.getLB())
                    || (what == VariableState.UB && val > this.getUB())
                    || (what == VariableState.DOM)) {
View Full Code Here

    @Test(groups = "1s")
    public void test01() {
        Solver solver = new Solver();
        IntVar v = VariableFactory.enumerated("A", 1, 5, solver);
        AntiDomain ad = new AntiDomBitset(v);
        Assert.assertFalse(ad.get(1));
        Assert.assertFalse(ad.get(2));
        Assert.assertFalse(ad.get(3));
        Assert.assertFalse(ad.get(4));
        Assert.assertFalse(ad.get(5));
        solver.getEnvironment().worldPush();
        ad.add(1);
        ad.add(5);
        Assert.assertTrue(ad.get(1));
        Assert.assertFalse(ad.get(2));
        Assert.assertFalse(ad.get(3));
        Assert.assertFalse(ad.get(4));
        Assert.assertTrue(ad.get(5));
        solver.getEnvironment().worldPush();
        ad.add(3);
        DisposableValueIterator values = ad.getValueIterator();
        while (values.hasNext()) {
            Assert.assertTrue(ad.get(values.next()));
        }
        Assert.assertTrue(ad.get(1));
        Assert.assertFalse(ad.get(2));
        Assert.assertTrue(ad.get(3));
        Assert.assertFalse(ad.get(4));
        Assert.assertTrue(ad.get(5));
        solver.getEnvironment().worldPop();
        Assert.assertTrue(ad.get(1));
        Assert.assertFalse(ad.get(2));
        Assert.assertFalse(ad.get(3));
        Assert.assertFalse(ad.get(4));
        Assert.assertTrue(ad.get(5));
        solver.getEnvironment().worldPop();
        Assert.assertFalse(ad.get(1));
        Assert.assertFalse(ad.get(2));
        Assert.assertFalse(ad.get(3));
        Assert.assertFalse(ad.get(4));
        Assert.assertFalse(ad.get(5));
    }
View Full Code Here

    @Test(groups = "1s")
    public void test02() {
        Solver solver = new Solver();
        IntVar v = VariableFactory.enumerated("A", 1, 10, solver);
        AntiDomain ad = new AntiDomInterval(v);
        for (int i = 1; i < 11; i++) {
            Assert.assertFalse(ad.get(i));
        }
        solver.getEnvironment().worldPush();
        ad.updateLowerBound(1, 4);
        ad.updateLowerBound(4, 5);
        ad.updateUpperBound(10, 7);
        Assert.assertTrue(ad.get(1));
        Assert.assertTrue(ad.get(2));
        Assert.assertTrue(ad.get(3));
        Assert.assertTrue(ad.get(4));
        Assert.assertFalse(ad.get(5));
        Assert.assertFalse(ad.get(6));
        Assert.assertFalse(ad.get(7));
        Assert.assertTrue(ad.get(8));
        Assert.assertTrue(ad.get(9));
        Assert.assertTrue(ad.get(10));
        solver.getEnvironment().worldPush();
        DisposableValueIterator values = ad.getValueIterator();
        while (values.hasNext()) {
            Assert.assertTrue(ad.get(values.next()));
        }
        solver.getEnvironment().worldPop();
        Assert.assertTrue(ad.get(1));
        Assert.assertTrue(ad.get(2));
        Assert.assertTrue(ad.get(3));
        Assert.assertTrue(ad.get(4));
        Assert.assertFalse(ad.get(5));
        Assert.assertFalse(ad.get(6));
        Assert.assertFalse(ad.get(7));
        Assert.assertTrue(ad.get(8));
        Assert.assertTrue(ad.get(9));
        Assert.assertTrue(ad.get(10));
        solver.getEnvironment().worldPop();
        for (int i = 1; i < 11; i++) {
            Assert.assertFalse(ad.get(i));
        }
    }
View Full Code Here

TOP

Related Classes of solver.explanations.antidom.AntiDomain

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.