int check_doublelook( const int nrval ) { if( failed_DL_stamp[ nrval ] != nodeCount ) { #ifdef PLOT sum_plot += DL_trigger; count_plot++; #endif dl_possibility_counter++; if( WNBCounter[ nrval ] > DL_trigger ) // if( NBCounter[ nrval ] > (int) DL_trigger ) { dl_actual_counter++; if( (currentTimeStamp + (DL_ITERATIONS+1)*tree_elements ) >= LOOK_MAX ) return SAT; else currentTimeStamp += tree_elements; if( doublelook( nrval, DL_ITERATIONS*tree_elements) == UNSAT ) return look_fix_forced_literal(-nrval); #ifdef DL_DECREASE DL_trigger = WNBCounter[ nrval ]; // DL_trigger = NBCounter[ nrval ]; #endif failed_DL_stamp[nrval] = nodeCount; } #ifdef DL_DECREASE else DL_trigger *= DL_decrease; #endif } return SAT; }
int serial_lookahead() { int i, j, sign, nrval, varnr, imp, iterTmp; init_lookahead_procedure(); #ifdef ITERATE_LOOKAHEAD do { #endif if( ( currentTimeStamp + 4 * lookaheadArrayLength ) >= LOOK_MAX ) { printf("c CTS: %i; LOOK_MAX: %i\n", currentTimeStamp, LOOK_MAX ); //cleanLookahead(); } iterCounter = 0; for( i = 0; i < lookaheadArrayLength; i++ ) { iterTmp = iterCounter; varnr = lookaheadArray[ i ]; if( varnr == lastChanged ) break; if( IS_FORCED(varnr) ) continue; lookAheadCount++; for( sign = 1; sign >= -1; sign -= 2 ) { nrval = varnr * sign; currentTimeStamp += 2; if( look_IFIUP(nrval) == UNSAT ) { if( look_fix_forced_literal(-nrval) == UNSAT ) return UNSAT; lastChanged = varnr; continue; } #ifdef AUTARKY if( new_binaries == 0 ) { look_fix_forced_literal(nrval); lastChanged = varnr; continue; } #endif NBCounter [ nrval ] = new_binaries; WNBCounter[ nrval ] = weighted_new_binaries; #ifdef DOUBLELOOK if( check_doublelook( nrval ) == UNSAT ) return UNSAT; if( IS_FORCED( nrval ) ) { lastChanged = varnr; continue; } #endif for( j = 2; j < BinaryImp[ -nrval ][ 0 ]; j++ ) { imp = BinaryImp[ -nrval ][ j ]; if( timeAssignments[ imp ] == currentTimeStamp ) { necessary_assignments++; if( look_fix_forced_literal(imp) == UNSAT ) return UNSAT; } } } } #ifdef ITERATE_LOOKAHEAD } while( iterCounter ); #endif return SAT; }
int treelookvar( const int nrval ) { int i, parent; const int *loc; assert( currentTimeStamp < VARMAX ); parent = assignment_array[ nrval ].parent; assert(parent != nrval); if( (parent != 0) && IS_FIXED(parent) && IS_NOT_FORCED(parent) ) { NBCounter [ nrval ] = NBCounter [ parent ]; WNBCounter[ nrval ] = WNBCounter[ parent ]; } else { NBCounter [ nrval ] = 0; WNBCounter[ nrval ] = 0; } if( IS_FIXED(nrval) ) { if (IS_FORCED(nrval) ) return SAT; if( FIXED_ON_COMPLEMENT(nrval) ) { return look_fix_forced_literal(-nrval); } #ifdef AUTARKY look_add_autarky_binary_implications( parent, nrval ); #endif return SAT; } lookAheadCount++; if( look_IFIUP(nrval) == UNSAT ) return look_fix_forced_literal(-nrval); NBCounter [ nrval ] += new_binaries; WNBCounter[ nrval ] += weighted_new_binaries; #ifdef DOUBLELOOK if( check_doublelook( nrval ) == UNSAT ) return UNSAT; #endif #ifdef AUTARKY if( new_binaries == 0 ) { if( (parent == 0) || IS_FORCED(parent) ) { look_fix_forced_literal( nrval ); return SAT; } look_add_autarky_binary_implications( parent, nrval ); } #endif loc = BinaryImp[ -nrval ]; for( i = 2; i < loc[ 0 ]; i++ ) { const int lit = loc[ i ]; if( IS_FIXED(lit) && IS_NOT_FORCED(lit) ) { if( !FIXED_ON_COMPLEMENT(lit) ) { necessary_assignments++; if( look_fix_forced_literal(lit) == UNSAT ) return UNSAT; loc = BinaryImp[ -nrval ]; } else { #ifdef BIEQ int bieq = -parent; if( VeqDepends[ NR(nrval) ] != INDEPENDENT ) return 1; while( VeqDepends[ NR(bieq) ] != INDEPENDENT ) { if( VeqDepends[ NR(bieq) ] != EQUIVALENT ) bieq = VeqDepends[ NR(bieq) ] * SGN(bieq); else bieq = EQUIVALENT; if( bieq == nrval ) break; } if( (bieq != EQUIVALENT) && (bieq != nrval) ) { VeqDepends[ NR(bieq) ] = nrval * SGN(bieq); PUSH( bieq, NR(bieq) ); } #endif } } } return SAT; }
void els_red() { int i, j; int stamp = 0; int lit, *bImp; int *fle, nroffailed = 0; fle = (int*) malloc ( sizeof(int) * 2 * nrofvars ); S = (int*) malloc ( sizeof(int) * 2 * nrofvars ); rep = (int*) malloc( sizeof(int) * (2*nrofvars+1) ); rep += nrofvars; for( i = -nrofvars; i <= nrofvars; i++ ) { dsc[ i ] = 0; fin[ i ] = 0; rep[ i ] = i; if( IS_FORCED( i ) ) { dsc[ i ] = 1; fin[ i ] = 1; } } dsc[ 0 ] = 1; for( i = -nrofvars; i <= nrofvars; i++ ) if( dsc[ i ] == 0 ) stamp = els_stamp_rec( i, stamp ); for( i = -nrofvars; i <= nrofvars; i++ ) { if( rep[ i ] == i ) { bImp = BIMP_START(i); for( j = BIMP_ELEMENTS; --j; ) { lit = *bImp; if( rep[ lit ] == -i ) { printf("c found failed literal %i\n", i ); fle[ nroffailed++ ] = -i; } else if( rep[ lit ] != i && rep[lit] != lit ) { // printf("c lit %i equal to lit %i (%i)\n", lit, rep[ lit ], i ); *bImp = rep[ lit ]; } bImp++; } } else { int flag = 1; // printf("c moving implications from %i to %i\n", i, rep[ i ] ); bImp = BIMP_START(i); CHECK_BIMP_UPPERBOUND( rep[ i ], BIMP_ELEMENTS +1 ); for( j = BIMP_ELEMENTS; --j; ) { lit = *bImp++; if( rep[ lit ] == -rep[ i ] ) { printf("c found failed literal %i\n", rep[ i ] ); fle[ nroffailed++ ] = -rep[ i]; } else if( rep[ lit ] != rep[ i ] ) { ADD_BINARY_IMPLICATION( -rep[ i ], rep[ lit ] ); // printf("c adding %i to %i\n", rep[ lit ], rep[ i ] ); } else if( lit == rep[ i ] ) flag = 0; } BinaryImp[ i ][ 0 ] = 3; BinaryImp[ i ][ 2 ] = rep[ i ]; if( flag ) ADD_BINARY_IMPLICATION( -rep[ i ], i ); } } for( i = 0; i < nroffailed; i++ ) look_fix_forced_literal( fle[i] ); free(fle); rep -= nrofvars; free(rep); free(S); }