Skip to content

Commit

Permalink
Allow setting the prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
msoos committed May 8, 2024
1 parent c40544b commit 7279e59
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
22 changes: 11 additions & 11 deletions src/Algebraic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ bool Permutation::getImage(const BLit* orig, size_t sz, vector<BLit>& img) const

// printing cycles

void Permutation::print(std::ostream& out) const
void Permutation::print(std::ostream& out, const char* prefix) const
{
out << "c ";
out << prefix;
for (auto lit : getCycleReprs()) {
out << "( ";
vector<BLit> cyc;
Expand Down Expand Up @@ -376,15 +376,15 @@ void Group::addMatrix(shared_ptr<Matrix> m)
if (conf->verbosity > 0) {
cout << "c -> Matrix with " << m->nbRows() << " rows and "
<< m->nbColumns() << " columns detected" << endl;
} else if (conf->verbosity > 2) m->print(cout);
} else if (conf->verbosity > 2) m->print(cout, "c ");
}

void Group::print(std::ostream& out) const
void Group::print(std::ostream& out, const char* prefix) const
{
out << "c -- Permutations:" << endl;
for (const auto& p : permutations) p->print(out);
out << "c -- Matrices:" << endl;
for (const auto& m : matrices) m->print(out);
out << prefix << "-- Permutations:" << endl;
for (const auto& p : permutations) p->print(out, prefix);
out << prefix << "-- Matrices:" << endl;
for (const auto& m : matrices) m->print(out, prefix);
}

void Group::get_perms_to(vector<std::unordered_map<BLit, BLit>>& out)
Expand Down Expand Up @@ -864,11 +864,11 @@ Matrix::~Matrix()
}
}

void Matrix::print(std::ostream& out) const
void Matrix::print(std::ostream& out, const char* prefix) const
{
out << "c rows " << nbRows() << " columns " << nbColumns() << endl;
out << prefix << "rows " << nbRows() << " columns " << nbColumns() << endl;
for (auto row : rows) {
out << "c ";
out << prefix;
for (auto lit : *row) out << lit << " ";
out << endl;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Algebraic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Permutation : public std::enable_shared_from_this<Permutation>
uint32_t supportSize() const;
bool isIdentity();

void print(std::ostream& out) const;
void print(std::ostream& out, const char* prefix) const;

bool formsMatrixWith(shared_ptr<Permutation> other);
std::pair<shared_ptr<Permutation>, shared_ptr<Permutation> > getLargest(
Expand Down Expand Up @@ -101,7 +101,7 @@ class Matrix
public:
Matrix(Config* conf);
~Matrix();
void print(std::ostream& out) const;
void print(std::ostream& out, const char* prefix) const;

void add(vector<BLit>* row);
uint32_t nbColumns() const;
Expand Down Expand Up @@ -131,7 +131,7 @@ class Group

void add(shared_ptr<Permutation> p);
void checkColumnInterchangeability(shared_ptr<Matrix> m);
void print(std::ostream& out) const;
void print(std::ostream& out, const char* prefix) const;
shared_ptr<Matrix> getInitialMatrix();
void addMatrices();

Expand Down
28 changes: 14 additions & 14 deletions src/breakid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@ uint64_t BreakID::get_num_subgroups() const
return dat->subgroups.size();
}

void BreakID::print_subgroups(std::ostream& out) {
void BreakID::print_subgroups(std::ostream& out, const char* prefix) {
for (auto& grp : dat->subgroups) {
out
<< "group size: " << grp->getSize()
<< " support: " << grp->getSupportSize() << endl;

grp->print(out);
grp->print(out, prefix);
}
}

Expand Down Expand Up @@ -191,15 +191,15 @@ void BreakID::break_symm()
}
}

void BreakID::print_symm_break_stats()
void BreakID::print_symm_break_stats(const char* prefix)
{
cout << "c matrices detected: " << dat->totalNbMatrices << endl;
cout << "c row swaps detected: " << dat->totalNbRowSwaps << endl;
cout << "c extra binary symmetry breaking clauses added: " << dat->brkr->getNbBinClauses() << "\n";
cout << "c regular symmetry breaking clauses added: " << dat->brkr->getNbRegClauses() << "\n";
cout << "c row interchangeability breaking clauses added: " << dat->brkr->getNbRowClauses() << "\n";
cout << "c total symmetry breaking clauses added: " << dat->brkr->getAddedNbClauses() << "\n";
cout << "c auxiliary variables introduced: " << dat->brkr->getAuxiliaryNbVars() << "\n";
cout << prefix << "matrices detected: " << dat->totalNbMatrices << endl;
cout << prefix << "row swaps detected: " << dat->totalNbRowSwaps << endl;
cout << prefix << "extra binary symmetry breaking clauses added: " << dat->brkr->getNbBinClauses() << "\n";
cout << prefix << "regular symmetry breaking clauses added: " << dat->brkr->getNbRegClauses() << "\n";
cout << prefix << "row interchangeability breaking clauses added: " << dat->brkr->getNbRowClauses() << "\n";
cout << prefix << "total symmetry breaking clauses added: " << dat->brkr->getAddedNbClauses() << "\n";
cout << prefix << "auxiliary variables introduced: " << dat->brkr->getAuxiliaryNbVars() << "\n";
}

uint32_t BreakID::get_num_break_cls()
Expand All @@ -217,15 +217,15 @@ vector<vector<BID::BLit>> BreakID::get_brk_cls()
return dat->brkr->get_brk_cls();
}

void BreakID::print_perms_and_matrices(std::ostream& out)
void BreakID::print_perms_and_matrices(std::ostream& out, const char* prefix)
{
for (auto grp : dat->subgroups) {
grp->print(out);
grp->print(out, prefix);
}
}

void BreakID::print_generators(std::ostream& out) {
dat->theory->group->print(cout);
void BreakID::print_generators(std::ostream& out, const char* prefix) {
dat->theory->group->print(cout, prefix);
}

void BreakID::get_perms(vector<std::unordered_map<BLit, BLit> >* out)
Expand Down
8 changes: 4 additions & 4 deletions src/breakid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ struct BreakID {
DLL_PUBLIC void break_symm();

//Print info
DLL_PUBLIC void print_subgroups(std::ostream& out);
DLL_PUBLIC void print_symm_break_stats();
DLL_PUBLIC void print_perms_and_matrices(std::ostream& out);
DLL_PUBLIC void print_generators(std::ostream& out);
DLL_PUBLIC void print_subgroups(std::ostream& out, const char* prefix = "c ");
DLL_PUBLIC void print_symm_break_stats(const char* prefix = "c ");
DLL_PUBLIC void print_perms_and_matrices(std::ostream& out, const char* prefix = "c ");
DLL_PUBLIC void print_generators(std::ostream& out, const char* prefix = "c ");

//Get info
DLL_PUBLIC uint32_t get_num_generators();
Expand Down

0 comments on commit 7279e59

Please sign in to comment.