Example #1
0
// Adds branching information to complete state
void
CbcTree::addBranchingInformation(const CbcModel * model, const CbcNodeInfo * nodeInfo,
                                 const double * currentLower,
                                 const double * currentUpper)
{
    const OsiBranchingObject * objA  = nodeInfo->owner()->branchingObject();
    const CbcIntegerBranchingObject * objBranch  = dynamic_cast<const CbcIntegerBranchingObject *> (objA);
    if (objBranch) {
        const CbcObject * objB = objBranch->object();
        const CbcSimpleInteger * obj = dynamic_cast<const CbcSimpleInteger *> (objB);
        assert (obj);
        int iColumn = obj->columnNumber();
        const double * down = objBranch->downBounds();
        const double * up = objBranch->upBounds();
        assert (currentLower[iColumn] == down[0]);
        assert (currentUpper[iColumn] == up[1]);
        if (dynamic_cast<const CbcPartialNodeInfo *> (nodeInfo)) {
            const CbcPartialNodeInfo * info = dynamic_cast<const CbcPartialNodeInfo *> (nodeInfo);
            const double * newBounds = info->newBounds();
            const int * variables = info->variables();
            int numberChanged = info->numberChangedBounds();
            for (int i = 0; i < numberChanged; i++) {
                int jColumn = variables[i];
                int kColumn = jColumn & (~0x80000000);
                if (iColumn == kColumn) {
                    jColumn |= 0x40000000;
#ifndef NDEBUG
                    double value = newBounds[i];
                    if ((jColumn&0x80000000) == 0) {
                        assert (value == up[0]);
                    } else {
                        assert (value == down[1]);
                    }
#endif
                }
                if (numberBranching_ == maximumBranching_)
                    increaseSpace();
                newBound_[numberBranching_] = static_cast<int> (newBounds[i]);
                branched_[numberBranching_++] = jColumn;
            }
        } else {
            const CbcFullNodeInfo * info = dynamic_cast<const CbcFullNodeInfo *> (nodeInfo);
            int numberIntegers = model->numberIntegers();
            const int * which = model->integerVariable();
            const double * newLower = info->lower();
            const double * newUpper = info->upper();
            if (numberBranching_ == maximumBranching_)
                increaseSpace();
            assert (newLower[iColumn] == up[0] ||
                    newUpper[iColumn] == down[1]);
            int jColumn = iColumn | 0x40000000;
            if (newLower[iColumn] == up[0]) {
                newBound_[numberBranching_] = static_cast<int> (up[0]);
            } else {
                newBound_[numberBranching_] = static_cast<int> (down[1]);
                jColumn |= 0x80000000;
            }
            branched_[numberBranching_++] = jColumn;
            for (int i = 0; i < numberIntegers; i++) {
                int jColumn = which[i];
                assert (currentLower[jColumn] == newLower[jColumn] ||
                        currentUpper[jColumn] == newUpper[jColumn]);
                if (jColumn != iColumn) {
                    bool changed = false;
                    double value;
                    if (newLower[jColumn] > currentLower[jColumn]) {
                        value = newLower[jColumn];
                        changed = true;
                    } else if (newUpper[jColumn] < currentUpper[jColumn]) {
                        value = newUpper[jColumn];
                        jColumn |= 0x80000000;
                        changed = true;
                    }
                    if (changed) {
                        if (numberBranching_ == maximumBranching_)
                            increaseSpace();
                        newBound_[numberBranching_] = static_cast<int> (value);
                        branched_[numberBranching_++] = jColumn;
                    }
                }
            }
        }
    } else {
        // switch off
        delete [] branched_;
        delete [] newBound_;
        maximumBranching_ = -1;
        branched_ = NULL;
        newBound_ = NULL;
    }
}
Example #2
0
void ScenePrettyPrinter::visitNodeTransformBefore(NodeTransform&) {
  increaseSpace();
}
Example #3
0
void ScenePrettyPrinter::visitNodeGroupBefore(NodeGroup&) {
  increaseSpace();
}
Example #4
0
void ScenePrettyPrinter::visitNodeDrawingStyleBefore(NodeDrawingStyle&) {
  increaseSpace();
}
Example #5
0
void ScenePrettyPrinter::visitNodeShapeBefore(NodeShape&) {
  increaseSpace();
}