| 75 | #ifdef SORT_VARIABLES_IN_INCREASING_ORDER |
| 76 | |
| 77 | std::vector<std::pair<int, double>> ordered_coefficients(const LinearExpression* expr, bool increasing_order /* = true*/) { |
| 78 | std::vector<std::pair<int, double>> coeffs(expr->coefficients().begin(), expr->coefficients().end()); |
| 79 | |
| 80 | // it is possible to make the order an parameter when constructing SortObj, but this is a bit more efficient |
| 81 | if (increasing_order) { |
| 82 | struct SortIncreasing { |
| 83 | bool operator()(const std::pair<int, double>& a, const std::pair<int, double>& b) { |
| 84 | return a.first < b.first; |
| 85 | } |
| 86 | }; |
| 87 | std::sort(coeffs.begin(), coeffs.end(), SortIncreasing()); |
| 88 | } |
| 89 | else { |
| 90 | struct SortDecreasing { |
| 91 | bool operator()(const std::pair<int, double>& a, const std::pair<int, double>& b) { |
| 92 | return a.first > b.first; |
| 93 | } |
| 94 | }; |
| 95 | std::sort(coeffs.begin(), coeffs.end(), SortDecreasing()); |
| 96 | } |
| 97 | |
| 98 | return coeffs; |
| 99 | } |
| 100 | #endif |
| 101 | |
| 102 | } |
no test coverage detected