Ignore:
Timestamp:
Dec 4, 2009 11:26:41 AM (10 years ago)
Author:
EdwinStraver
Message:

Combined CbcBranchDynamic?.cpp with CbcDynamicPseudoCostBranchingObject?
Combined CbcBranchCut? with CbcCutBranchingObject?
Combined CbcLotsize? with CbcBranchLotsize?.cpp

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/sandbox/Cbc/src/CbcBranchDynamic.cpp

    r1308 r1351  
    605605}
    606606#endif
     607
     608// Default Constructor
     609CbcDynamicPseudoCostBranchingObject::CbcDynamicPseudoCostBranchingObject()
     610        : CbcIntegerBranchingObject()
     611{
     612    changeInGuessed_ = 1.0e-5;
     613    object_ = NULL;
     614}
     615
     616// Useful constructor
     617CbcDynamicPseudoCostBranchingObject::CbcDynamicPseudoCostBranchingObject (CbcModel * model,
     618        int variable,
     619        int way , double value,
     620        CbcSimpleIntegerDynamicPseudoCost * object)
     621        : CbcIntegerBranchingObject(model, variable, way, value)
     622{
     623    changeInGuessed_ = 1.0e-5;
     624    object_ = object;
     625}
     626// Does part of work for constructor
     627void
     628CbcDynamicPseudoCostBranchingObject::fillPart (int variable,
     629        int way , double value,
     630        CbcSimpleIntegerDynamicPseudoCost * object)
     631{
     632    CbcIntegerBranchingObject::fillPart(variable, way, value);
     633    changeInGuessed_ = 1.0e-5;
     634    object_ = object;
     635}
     636// Useful constructor for fixing
     637CbcDynamicPseudoCostBranchingObject::CbcDynamicPseudoCostBranchingObject (CbcModel * model,
     638        int variable, int way,
     639        double lowerValue,
     640        double /*upperValue*/)
     641        : CbcIntegerBranchingObject(model, variable, way, lowerValue)
     642{
     643    changeInGuessed_ = 1.0e100;
     644    object_ = NULL;
     645}
     646
     647
     648// Copy constructor
     649CbcDynamicPseudoCostBranchingObject::CbcDynamicPseudoCostBranchingObject (
     650    const CbcDynamicPseudoCostBranchingObject & rhs)
     651        : CbcIntegerBranchingObject(rhs)
     652{
     653    changeInGuessed_ = rhs.changeInGuessed_;
     654    object_ = rhs.object_;
     655}
     656
     657// Assignment operator
     658CbcDynamicPseudoCostBranchingObject &
     659CbcDynamicPseudoCostBranchingObject::operator=( const CbcDynamicPseudoCostBranchingObject & rhs)
     660{
     661    if (this != &rhs) {
     662        CbcIntegerBranchingObject::operator=(rhs);
     663        changeInGuessed_ = rhs.changeInGuessed_;
     664        object_ = rhs.object_;
     665    }
     666    return *this;
     667}
     668CbcBranchingObject *
     669CbcDynamicPseudoCostBranchingObject::clone() const
     670{
     671    return (new CbcDynamicPseudoCostBranchingObject(*this));
     672}
     673
     674// Destructor
     675CbcDynamicPseudoCostBranchingObject::~CbcDynamicPseudoCostBranchingObject ()
     676{
     677}
     678
     679/*
     680  Perform a branch by adjusting the bounds of the specified variable. Note
     681  that each arm of the branch advances the object to the next arm by
     682  advancing the value of way_.
     683
     684  Providing new values for the variable's lower and upper bounds for each
     685  branching direction gives a little bit of additional flexibility and will
     686  be easily extensible to multi-way branching.
     687  Returns change in guessed objective on next branch
     688*/
     689double
     690CbcDynamicPseudoCostBranchingObject::branch()
     691{
     692    CbcIntegerBranchingObject::branch();
     693    return changeInGuessed_;
     694}
     695/* Some branchingObjects may claim to be able to skip
     696   strong branching.  If so they have to fill in CbcStrongInfo.
     697   The object mention in incoming CbcStrongInfo must match.
     698   Returns nonzero if skip is wanted */
     699int
     700CbcDynamicPseudoCostBranchingObject::fillStrongInfo( CbcStrongInfo & info)
     701{
     702    assert (object_);
     703    assert (info.possibleBranch == this);
     704    info.upMovement = object_->upDynamicPseudoCost() * (ceil(value_) - value_);
     705    info.downMovement = object_->downDynamicPseudoCost() * (value_ - floor(value_));
     706    info.numIntInfeasUp  -= static_cast<int> (object_->sumUpDecrease() /
     707                            (1.0e-12 + static_cast<double> (object_->numberTimesUp())));
     708    info.numIntInfeasUp = CoinMax(info.numIntInfeasUp, 0);
     709    info.numObjInfeasUp = 0;
     710    info.finishedUp = false;
     711    info.numItersUp = 0;
     712    info.numIntInfeasDown  -= static_cast<int> (object_->sumDownDecrease() /
     713                              (1.0e-12 + static_cast<double> (object_->numberTimesDown())));
     714    info.numIntInfeasDown = CoinMax(info.numIntInfeasDown, 0);
     715    info.numObjInfeasDown = 0;
     716    info.finishedDown = false;
     717    info.numItersDown = 0;
     718    info.fix = 0;
     719    if (object_->numberTimesUp() < object_->numberBeforeTrust() +
     720            2*object_->numberTimesUpInfeasible() ||
     721            object_->numberTimesDown() < object_->numberBeforeTrust() +
     722            2*object_->numberTimesDownInfeasible()) {
     723        return 0;
     724    } else {
     725        return 1;
     726    }
     727}
Note: See TracChangeset for help on using the changeset viewer.