00001
00002
00003 #if defined(_MSC_VER)
00004
00005 # pragma warning(disable:4786)
00006 #endif
00007 #include <cassert>
00008 #include <cmath>
00009 #include <cfloat>
00010
00011 #include "OsiSolverInterface.hpp"
00012 #include "SbbModel.hpp"
00013 #include "SbbMessage.hpp"
00014 #include "SbbBranchBase.hpp"
00015
00016
00017
00018 SbbObject::SbbObject()
00019 :model_(NULL),
00020 id_(-1)
00021 {
00022 }
00023
00024
00025 SbbObject::SbbObject(SbbModel * model)
00026 :
00027 model_(model),
00028 id_(-1)
00029 {
00030 }
00031
00032
00033
00034 SbbObject::~SbbObject ()
00035 {
00036 }
00037
00038
00039 SbbObject::SbbObject ( const SbbObject & rhs)
00040 {
00041 model_ = rhs.model_;
00042 id_ = rhs.id_;
00043 }
00044
00045
00046 SbbObject &
00047 SbbObject::operator=( const SbbObject& rhs)
00048 {
00049 if (this!=&rhs) {
00050 model_ = rhs.model_;
00051 id_ = rhs.id_;
00052 }
00053 return *this;
00054 }
00055
00056
00057
00058 SbbBranchingObject::SbbBranchingObject()
00059 {
00060 model_=NULL;
00061 variable_=-1;
00062 way_=0;
00063 value_=0.0;
00064 numberBranchesLeft_=0;
00065 }
00066
00067
00068 SbbBranchingObject::SbbBranchingObject (SbbModel * model, int variable, int way , double value)
00069 {
00070 model_= model;
00071 variable_=variable;
00072 way_=way;
00073 value_=value;
00074 numberBranchesLeft_=2;
00075 }
00076
00077
00078 SbbBranchingObject::SbbBranchingObject ( const SbbBranchingObject & rhs)
00079 {
00080 model_=rhs.model_;
00081 variable_=rhs.variable_;
00082 way_=rhs.way_;
00083 value_=rhs.value_;
00084 numberBranchesLeft_=rhs.numberBranchesLeft_;
00085 }
00086
00087
00088 SbbBranchingObject &
00089 SbbBranchingObject::operator=( const SbbBranchingObject& rhs)
00090 {
00091 if (this != &rhs) {
00092 model_=rhs.model_;
00093 variable_=rhs.variable_;
00094 way_=rhs.way_;
00095 value_=rhs.value_;
00096 numberBranchesLeft_=rhs.numberBranchesLeft_;
00097 }
00098 return *this;
00099 }
00100
00101
00102 SbbBranchingObject::~SbbBranchingObject ()
00103 {
00104 }
00105
00106 SbbBranchDecision::SbbBranchDecision ()
00107 {
00108 }
00109
00110 SbbBranchDecision::~SbbBranchDecision()
00111 {
00112 }
00113
00114
00115
00116
00117
00118
00119
00120 int
00121 SbbBranchDecision::bestBranch (SbbBranchingObject ** objects, int numberObjects,
00122 int numberUnsatisfied,
00123 double * changeUp, int * numberInfeasibilitiesUp,
00124 double * changeDown, int * numberInfeasibilitiesDown,
00125 double objectiveValue)
00126 {
00127 int bestWay=0;
00128 int whichObject = -1;
00129 if (numberObjects) {
00130 initialize(objects[0]->model());
00131 SbbBranchingObject * bestObject = NULL;
00132 for (int i = 0 ; i < numberObjects ; i++) {
00133 int betterWay = betterBranch(objects[i],
00134 bestObject,
00135 changeUp[i],
00136 numberInfeasibilitiesUp [i],
00137 changeDown[i],
00138 numberInfeasibilitiesDown[i] );
00139 if (betterWay) {
00140 bestObject = objects[i];
00141 bestWay = betterWay;
00142 whichObject=i;
00143 }
00144 }
00145
00146 bestObject->way(bestWay);
00147 }
00148 return whichObject;
00149 }
00150
00151