- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

# /home/coin/svn-release/Blis-0.93.10/Blis/src/BlisBranchObjectInt.h

Go to the documentation of this file.

    00001 /*===========================================================================*
    00002  * This file is part of the BiCePS Linear Integer Solver (BLIS).             *
    00003  *                                                                           *
    00004  * BLIS is distributed under the Eclipse Public License as part of the       *
    00005  * COIN-OR repository (http://www.coin-or.org).                              *
    00006  *                                                                           *
    00007  * Authors:                                                                  *
    00008  *                                                                           *
    00009  *          Yan Xu, Lehigh University                                        *
    00010  *          Ted Ralphs, Lehigh University                                    *
    00011  *                                                                           *
    00012  * Conceptual Design:                                                        *
    00013  *                                                                           *
    00014  *          Yan Xu, Lehigh University                                        *
    00015  *          Ted Ralphs, Lehigh University                                    *
    00016  *          Laszlo Ladanyi, IBM T.J. Watson Research Center                  *
    00017  *          Matthew Saltzman, Clemson University                             *
    00018  *                                                                           *
    00019  *                                                                           *
    00020  * Copyright (C) 2001-2013, Lehigh University, Yan Xu, and Ted Ralphs.       *
    00021  * All Rights Reserved.                                                      *
    00022  *===========================================================================*/
    00023
    00024
    00025 //#############################################################################
    00026 // Borrow ideas from COIN/Cbc
    00027 //#############################################################################
    00028
    00029
    00030 #include "BcpsBranchObject.h"
    00031
    00032 #include "BlisModel.h"
    00033
    00034
    00035 //#############################################################################
    00036
    00037
    00038 class BlisBranchObjectInt : public BcpsBranchObject {
    00039
    00040  protected:
    00041
    00044     double down_[2];
    00045
    00048     double up_[2];
    00049
    00050  public:
    00051
    00053     BlisBranchObjectInt()
    00054         :
    00055         BcpsBranchObject()
    00056         {
    00057             type_ = BlisBranchingObjectTypeInt;
    00058             down_[0] = 0.0;
    00059             down_[1] = 0.0;
    00060             up_[0] = 0.0;
    00061             up_[1] = 0.0;
    00062         }
    00063
    00069     BlisBranchObjectInt(BlisModel * model,
    00070                         int varInd,
    00071                         int direction,
    00072                         double value)
    00073         :
    00074         BcpsBranchObject(model, varInd, direction, value)
    00075         {
    00076             type_ = BlisBranchingObjectTypeInt;
    00077             int iColumn = model->getIntColIndices()[objectIndex_];
    00078             down_[0] = model->solver()->getColLower()[iColumn];
    00079             down_[1] = floor(value_);
    00080             up_[0] = ceil(value_);
    00081             up_[1] = model->getColUpper()[iColumn];
    00082         }
    00083
    00091     BlisBranchObjectInt(BlisModel * model,
    00092                         int varInd,
    00093                         int intScore,
    00094                         double dblScore,
    00095                         int direction,
    00096                         double value)
    00097         :
    00098         BcpsBranchObject(model, varInd, intScore, dblScore, direction, value)
    00099         {
    00100             type_ = BlisBranchingObjectTypeInt;
    00101             int iColumn = model->getIntColIndices()[objectIndex_];
    00102             down_[0] = model->solver()->getColLower()[iColumn];
    00103             down_[1] = floor(value_);
    00104             up_[0] = ceil(value_);
    00105             up_[1] = model->getColUpper()[iColumn];
    00106         }
    00107
    00113     BlisBranchObjectInt(BlisModel * model,
    00114                         int varInd,
    00115                         int direction,
    00116                         double lowerValue,
    00117                         double upperValue)
    00118         :
    00119         BcpsBranchObject(model, varInd, direction, lowerValue)
    00120         {
    00121             type_ = BlisBranchingObjectTypeInt;
    00122             numBranchesLeft_ = 1;
    00123             down_[0] = lowerValue;
    00124             down_[1] = upperValue;
    00125             up_[0] = lowerValue;
    00126             up_[1] = upperValue;
    00127         }
    00128
    00130     BlisBranchObjectInt(const BlisBranchObjectInt &);
    00131
    00133     BlisBranchObjectInt & operator = (const BlisBranchObjectInt& rhs);
    00134
    00136     virtual BcpsBranchObject * clone() const {
    00137         return (new BlisBranchObjectInt(*this));
    00138     }
    00139
    00141     virtual ~BlisBranchObjectInt() {}
    00142
    00146     virtual double branch(bool normalBranch = false);
    00147
    00149     virtual void print(bool normalBranch);
    00150
    00152     const double *getDown() const { return down_; }
    00153
    00155     const double *getUp() const { return up_; }
    00156
    00157  protected:
    00158
    00160     AlpsReturnStatus encodeBlis(AlpsEncoded *encoded) const {
    00161         assert(encoded);
    00162         AlpsReturnStatus status = AlpsReturnStatusOk;
    00163         int j;
    00164         // TODO: N-way.
    00165         for (j = 0; j < 2; ++j) {
    00166             encoded->writeRep(down_[j]);
    00167         }
    00168         for (j = 0; j < 2; ++j) {
    00169             encoded->writeRep(up_[j]);
    00170         }
    00171
    00172         return status;
    00173     }
    00174
    00176     AlpsReturnStatus decodeBlis(AlpsEncoded &encoded) {
    00177         AlpsReturnStatus status = AlpsReturnStatusOk;
    00178         int j;
    00179         // TODO: N-way.
    00180         for (j = 0; j < 2; ++j) {
    00181             encoded.readRep(down_[j]);
    00182         }
    00183         for (j = 0; j < 2; ++j) {
    00184             encoded.readRep(up_[j]);
    00185         }
    00186
    00187         return status;
    00188     }
    00189
    00190  public:
    00191
    00193     virtual AlpsReturnStatus encode(AlpsEncoded *encoded) const {
    00194         AlpsReturnStatus status = AlpsReturnStatusOk;
    00195
    00196         status = encodeBcps(encoded);
    00197         status = encodeBlis(encoded);
    00198
    00199         return status;
    00200     }
    00201
    00203     virtual AlpsReturnStatus decode(AlpsEncoded &encoded) {
    00204
    00205         AlpsReturnStatus status = AlpsReturnStatusOk;
    00206
    00207         status = decodeBcps(encoded);
    00208         status = decodeBlis(encoded);
    00209
    00210         return status;
    00211     }
    00212
    00213 };
    00214