Ignore:
Timestamp:
Nov 9, 2009 6:33:07 PM (10 years ago)
Author:
EdwinStraver
Message:

Changed formatting using AStyle -A4 -p

File:
1 edited

Legend:

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

    r1271 r1286  
    2020
    2121// Default Constructor
    22 CbcObject::CbcObject() 
    23   : OsiObject(),
    24     model_(NULL),
    25    id_(-1),
    26    position_(-1),
    27    preferredWay_(0)
     22CbcObject::CbcObject()
     23        : OsiObject(),
     24        model_(NULL),
     25        id_(-1),
     26        position_(-1),
     27        preferredWay_(0)
    2828{
    2929}
     
    3131// Constructor from model
    3232CbcObject::CbcObject(CbcModel * model)
    33   : OsiObject(),
    34     model_(model),
    35     id_(-1),
    36     position_(-1),
    37     preferredWay_(0)
    38 {
    39 }
    40 
    41 
    42 // Destructor 
     33        : OsiObject(),
     34        model_(model),
     35        id_(-1),
     36        position_(-1),
     37        preferredWay_(0)
     38{
     39}
     40
     41
     42// Destructor
    4343CbcObject::~CbcObject ()
    4444{
    4545}
    4646
    47 // Copy constructor 
     47// Copy constructor
    4848CbcObject::CbcObject ( const CbcObject & rhs)
    49   : OsiObject(rhs)
    50 {
    51   model_ = rhs.model_;
    52   id_ = rhs.id_;
    53   position_ = rhs.position_;
    54   preferredWay_ = rhs.preferredWay_;
    55 }
    56 
    57 // Assignment operator
    58 CbcObject &
    59 CbcObject::operator=( const CbcObject& rhs)
    60 {
    61   if (this!=&rhs) {
    62     OsiObject::operator=(rhs);
     49        : OsiObject(rhs)
     50{
    6351    model_ = rhs.model_;
    6452    id_ = rhs.id_;
    6553    position_ = rhs.position_;
    6654    preferredWay_ = rhs.preferredWay_;
    67   }
    68   return *this;
     55}
     56
     57// Assignment operator
     58CbcObject &
     59CbcObject::operator=( const CbcObject & rhs)
     60{
     61    if (this != &rhs) {
     62        OsiObject::operator=(rhs);
     63        model_ = rhs.model_;
     64        id_ = rhs.id_;
     65        position_ = rhs.position_;
     66        preferredWay_ = rhs.preferredWay_;
     67    }
     68    return *this;
    6969}
    7070
    7171/* Returns floor and ceiling i.e. closest valid points
    7272 */
    73 void 
     73void
    7474CbcObject::floorCeiling(double & floorValue, double & ceilingValue, double value,
    75                         double tolerance) const
    76 {
    77   if (fabs(floor(value+0.5)-value)>tolerance) {
    78     floorValue = floor(value);
    79   } else {
    80     floorValue = floor(value+0.5);
    81   }
    82   ceilingValue = floorValue+1.0;
     75                        double tolerance) const
     76{
     77    if (fabs(floor(value + 0.5) - value) > tolerance) {
     78        floorValue = floor(value);
     79    } else {
     80        floorValue = floor(value + 0.5);
     81    }
     82    ceilingValue = floorValue + 1.0;
    8383}
    8484/* For the variable(s) referenced by the object,
     
    8686      Returns measure of how much it had to move solution to make feasible
    8787*/
    88 double 
    89 CbcObject::feasibleRegion(OsiSolverInterface * /*solver*/) const 
    90 {
    91   //assert (solver==model_->solver());
    92   CbcObject * fudge = const_cast<CbcObject *>(this);
    93   fudge->feasibleRegion();
    94   return 0.0;
    95 }
    96  
     88double
     89CbcObject::feasibleRegion(OsiSolverInterface * /*solver*/) const
     90{
     91    //assert (solver==model_->solver());
     92    CbcObject * fudge = const_cast<CbcObject *>(this);
     93    fudge->feasibleRegion();
     94    return 0.0;
     95}
     96
    9797/* For the variable(s) referenced by the object,
    9898      look at the current solution and set bounds to match the solution.
    9999      Returns measure of how much it had to move solution to make feasible
    100100*/
    101 double 
     101double
    102102CbcObject::feasibleRegion(OsiSolverInterface * /*solver*/,
    103                           const OsiBranchingInformation * /*info*/) const
    104 {
    105   //assert (solver==model_->solver());
    106   CbcObject * fudge = const_cast<CbcObject *>(this);
    107   fudge->feasibleRegion();
    108   return 0.0;
     103                          const OsiBranchingInformation * /*info*/) const
     104{
     105    //assert (solver==model_->solver());
     106    CbcObject * fudge = const_cast<CbcObject *>(this);
     107    fudge->feasibleRegion();
     108    return 0.0;
    109109}
    110110/* Create a branching object and indicate which way to branch first.
    111      
     111
    112112      The branching object has to know how to create branches (fix
    113113      variables, etc.)
    114114*/
    115 OsiBranchingObject * 
     115OsiBranchingObject *
    116116CbcObject::createOsiBranch(OsiSolverInterface * solver,
    117                         const OsiBranchingInformation * info,
    118                         int way) const
    119 {
    120   //assert (solver==model_->solver());
    121   CbcObject * fudge = const_cast<CbcObject *>(this);
    122   return fudge->createBranch(solver,info,way);
     117                           const OsiBranchingInformation * info,
     118                           int way) const
     119{
     120    //assert (solver==model_->solver());
     121    CbcObject * fudge = const_cast<CbcObject *>(this);
     122    return fudge->createBranch(solver, info, way);
    123123}
    124124/* Create an OsiSolverBranch object
    125    
     125
    126126This returns NULL if branch not represented by bound changes
    127127*/
    128 OsiSolverBranch * 
     128OsiSolverBranch *
    129129CbcObject::solverBranch() const
    130130{
    131   return NULL;
     131    return NULL;
    132132}
    133133/* Pass in information on branch just done and create CbcObjectUpdateData instance.
    134134   If object does not need data then backward pointer will be NULL.
    135135   Assumes can get information from solver */
    136 CbcObjectUpdateData 
    137 CbcObject::createUpdateInformation(const OsiSolverInterface * /*solver*/, 
    138                                    const CbcNode * /*node*/,
    139                                    const CbcBranchingObject * /*branchingObject*/)
    140 {
    141   return CbcObjectUpdateData();
    142 }
    143  
    144 // Default Constructor 
     136CbcObjectUpdateData
     137CbcObject::createUpdateInformation(const OsiSolverInterface * /*solver*/,
     138                                   const CbcNode * /*node*/,
     139                                   const CbcBranchingObject * /*branchingObject*/)
     140{
     141    return CbcObjectUpdateData();
     142}
     143
     144// Default Constructor
    145145CbcBranchingObject::CbcBranchingObject()
    146   : OsiBranchingObject()
    147 {
    148   model_=NULL;
    149   originalCbcObject_=NULL;
    150   variable_=-1;
    151   way_=0;
     146        : OsiBranchingObject()
     147{
     148    model_ = NULL;
     149    originalCbcObject_ = NULL;
     150    variable_ = -1;
     151    way_ = 0;
    152152}
    153153
    154154// Useful constructor
    155155CbcBranchingObject::CbcBranchingObject (CbcModel * model, int variable, int way , double value)
    156   : OsiBranchingObject(model->solver(),value)
    157 {
    158   model_= model;
    159   originalCbcObject_=NULL;
    160   variable_=variable;
    161   way_=way;
    162 }
    163 
    164 // Copy constructor 
     156        : OsiBranchingObject(model->solver(), value)
     157{
     158    model_ = model;
     159    originalCbcObject_ = NULL;
     160    variable_ = variable;
     161    way_ = way;
     162}
     163
     164// Copy constructor
    165165CbcBranchingObject::CbcBranchingObject ( const CbcBranchingObject & rhs)
    166   : OsiBranchingObject(rhs)
    167 {
    168   model_=rhs.model_;
    169   originalCbcObject_=rhs.originalCbcObject_;
    170   variable_=rhs.variable_;
    171   way_=rhs.way_;
    172   value_=rhs.value_;
    173 }
    174 
    175 // Assignment operator 
    176 CbcBranchingObject & 
    177 CbcBranchingObject::operator=( const CbcBranchingObject& rhs)
    178 {
    179   if (this != &rhs) {
    180     OsiBranchingObject::operator=(rhs);
    181     model_=rhs.model_;
    182     originalCbcObject_=rhs.originalCbcObject_;
    183     variable_=rhs.variable_;
    184     way_=rhs.way_;
    185   }
    186   return *this;
    187 }
    188 
    189 // Destructor 
     166        : OsiBranchingObject(rhs)
     167{
     168    model_ = rhs.model_;
     169    originalCbcObject_ = rhs.originalCbcObject_;
     170    variable_ = rhs.variable_;
     171    way_ = rhs.way_;
     172    value_ = rhs.value_;
     173}
     174
     175// Assignment operator
     176CbcBranchingObject &
     177CbcBranchingObject::operator=( const CbcBranchingObject & rhs)
     178{
     179    if (this != &rhs) {
     180        OsiBranchingObject::operator=(rhs);
     181        model_ = rhs.model_;
     182        originalCbcObject_ = rhs.originalCbcObject_;
     183        variable_ = rhs.variable_;
     184        way_ = rhs.way_;
     185    }
     186    return *this;
     187}
     188
     189// Destructor
    190190CbcBranchingObject::~CbcBranchingObject ()
    191191{
    192192}
    193 // Default Constructor 
     193// Default Constructor
    194194CbcBranchDecision::CbcBranchDecision ()
    195   : object_(NULL),model_(NULL),chooseMethod_(NULL)
    196 {
    197 }
    198 
    199 // Copy Constructor 
     195        : object_(NULL), model_(NULL), chooseMethod_(NULL)
     196{
     197}
     198
     199// Copy Constructor
    200200CbcBranchDecision::CbcBranchDecision (const CbcBranchDecision &rhs)
    201   : object_(NULL),model_(rhs.model_),chooseMethod_(NULL)
    202 {
    203   if (rhs.chooseMethod_)
    204     chooseMethod_ = rhs.chooseMethod_->clone();
     201        : object_(NULL), model_(rhs.model_), chooseMethod_(NULL)
     202{
     203    if (rhs.chooseMethod_)
     204        chooseMethod_ = rhs.chooseMethod_->clone();
    205205}
    206206
    207207CbcBranchDecision::~CbcBranchDecision()
    208208{
    209   delete object_;
    210   delete chooseMethod_;
     209    delete object_;
     210    delete chooseMethod_;
    211211}
    212212/* Compare N branching objects. Return index of best
    213213   and sets way of branching in chosen object.
    214    
     214
    215215   This routine is used only after strong branching.
    216216   This is reccommended version as it can be more sophisticated
     
    219219int
    220220CbcBranchDecision::bestBranch (CbcBranchingObject ** objects, int numberObjects,
    221                                int /*numberUnsatisfied*/,
    222                                double * changeUp, int * numberInfeasibilitiesUp,
    223                                double * changeDown, int * numberInfeasibilitiesDown,
    224                                double /*objectiveValue*/)
    225 {
    226   int bestWay=0;
    227   int whichObject = -1;
    228   if (numberObjects) {
    229     initialize(objects[0]->model());
    230     CbcBranchingObject * bestObject = NULL;
    231     for (int i = 0 ; i < numberObjects ; i++) {
    232       int betterWay = betterBranch(objects[i],
    233                                    bestObject,
    234                                    changeUp[i],
    235                                    numberInfeasibilitiesUp [i],
    236                                    changeDown[i],
    237                                    numberInfeasibilitiesDown[i] );
    238       if (betterWay) {
    239         bestObject = objects[i];
    240         bestWay = betterWay;
    241         whichObject=i;
    242       }
    243     }
    244     // set way in best
    245     if (whichObject>=0)
    246       objects[whichObject]->way(bestWay);
    247   }
    248   return whichObject;
     221                               int /*numberUnsatisfied*/,
     222                               double * changeUp, int * numberInfeasibilitiesUp,
     223                               double * changeDown, int * numberInfeasibilitiesDown,
     224                               double /*objectiveValue*/)
     225{
     226    int bestWay = 0;
     227    int whichObject = -1;
     228    if (numberObjects) {
     229        initialize(objects[0]->model());
     230        CbcBranchingObject * bestObject = NULL;
     231        for (int i = 0 ; i < numberObjects ; i++) {
     232            int betterWay = betterBranch(objects[i],
     233                                         bestObject,
     234                                         changeUp[i],
     235                                         numberInfeasibilitiesUp [i],
     236                                         changeDown[i],
     237                                         numberInfeasibilitiesDown[i] );
     238            if (betterWay) {
     239                bestObject = objects[i];
     240                bestWay = betterWay;
     241                whichObject = i;
     242            }
     243        }
     244        // set way in best
     245        if (whichObject >= 0)
     246            objects[whichObject]->way(bestWay);
     247    }
     248    return whichObject;
    249249}
    250250// Set (clone) chooseMethod
    251 void 
     251void
    252252CbcBranchDecision::setChooseMethod(const OsiChooseVariable & method)
    253 { 
    254   delete chooseMethod_;
    255   chooseMethod_ = method.clone();
     253{
     254    delete chooseMethod_;
     255    chooseMethod_ = method.clone();
    256256}
    257257// Default constructor
     
    261261
    262262
    263 // Destructor 
     263// Destructor
    264264CbcConsequence::~CbcConsequence ()
    265265{
    266266}
    267267
    268 // Copy constructor 
     268// Copy constructor
    269269CbcConsequence::CbcConsequence ( const CbcConsequence & /*rhs*/)
    270270{
    271271}
    272272
    273 // Assignment operator 
    274 CbcConsequence & 
    275 CbcConsequence::operator=( const CbcConsequence& rhs)
    276 {
    277   if (this!=&rhs) {
    278   }
    279   return *this;
     273// Assignment operator
     274CbcConsequence &
     275CbcConsequence::operator=( const CbcConsequence & rhs)
     276{
     277    if (this != &rhs) {
     278    }
     279    return *this;
    280280}
    281281// Default constructor
    282282CbcObjectUpdateData::CbcObjectUpdateData()
    283   : object_(NULL),
    284     way_(0),
    285     objectNumber_(-1),
    286     change_(0.0),
    287     status_(0),
    288     intDecrease_(0),
    289     branchingValue_(0.0),
    290     originalObjective_(COIN_DBL_MAX),
    291     cutoff_(COIN_DBL_MAX)
     283        : object_(NULL),
     284        way_(0),
     285        objectNumber_(-1),
     286        change_(0.0),
     287        status_(0),
     288        intDecrease_(0),
     289        branchingValue_(0.0),
     290        originalObjective_(COIN_DBL_MAX),
     291        cutoff_(COIN_DBL_MAX)
    292292{
    293293}
     
    295295// Useful constructor
    296296CbcObjectUpdateData::CbcObjectUpdateData (CbcObject * object,
    297                                           int way,
    298                                           double change,
    299                                           int status,
    300                                           int intDecrease,
    301                                           double branchingValue)
    302   : object_(object),
    303     way_(way),
    304     objectNumber_(-1),
    305     change_(change),
    306     status_(status),
    307     intDecrease_(intDecrease),
    308     branchingValue_(branchingValue),
    309     originalObjective_(COIN_DBL_MAX),
    310     cutoff_(COIN_DBL_MAX)
    311 {
    312 }
    313 
    314 // Destructor 
     297        int way,
     298        double change,
     299        int status,
     300        int intDecrease,
     301        double branchingValue)
     302        : object_(object),
     303        way_(way),
     304        objectNumber_(-1),
     305        change_(change),
     306        status_(status),
     307        intDecrease_(intDecrease),
     308        branchingValue_(branchingValue),
     309        originalObjective_(COIN_DBL_MAX),
     310        cutoff_(COIN_DBL_MAX)
     311{
     312}
     313
     314// Destructor
    315315CbcObjectUpdateData::~CbcObjectUpdateData ()
    316316{
    317317}
    318318
    319 // Copy constructor 
     319// Copy constructor
    320320CbcObjectUpdateData::CbcObjectUpdateData ( const CbcObjectUpdateData & rhs)
    321   : object_(rhs.object_),
    322     way_(rhs.way_),
    323     objectNumber_(rhs.objectNumber_),
    324     change_(rhs.change_),
    325     status_(rhs.status_),
    326     intDecrease_(rhs.intDecrease_),
    327     branchingValue_(rhs.branchingValue_),
    328     originalObjective_(rhs.originalObjective_),
    329     cutoff_(rhs.cutoff_)
    330 {
    331 }
    332 
    333 // Assignment operator 
    334 CbcObjectUpdateData & 
    335 CbcObjectUpdateData::operator=( const CbcObjectUpdateData& rhs)
    336 {
    337   if (this!=&rhs) {
    338     object_ = rhs.object_;
    339     way_ = rhs.way_;
    340     objectNumber_ = rhs.objectNumber_;
    341     change_ = rhs.change_;
    342     status_ = rhs.status_;
    343     intDecrease_ = rhs.intDecrease_;
    344     branchingValue_ = rhs.branchingValue_;
    345     originalObjective_ = rhs.originalObjective_;
    346     cutoff_ = rhs.cutoff_;
    347   }
    348   return *this;
    349 }
    350 
    351  
     321        : object_(rhs.object_),
     322        way_(rhs.way_),
     323        objectNumber_(rhs.objectNumber_),
     324        change_(rhs.change_),
     325        status_(rhs.status_),
     326        intDecrease_(rhs.intDecrease_),
     327        branchingValue_(rhs.branchingValue_),
     328        originalObjective_(rhs.originalObjective_),
     329        cutoff_(rhs.cutoff_)
     330{
     331}
     332
     333// Assignment operator
     334CbcObjectUpdateData &
     335CbcObjectUpdateData::operator=( const CbcObjectUpdateData & rhs)
     336{
     337    if (this != &rhs) {
     338        object_ = rhs.object_;
     339        way_ = rhs.way_;
     340        objectNumber_ = rhs.objectNumber_;
     341        change_ = rhs.change_;
     342        status_ = rhs.status_;
     343        intDecrease_ = rhs.intDecrease_;
     344        branchingValue_ = rhs.branchingValue_;
     345        originalObjective_ = rhs.originalObjective_;
     346        cutoff_ = rhs.cutoff_;
     347    }
     348    return *this;
     349}
     350
     351
Note: See TracChangeset for help on using the changeset viewer.