abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
msatSolverIo.c File Reference
#include "msatInt.h"

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START char * 
Msat_TimeStamp ()
 DECLARATIONS ///. More...
 
void Msat_SolverPrintAssignment (Msat_Solver_t *p)
 FUNCTION DEFINITIONS ///. More...
 
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 47 of file msatSolverIo.c.

48 {
49  int i;
50  printf( "Current assignments are: \n" );
51  for ( i = 0; i < p->nVars; i++ )
52  printf( "%d", i % 10 );
53  printf( "\n" );
54  for ( i = 0; i < p->nVars; i++ )
55  if ( p->pAssigns[i] == MSAT_VAR_UNASSIGNED )
56  printf( "." );
57  else
58  {
59  assert( i == MSAT_LIT2VAR(p->pAssigns[i]) );
60  if ( MSAT_LITSIGN(p->pAssigns[i]) )
61  printf( "0" );
62  else
63  printf( "1" );
64  }
65  printf( "\n" );
66 }
#define MSAT_VAR_UNASSIGNED
Definition: msatInt.h:68
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define MSAT_LIT2VAR(l)
Definition: msat.h:59
#define MSAT_LITSIGN(l)
Definition: msat.h:58
#define assert(ex)
Definition: util_old.h:213
int nVars
Definition: llb3Image.c:58
void Msat_SolverPrintClauses ( Msat_Solver_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 79 of file msatSolverIo.c.

80 {
81  Msat_Clause_t ** pClauses;
82  int nClauses, i;
83 
84  printf( "Original clauses: \n" );
85  nClauses = Msat_ClauseVecReadSize( p->vClauses );
86  pClauses = Msat_ClauseVecReadArray( p->vClauses );
87  for ( i = 0; i < nClauses; i++ )
88  {
89  printf( "%3d: ", i );
90  Msat_ClausePrint( pClauses[i] );
91  }
92 
93  printf( "Learned clauses: \n" );
94  nClauses = Msat_ClauseVecReadSize( p->vLearned );
95  pClauses = Msat_ClauseVecReadArray( p->vLearned );
96  for ( i = 0; i < nClauses; i++ )
97  {
98  printf( "%3d: ", i );
99  Msat_ClausePrint( pClauses[i] );
100  }
101 
102  printf( "Variable activity: \n" );
103  for ( i = 0; i < p->nVars; i++ )
104  printf( "%3d : %.4f\n", i, p->pdActivity[i] );
105 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_HEADER_START struct Msat_Clause_t_ Msat_Clause_t
INCLUDES ///.
Definition: msatInt.h:57
int Msat_ClauseVecReadSize(Msat_ClauseVec_t *p)
void Msat_ClausePrint(Msat_Clause_t *pC)
Definition: msatClause.c:468
Msat_Clause_t ** Msat_ClauseVecReadArray(Msat_ClauseVec_t *p)
Definition: msatClauseVec.c:85
int nVars
Definition: llb3Image.c:58
void Msat_SolverWriteDimacs ( Msat_Solver_t p,
char *  pFileName 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 118 of file msatSolverIo.c.

119 {
120  FILE * pFile;
121  Msat_Clause_t ** pClauses;
122  int nClauses, i;
123 
124  nClauses = Msat_ClauseVecReadSize(p->vClauses) + Msat_ClauseVecReadSize(p->vLearned);
125  for ( i = 0; i < p->nVars; i++ )
126  nClauses += ( p->pLevel[i] == 0 );
127 
128  pFile = fopen( pFileName, "wb" );
129  fprintf( pFile, "c Produced by Msat_SolverWriteDimacs() on %s\n", Msat_TimeStamp() );
130  fprintf( pFile, "p cnf %d %d\n", p->nVars, nClauses );
131 
132  nClauses = Msat_ClauseVecReadSize( p->vClauses );
133  pClauses = Msat_ClauseVecReadArray( p->vClauses );
134  for ( i = 0; i < nClauses; i++ )
135  Msat_ClauseWriteDimacs( pFile, pClauses[i], 1 );
136 
137  nClauses = Msat_ClauseVecReadSize( p->vLearned );
138  pClauses = Msat_ClauseVecReadArray( p->vLearned );
139  for ( i = 0; i < nClauses; i++ )
140  Msat_ClauseWriteDimacs( pFile, pClauses[i], 1 );
141 
142  // write zero-level assertions
143  for ( i = 0; i < p->nVars; i++ )
144  if ( p->pLevel[i] == 0 )
145  fprintf( pFile, "%s%d 0\n", ((p->pAssigns[i]&1)? "-": ""), i + 1 );
146 
147  fprintf( pFile, "\n" );
148  fclose( pFile );
149 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static ABC_NAMESPACE_IMPL_START char * Msat_TimeStamp()
DECLARATIONS ///.
Definition: msatSolverIo.c:163
typedefABC_NAMESPACE_HEADER_START struct Msat_Clause_t_ Msat_Clause_t
INCLUDES ///.
Definition: msatInt.h:57
int Msat_ClauseVecReadSize(Msat_ClauseVec_t *p)
Msat_Clause_t ** Msat_ClauseVecReadArray(Msat_ClauseVec_t *p)
Definition: msatClauseVec.c:85
void Msat_ClauseWriteDimacs(FILE *pFile, Msat_Clause_t *pC, int fIncrement)
Definition: msatClause.c:494
int nVars
Definition: llb3Image.c:58
char * Msat_TimeStamp ( )
static

DECLARATIONS ///.

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 alanm.nosp@m.i@ee.nosp@m.cs.be.nosp@m.rkel.nosp@m.ey.ed.nosp@m.u]

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

]

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

Synopsis [Returns the time stamp.]

Description []

SideEffects []

SeeAlso []

Definition at line 163 of file msatSolverIo.c.

164 {
165  static char Buffer[100];
166  time_t ltime;
167  char * TimeStamp;
168  // get the current time
169  time( &ltime );
170  TimeStamp = asctime( localtime( &ltime ) );
171  TimeStamp[ strlen(TimeStamp) - 1 ] = 0;
172  strcpy( Buffer, TimeStamp );
173  return Buffer;
174 }
char * strcpy()
int strlen()