Solver.prototype.satisfy = function()

in src/lib/vpsc.js [413:471]


    Solver.prototype.satisfy = function () {
        if (this.bs == null) {
            this.bs = new Blocks(this.vs);
        }
        /* DEBUG
                    console.log("satisfy: " + this.bs);
        DEBUG */
        this.bs.split(this.inactive);
        var v = null;
        while ((v = this.mostViolated()) && (v.equality || v.slack() < Solver.ZERO_UPPERBOUND && !v.active)) {
            var lb = v.left.block, rb = v.right.block;
            /* DEBUG
                            console.log("most violated is: " + v);
                            this.bs.contains(lb);
                            this.bs.contains(rb);
            DEBUG */
            if (lb !== rb) {
                this.bs.merge(v);
            }
            else {
                if (lb.isActiveDirectedPathBetween(v.right, v.left)) {
                    // cycle found!
                    v.unsatisfiable = true;
                    continue;
                }
                // constraint is within block, need to split first
                var split = lb.splitBetween(v.left, v.right);
                if (split !== null) {
                    this.bs.insert(split.lb);
                    this.bs.insert(split.rb);
                    this.bs.remove(lb);
                    this.inactive.push(split.constraint);
                }
                else {
                    /* DEBUG
                                            console.log("unsatisfiable constraint found");
                    DEBUG */
                    v.unsatisfiable = true;
                    continue;
                }
                if (v.slack() >= 0) {
                    /* DEBUG
                                            console.log("violated constraint indirectly satisfied: " + v);
                    DEBUG */
                    // v was satisfied by the above split!
                    this.inactive.push(v);
                }
                else {
                    /* DEBUG
                                            console.log("merge after split:");
                    DEBUG */
                    this.bs.merge(v);
                }
            }
        }
        /* DEBUG
                    this.checkSatisfied();
        DEBUG */
    };