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

Go to the source code of this file.

Functions

static ABC_NAMESPACE_IMPL_START int Msat_SolverSortCompare (Msat_Clause_t **ppC1, Msat_Clause_t **ppC2)
 DECLARATIONS ///. More...
 
static double drand (double seed)
 
static int irand (double seed, int size)
 
static void Msat_SolverSort (Msat_Clause_t **array, int size, double seed)
 
void Msat_SolverSortDB (Msat_Solver_t *p)
 FUNCTION DEFINITIONS ///. More...
 
void Msat_SolverSortSelection (Msat_Clause_t **array, int size)
 

Function Documentation

static double drand ( double  seed)
static

Definition at line 33 of file msatSort.c.

33  {
34  int q;
35  seed *= 1389796;
36  q = (int)(seed / 2147483647);
37  seed -= (double)q * 2147483647;
38  return seed / 2147483647; }
static int irand ( double  seed,
int  size 
)
static

Definition at line 41 of file msatSort.c.

41  {
42  return (int)(drand(seed) * size); }
static double drand(double seed)
Definition: msatSort.c:33
static int size
Definition: cuddSign.c:86
void Msat_SolverSort ( Msat_Clause_t **  array,
int  size,
double  seed 
)
static

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

Synopsis [The original MiniSat sorting procedure.]

Description [This procedure is used to preserve trace-equivalence with the orignal C++ implemenation of the solver.]

SideEffects []

SeeAlso []

Definition at line 147 of file msatSort.c.

148 {
149  if (size <= 15)
150  Msat_SolverSortSelection( array, size );
151  else
152  {
153  Msat_Clause_t * pivot = array[irand(seed, size)];
154  Msat_Clause_t * tmp;
155  int i = -1;
156  int j = size;
157 
158  for(;;)
159  {
160  do i++; while( Msat_ClauseReadActivity(array[i]) < Msat_ClauseReadActivity(pivot) );
161  do j--; while( Msat_ClauseReadActivity(pivot) < Msat_ClauseReadActivity(array[j]) );
162 
163  if ( i >= j ) break;
164 
165  tmp = array[i]; array[i] = array[j]; array[j] = tmp;
166  }
167  Msat_SolverSort(array , i , seed);
168  Msat_SolverSort(&array[i], size-i, seed);
169  }
170 }
void Msat_SolverSortSelection(Msat_Clause_t **array, int size)
Definition: msatSort.c:119
typedefABC_NAMESPACE_HEADER_START struct Msat_Clause_t_ Msat_Clause_t
INCLUDES ///.
Definition: msatInt.h:57
static int irand(double seed, int size)
Definition: msatSort.c:41
static int size
Definition: cuddSign.c:86
static void Msat_SolverSort(Msat_Clause_t **array, int size, double seed)
Definition: msatSort.c:147
float Msat_ClauseReadActivity(Msat_Clause_t *pC)
Definition: msatClause.c:295
int Msat_SolverSortCompare ( Msat_Clause_t **  ppC1,
Msat_Clause_t **  ppC2 
)
static

DECLARATIONS ///.

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

FileName [msatSort.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 [Sorting clauses.]

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:
msatSort.c,v 1.0 2004/01/01 1:00:00 alanmi Exp

]

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

Synopsis [Comparison procedure for two clauses.]

Description []

SideEffects []

SeeAlso []

Definition at line 96 of file msatSort.c.

97 {
98  float Value1 = Msat_ClauseReadActivity( *ppC1 );
99  float Value2 = Msat_ClauseReadActivity( *ppC2 );
100  if ( Value1 < Value2 )
101  return -1;
102  if ( Value1 > Value2 )
103  return 1;
104  return 0;
105 }
float Msat_ClauseReadActivity(Msat_Clause_t *pC)
Definition: msatClause.c:295
void Msat_SolverSortDB ( Msat_Solver_t p)

FUNCTION DEFINITIONS ///.

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

Synopsis [Msat_SolverSort the learned clauses in the increasing order of activity.]

Description []

SideEffects []

SeeAlso []

Definition at line 61 of file msatSort.c.

62 {
63  Msat_ClauseVec_t * pVecClauses;
64  Msat_Clause_t ** pLearned;
65  int nLearned;
66  // read the parameters
67  pVecClauses = Msat_SolverReadLearned( p );
68  nLearned = Msat_ClauseVecReadSize( pVecClauses );
69  pLearned = Msat_ClauseVecReadArray( pVecClauses );
70  // Msat_SolverSort the array
71 // qMsat_SolverSort( (void *)pLearned, nLearned, sizeof(Msat_Clause_t *),
72 // (int (*)(const void *, const void *)) Msat_SolverSortCompare );
73 // printf( "Msat_SolverSorting.\n" );
74  Msat_SolverSort( pLearned, nLearned, 91648253 );
75 /*
76  if ( nLearned > 2 )
77  {
78  printf( "Clause 1: %0.20f\n", Msat_ClauseReadActivity(pLearned[0]) );
79  printf( "Clause 2: %0.20f\n", Msat_ClauseReadActivity(pLearned[1]) );
80  printf( "Clause 3: %0.20f\n", Msat_ClauseReadActivity(pLearned[2]) );
81  }
82 */
83 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Msat_ClauseVec_t * Msat_SolverReadLearned(Msat_Solver_t *p)
Definition: msatSolverApi.c:54
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
static void Msat_SolverSort(Msat_Clause_t **array, int size, double seed)
Definition: msatSort.c:147
void Msat_SolverSortSelection ( Msat_Clause_t **  array,
int  size 
)

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

Synopsis [Selection sort for small array size.]

Description []

SideEffects []

SeeAlso []

Definition at line 119 of file msatSort.c.

120 {
121  Msat_Clause_t * tmp;
122  int i, j, best_i;
123  for ( i = 0; i < size-1; i++ )
124  {
125  best_i = i;
126  for (j = i+1; j < size; j++)
127  {
128  if ( Msat_ClauseReadActivity(array[j]) < Msat_ClauseReadActivity(array[best_i]) )
129  best_i = j;
130  }
131  tmp = array[i]; array[i] = array[best_i]; array[best_i] = tmp;
132  }
133 }
typedefABC_NAMESPACE_HEADER_START struct Msat_Clause_t_ Msat_Clause_t
INCLUDES ///.
Definition: msatInt.h:57
static int size
Definition: cuddSign.c:86
float Msat_ClauseReadActivity(Msat_Clause_t *pC)
Definition: msatClause.c:295