Ejemplo n.º 1
0
void dispose_lookahead()
{
	dispose_tree();
	FREE( treeArray );

#ifdef NO_TRANSLATOR
	FREE( size_diff );
#endif
#ifdef EQ
	FREE( lengthWeight );
#endif
	FREE_OFFSET( EqDiff          );
//	FREE_OFFSET( diff            );
//	FREE_OFFSET( diff_tmp        );
	FREE_OFFSET( NBCounter       );
	FREE_OFFSET( WNBCounter      );
	FREE_OFFSET( failed_DL_stamp );

	FREE( diff_table           );
	FREE( diff_depth           );
	FREE( lookaheadArray       );
	FREE( look_fixstack        );
	FREE( look_resstack        );
	FREE( forced_literal_array );
}
Ejemplo n.º 2
0
void freeTernaryImp( int *_tImpTable, int **_tImp, int *_tImpSize )
{
	FREE_OFFSET( _tImp      );
	FREE_OFFSET( _tImpSize  );

	FREE( _tImpTable );
}
Ejemplo n.º 3
0
void free_big_clauses_datastructures()
{
	FREE_OFFSET( big_occ    );
	FREE_OFFSET( clause_set );

	FREE( literal_list    );
	FREE( clause_list     );
	FREE( clause_length   );
	FREE( clause_database );
}
Ejemplo n.º 4
0
void disposeSolver()
{
	if( kSAT_flag )
	{
		free_big_clauses_datastructures();
          	FREE( clause_reduction );
           	FREE( big_global_table );
           	FREE( clause_red_depth );
           	FREE( clause_SAT_flag );

           	FREE_OFFSET( big_to_binary );
           	FREE_OFFSET( btb_size );
	}

        free_BinaryImp();

        dispose_lookahead();
        dispose_preselection();
        dispose_freevars();

        FREE_OFFSET( TernaryImp        );
        FREE_OFFSET( TernaryImpSize    );
        FREE_OFFSET( tmpTernaryImpSize );
        FREE_OFFSET( bImp_stamps       );
        FREE_OFFSET( bImp_satisfied    );
        FREE_OFFSET( node_stamps       );

	FREE( tmpEqImpSize );
        FREE( impstack );
        FREE( rstack );
}
Ejemplo n.º 5
0
/*
	MALLOCS: 	-
	REALLOCS:	-
	FREES:	 	Cv[ * ], Cv, Clength, timeAssignments, VeqDepends
*/
void disposeFormula()
{
    int i;

    /*
    	Can also be used to delete a partial formula, because Cv[ i ]
    	is initialized to NULL. IMPORTANT: according to 'man free',
    	free( void *ptr ) does nothing iff ( ptr == NULL ). This
    	behaviour is vital to disposeFormula() and other parts of
    	the solver where memory is freed.
    */
    if( Cv != NULL )
    {
        for( i = 0; i < nrofclauses; i++ )
            free( Cv[ i ] );
        free( Cv );
        Cv = NULL;
    }

    /*
    	IMPORTANT: timeAssignments should be corrected before
    	attempting this. (In the lookahead, nrofvars is added to both
    	pointers to speed up indexing.) Neglecting this correction
    	means Segfault Suicide!
    */
    FREE_OFFSET( timeAssignments );

    FREE( VeqDepends );
    FREE( Clength );

    /*
    	Update cnf structure.
    */
    original_nrofvars    = 0;
    original_nrofclauses = 0;
    nrofvars 	     = 0;
    nrofclauses	     = 0;


    dispose_equivalence();
}
Ejemplo n.º 6
0
int initSolver()
{
	int i, j, _tmp;

	/* initialise global counters */

	current_node_stamp = 1;
	lookDead 	   = 0;
	mainDead 	   = 0;
#ifdef COUNT_SAT
	count_sat	   = 0;
#endif
       solution_bin = 0;
       solution_bits = 63;
#ifdef DISTRIBUTION
       first_time = 0;
       skip_flag = 0;
       first_depth = 20;
#endif
       currentNodeNumber = 1;
       UNSATflag = 0;

	/* allocate recursion stack */
	/* tree is max. nrofvars deep and we thus have max. nrofvars STACK_BLOCKS
		 -> 2 * nrofvars should be enough for everyone :)
	*/
	INIT_ARRAY( r       , 3 * nrofvars + 1   );

	INIT_ARRAY( imp     , INITIAL_ARRAY_SIZE );
	INIT_ARRAY( subsume , INITIAL_ARRAY_SIZE );
	INIT_ARRAY( bieq    , INITIAL_ARRAY_SIZE );
	INIT_ARRAY( newbi   , INITIAL_ARRAY_SIZE );
	INIT_ARRAY( sub     , INITIAL_ARRAY_SIZE );

	MALLOC_OFFSET( bImp_satisfied, int, nrofvars, 2 );
	MALLOC_OFFSET( bImp_start,     int, nrofvars, 2 );
	MALLOC_OFFSET( bImp_stamps,    int, nrofvars, 0 );
	MALLOC_OFFSET( node_stamps, tstamp, nrofvars, 0 );

	tmpEqImpSize  = (int*) malloc( sizeof(int) * (nrofvars+1) );

	init_lookahead();
	init_preselection();
#ifdef DISTRIBUTION
	init_direction();
#endif
	tmpTernaryImpSize = (int* ) malloc( sizeof(int ) * ( 2*nrofvars+1 ) );
#ifdef TERNARYLOOK
        TernaryImp 	  = (int**) malloc( sizeof(int*) * ( 2*nrofvars+1 ) );
        TernaryImpSize 	  = (int* ) malloc( sizeof(int ) * ( 2*nrofvars+1 ) );

        for( i = 0; i <= 2 * nrofvars; i++ )
	{
	    tmpTernaryImpSize[ i ] = 0;
	    TernaryImpSize   [ i ] = 0;
	}

	for( i = 0; i < nrofclauses; i++ )
	    if( Clength[ i ] == 3 )
		for( j = 0; j < 3; j++ )
		    TernaryImpSize[ Cv[ i ][ j ] + nrofvars ]++;

        for( i = 0; i <= 2 * nrofvars; i++ )
	    TernaryImp[ i ] = (int*) malloc(sizeof(int)*(4*TernaryImpSize[i]+4));

        tmpTernaryImpSize 	+= nrofvars;
        TernaryImp 		+= nrofvars;
	TernaryImpSize 		+= nrofvars;

	fill_ternary_implication_arrays();

        for( i = -nrofvars; i <= nrofvars; i++ )
//	    tmpTernaryImpSize[ i ] = 2 * tmpTernaryImpSize[ i ] + 2;	
	    tmpTernaryImpSize[ i ] = 4 * TernaryImpSize[ i ] + 2;	

//	branch_on_dummies_from_long_clauses();

	while( AddTernaryResolvents() );

        for( i = -nrofvars; i <= nrofvars; i++ )
	    free( TernaryImp[ i ] );

	FREE_OFFSET( TernaryImp     );
	FREE_OFFSET( TernaryImpSize );
#else
        tmpTernaryImpSize 	+= nrofvars;
#endif
	/* initialise global datastructures */

#ifdef GLOBAL_AUTARKY
	MALLOC_OFFSET( TernaryImpReduction, int, nrofvars, 0 );

	if( kSAT_flag )
	{
	    int _nrofliterals = 0;

	    for( i = 0; i < nrofbigclauses; ++i )
		_nrofliterals += clause_length[ i ];

	    clause_reduction = (int*)  malloc( sizeof(int ) * nrofbigclauses );
	    clause_red_depth = (int*)  malloc( sizeof(int ) * nrofbigclauses );
	    big_global_table = (int*)  malloc( sizeof(int ) * _nrofliterals );
	    clause_SAT_flag  = (int*)  malloc( sizeof(int ) * nrofbigclauses );

	    MALLOC_OFFSET( big_to_binary, int*, nrofvars, NULL );
	    MALLOC_OFFSET( btb_size,      int , nrofvars,    0 );

	    for( i = 0; i < nrofbigclauses; ++i )
	    {
		clause_reduction[ i ] =  0;
		clause_red_depth[ i ] =  nrofvars;
		clause_SAT_flag [ i ] =  0;
	    }

	    int tmp = 0;
            for( i = 1; i <= nrofvars; i++ )
            {
                big_to_binary[  i ] = (int*) &big_global_table[ tmp ];
                tmp += big_occ[  i ];

                big_to_binary[ -i ] = (int*) &big_global_table[ tmp ];
                tmp += big_occ[ -i ];

            }
	    assert( tmp == _nrofliterals );
	}
#endif
        TernaryImp 	= (int**) malloc( sizeof(int*) * ( 2*nrofvars+1 ) );
        TernaryImpSize 	= (int* ) malloc( sizeof(int ) * ( 2*nrofvars+1 ) );
        TernaryImpLast 	= (int* ) malloc( sizeof(int ) * ( 2*nrofvars+1 ) );
        TernaryImpTable	= (int* ) malloc( sizeof(int ) * ( 6*nrofclauses+1 ) );

	TernaryImp	       += nrofvars;
	TernaryImpSize	       += nrofvars;
	TernaryImpLast	       += nrofvars;

	if( simplify_formula() == UNSAT ) return UNSAT;

	for( i = -nrofvars; i <= nrofvars; i++ )
	{
	    tmpTernaryImpSize[ i ] = 0;
	    TernaryImpSize   [ i ] = 0;
	    bImp_satisfied   [ i ] = 2;	//waarom staat dit hier?
	}

	for( i = 0; i < nrofclauses; i++ )
	    if( Clength[ i ] == 3 )
		for( j = 0; j < 3; j++ )
		    TernaryImpSize[ Cv[ i ][ j ] ]++;

	_tmp = 0;
        for( i = -nrofvars; i <= nrofvars; i++ )
        {
	    TernaryImp[ i ]     = TernaryImpTable + 2 * _tmp;
            _tmp               += TernaryImpSize[ i ];
	    TernaryImpLast[ i ] = TernaryImpSize[ i ];
        }

	fill_ternary_implication_arrays();

	rebuild_BinaryImp();

	init_freevars();

	for( i = 0; i < nrofceq ; i++ )
	    assert( CeqSizes[ i ] != 1 );
#ifdef EQ
	for( i = 0; i < nrofceq ; i++ )	
	    if( CeqSizes[ i ] == 2 )
            	DPLL_propagate_binary_equivalence( i );
#endif
#ifdef DETECT_COMPONENTS
	init_localbranching();
#endif
#ifdef CUT_OFF
	solution_bits = CUT_OFF - 1;
#endif

	push_stack_blocks();

	return 1;
}