#ifndef __GLOBALS_H__ #define __GLOBALS_H__ enum {FAILURE=0,SUCCESS=1}; enum {FALSE=-1,TRUE=1}; /** Every clause will be read into such structure on initialization */ typedef struct clause{ int literalCount; int* literals; int currentStatus; int *stepsToLastFlip; int mostRecentlyFlipped; void* data; } CLAUSE; typedef struct literal{ /* Number of the literal as defined in input file */ int literalNumber; //WARNING: Do not modify this value. int countTrueClauses; int countFalseClauses; void * data; int value; //initialized to 0 } LITERAL; /** These values would be initialized apriori */ int numberOfClauses; int numberOfLiterals; int maxLiteralsPerClause; CLAUSE* clauses; LITERAL* literals; // -- WALKSAT -- // //extern int resultTryNumber; // Counts #try when WALKSAT terminates //extern int resultFlipNumber; // Counts #flip at #try when WALKSAT terminates /* This function will be called by the main function to initialize the above variables*/ /* DO NOT CALL THIS FUNCTION IN ANY ALGORITHM */ void readInputFile(char* filename); /* Special function provided since the literal number and the array index differ by 1. This function requires the literal number and would do the necessary mapping*/ /* Note: The correctness of this function depends on the fact that the array of LITERALS is not re-ordered by the algorithm. Assertion would fail if that happens */ LITERAL* getLiteral(int literalNumber); /* Sets the value of a literal and returns the previous value. 0 returned if literal was not set previously.*/ /* Assertion fails if the literalNumber is out of range */ int setLiteral(int literalNumber, int value); /* Returns the previous value of the literal */ /* Assertion fails if literal number is out of range */ int resetLiteral(int literalNumber); /* Returns 0 if the clause does not have the literal. Returns +literalNumber of the literal occurs as positive value and -literalNumber of the literal occurs as its negation. The literal number that is passed may be positive or negative. It is not checked for any sort of range conditions.!!! If more than one instances of the literal occur in a clause then this function is NOT guaranteed to return correctly. */ int hasLiteral(CLAUSE* clause, int literalNumber); #endif