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

- File List
- File Members

# /home/coin/svn-release/Alps-1.4.8/Alps/examples/Abc/AbcNodeDesc.h

Go to the documentation of this file.

    00001 /*===========================================================================*
    00002  * This file is part of the Abstract Library for Parallel Search (ALPS).     *
    00003  *                                                                           *
    00004  * ALPS 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  *===========================================================================*/
    00022
    00023 //#############################################################################
    00024 // This file is modified from SbbNode.hpp
    00025 //#############################################################################
    00026
    00027 #ifndef AbcNodeDesc_h_
    00028 #define AbcNodeDesc_h_
    00029
    00030 #include "CoinHelperFunctions.hpp"
    00031 #include "CoinWarmStartBasis.hpp"
    00032
    00033 #include "AlpsNodeDesc.h"
    00034 #include "AbcModel.h"
    00035
    00036 class OsiSolverInterface;
    00037
    00038 class OsiCuts;
    00039 class OsiRowCut;
    00040 class OsiRowCutDebugger;
    00041
    00042 class AbcModel;
    00043 class AbcNode;
    00044
    00045 //#############################################################################
    00046
    00047
    00048 class AbcNodeDesc : public AlpsNodeDesc {
    00049
    00050  private:
    00051
    00052     /* Here, we need to fill in what the node description will look
    00053        like. For now, we will not use differencing -- just explicitly
    00054        represent it. Probably this means that we will just store the
    00055        original problem data and a list of the variables that have been
    00056        fixed. */
    00057
    00059     double* lowerBounds_;
    00061     double* upperBounds_;
    00062
    00065     int numberRows_;
    00067     int numberCols_;
    00068
    00070     int branchedOn_;
    00071
    00073     double branchedOnVal_;
    00074
    00076     int branchedDir_;
    00077  public:
    00078     AbcNodeDesc()
    00079         :
    00080         AlpsNodeDesc(0),
    00081         lowerBounds_(0),
    00082         upperBounds_(0),
    00083         numberRows_(0),
    00084         numberCols_(0),
    00085         branchedOn_(-8),
    00086         branchedOnVal_(0),
    00087         branchedDir_(1)
    00088         {
    00089         }
    00090
    00091     AbcNodeDesc(AbcModel* m)
    00092         :
    00093         AlpsNodeDesc(m),
    00094         lowerBounds_(0),
    00095         upperBounds_(0),
    00096         numberRows_(0),
    00097         numberCols_(0),
    00098         branchedOn_(-9),
    00099         branchedOnVal_(0),
    00100         branchedDir_(1)
    00101         {
    00102         }
    00103
    00104     AbcNodeDesc(AbcModel* m, const double* lb, const double* ub)
    00105         :
    00106         AlpsNodeDesc(m),
    00107         branchedOn_(-10),
    00108         branchedOnVal_(0),
    00109         branchedDir_(1)
    00110         {
    00111             numberRows_ = m->solver()->getNumRows();
    00112             numberCols_ = m->solver()->getNumCols();
    00113             assert(numberRows_ && numberCols_);
    00114             lowerBounds_ = new double [numberCols_];
    00115             upperBounds_ = new double [numberCols_];
    00116             memcpy(lowerBounds_, lb, sizeof(double)*numberCols_);
    00117             memcpy(upperBounds_, ub, sizeof(double)*numberCols_);
    00118         }
    00119
    00120     virtual ~AbcNodeDesc() {
    00121         if (lowerBounds_ != 0) {
    00122             delete [] lowerBounds_;
    00123             lowerBounds_ = 0;
    00124         }
    00125         if (upperBounds_ != 0) {
    00126             delete [] upperBounds_;
    00127             upperBounds_ = 0;
    00128         }
    00129     }
    00130
    00131     double* lowerBounds()
    00132         {
    00133             if(lowerBounds_ == 0) {
    00134                 assert(model_);
    00135                 AbcModel* m = dynamic_cast<AbcModel*>(model_);
    00136                 const int num = m->getNumCols();
    00137                 const double* lb = m->getColLower();
    00138                 lowerBounds_ = new double [num];
    00139                 memcpy(lowerBounds_, lb, sizeof(double)*num);
    00140 //              std::cout << "AbcNodeDesc::lowerBounds--num=" << num
    00141 //                        <<std::endl;
    00142             }
    00143             return lowerBounds_;
    00144         }
    00145
    00146     void setLowerBounds(const double* lb, const int size)
    00147         {
    00148             if(!lowerBounds_) {
    00149                 lowerBounds_ = new double [size];
    00150             }
    00151             CoinCopyN(lb, size, lowerBounds_);
    00152         }
    00153
    00154     void setLowerBound(const int index, const double lb)
    00155         {
    00156             if(!lowerBounds_) {
    00157                 AbcModel * model = dynamic_cast<AbcModel*>(model_);
    00158                 const int numCols = model->getNumCols();
    00159                 assert(numCols > index);
    00160                 lowerBounds_ = new double [numCols];
    00161             }
    00162
    00163             lowerBounds_[index] = lb;
    00164         }
    00165
    00166     double* upperBounds()
    00167         {
    00168             if(upperBounds_ == 0) {
    00169                 assert(model_);
    00170                 AbcModel* m = dynamic_cast<AbcModel*>(model_);
    00171                 const int num = m->getNumCols();
    00172                 const double* ub = m->getColUpper();
    00173                 upperBounds_ = new double [num];
    00174                 memcpy(upperBounds_, ub, sizeof(double)*num);
    00175             }
    00176             return upperBounds_;
    00177         }
    00178
    00179     void setUpperBounds(const double* ub, const int size)
    00180         {
    00181             if(!upperBounds_) {
    00182                 upperBounds_ = new double [size];
    00183             }
    00184             CoinCopyN(ub, size, upperBounds_);
    00185         }
    00186
    00187     void setUpperBound(const int index, const double ub)
    00188         {
    00189             if (!upperBounds_) {
    00190                 AbcModel * model = dynamic_cast<AbcModel*>(model_);
    00191                 const int numCols = model->getNumCols();
    00192                 assert(numCols > index);
    00193                 upperBounds_ = new double [numCols];
    00194             }
    00195
    00196             upperBounds_[index] = ub;
    00197         }
    00199     void setBranchedOn(int b) { branchedOn_ = b; }
    00201     void setBranchedDir(int d) { branchedDir_ = d; }
    00203     void setBranchedOnValue(double b) { branchedOnVal_ = b; }
    00205     int getBranchedOn() const { return branchedOn_; }
    00207     int getBranchedDir() const { return branchedDir_; }
    00209     double getBranchedOnValue() const { return branchedOnVal_; }
    00210 };
    00211
    00212 #endif