Skip to content

Commit

Permalink
Aggiunto il debug ridotto -d2
Browse files Browse the repository at this point in the history
  • Loading branch information
Merry38 committed Jun 26, 2013
1 parent 747bc5c commit 604b0d7
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 8 deletions.
19 changes: 18 additions & 1 deletion src/AF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ string AF::toString() {
ostringstream desc;

for( SetArgumentsIterator i = this -> begin(); i != this -> end(); i++ ) {
desc << ( *i ) -> getName() << " attacks ";
desc << "Argument " << ( *i ) -> getName() << "\tattacks ";

SetArguments* attacks = ( *i ) -> get_attacks();
SetArgumentsIterator j = attacks -> begin();
Expand All @@ -182,6 +182,23 @@ string AF::toString() {
desc << ", " << ( *j ) -> getName();

desc << endl;

desc << "\t\tattacked by ";

SetArguments* attackers = ( *i ) -> get_attackers();
j = attackers -> begin();

if( j == attackers -> end() )
desc << "none";
else {
desc << ( *j ) -> getName();
j++;
}

for( ; j != attackers -> end(); j++ )
desc << ", " << ( *j ) -> getName();

desc << endl;
}

return desc.str();
Expand Down
1 change: 1 addition & 0 deletions src/Preferred.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ using namespace std;
int precosat_lib(stringstream *the_cnf, int num_var, int num_cl, vector<int> *result);

extern bool debug;
extern bool stages;

class Preferred
{
Expand Down
20 changes: 13 additions & 7 deletions src/Preferred_pref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,25 @@ void Preferred::pref( AF* theAF, SetArguments* theC )
this->af = theAF;
this->C = theC;

if ( debug ) {
cerr << "\tAF initialized. Showing structure\n" << endl
<< this->af->toString();
if ( stages ) {
cerr << "AF initialized. Showing structure" << endl
<< this->af->toString() << endl;
}

SetArguments e = SetArguments(),
I = SetArguments();
Grounded( &e, &I );

if ( stages )
cerr << "e: " << e << endl << "I: " << I << endl;

// Convert Grounded's output into a Labelling
Labelling first = Labelling();
for ( SetArgumentsIterator it = e.begin(); it != e.end(); ++it )
first.add_label( *it, Labelling::lab_in );
// TODO: Label I as undec and everything else as out?

if ( debug )
if ( stages )
cerr << "\tFirst Labelling: " << *(first.inargs()) << endl;

// Add the Labelling to the solutions
Expand All @@ -60,8 +63,8 @@ void Preferred::pref( AF* theAF, SetArguments* theC )
this->af->restrictTo( &I, restricted );
this->af = restricted;

if ( debug )
cerr << "\tNew AF:\n" << this->af->toString() << endl;
if ( stages )
cerr << "\tNew AF ( restricted ):\n" << this->af->toString() << endl;

// Structure used in SCCSSEQ
this->initDFSAF();
Expand All @@ -72,7 +75,7 @@ void Preferred::pref( AF* theAF, SetArguments* theC )
// Calculate the Strongly Connected Components
list<SetArguments*> S = SCCSSEQ();

if ( debug )
if ( stages )
for ( list<SetArguments*>::iterator it = S.begin(); it != S.end(); ++it )
cerr << "\tSCC: " << **it << endl;

Expand All @@ -88,6 +91,9 @@ void Preferred::pref( AF* theAF, SetArguments* theC )

boundcond( *aSCC, (*aLabelling).inargs(), &O, &I );

if ( stages )
cerr << "O: " << O << endl << "I: " << I << endl;

if ( O.empty() )
{
if ( debug )
Expand Down
9 changes: 9 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* @brief Configuration variables
*/
bool debug = false;
bool stages = false;
bool externalsat = true;
string satsolver;
int labellingconditions = 0;
Expand All @@ -35,9 +36,17 @@ int main(int argc, char *argv[])
{
// More verbose
debug = true;
stages = true;

cerr << "Debug on.\n";
}
else if( !strcmp( argv[ i ], "-d2" ) )
{
// Verbose but not that much
stages = true;

cerr << "Stages output on.\n";
}
else
{
// Custom input file
Expand Down

0 comments on commit 604b0d7

Please sign in to comment.