Skip to content

Commit 84573f8

Browse files
committed
Priortise vbs more. Fix some comments
1 parent 00d6c59 commit 84573f8

File tree

1 file changed

+26
-38
lines changed

1 file changed

+26
-38
lines changed

highs/mip/HighsTransformedLp.cpp

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ bool HighsTransformedLp::transformSNFRelaxation(
628628
double ub, bool isVub) {
629629
// a_j coefficient of y_j in row. c_j coefficient of x_j in row.
630630
// u_j, l_j, closest simple bounds imposed on y_j.
631-
// y_j <= l'_j x_j + d_j || y_j >= u'_j x_j + d_j
631+
// y_j <= u'_j x_j + d_j || y_j >= l'_j x_j + d_j
632632
// variable bound can only be used if following properties respected:
633633
// |l'_j| <= 1e6 && |u'_j| <= 1e6
634634
// if a_j > 0
@@ -768,56 +768,44 @@ bool HighsTransformedLp::transformSNFRelaxation(
768768
}
769769
} else {
770770
// Decide whether to use {simple, variable} {lower, upper} bound
771-
if (lbDist[col] < ubDist[col] - mip.mipdata_->feastol) {
772-
if (!checkValidityVB(bestVlb[col].first, bestVlb[col].second, vals[i],
771+
bool vlbValid = checkValidityVB(bestVlb[col].first, bestVlb[col].second, vals[i],
773772
bestVlb[col].first == -1
774773
? 0
775774
: vectorsum.getValue(bestVlb[col].first),
776-
lb, ub, false)) {
777-
boundTypes[col] = BoundType::kSimpleLb;
778-
} else if (simpleLbDist[col] > lbDist[col] + mip.mipdata_->feastol) {
779-
boundTypes[col] = BoundType::kVariableLb;
780-
} else
781-
boundTypes[col] = BoundType::kSimpleLb;
782-
} else if (ubDist[col] < lbDist[col] - mip.mipdata_->feastol) {
783-
if (!checkValidityVB(bestVub[col].first, bestVub[col].second, vals[i],
775+
lb, ub, false);
776+
bool vubValid = checkValidityVB(bestVub[col].first, bestVub[col].second, vals[i],
784777
bestVub[col].first == -1
785778
? 0
786779
: vectorsum.getValue(bestVub[col].first),
787-
lb, ub, true)) {
788-
boundTypes[col] = BoundType::kSimpleUb;
789-
} else if (simpleUbDist[col] > ubDist[col] + mip.mipdata_->feastol) {
790-
boundTypes[col] = BoundType::kVariableUb;
791-
} else {
792-
boundTypes[col] = BoundType::kSimpleUb;
793-
}
780+
lb, ub, true);
781+
BoundType boundType = BoundType::kSimpleLb;
782+
if (lbDist[col] < ubDist[col] - mip.mipdata_->feastol && vlbValid) {
783+
boundType = BoundType::kVariableLb;
784+
} else if (ubDist[col] < lbDist[col] - mip.mipdata_->feastol && vubValid) {
785+
boundType = BoundType::kVariableUb;
786+
} else if (vals[i] > 0 && vlbValid) {
787+
boundType = BoundType::kVariableLb;
788+
} else if (vals[i] < 0 && vubValid) {
789+
boundType = BoundType::kVariableUb;
790+
} else if (vlbValid) {
791+
boundType = BoundType::kVariableLb;
792+
} else if (vubValid) {
793+
boundType = BoundType::kVariableUb;
794+
} else if (lbDist[col] < ubDist[col] - mip.mipdata_->feastol) {
795+
boundType = BoundType::kSimpleLb;
796+
} else if (ubDist[col] < lbDist[col] - mip.mipdata_->feastol) {
797+
boundType = BoundType::kSimpleUb;
794798
} else if (vals[i] > 0) {
795-
if (checkValidityVB(bestVlb[col].first, bestVlb[col].second, vals[i],
796-
bestVlb[col].first == -1
797-
? 0
798-
: vectorsum.getValue(bestVlb[col].first),
799-
lb, ub, false)) {
800-
boundTypes[col] = BoundType::kVariableLb;
801-
} else {
802-
boundTypes[col] = BoundType::kSimpleLb;
803-
}
799+
boundType = BoundType::kSimpleLb;
804800
} else {
805-
if (checkValidityVB(bestVub[col].first, bestVub[col].second, vals[i],
806-
bestVub[col].first == -1
807-
? 0
808-
: vectorsum.getValue(bestVub[col].first),
809-
lb, ub, true)) {
810-
boundTypes[col] = BoundType::kVariableUb;
811-
} else {
812-
boundTypes[col] = BoundType::kSimpleUb;
813-
}
801+
boundType = BoundType::kSimpleUb;
814802
}
815803

816804
double vbcoef;
817805
double substsolval;
818806
double aggrconstant;
819807
HighsInt vbcol;
820-
switch (boundTypes[col]) {
808+
switch (boundType) {
821809
case BoundType::kSimpleLb:
822810
// Case (1) -> a_j > 0, y'_j -> N- Case (2) -> a_j < 0, y'_j ->N+
823811
// (1) y'_j = -a_j(y_j - u_j), 0 <= y'_j <= a_j(u_j - l_j)x_j, x_j = 1
@@ -887,7 +875,7 @@ bool HighsTransformedLp::transformSNFRelaxation(
887875
tmpSnfrRhs -= aggrconstant;
888876
break;
889877
case BoundType::kVariableUb:
890-
// vub: y_j >= u'_j x_j + d_j. c_j is the coefficient of x_j in row
878+
// vub: y_j <= u'_j x_j + d_j. c_j is the coefficient of x_j in row
891879
// Case (1) -> a_j > 0, y'_j -> N+ Case (2) -> a_j < 0, y'_j ->N-
892880
// (1) y'_j = a_j(y_j - d_j) + c_j * x_j),
893881
// 0 <= y'_j <= (a_j u'_j + c_j)x_j

0 commit comments

Comments
 (0)