Skip to content

Commit 29c5c20

Browse files
NikolajBjornerlevnach
authored andcommitted
use more descriptive functions than casting comparisons
1 parent 7fb40e8 commit 29c5c20

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/math/lp/dioph_eq.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -1801,12 +1801,12 @@ namespace lp {
18011801
lp_status st = lra.find_feasible_solution();
18021802
if (st == lp_status::CANCELLED)
18031803
return false;
1804-
if ((int)st >= (int)lp::lp_status::FEASIBLE)
1804+
if (lp::is_sat(st))
18051805
return false;
18061806
lra.get_infeasibility_explanation(m_infeas_explanation);
18071807
return true;
18081808
}
1809-
1809+
18101810

18111811
// returns true only on a conflict
18121812
bool tighten_bound_kind(const mpq& g, unsigned j, const mpq& ub, bool upper) {
@@ -1840,10 +1840,8 @@ namespace lp {
18401840
lra.update_column_type_and_bound(j, kind, bound, dep);
18411841

18421842
lp_status st = lra.find_feasible_solution();
1843-
if ((int)st >= (int)lp::lp_status::FEASIBLE) {
1843+
if (is_sat(st) || st == lp::lp_status::CANCELLED)
18441844
return false;
1845-
}
1846-
if (st == lp_status::CANCELLED) return false;
18471845
lra.get_infeasibility_explanation(m_infeas_explanation);
18481846
return true;
18491847
}
@@ -2069,7 +2067,7 @@ namespace lp {
20692067
TRACE("dio_br", tout << "st:" << lp_status_to_string(st) << std::endl;);
20702068
if (st == lp_status::CANCELLED)
20712069
return lia_move::undef;
2072-
else if ((int)st >= (int)(lp_status::FEASIBLE)) {
2070+
else if (lp::is_sat(st)) {
20732071
// have a feasible solution
20742072
unsigned n_of_ii = get_number_of_int_inf();
20752073
TRACE("dio_br", tout << "n_of_ii:" << n_of_ii << "\n";);

src/math/lp/lp_settings.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,14 @@ enum class lp_status {
7474
OPTIMAL
7575
};
7676

77+
inline bool is_sat(lp_status st) {
78+
return st == lp_status::FEASIBLE || st == lp_status::OPTIMAL;
79+
}
80+
7781
// when the ratio of the vector length to domain size to is greater than the return value we switch to solve_By_for_T_indexed_only
7882
template <typename X>
7983
unsigned ratio_of_index_size_to_all_size() {
80-
return 10;
81-
84+
return 10;
8285
}
8386

8487
const char* lp_status_to_string(lp_status status);

0 commit comments

Comments
 (0)