src/sat/msat/msatSolverIo.c File Reference

#include "msatInt.h"
Include dependency graph for msatSolverIo.c:

Go to the source code of this file.

Functions

static char * Msat_TimeStamp ()
void Msat_SolverPrintAssignment (Msat_Solver_t *p)
void Msat_SolverPrintClauses (Msat_Solver_t *p)
void Msat_SolverWriteDimacs (Msat_Solver_t *p, char *pFileName)

Function Documentation

void Msat_SolverPrintAssignment ( Msat_Solver_t p  ) 

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 44 of file msatSolverIo.c.

00045 {
00046     int i;
00047     printf( "Current assignments are: \n" );
00048     for ( i = 0; i < p->nVars; i++ )
00049         printf( "%d", i % 10 );
00050     printf( "\n" );
00051     for ( i = 0; i < p->nVars; i++ )
00052         if ( p->pAssigns[i] == MSAT_VAR_UNASSIGNED )
00053             printf( "." );
00054         else
00055         {
00056             assert( i == MSAT_LIT2VAR(p->pAssigns[i]) );
00057             if ( MSAT_LITSIGN(p->pAssigns[i]) )
00058                 printf( "0" );
00059             else 
00060                 printf( "1" );
00061         }
00062     printf( "\n" );
00063 }

void Msat_SolverPrintClauses ( Msat_Solver_t p  ) 

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 76 of file msatSolverIo.c.

00077 {
00078     Msat_Clause_t ** pClauses;
00079     int nClauses, i;
00080 
00081     printf( "Original clauses: \n" );
00082     nClauses = Msat_ClauseVecReadSize( p->vClauses );
00083     pClauses = Msat_ClauseVecReadArray( p->vClauses );
00084     for ( i = 0; i < nClauses; i++ )
00085     {
00086         printf( "%3d: ", i );
00087         Msat_ClausePrint( pClauses[i] );
00088     }
00089 
00090     printf( "Learned clauses: \n" );
00091     nClauses = Msat_ClauseVecReadSize( p->vLearned );
00092     pClauses = Msat_ClauseVecReadArray( p->vLearned );
00093     for ( i = 0; i < nClauses; i++ )
00094     {
00095         printf( "%3d: ", i );
00096         Msat_ClausePrint( pClauses[i] );
00097     }
00098 
00099     printf( "Variable activity: \n" );
00100     for ( i = 0; i < p->nVars; i++ )
00101         printf( "%3d : %.4f\n", i, p->pdActivity[i] );
00102 }

void Msat_SolverWriteDimacs ( Msat_Solver_t p,
char *  pFileName 
)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 115 of file msatSolverIo.c.

00116 {
00117     FILE * pFile;
00118     Msat_Clause_t ** pClauses;
00119     int nClauses, i;
00120 
00121     nClauses = Msat_ClauseVecReadSize(p->vClauses) + Msat_ClauseVecReadSize(p->vLearned);
00122     for ( i = 0; i < p->nVars; i++ )
00123         nClauses += ( p->pLevel[i] == 0 );
00124 
00125     pFile = fopen( pFileName, "wb" );
00126     fprintf( pFile, "c Produced by Msat_SolverWriteDimacs() on %s\n", Msat_TimeStamp() );
00127     fprintf( pFile, "p cnf %d %d\n", p->nVars, nClauses );
00128 
00129     nClauses = Msat_ClauseVecReadSize( p->vClauses );
00130     pClauses = Msat_ClauseVecReadArray( p->vClauses );
00131     for ( i = 0; i < nClauses; i++ )
00132         Msat_ClauseWriteDimacs( pFile, pClauses[i], 1 );
00133 
00134     nClauses = Msat_ClauseVecReadSize( p->vLearned );
00135     pClauses = Msat_ClauseVecReadArray( p->vLearned );
00136     for ( i = 0; i < nClauses; i++ )
00137         Msat_ClauseWriteDimacs( pFile, pClauses[i], 1 );
00138 
00139     // write zero-level assertions
00140     for ( i = 0; i < p->nVars; i++ )
00141         if ( p->pLevel[i] == 0 )
00142             fprintf( pFile, "%s%d 0\n", ((p->pAssigns[i]&1)? "-": ""), i + 1 );
00143 
00144     fprintf( pFile, "\n" );
00145     fclose( pFile );
00146 }

char * Msat_TimeStamp (  )  [static]

CFile****************************************************************

FileName [msatSolverIo.c]

PackageName [A C version of SAT solver MINISAT, originally developed in C++ by Niklas Een and Niklas Sorensson, Chalmers University of Technology, Sweden: http://www.cs.chalmers.se/~een/Satzoo.]

Synopsis [Input/output of CNFs.]

Author [Alan Mishchenko <alanmi@eecs.berkeley.edu>]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - January 1, 2004.]

Revision [

Id
msatSolverIo.c,v 1.0 2004/01/01 1:00:00 alanmi Exp

] DECLARATIONS ///

Function*************************************************************

Synopsis [Returns the time stamp.]

Description []

SideEffects []

SeeAlso []

Definition at line 160 of file msatSolverIo.c.

00161 {
00162     static char Buffer[100];
00163         time_t ltime;
00164         char * TimeStamp;
00165     // get the current time
00166         time( &ltime );
00167         TimeStamp = asctime( localtime( &ltime ) );
00168         TimeStamp[ strlen(TimeStamp) - 1 ] = 0;
00169     strcpy( Buffer, TimeStamp );
00170     return Buffer;
00171 }


Generated on Tue Jan 5 12:19:40 2010 for abc70930 by  doxygen 1.6.1