abc/src/sat/msat/msatSolverCore.c
/**Function*************************************************************

  Synopsis    [Top-level solve.]

  Description [If using assumptions (non-empty 'assumps' vector), you must 
  call 'simplifyDB()' first to see that no top-level conflict is present 
  (which would put the solver in an undefined state. If the last argument
  is given (vProj), the solver enumerates through the satisfying solutions,
  which are projected on the variables listed in this array. Note that the
  variables in the array may be complemented, in which case the derived
  assignment for the variable is complemented.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Function
Synopsis    [Top-level solve.]

Description [If using assumptions (non-empty 'assumps' vector), you must
call 'simplifyDB()' first to see that no top-level conflict is present
(which would put the solver in an undefined state. If the last argument
is given (vProj), the solver enumerates through the satisfying solutions,
which are projected on the variables listed in this array. Note that the
variables in the array may be complemented, in which case the derived
assignment for the variable is complemented.]




Function Synopsis [ Top - level solve . ] Description [ If using assumptions ( non - empty ' assumps ' vector ) you must call ' simplifyDB () ' first to see that no top - level conflict is present ( which would put the solver in an undefined state . If the last argument is given ( vProj ) the solver enumerates through the satisfying solutions which are projected on the variables listed in this array . Note that the variables in the array may be complemented in which case the derived assignment for the variable is complemented . ]
int  Msat_SolverSolve( Msat_Solver_t * p, Msat_IntVec_t * vAssumps, int nBackTrackLimit, int nTimeLimit )
{
    Msat_SearchParams_t Params = { 0.95, 0.999 };
    double nConflictsLimit, nLearnedLimit;
    Msat_Type_t Status;
    abctime timeStart = Abc_Clock();
    if ( vAssumps )
    {
        int * pAssumps, nAssumps, i;
        assert( Msat_IntVecReadSize(p->vTrailLim) == 0 );
        nAssumps = Msat_IntVecReadSize( vAssumps );
        pAssumps = Msat_IntVecReadArray( vAssumps );
        for ( i = 0; i < nAssumps; i++ )
        {
            if ( !Msat_SolverAssume(p, pAssumps[i]) || Msat_SolverPropagate(p) )
            {
                Msat_QueueClear( p->pQueue );
                Msat_SolverCancelUntil( p, 0 );
                return MSAT_FALSE;
            }
        }
    }
    p->nLevelRoot   = Msat_SolverReadDecisionLevel(p);
    p->nClausesInit = Msat_ClauseVecReadSize( p->vClauses );    
    nConflictsLimit = 100;
    nLearnedLimit   = Msat_ClauseVecReadSize(p->vClauses) / 3;
    Status = MSAT_UNKNOWN;
    p->nBackTracks = (int)p->Stats.nConflicts;
    while ( Status == MSAT_UNKNOWN )
    {
        if ( p->fVerbose )
            printf("Solving -- conflicts=%d   learnts=%d   progress=%.4f %%\n", 
                (int)nConflictsLimit, (int)nLearnedLimit, p->dProgress*100);
        Status = Msat_SolverSearch( p, (int)nConflictsLimit, (int)nLearnedLimit, nBackTrackLimit, &Params );
        nConflictsLimit *= 1.5;
        nLearnedLimit   *= 1.1;
        if ( nBackTrackLimit > 0 && (int)p->Stats.nConflicts - p->nBackTracks > nBackTrackLimit )
            break;
        if ( nTimeLimit > 0 && Abc_Clock() - timeStart >= nTimeLimit * CLOCKS_PER_SEC )
            break;
    }
    Msat_SolverCancelUntil( p, 0 );
    p->nBackTracks = (int)p->Stats.nConflicts - p->nBackTracks;
    return Status;
}
int Msat_SolverSolve ( Msat_Solver_t * p , Msat_IntVec_t * vAssumps , int nBackTrackLimit , int nTimeLimit ) { Msat_SearchParams_t Params = { 0.95 , 0.999 } ; double nConflictsLimit , nLearnedLimit ; Msat_Type_t Status ; abctime timeStart = Abc_Clock ( ) ; if ( vAssumps ) { int * pAssumps , nAssumps , i ; assert ( Msat_IntVecReadSize ( p -> vTrailLim ) == 0 ) ; nAssumps = Msat_IntVecReadSize ( vAssumps ) ; pAssumps = Msat_IntVecReadArray ( vAssumps ) ; for ( i = 0 ; i < nAssumps ; i ++ ) { if ( ! Msat_SolverAssume ( p , pAssumps [ i ] ) || Msat_SolverPropagate ( p ) ) { Msat_QueueClear ( p -> pQueue ) ; Msat_SolverCancelUntil ( p , 0 ) ; return MSAT_FALSE ; } } } p -> nLevelRoot = Msat_SolverReadDecisionLevel ( p ) ; p -> nClausesInit = Msat_ClauseVecReadSize ( p -> vClauses ) ; nConflictsLimit = 100 ; nLearnedLimit = Msat_ClauseVecReadSize ( p -> vClauses ) / 3 ; Status = MSAT_UNKNOWN ; p -> nBackTracks = ( int ) p -> Stats . nConflicts ; while ( Status == MSAT_UNKNOWN ) { if ( p -> fVerbose ) printf ( " \n " , ( int ) nConflictsLimit , ( int ) nLearnedLimit , p -> dProgress * 100 ) ; Status = Msat_SolverSearch ( p , ( int ) nConflictsLimit , ( int ) nLearnedLimit , nBackTrackLimit , & Params ) ; nConflictsLimit *= 1.5 ; nLearnedLimit *= 1.1 ; if ( nBackTrackLimit > 0 && ( int ) p -> Stats . nConflicts - p -> nBackTracks > nBackTrackLimit ) break ; if ( nTimeLimit > 0 && Abc_Clock ( ) - timeStart >= nTimeLimit * CLOCKS_PER_SEC ) break ; } Msat_SolverCancelUntil ( p , 0 ) ; p -> nBackTracks = ( int ) p -> Stats . nConflicts - p -> nBackTracks ; return Status ; }
Function
Synopsis    [Top-level solve.]
Function Synopsis [ Top - level solve . ]
//    p->pFreq = ABC_ALLOC( int, p->nVarsAlloc ); //    memset( p->pFreq, 0, sizeof(int) * p->nVarsAlloc ); // if the limit on the number of backtracks is given, quit the restart loop // if the runtime limit is exceeded, quit the restart loop /*
    ABC_PRT( "True solver runtime", Abc_Clock() - timeStart );
    // print the statistics
    {
        int i, Counter = 0;
        for ( i = 0; i < p->nVars; i++ )
            if ( p->pFreq[i] > 0 )
            {
                printf( "%d ", p->pFreq[i] );
                Counter++;
            }
        if ( Counter )
            printf( "\n" );
        printf( "Total = %d. Used = %d.  Decisions = %d. Imps = %d. Conflicts = %d. ", p->nVars, Counter, (int)p->Stats.nDecisions, (int)p->Stats.nPropagations, (int)p->Stats.nConflicts );
        ABC_PRT( "Time", Abc_Clock() - timeStart );
    }
*/