ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
msatOrderJ.c File Reference
#include "msatInt.h"
Include dependency graph for msatOrderJ.c:

Go to the source code of this file.

Classes

struct  Msat_OrderVar_t_
 
struct  Msat_OrderRing_t_
 
struct  Msat_Order_t_
 DECLARATIONS ///. More...
 

Macros

#define Msat_OrderVarIsInBoundary(p, i)
 
#define Msat_OrderVarIsAssigned(p, i)
 
#define Msat_OrderVarIsUsedInCone(p, i)
 
#define Msat_OrderRingForEachEntry(pRing, pVar, pNext)
 

Typedefs

typedef typedefABC_NAMESPACE_IMPL_START struct Msat_OrderVar_t_ Msat_OrderVar_t
 DECLARATIONS ///.
 
typedef struct Msat_OrderRing_t_ Msat_OrderRing_t
 

Functions

Msat_Order_tMsat_OrderAlloc (Msat_Solver_t *pSat)
 FUNCTION DEFINITIONS ///.
 
void Msat_OrderSetBounds (Msat_Order_t *p, int nVarsMax)
 
void Msat_OrderClean (Msat_Order_t *p, Msat_IntVec_t *vCone)
 
int Msat_OrderCheck (Msat_Order_t *p)
 
void Msat_OrderFree (Msat_Order_t *p)
 
int Msat_OrderVarSelect (Msat_Order_t *p)
 
void Msat_OrderVarAssigned (Msat_Order_t *p, int Var)
 
void Msat_OrderVarUnassigned (Msat_Order_t *p, int Var)
 
void Msat_OrderUpdate (Msat_Order_t *p, int Var)
 

Variables

clock_t timeSelect
 DECLARATIONS ///.
 
clock_t timeAssign
 

Macro Definition Documentation

◆ Msat_OrderRingForEachEntry

#define Msat_OrderRingForEachEntry ( pRing,
pVar,
pNext )
Value:
for ( pVar = pRing, \
pNext = pVar? pVar->pNext : NULL; \
pVar; \
pVar = (pNext != pRing)? pNext : NULL, \
pNext = pVar? pVar->pNext : NULL )

Definition at line 74 of file msatOrderJ.c.

74#define Msat_OrderRingForEachEntry( pRing, pVar, pNext ) \
75 for ( pVar = pRing, \
76 pNext = pVar? pVar->pNext : NULL; \
77 pVar; \
78 pVar = (pNext != pRing)? pNext : NULL, \
79 pNext = pVar? pVar->pNext : NULL )

◆ Msat_OrderVarIsAssigned

#define Msat_OrderVarIsAssigned ( p,
i )
Value:
((p)->pSat->pAssigns[i] != MSAT_VAR_UNASSIGNED)
Cube * p
Definition exorList.c:222
#define MSAT_VAR_UNASSIGNED
Definition msatInt.h:68

Definition at line 70 of file msatOrderJ.c.

◆ Msat_OrderVarIsInBoundary

#define Msat_OrderVarIsInBoundary ( p,
i )
Value:
((p)->pVars[i].pNext)

Definition at line 69 of file msatOrderJ.c.

◆ Msat_OrderVarIsUsedInCone

#define Msat_OrderVarIsUsedInCone ( p,
i )
Value:
((p)->pSat->vVarsUsed->pArray[i])

Definition at line 71 of file msatOrderJ.c.

Typedef Documentation

◆ Msat_OrderRing_t

Definition at line 37 of file msatOrderJ.c.

◆ Msat_OrderVar_t

typedef typedefABC_NAMESPACE_IMPL_START struct Msat_OrderVar_t_ Msat_OrderVar_t

DECLARATIONS ///.

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

FileName [msatOrder.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 [The manager of variable assignment.]

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
msatOrder.c,v 1.0 2005/05/30 1:00:00 alanmi Exp

]

Definition at line 36 of file msatOrderJ.c.

Function Documentation

◆ Msat_OrderAlloc()

Msat_Order_t * Msat_OrderAlloc ( Msat_Solver_t * pSat)

FUNCTION DEFINITIONS ///.

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

Synopsis [Allocates the ordering structure.]

Description []

SideEffects []

SeeAlso []

Definition at line 102 of file msatOrderJ.c.

103{
104 Msat_Order_t * p;
105 p = ALLOC( Msat_Order_t, 1 );
106 memset( p, 0, sizeof(Msat_Order_t) );
107 p->pSat = pSat;
108 Msat_OrderSetBounds( p, pSat->nVarsAlloc );
109 return p;
110}
#define ALLOC(type, num)
Definition avl.h:27
struct Msat_Order_t_ Msat_Order_t
Definition msatInt.h:59
void Msat_OrderSetBounds(Msat_Order_t *p, int nVarsMax)
Definition msatOrderJ.c:123
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Msat_OrderCheck()

int Msat_OrderCheck ( Msat_Order_t * p)

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

Synopsis [Checks that the J-boundary is okay.]

Description []

SideEffects []

SeeAlso []

Definition at line 171 of file msatOrderJ.c.

172{
173 Msat_OrderVar_t * pVar, * pNext;
174 Msat_IntVec_t * vRound;
175 int * pRound, nRound;
176 int * pVars, nVars, i, k;
177 int Counter = 0;
178
179 // go through all the variables in the boundary
180 Msat_OrderRingForEachEntry( p->rVars.pRoot, pVar, pNext )
181 {
182 assert( !Msat_OrderVarIsAssigned(p, pVar->Num) );
183 // go though all the variables in the neighborhood
184 // and check that it is true that there is least one assigned
185 vRound = (Msat_IntVec_t *)Msat_ClauseVecReadEntry( p->pSat->vAdjacents, pVar->Num );
186 nRound = Msat_IntVecReadSize( vRound );
187 pRound = Msat_IntVecReadArray( vRound );
188 for ( i = 0; i < nRound; i++ )
189 {
190 if ( !Msat_OrderVarIsUsedInCone(p, pRound[i]) )
191 continue;
192 if ( Msat_OrderVarIsAssigned(p, pRound[i]) )
193 break;
194 }
195// assert( i != nRound );
196// if ( i == nRound )
197// return 0;
198 if ( i == nRound )
199 Counter++;
200 }
201 if ( Counter > 0 )
202 printf( "%d(%d) ", Counter, p->rVars.nItems );
203
204 // we may also check other unassigned variables in the cone
205 // to make sure that if they are not in J-boundary,
206 // then they do not have an assigned neighbor
207 nVars = Msat_IntVecReadSize( p->pSat->vConeVars );
208 pVars = Msat_IntVecReadArray( p->pSat->vConeVars );
209 for ( i = 0; i < nVars; i++ )
210 {
211 assert( Msat_OrderVarIsUsedInCone(p, pVars[i]) );
212 // skip assigned vars, vars in the boundary, and vars not used in the cone
213 if ( Msat_OrderVarIsAssigned(p, pVars[i]) ||
214 Msat_OrderVarIsInBoundary(p, pVars[i]) )
215 continue;
216 // make sure, it does not have assigned neighbors
217 vRound = (Msat_IntVec_t *)Msat_ClauseVecReadEntry( p->pSat->vAdjacents, pVars[i] );
218 nRound = Msat_IntVecReadSize( vRound );
219 pRound = Msat_IntVecReadArray( vRound );
220 for ( k = 0; k < nRound; k++ )
221 {
222 if ( !Msat_OrderVarIsUsedInCone(p, pRound[k]) )
223 continue;
224 if ( Msat_OrderVarIsAssigned(p, pRound[k]) )
225 break;
226 }
227// assert( k == nRound );
228// if ( k != nRound )
229// return 0;
230 }
231 return 1;
232}
Msat_Clause_t * Msat_ClauseVecReadEntry(Msat_ClauseVec_t *p, int i)
#define Msat_OrderVarIsUsedInCone(p, i)
Definition msatOrderJ.c:71
#define Msat_OrderVarIsAssigned(p, i)
Definition msatOrderJ.c:70
#define Msat_OrderRingForEachEntry(pRing, pVar, pNext)
Definition msatOrderJ.c:74
typedefABC_NAMESPACE_IMPL_START struct Msat_OrderVar_t_ Msat_OrderVar_t
DECLARATIONS ///.
Definition msatOrderJ.c:36
#define Msat_OrderVarIsInBoundary(p, i)
Definition msatOrderJ.c:69
struct Msat_IntVec_t_ Msat_IntVec_t
Definition msat.h:45
int Msat_IntVecReadSize(Msat_IntVec_t *p)
Definition msatVec.c:233
int * Msat_IntVecReadArray(Msat_IntVec_t *p)
Definition msatVec.c:217
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:

◆ Msat_OrderClean()

void Msat_OrderClean ( Msat_Order_t * p,
Msat_IntVec_t * vCone )

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

Synopsis [Cleans the ordering structure.]

Description []

SideEffects []

SeeAlso []

Definition at line 150 of file msatOrderJ.c.

151{
152 Msat_OrderVar_t * pVar, * pNext;
153 // quickly undo the ring
154 Msat_OrderRingForEachEntry( p->rVars.pRoot, pVar, pNext )
155 pVar->pNext = pVar->pPrev = NULL;
156 p->rVars.pRoot = NULL;
157 p->rVars.nItems = 0;
158}
Here is the caller graph for this function:

◆ Msat_OrderFree()

void Msat_OrderFree ( Msat_Order_t * p)

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

Synopsis [Frees the ordering structure.]

Description []

SideEffects []

SeeAlso []

Definition at line 245 of file msatOrderJ.c.

246{
247 free( p->pVars );
248 free( p );
249}
VOID_HACK free()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Msat_OrderSetBounds()

void Msat_OrderSetBounds ( Msat_Order_t * p,
int nVarsMax )

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

Synopsis [Sets the bound of the ordering structure.]

Description [Should be called whenever the SAT solver is resized.]

SideEffects []

SeeAlso []

Definition at line 123 of file msatOrderJ.c.

124{
125 int i;
126 // add variables if they are missing
127 if ( p->nVarsAlloc < nVarsMax )
128 {
129 p->pVars = REALLOC( Msat_OrderVar_t, p->pVars, nVarsMax );
130 for ( i = p->nVarsAlloc; i < nVarsMax; i++ )
131 {
132 p->pVars[i].pNext = p->pVars[i].pPrev = NULL;
133 p->pVars[i].Num = i;
134 }
135 p->nVarsAlloc = nVarsMax;
136 }
137}
#define REALLOC(type, obj, num)
Definition avl.h:29
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Msat_OrderUpdate()

void Msat_OrderUpdate ( Msat_Order_t * p,
int Var )

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

Synopsis [Updates the order after a variable changed weight.]

Description []

SideEffects []

SeeAlso []

Definition at line 390 of file msatOrderJ.c.

391{
392}
Here is the caller graph for this function:

◆ Msat_OrderVarAssigned()

void Msat_OrderVarAssigned ( Msat_Order_t * p,
int Var )

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

Synopsis [Updates J-boundary when the variable is assigned.]

Description []

SideEffects []

SeeAlso []

Definition at line 305 of file msatOrderJ.c.

306{
307 Msat_IntVec_t * vRound;
308 int i;//, clk = clock();
309
310 // make sure the variable is in the boundary
311 assert( Var < p->nVarsAlloc );
312 // if it is not in the boundary (initial decision, random decision), do not remove
314 Msat_OrderRingRemove( &p->rVars, &p->pVars[Var] );
315 // add to the boundary those neighbors that are (1) unassigned, (2) not in boundary
316 // because for them we know that there is a variable (Var) which is assigned
317 vRound = (Msat_IntVec_t *)p->pSat->vAdjacents->pArray[Var];
318 for ( i = 0; i < vRound->nSize; i++ )
319 {
320 if ( !Msat_OrderVarIsUsedInCone(p, vRound->pArray[i]) )
321 continue;
322 if ( Msat_OrderVarIsAssigned(p, vRound->pArray[i]) )
323 continue;
324 if ( Msat_OrderVarIsInBoundary(p, vRound->pArray[i]) )
325 continue;
326 Msat_OrderRingAddLast( &p->rVars, &p->pVars[vRound->pArray[i]] );
327 }
328//timeSelect += clock() - clk;
329// Msat_OrderCheck( p );
330}
int Var
Definition exorList.c:228
Here is the caller graph for this function:

◆ Msat_OrderVarSelect()

int Msat_OrderVarSelect ( Msat_Order_t * p)

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

Synopsis [Selects the next variable to assign.]

Description []

SideEffects []

SeeAlso []

Definition at line 262 of file msatOrderJ.c.

263{
264 Msat_OrderVar_t * pVar, * pNext, * pVarBest;
265 double * pdActs = p->pSat->pdActivity;
266 double dfActBest;
267// clock_t clk = clock();
268
269 pVarBest = NULL;
270 dfActBest = -1.0;
271 Msat_OrderRingForEachEntry( p->rVars.pRoot, pVar, pNext )
272 {
273 if ( dfActBest < pdActs[pVar->Num] )
274 {
275 dfActBest = pdActs[pVar->Num];
276 pVarBest = pVar;
277 }
278 }
279//timeSelect += clock() - clk;
280//timeAssign += clock() - clk;
281
282//if ( pVarBest && pVarBest->Num % 1000 == 0 )
283//printf( "%d ", p->rVars.nItems );
284
285// Msat_OrderCheck( p );
286 if ( pVarBest )
287 {
288 assert( Msat_OrderVarIsUsedInCone(p, pVarBest->Num) );
289 return pVarBest->Num;
290 }
291 return MSAT_ORDER_UNKNOWN;
292}
#define MSAT_ORDER_UNKNOWN
Definition msatInt.h:70
Here is the caller graph for this function:

◆ Msat_OrderVarUnassigned()

void Msat_OrderVarUnassigned ( Msat_Order_t * p,
int Var )

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

Synopsis [Updates the order after a variable is unassigned.]

Description []

SideEffects []

SeeAlso []

Definition at line 343 of file msatOrderJ.c.

344{
345 Msat_IntVec_t * vRound, * vRound2;
346 int i, k;//, clk = clock();
347
348 // make sure the variable is not in the boundary
349 assert( Var < p->nVarsAlloc );
351 // go through its neigbors - if one of them is assigned add this var
352 // add to the boundary those neighbors that are not there already
353 // this will also get rid of variable outside of the current cone
354 // because they are unassigned in Msat_SolverPrepare()
355 vRound = (Msat_IntVec_t *)p->pSat->vAdjacents->pArray[Var];
356 for ( i = 0; i < vRound->nSize; i++ )
357 if ( Msat_OrderVarIsAssigned(p, vRound->pArray[i]) )
358 break;
359 if ( i != vRound->nSize )
360 Msat_OrderRingAddLast( &p->rVars, &p->pVars[Var] );
361
362 // unassigning a variable may lead to its adjacents dropping from the boundary
363 for ( i = 0; i < vRound->nSize; i++ )
364 if ( Msat_OrderVarIsInBoundary(p, vRound->pArray[i]) )
365 { // the neighbor is in the J-boundary (and unassigned)
366 assert( !Msat_OrderVarIsAssigned(p, vRound->pArray[i]) );
367 vRound2 = (Msat_IntVec_t *)p->pSat->vAdjacents->pArray[vRound->pArray[i]];
368 // go through its neighbors and determine if there is at least one assigned
369 for ( k = 0; k < vRound2->nSize; k++ )
370 if ( Msat_OrderVarIsAssigned(p, vRound2->pArray[k]) )
371 break;
372 if ( k == vRound2->nSize ) // there is no assigned vars, delete this one
373 Msat_OrderRingRemove( &p->rVars, &p->pVars[vRound->pArray[i]] );
374 }
375//timeSelect += clock() - clk;
376// Msat_OrderCheck( p );
377}

Variable Documentation

◆ timeAssign

clock_t timeAssign
extern

Definition at line 29 of file fraigMan.c.

◆ timeSelect

clock_t timeSelect
extern

DECLARATIONS ///.

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

FileName [fraigMan.c]

PackageName [FRAIG: Functionally reduced AND-INV graphs.]

Synopsis [Implementation of the FRAIG manager.]

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. 2.0. Started - October 1, 2004]

Revision [

Id
fraigMan.c,v 1.11 2005/07/08 01:01:31 alanmi Exp

]

Definition at line 28 of file fraigMan.c.