diff --git a/src/multiwinner/auction.cc b/src/multiwinner/auction.cc index fce0541..ffa6b97 100644 --- a/src/multiwinner/auction.cc +++ b/src/multiwinner/auction.cc @@ -18,12 +18,10 @@ int r_auction::elect_and_update(std::vector & elected, // to the sum (for all non-elected candidates). Note the potential // for vote-management. size_t counter = 0; - double voters = 0; for (election_t::const_iterator pos = ballots.begin(); pos != ballots.end(); ++pos) { assert(pos->rated); - voters += pos->get_weight(); // not req'd? double adjust = 0; // maximum if not cumulative, sum if so. ordering::const_iterator sec; diff --git a/src/multiwinner/qpq.cc b/src/multiwinner/qpq.cc index beb41e3..872143e 100644 --- a/src/multiwinner/qpq.cc +++ b/src/multiwinner/qpq.cc @@ -76,7 +76,7 @@ std::list QPQ::get_council(std::vector & eliminated, contributing_weights(num_candidates), quotients(num_candidates); std::list council; - size_t num_elected = 0, num_elim = 0; + size_t num_elected = 0; std::vector elected(num_candidates, false); @@ -104,7 +104,7 @@ std::list QPQ::get_council(std::vector & eliminated, counter = 0; double inactive_ballot_fraction = 0, - active_ballots = 0, sum_weights = 0; + active_ballots = 0; // Bah dual track. Get the active and inactive ballot data. @@ -112,10 +112,7 @@ std::list QPQ::get_council(std::vector & eliminated, ordering::const_iterator contribute = ballot_contribution(eliminated, elected, *pos); - sum_weights += elect_fraction[counter] * pos->get_weight(); - if (contribute == pos->contents.end()) { - //inactive_ballots += pos->get_weight(); inactive_ballot_fraction += elect_fraction[counter] * pos->get_weight(); } else { @@ -228,7 +225,6 @@ std::list QPQ::get_council(std::vector & eliminated, // reset set to true, tail-recurse. Otherwise, just loop // through. eliminated[lowest] = true; - ++num_elim; // TODO: Heuristic that automatically elects rest if // just enough to fill council. diff --git a/src/multiwinner/qrange_stv.cc b/src/multiwinner/qrange_stv.cc index 127438b..281df3f 100644 --- a/src/multiwinner/qrange_stv.cc +++ b/src/multiwinner/qrange_stv.cc @@ -144,7 +144,6 @@ int QRangeSTV::elect_next(size_t council_size, size_t num_candidates, // i.e... double p_y = quota / count_quad[winner]; - double verify = 0; election_t::iterator pos = altered_ballots.begin(); @@ -165,7 +164,6 @@ int QRangeSTV::elect_next(size_t council_size, size_t num_candidates, pos = altered_ballots.erase(pos); } else { pos->set_weight(std::max(0.0, pos->get_weight() - subtr)); - verify += pos->get_weight() * winner_score; ++pos; } } diff --git a/src/tools/tools.cc b/src/tools/tools.cc index 8bc3322..179c3e4 100644 --- a/src/tools/tools.cc +++ b/src/tools/tools.cc @@ -457,7 +457,12 @@ std::vector > power_set( } } - assert(power_set_out.size() == (1ULL << num_hopefuls)); + // Can't use assert because then clang will complain when making + // a Release build. + if (power_set_out.size() != (1ULL << num_hopefuls)) { + throw std::logic_error("power_set: output set is of the wrong size! " + "This is a bug."); + } return power_set_out; } diff --git a/src/tools/tools.h b/src/tools/tools.h index f0f6883..cfe7ff4 100644 --- a/src/tools/tools.h +++ b/src/tools/tools.h @@ -9,6 +9,8 @@ #include #include +typedef ptrdiff_t ssize_t; /* ssize_t is not part of the C standard */ + const double PI = 4 * atan(1); // Transforms parameters of 0 1 2 ... skip skip+1 ... into