Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update linking related variable name and replace some binarySearch #128

Merged
merged 5 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/MibSBilevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,13 @@ MibSBilevel::createBilevel(CoinPackedVector* sol,
}
}

for(i = 0; i < N; i ++){
if(binarySearch(0, uN - 1, i, upperColInd) >= 0){
if((varType[i] == MibSVarLinking) &&
(fabs(upper[i] - lower[i]) > etol)){
isLinkVarsFixed_ = false;
break;
}
}
for(i = 0; i < uN; i++){
index = upperColInd[i];
if((varType[index] == MibSVarLinking) &&
(fabs(upper[index] - lower[index]) > etol)){
isLinkVarsFixed_ = false;
break;
}
tkralphs marked this conversation as resolved.
Show resolved Hide resolved
}

/* put the solution in order by integers first */
Expand Down
12 changes: 7 additions & 5 deletions src/MibSCutGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1703,22 +1703,24 @@ MibSCutGenerator::storeBestSolHypercubeIC(const double* lpSol, double optLowerOb

OsiSolverInterface * oSolver = localModel_->solver();
MibSBilevel *bS = localModel_->bS_;
int i(0);
int i(0), index(0);
int numCols(oSolver->getNumCols());
int uN(localModel_->getUpperDim());
int lN(localModel_->getLowerDim());
double objVal(0.0);
//double startTimeUB(0.0);
int * varType = localModel_->getVarType();
int * uColInd = localModel_->getUpperColInd();

int useLinkingSolutionPool(localModel_->MibSPar_->entry
(MibSParams::useLinkingSolutionPool));

std::vector<double> linkSol;
for(i = 0; i < uN + lN; i++){
if(varType[i] == MibSVarLinking){
linkSol.push_back(lpSol[i]);
}
for(i = 0; i < uN; i++){
index = uColInd[i];
if(varType[index] == MibSVarLinking){
linkSol.push_back(lpSol[index]);
}
}

OsiSolverInterface *UBSolver;
Expand Down
21 changes: 7 additions & 14 deletions src/MibSModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ MibSModel::initialize()
upperRowNum_ = 0;
origUpperRowNum_ =0;
structRowNum_ = 0;
sizeFixedInd_ = 0;
sizeLinkVars_ = 0;
tkralphs marked this conversation as resolved.
Show resolved Hide resolved
objAlignment_ = 0;
counterVF_ = 0;
counterUB_ = 0;
Expand Down Expand Up @@ -1048,17 +1048,6 @@ MibSModel::readProblemData()
}

delete [] colType;

for (int i = 0; i < upperDim_; i++){
if (varType_[i] == MibSVarLinking){
if (colType_[i] == 'C'){
throw CoinError("All linking variables should be integer",
"readProblemData",
"MibSModel");
}
}
}

delete mps;
}

Expand Down Expand Up @@ -3503,7 +3492,7 @@ MibSModel::setVarTypes()
posRow = binarySearch(0, lRows - 1, rowIndex, lowerRowInd);
if(posRow >= 0){
varType_[i] = MibSVarLinking;
sizeFixedInd_ ++;
sizeLinkVars_ ++;
break;
}
}
Expand Down Expand Up @@ -3531,8 +3520,12 @@ MibSModel::analyzeStructure()

for(i = 0; i < uCols; i++){
index = uColIndices[i];
if (colType_[index] != 'C'){
if(colType_[index] != 'C'){
numUpperInt_ ++;
}else if(varType_[index] == MibSVarLinking){
throw CoinError("All linking variables should be integer",
"analyzeStructure",
"MibSModel");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/MibSModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class MibSModel : public BlisModel {
int structRowNum_;

/** Size of first-stage variables in second-stage constraints **/
int sizeFixedInd_;
int sizeLinkVars_;

/** Alignment between lower and upper objectives **/
double objAlignment_;
Expand Down