Skip to content

Commit

Permalink
New branching scheme (#121)
Browse files Browse the repository at this point in the history
* Changes for allowing prioritizing branching on the lower level variables

* Changing the way tail off is detected

* Setting new default for tailoff parameter.
  • Loading branch information
tkralphs authored Aug 31, 2023
1 parent bfc7780 commit b4d7613
Show file tree
Hide file tree
Showing 9 changed files with 236 additions and 241 deletions.
23 changes: 12 additions & 11 deletions src/MibSBilevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ MibSBilevel::createBilevel(CoinPackedVector* sol,
int *indices = sol->getIndices();
double *values = sol->getElements();
int numElements(sol->getNumElements()); // number of nonzero elements
int * fixedInd = model_->fixedInd_;
int * varType = model_->varType_;

if(!upperSolutionOrd_){
upperSolutionOrd_ = new double[uN];
Expand Down Expand Up @@ -134,7 +134,7 @@ MibSBilevel::createBilevel(CoinPackedVector* sol,
if(binarySearch(0, uN - 1, index, upperColInd) >= 0){
if(fabs(floor(value + 0.5) - value) > etol){
#if 1
if(fixedInd[index] == 1){
if(varType[index] == MibSVarLinking){
isLinkVarsIntegral_ = false;
}
if(mibs->solver()->isInteger(index)){
Expand Down Expand Up @@ -162,7 +162,8 @@ MibSBilevel::createBilevel(CoinPackedVector* sol,

for(i = 0; i < N; i ++){
if(binarySearch(0, uN - 1, i, upperColInd) >= 0){
if((fixedInd[i] == 1) && (fabs(upper[i] - lower[i]) > etol)){
if((varType[i] == MibSVarLinking) &&
(fabs(upper[i] - lower[i]) > etol)){
isLinkVarsFixed_ = false;
break;
}
Expand Down Expand Up @@ -204,7 +205,7 @@ MibSBilevel::createBilevel(CoinPackedVector* sol,
std::vector<double> linkSol;
for(i = 0; i < uN; i++){
index = upperColInd[i];
if(fixedInd[index] == 1){
if(varType[index] == MibSVarLinking){
linkSol.push_back(upperSolutionOrd_[i]);
}
}
Expand Down Expand Up @@ -288,7 +289,7 @@ MibSBilevel::checkBilevelFeasibility(bool isRoot)
int uN(model_->upperDim_); // upper-level dimension
int i(0), index(0), pos(0);
double etol(model_->etol_), objVal(0.0), lowerObj(0.0);
int * fixedInd = model_->fixedInd_;
int * varType = model_->varType_;
int * lowerColInd = model_->getLowerColInd();
int * upperColInd = model_->getUpperColInd();
double *lowerSol = new double[lN];
Expand All @@ -302,7 +303,7 @@ MibSBilevel::checkBilevelFeasibility(bool isRoot)
std::vector<double> linkSol;
for(i = 0; i < uN; i++){
index = upperColInd[i];
if(fixedInd[index] == 1){
if(varType[index] == MibSVarLinking){
linkSol.push_back(upperSolutionOrd_[i]);
}
}
Expand Down Expand Up @@ -709,7 +710,7 @@ MibSBilevel::setUpUBModel(OsiSolverInterface * oSolver, double objValLL,
lpSol = oSolver->getColSolution();
}

int * fixedInd = model_->fixedInd_;
int * varType = model_->varType_;

int i(0), index1(0);
double value(0.0);
Expand Down Expand Up @@ -753,7 +754,7 @@ MibSBilevel::setUpUBModel(OsiSolverInterface * oSolver, double objValLL,

for(i = 0; i < uCols; i++){
index1 = uColIndices[i];
if(fixedInd[index1] == 1){
if(varType[index1] == MibSVarLinking){
colLb[index1] = floor(lpSol[index1] + 0.5);
colUb[index1] = colLb[index1];
}
Expand Down Expand Up @@ -846,7 +847,7 @@ MibSBilevel::setUpUBModel(OsiSolverInterface * oSolver, double objValLL,
nSolver->setRowUpper(rowNum-1, objValLL);
for(i = 0; i < uCols; i++){
index1 = uColIndices[i];
if(fixedInd[index1] == 1){
if(varType[index1] == MibSVarLinking){
value = floor(lpSol[index1] + 0.5);
nSolver->setColLower(index1, value);
nSolver->setColUpper(index1, value);
Expand Down Expand Up @@ -1345,15 +1346,15 @@ void
int i(0),index(0);
int uN(model_->upperDim_);
int * upperColInd = model_->getUpperColInd();
int * fixedInd = model_->fixedInd_;
int * varType = model_->varType_;
int solType = static_cast<int>(solTag);

LINKING_SOLUTION linkingSolution;

std::vector<double> linkSol;
for(i = 0; i < uN; i++){
index = upperColInd[i];
if(fixedInd[index] == 1){
if(varType[index] == MibSVarLinking){
linkSol.push_back(upperSolutionOrd_[i]);
}
}
Expand Down
Loading

0 comments on commit b4d7613

Please sign in to comment.