Skip to content

Commit 5796e88

Browse files
committed
use vector instead of unordered_map in gomory
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
1 parent a3529a0 commit 5796e88

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/math/lp/gomory.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,8 @@ struct create_cut {
519519
lia_move gomory::get_gomory_cuts(unsigned num_cuts) {
520520
struct cut_result {u_dependency *dep; lar_term t; mpq k; int polarity; lpvar j;};
521521
vector<cut_result> big_cuts;
522-
struct polar_pair {int polarity; u_dependency *dep;};
523-
std::unordered_map<lpvar, polar_pair> polar_vars;
522+
struct polar_info {lpvar j; int polarity; u_dependency *dep;};
523+
vector<polar_info> polar_vars;
524524
unsigned_vector columns_for_cuts = gomory_select_int_infeasible_vars(num_cuts);
525525

526526
// define inline helper functions
@@ -556,7 +556,7 @@ struct create_cut {
556556
continue;
557557
cut_result cr = {cc.m_dep, lia.m_t, lia.m_k, cc.m_polarity, j};
558558
if (abs(cr.polarity) == 1) // need to delay the update of the bounds for j in a polar case, because simplify_inequality relies on the old bounds
559-
polar_vars[j] = {cr.polarity, cc.m_dep};
559+
polar_vars.push_back( {j, cr.polarity, cc.m_dep} );
560560

561561
if (!is_small_cut(lia.m_t)) {
562562
big_cuts.push_back(cr);
@@ -584,12 +584,12 @@ struct create_cut {
584584

585585
// this way we create bounds for the variables in polar cases even where the terms had big numbers
586586
for (auto const& p : polar_vars) {
587-
if (p.second.polarity == 1) {
588-
lra.update_column_type_and_bound(p.first, lp::lconstraint_kind::LE, floor(lra.get_column_value(p.first).x), p.second.dep);
587+
if (p.polarity == 1) {
588+
lra.update_column_type_and_bound(p.j, lp::lconstraint_kind::LE, floor(lra.get_column_value(p.j).x), p.dep);
589589
}
590590
else {
591-
SASSERT(p.second.polarity == -1);
592-
lra.update_column_type_and_bound(p.first, lp::lconstraint_kind::GE, ceil(lra.get_column_value(p.first).x), p.second.dep);
591+
SASSERT(p.polarity == -1);
592+
lra.update_column_type_and_bound(p.j, lp::lconstraint_kind::GE, ceil(lra.get_column_value(p.j).x), p.dep);
593593
}
594594
}
595595

0 commit comments

Comments
 (0)