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

- File List
- File Members

# /home/coin/SVN-release/Blis-0.91.2/Bcps/src/BcpsNodeDesc.h

Go to the documentation of this file.

    00001 /*===========================================================================*
    00002  * This file is part of the Branch, Constrain and Price Software (BiCePS)    *
    00003  *                                                                           *
    00004  * BiCePS is distributed under the Common 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  * Copyright (C) 2001-2009, Lehigh University, Yan Xu, and Ted Ralphs.       *
    00020  * All Rights Reserved.                                                      *
    00021  *===========================================================================*/
    00022
    00023 #ifndef BcpsNodeDesc_h_
    00024 #define BcpsNodeDesc_h_
    00025
    00026 #include "BcpsModel.h"
    00027
    00028 #include "Alps.h"
    00029 #include "AlpsNodeDesc.h"
    00030
    00031 #include "BcpsObject.h"
    00032
    00033
    00034 //#############################################################################
    00035
    00039 template <class T> struct BcpsFieldListMod {
    00044     bool relative;
    00045
    00047     int  numModify;
    00048
    00050     int* posModify;
    00051
    00053     T*   entries;
    00054 };
    00055
    00056
    00057 //#############################################################################
    00058
    00059
    00066 struct BcpsObjectListMod {
    00067
    00070     int  numRemove;
    00071
    00073     int* posRemove;
    00074
    00076     int  numAdd;
    00078     BcpsObject **objects;
    00079
    00083     BcpsFieldListMod<double> lbHard;
    00084     BcpsFieldListMod<double> ubHard;
    00085     BcpsFieldListMod<double> lbSoft;
    00086     BcpsFieldListMod<double> ubSoft;
    00087     BcpsFieldListMod<int> status;
    00089 };
    00090
    00091
    00092 //#############################################################################
    00093
    00119 //#############################################################################
    00120
    00128 class BcpsNodeDesc : public AlpsNodeDesc {
    00129
    00130  protected:
    00131
    00133     BcpsObjectListMod *vars_;
    00134
    00136     BcpsObjectListMod *cons_;
    00137
    00138  public:
    00139
    00141     BcpsNodeDesc() { initToNull(); }
    00142
    00144     BcpsNodeDesc(BcpsModel* m)
    00145         :
    00146         AlpsNodeDesc(m) { initToNull(); }
    00147
    00149     virtual ~BcpsNodeDesc();
    00150
    00152     void initToNull();
    00153
    00155     void setVars(int numRem,
    00156                  const int    *posRem,
    00157                  int numAdd,
    00158                  const BcpsObject **objects,
    00159                  bool relvlh,
    00160                  int numvlh,
    00161                  const int    *vlhp,
    00162                  const double *vlhe,
    00163                  bool relvuh,
    00164                  int numvuh,
    00165                  const int    *vuhp,
    00166                  const double *vuhe,
    00167                  bool relvls,
    00168                  int numvls,
    00169                  const int    *vlsp,
    00170                  const double *vlse,
    00171                  bool relvus,
    00172                  int numvus,
    00173                  const int    *vusp,
    00174                  const double *vuse);
    00175
    00177     void assignVars(int numRem,
    00178                     int    *&posRem,
    00179                     int numAdd,
    00180                     BcpsObject **&objects,
    00181                     bool relvlh,
    00182                     int numvlh,
    00183                     int    *&vlhp,
    00184                     double *&vlhe,
    00185                     bool relvuh,
    00186                     int numvuh,
    00187                     int    *&vuhp,
    00188                     double *&vuhe,
    00189                     bool relvls,
    00190                     int numvls,
    00191                     int    *&vlsp,
    00192                     double *&vlse,
    00193                     bool relvus,
    00194                     int numvus,
    00195                     int    *&vusp,
    00196                     double *&vuse);
    00197
    00199     void setCons(int numRem,
    00200                  const int    *posRem,
    00201                  int numAdd,
    00202                  const BcpsObject **objects,
    00203                  bool relclh,
    00204                  int numclh,
    00205                  const int    *clhp,
    00206                  const double *clhe,
    00207                  bool relcuh,
    00208                  int numcuh,
    00209                  const int    *cuhp,
    00210                  const double *cuhe,
    00211                  bool relcls,
    00212                  int numcls,
    00213                  const int    *clsp,
    00214                  const double *clse,
    00215                  bool relcus,
    00216                  int numcus,
    00217                  const int    *cusp,
    00218                  const double *cuse);
    00219
    00221     void assignCons(int numRem,
    00222                     int    *&posRem,
    00223                     int numAdd,
    00224                     BcpsObject **&objects,
    00225                     bool relclh,
    00226                     int numclh,
    00227                     int    *&clhp,
    00228                     double *&clhe,
    00229                     bool relcuh,
    00230                     int numcuh,
    00231                     int    *&cuhp,
    00232                     double *&cuhe,
    00233                     bool relcls,
    00234                     int numcls,
    00235                     int    *&clsp,
    00236                     double *&clse,
    00237                     bool relcus,
    00238                     int numcus,
    00239                     int    *&cusp,
    00240                     double *&cuse);
    00241
    00243     BcpsObjectListMod *getVars() const { return vars_; }
    00244
    00246     BcpsObjectListMod *getCons() const { return cons_; }
    00247
    00249     BcpsObjectListMod *vars() { return vars_; }
    00250
    00252     BcpsObjectListMod *cons() { return cons_; }
    00253
    00255     void assignVarSoftBound(int numModSoftVarLB,
    00256                             int *&varLBi,
    00257                             double *&varLBv,
    00258                             int numModSoftVarUB,
    00259                             int *&varUBi,
    00260                             double *&varUBv);
    00261
    00263     void setVarSoftBound(int numModSoftVarLB,
    00264                          const int *varLBi,
    00265                          const double *varLBv,
    00266                          int numModSoftVarUB,
    00267                          const int *varUBi,
    00268                          const double *varUBv);
    00269
    00271     void assignVarHardBound(int numModHardVarLB,
    00272                             int *&varLBi,
    00273                             double *&varLBv,
    00274                             int numModHardVarUB,
    00275                             int *&varUBi,
    00276                             double *&varUBv);
    00277
    00279     void setConSoftBound(int numModSoftConLB,
    00280                          const int *conLBi,
    00281                          const double *conLBv,
    00282                          int numModSoftConUB,
    00283                          const int *conUBi,
    00284                          const double *conUBv);
    00285
    00287     void setVarHardBound(int numModHardVarLB,
    00288                          const int *varLBi,
    00289                          const double *varLBv,
    00290                          int numModHardVarUB,
    00291                          const int *varUBi,
    00292                          const double *varUBv);
    00293
    00295     void setConHardBound(int numModHardConLB,
    00296                          const int *conLBi,
    00297                          const double *conLBv,
    00298                          int numModHardConUB,
    00299                          const int *conUBi,
    00300                          const double *conUBv);
    00301
    00304     void appendAddedConstraints(int numAdd, BcpsObject **addCons){
    00305         int numAll = numAdd + cons_->numAdd;
    00306         BcpsObject ** allAdd = new BcpsObject* [numAll];
    00307         int k;
    00308
    00309         for (k = 0; k < cons_->numAdd; ++k) {
    00310             allAdd[k] = cons_->objects[k];
    00311         }
    00312         for (k = 0; k < numAdd; ++k) {
    00313             allAdd[(k+cons_->numAdd)] = addCons[k];
    00314         }
    00315
    00316         delete [] cons_->objects;
    00317         cons_->numAdd = numAll;
    00318         cons_->objects = allAdd;
    00319     }
    00320
    00323     void setAddedConstraints(int numAdd, BcpsObject **addCons){
    00324         // NOTE: make sure objects can be safely deleted.
    00325         if (cons_->objects) {
    00326             for (int k = 0; k < cons_->numAdd; ++k) {
    00327                 delete cons_->objects[k];
    00328             }
    00329             delete [] cons_->objects;
    00330         }
    00331         cons_->numAdd = numAdd;
    00332         cons_->objects = addCons;
    00333     }
    00334
    00337     void delConstraints(int numDel, int *indices){
    00338         if ( cons_->posRemove) delete []  cons_->posRemove;
    00339         cons_->numRemove = numDel;
    00340         cons_->posRemove = indices;
    00341     }
    00342
    00344     void addVariables(int numAdd, BcpsObject **addVars){
    00345         if (vars_->objects) {
    00346             for (int k = 0; k < vars_->numAdd; ++k) {
    00347                 delete vars_->objects[k];
    00348             }
    00349             delete [] vars_->objects;
    00350         }
    00351
    00352         vars_->numAdd = numAdd;
    00353         vars_->objects = addVars;
    00354     }
    00355
    00357     void delVariables(int numDel, int *indices){
    00358         if (vars_->posRemove) delete []  vars_->posRemove;
    00359         vars_->numRemove = numDel;
    00360         vars_->posRemove = indices;
    00361     }
    00362
    00363  protected:
    00364
    00366     AlpsReturnStatus encodeDblFieldMods(AlpsEncoded *encoded,
    00367                                       BcpsFieldListMod<double> * field) const;
    00368
    00370     AlpsReturnStatus encodeIntFieldMods(AlpsEncoded *encoded,
    00371                                       BcpsFieldListMod<int> * field) const;
    00372
    00374     AlpsReturnStatus encodeObjectMods(AlpsEncoded *encoded,
    00375                                     BcpsObjectListMod *objMod) const;
    00376
    00378     AlpsReturnStatus decodeDblFieldMods(AlpsEncoded &encoded,
    00379                                       BcpsFieldListMod<double>*field);
    00380
    00382     AlpsReturnStatus decodeIntFieldMods(AlpsEncoded &encoded,
    00383                                       BcpsFieldListMod<int> *field);
    00384
    00386     AlpsReturnStatus decodeObjectMods(AlpsEncoded &encoded,
    00387                                     BcpsObjectListMod *objMod);
    00388
    00389  public:
    00390
    00392     AlpsReturnStatus encodeBcps(AlpsEncoded *encoded) const;
    00393
    00395     AlpsReturnStatus decodeBcps(AlpsEncoded &encoded);
    00396
    00397 };
    00398
    00399 #endif /* End of file */