#pragma once /*++ Copyright (c) 2017 Microsoft Corporation Module Name: Abstract: Author: Lev Nachmanson (levnach) Revision History: --*/ #include #include "math/lp/static_matrix.h" namespace lp { class column_namer { public: virtual std::string get_variable_name(unsigned j) const = 0; template std::ostream & 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); return out; } 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_variable_name(it.second); } } }; }