コード例 #1
0
ファイル: CbcGeneralDepth.cpp プロジェクト: amosr/limp-cbc
double
CbcOneGeneralBranchingObject::branch()
{
    assert (numberBranchesLeft());
    decrementNumberBranchesLeft();
    assert (!numberBranchesLeft());
    object_->setWhichNode(whichOne_);
    object_->branch();
    return 0.0;
}
コード例 #2
0
ファイル: CbcGeneralDepth.cpp プロジェクト: amosr/limp-cbc
double
CbcGeneralBranchingObject::branch()
{
    double cutoff = model_->getCutoff();
    //printf("GenB %x whichNode %d numberLeft %d which %d\n",
    // this,whichNode_,numberBranchesLeft(),branchIndex());
    if (whichNode_ < 0) {
        assert (node_);
        bool applied = false;
        while (numberBranchesLeft()) {
            int which = branchIndex();
            decrementNumberBranchesLeft();
            CbcSubProblem * thisProb = subProblems_ + which;
            if (thisProb->objectiveValue_ < cutoff) {
                //printf("branch %x (sub %x) which now %d\n",this,
                //     subProblems_,which);
                OsiSolverInterface * solver = model_->solver();
                thisProb->apply(solver);
                OsiClpSolverInterface * clpSolver
                = dynamic_cast<OsiClpSolverInterface *> (solver);
                assert (clpSolver);
                // Move status to basis
                clpSolver->setWarmStart(NULL);
                //ClpSimplex * simplex = clpSolver->getModelPtr();
                node_->setObjectiveValue(thisProb->objectiveValue_);
                node_->setSumInfeasibilities(thisProb->sumInfeasibilities_);
                node_->setNumberUnsatisfied(thisProb->numberInfeasibilities_);
                applied = true;
                doingDoneBranch = true;
                break;
            } else if (numberBranchesLeft()) {
                node_->nodeInfo()->branchedOn() ;
            }
        }
        if (!applied) {
            // no good one
            node_->setObjectiveValue(cutoff + 1.0e20);
            node_->setSumInfeasibilities(1.0);
            node_->setNumberUnsatisfied(1);
            assert (whichNode_ < 0);
        }
    } else {
        decrementNumberBranchesLeft();
        CbcSubProblem * thisProb = subProblems_ + whichNode_;
        assert (thisProb->objectiveValue_ < cutoff);
        OsiSolverInterface * solver = model_->solver();
        thisProb->apply(solver);
        //OsiClpSolverInterface * clpSolver
        //= dynamic_cast<OsiClpSolverInterface *> (solver);
        //assert (clpSolver);
        // Move status to basis
        //clpSolver->setWarmStart(NULL);
    }
    return 0.0;
}
コード例 #3
0
ファイル: CbcGeneralDepth.cpp プロジェクト: amosr/limp-cbc
/* Double checks in case node can change its mind!
   Can change objective etc */
void
CbcGeneralBranchingObject::checkIsCutoff(double cutoff)
{
    assert (node_);
    int first = branchIndex();
    int last = first + numberBranchesLeft();
    for (int which = first; which < last; which++) {
        CbcSubProblem * thisProb = subProblems_ + which;
        if (thisProb->objectiveValue_ < cutoff) {
            node_->setObjectiveValue(thisProb->objectiveValue_);
            node_->setSumInfeasibilities(thisProb->sumInfeasibilities_);
            node_->setNumberUnsatisfied(thisProb->numberInfeasibilities_);
            break;
        }
    }
}
コード例 #4
0
ファイル: CbcNWay.cpp プロジェクト: SnowyJune973/future_net
double
CbcNWayBranchingObject::branch()
{
    int which = branchIndex_;
    branchIndex_++;
    assert (numberBranchesLeft() >= 0);
    if (which == 0) {
        // first branch so way_ may mean something
        assert (way_ == -1 || way_ == 1);
        if (way_ == -1)
            which++;
    } else if (which == 1) {
        // second branch so way_ may mean something
        assert (way_ == -1 || way_ == 1);
        if (way_ == -1)
            which--;
        // switch way off
        way_ = 0;
    }
    const double * lower = model_->solver()->getColLower();
    const double * upper = model_->solver()->getColUpper();
    const int * members = object_->members();
    for (int j = 0; j < numberInSet_; j++) {
        int iSequence = order_[j];
        int iColumn = members[iSequence];
        if (j != which) {
            model_->solver()->setColUpper(iColumn, lower[iColumn]);
            //model_->solver()->setColLower(iColumn,lower[iColumn]);
            assert (lower[iColumn] > -1.0e20);
            // apply any consequences
            object_->applyConsequence(iSequence, -9999);
        } else {
            model_->solver()->setColLower(iColumn, upper[iColumn]);
            //model_->solver()->setColUpper(iColumn,upper[iColumn]);
#ifdef FULL_PRINT
            printf("Up Fix %d to %g\n", iColumn, upper[iColumn]);
#endif
            assert (upper[iColumn] < 1.0e20);
            // apply any consequences
            object_->applyConsequence(iSequence, 9999);
        }
    }
    return 0.0;
}
コード例 #5
0
ファイル: CbcGeneralDepth.cpp プロジェクト: amosr/limp-cbc
/* Double checks in case node can change its mind!
   Can change objective etc */
void
CbcOneGeneralBranchingObject::checkIsCutoff(double /*cutoff*/)
{
    assert (numberBranchesLeft());
}