#pragma once /*++ Copyright (c) 2017 Microsoft Corporation Module Name: Abstract: Author: Lev Nachmanson (levnach) Revision History: --*/ #include #include "util/lp/static_matrix.h" namespace lp { class column_namer { public: virtual std::string get_column_name(unsigned j) const = 0; template void print_row(const row_strip & row, std::ostream & out) const { vector> coeff; for (auto & p : row) { coeff.push_back(std::make_pair(p.coeff(), p.var())); } print_linear_combination_of_column_indices(coeff, out); } template void print_linear_combination_of_column_indices_only(const vector> & coeffs, std::ostream & out) const { bool first = true; for (const auto & it : coeffs) { auto val = it.first; if (first) { first = false; } else { if (numeric_traits::is_pos(val)) { out << " + "; } else { out << " - "; val = -val; } } if (val == -numeric_traits::one()) out << " - "; else if (val != numeric_traits::one()) out << T_to_string(val); out << "v" << it.second; } } template void print_linear_combination_of_column_indices_std(const vector> & coeffs, std::ostream & out) const { bool first = true; for (const auto & it : coeffs) { auto val = it.first; if (first) { first = false; } else { if (numeric_traits::is_pos(val)) { out << " + "; } else { out << " - "; val = -val; } } if (val == -numeric_traits::one()) out << " - "; else if (val != numeric_traits::one()) out << val; out << get_column_name(it.second); } } template void print_linear_combination_of_column_indices(const vector> & coeffs, std::ostream & out) const { bool first = true; for (const auto & it : coeffs) { auto val = it.first; if (first) { first = false; } else { if (numeric_traits::is_pos(val)) { out << " + "; } else { out << " - "; val = -val; } } if (val == -numeric_traits::one()) out << " - "; else if (val != numeric_traits::one()) out << val; out << get_column_name(it.second); } } }; }