Package solver.explanations.antidom

Examples of solver.explanations.antidom.AntiDomain


        return new AntiDomInterval(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


        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

     * @param what
     * @param to
     */
    @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

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

    @Override
    public AntiDomain getRemovedValues(IntVar v) {
        int vid = v.getId();
        AntiDomain toreturn = removedvalues.get(vid);
        if (toreturn == null) {
            toreturn = v.antiDomain();
            removedvalues.put(vid, toreturn);
            TIntObjectHashMap<ValueRemoval> hm = valueremovals.get(vid);
            if (hm == null) {
View Full Code Here

    public void removeValue(IntVar var, int val, ICause cause) {
        assert cause != null;
        // 1. explain the value removal
        explainValueRemoval(var, val, cause);
        // 2. update the inverse domain
        AntiDomain invdom = getRemovedValues(var);
        invdom.add(val);
    }
View Full Code Here

    }

    @Override
    public void updateLowerBound(IntVar var, int old, int val, ICause cause) {
        assert cause != null;
        AntiDomain invdom = getRemovedValues(var);
        if (invdom.isEnumerated()) {
            for (int v = old; v < val; v++) {
                if (!invdom.get(v)) {
                    explainValueRemoval(var, v, cause);
                    invdom.add(v);
                }
            }
        } else {
            // PREREQUISITE: val is the new LB, so val-1 is the one explained
            val--;
            if (!invdom.get(val)) {
                explainValueRemoval(var, val, cause);
                // we add +1, because val is the value just BEFORE the new LB
                invdom.updateLowerBound(old, val + 1);
            }
        }
    }
View Full Code Here

    }

    @Override
    public void updateUpperBound(IntVar var, int old, int val, ICause cause) {
        assert cause != null;
        AntiDomain invdom = getRemovedValues(var);
        if (invdom.isEnumerated()) {
            for (int v = old; v > val; v--) {
                if (!invdom.get(v)) {
                    explainValueRemoval(var, v, cause);
                    invdom.add(v);
                }
            }
        } else {
            // PREREQUISITE: val is the new UB, so val+1 is the one explained
            val++;
            if (!invdom.get(val)) {
                explainValueRemoval(var, val, cause);
                // we add -1, because val is the value just AFTER the new LB
                invdom.updateUpperBound(old, val - 1);
            }
        }
    }
View Full Code Here

    }


    @Override
    public void instantiateTo(IntVar var, int val, ICause cause, int oldLB, int oldUB) {
        AntiDomain invdom = getRemovedValues(var);

        if (invdom.isEnumerated()) {
            for (int v = oldLB; v < val; v++) {
                if (!invdom.get(v)) {
                    explainValueRemoval(var, v, cause);
                    invdom.add(v);
                }
            }
            for (int v = oldUB; v > val; v--) {
                if (!invdom.get(v)) {
                    explainValueRemoval(var, v, cause);
                    invdom.add(v);
                }
            }
        } else {
            if (val < oldLB) {
                // domain wipe out
                explainValueRemoval(var, oldLB, cause);
                invdom.updateUpperBound(oldUB, oldLB - 1);
            } else if (val > oldUB) {
                // domain wipe out
                explainValueRemoval(var, oldUB, cause);
                invdom.updateLowerBound(oldLB, oldUB + 1);
            } else {
                if (val > oldLB && !invdom.get(val)) {
                    explainValueRemoval(var, val - 1, cause);
                    invdom.updateLowerBound(oldLB, val);
                }
                if (val < oldUB && !invdom.get(val)) {
                    explainValueRemoval(var, val + 1, cause);
                    invdom.updateUpperBound(oldUB, val);
                }
            }
        }
    }
View Full Code Here

    }

    @Override
    public Explanation flatten(IntVar var, int val) {
        // TODO check that it is always called with val NOT in var
        AntiDomain ad = getRemovedValues(var);
        return flatten(getValueRemoval(var, ad.getKeyValue(val)));
    }
View Full Code Here

        return flatten(expl);
    }

    @Override
    public Deduction explain(IntVar var, int val) {
        AntiDomain ad = getRemovedValues(var);
        return explain(getValueRemoval(var, ad.getKeyValue(val)));
    }
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.