abc/src/opt/fxu/fxu.c
/**Function*************************************************************

  Synopsis    [Performs fast_extract on a set of covers.]

  Description [All the covers are given in the array p->vSops. 
  The resulting covers are returned in the array p->vSopsNew.
  The entries in these arrays correspond to objects in the network.
  The entries corresponding to the PI and objects with trivial covers are NULL.
  The number of extracted covers (not exceeding p->nNodesExt) is returned. 
  Two other things are important for the correct operation of this procedure:
  (1) The input covers do not have duplicated fanins and are SCC-free. 
  (2) The fanins array contains the numbers of the fanin objects.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Function
Synopsis    [Performs fast_extract on a set of covers.]

Description [All the covers are given in the array p->vSops.
The resulting covers are returned in the array p->vSopsNew.
The entries in these arrays correspond to objects in the network.
The entries corresponding to the PI and objects with trivial covers are NULL.
The number of extracted covers (not exceeding p->nNodesExt) is returned.
Two other things are important for the correct operation of this procedure:
(1) The input covers do not have duplicated fanins and are SCC-free.
(2) The fanins array contains the numbers of the fanin objects.]




Function Synopsis [ Performs fast_extract on a set of covers . ] Description [ All the covers are given in the array p - > vSops . The resulting covers are returned in the array p - > vSopsNew . The entries in these arrays correspond to objects in the network . The entries corresponding to the PI and objects with trivial covers are NULL . The number of extracted covers ( not exceeding p - > nNodesExt ) is returned . Two other things are important for the correct operation of this procedure : ( 1 ) The input covers do not have duplicated fanins and are SCC - free . ( 2 ) The fanins array contains the numbers of the fanin objects . ]
int Fxu_FastExtract( Fxu_Data_t * pData )
{
    int fScrollLines = 0;
    Fxu_Matrix * p;
    Fxu_Single * pSingle;
    Fxu_Double * pDouble;
    int Weight1, Weight2, Weight3;
    int Counter = 0;
    s_MemoryTotal = 0;
    s_MemoryPeak  = 0;
    p = Fxu_CreateMatrix( pData );
    if ( p == NULL )
        return -1;
    if ( pData->fOnlyS )
    {
        pData->nNodesNew = 0;
        do
        {
            Weight1 = Fxu_HeapSingleReadMaxWeight( p->pHeapSingle );
            if ( pData->fVerbose )
                printf( "Div %5d : Best single = %5d.%s", Counter++, Weight1, fScrollLines?"\n":"\r" );
            if ( Weight1 > pData->WeightMin || (Weight1 == 0 && pData->fUse0) )
                Fxu_UpdateSingle( p );
            else
                break;
        }
        while ( ++pData->nNodesNew < pData->nNodesExt );
    }
    else if ( pData->fOnlyD )
    {
        pData->nNodesNew = 0;
        do
        {
            Weight2 = Fxu_HeapDoubleReadMaxWeight( p->pHeapDouble );
            if ( pData->fVerbose )
                printf( "Div %5d : Best double = %5d.%s", Counter++, Weight2, fScrollLines?"\n":"\r" );
            if ( Weight2 > pData->WeightMin || (Weight2 == 0 && pData->fUse0) )
                Fxu_UpdateDouble( p );
            else
                break;
        }
        while ( ++pData->nNodesNew < pData->nNodesExt );
    }
    else if ( !pData->fUseCompl )
    {
        pData->nNodesNew = 0;
        do
        {
            Weight1 = Fxu_HeapSingleReadMaxWeight( p->pHeapSingle );
            Weight2 = Fxu_HeapDoubleReadMaxWeight( p->pHeapDouble );
            if ( pData->fVerbose )
                printf( "Div %5d : Best double = %5d. Best single = %5d.%s", Counter++, Weight2, Weight1, fScrollLines?"\n":"\r" );
            if ( Weight1 >= Weight2 )
            {
                if ( Weight1 > pData->WeightMin || (Weight1 == 0 && pData->fUse0) )
                    Fxu_UpdateSingle( p );
                else
                    break;
            }
            else
            {
                if ( Weight2 > pData->WeightMin || (Weight2 == 0 && pData->fUse0) )
                    Fxu_UpdateDouble( p );
                else
                    break;
            }
        }
        while ( ++pData->nNodesNew < pData->nNodesExt );
    }
    else
    { 
        pData->nNodesNew = 0;
        do
        {
            Weight1 = Fxu_HeapSingleReadMaxWeight( p->pHeapSingle );
            Weight2 = Fxu_HeapDoubleReadMaxWeight( p->pHeapDouble );
            Weight3 = Fxu_Select( p, &pSingle, &pDouble );
            if ( pData->fVerbose )
                printf( "Div %5d : Best double = %5d. Best single = %5d. Best complement = %5d.%s", 
                    Counter++, Weight2, Weight1, Weight3, fScrollLines?"\n":"\r" );
            if ( Weight3 > pData->WeightMin || (Weight3 == 0 && pData->fUse0) )
                Fxu_Update( p, pSingle, pDouble );
            else
                break;
        }
        while ( ++pData->nNodesNew < pData->nNodesExt );
    }
    if ( pData->fVerbose )
        printf( "Total single = %3d. Total double = %3d. Total compl = %3d.                    \n", 
        p->nDivs1, p->nDivs2, p->nDivs3 );
    if ( pData->nNodesNew )
        Fxu_CreateCovers( p, pData );
    Fxu_MatrixDelete( p );
    if ( pData->nNodesNew == pData->nNodesExt )
        printf( "Warning: The limit on the number of extracted divisors has been reached.\n" );
    return pData->nNodesNew;
}
int Fxu_FastExtract ( Fxu_Data_t * pData ) { int fScrollLines = 0 ; Fxu_Matrix * p ; Fxu_Single * pSingle ; Fxu_Double * pDouble ; int Weight1 , Weight2 , Weight3 ; int Counter = 0 ; s_MemoryTotal = 0 ; s_MemoryPeak = 0 ; p = Fxu_CreateMatrix ( pData ) ; if ( p == NULL ) return -1 ; if ( pData -> fOnlyS ) { pData -> nNodesNew = 0 ; do { Weight1 = Fxu_HeapSingleReadMaxWeight ( p -> pHeapSingle ) ; if ( pData -> fVerbose ) printf ( " " , Counter ++ , Weight1 , fScrollLines ? " \n " : " \r " ) ; if ( Weight1 > pData -> WeightMin || ( Weight1 == 0 && pData -> fUse0 ) ) Fxu_UpdateSingle ( p ) ; else break ; } while ( ++ pData -> nNodesNew < pData -> nNodesExt ) ; } else if ( pData -> fOnlyD ) { pData -> nNodesNew = 0 ; do { Weight2 = Fxu_HeapDoubleReadMaxWeight ( p -> pHeapDouble ) ; if ( pData -> fVerbose ) printf ( " " , Counter ++ , Weight2 , fScrollLines ? " \n " : " \r " ) ; if ( Weight2 > pData -> WeightMin || ( Weight2 == 0 && pData -> fUse0 ) ) Fxu_UpdateDouble ( p ) ; else break ; } while ( ++ pData -> nNodesNew < pData -> nNodesExt ) ; } else if ( ! pData -> fUseCompl ) { pData -> nNodesNew = 0 ; do { Weight1 = Fxu_HeapSingleReadMaxWeight ( p -> pHeapSingle ) ; Weight2 = Fxu_HeapDoubleReadMaxWeight ( p -> pHeapDouble ) ; if ( pData -> fVerbose ) printf ( " " , Counter ++ , Weight2 , Weight1 , fScrollLines ? " \n " : " \r " ) ; if ( Weight1 >= Weight2 ) { if ( Weight1 > pData -> WeightMin || ( Weight1 == 0 && pData -> fUse0 ) ) Fxu_UpdateSingle ( p ) ; else break ; } else { if ( Weight2 > pData -> WeightMin || ( Weight2 == 0 && pData -> fUse0 ) ) Fxu_UpdateDouble ( p ) ; else break ; } } while ( ++ pData -> nNodesNew < pData -> nNodesExt ) ; } else { pData -> nNodesNew = 0 ; do { Weight1 = Fxu_HeapSingleReadMaxWeight ( p -> pHeapSingle ) ; Weight2 = Fxu_HeapDoubleReadMaxWeight ( p -> pHeapDouble ) ; Weight3 = Fxu_Select ( p , & pSingle , & pDouble ) ; if ( pData -> fVerbose ) printf ( " " , Counter ++ , Weight2 , Weight1 , Weight3 , fScrollLines ? " \n " : " \r " ) ; if ( Weight3 > pData -> WeightMin || ( Weight3 == 0 && pData -> fUse0 ) ) Fxu_Update ( p , pSingle , pDouble ) ; else break ; } while ( ++ pData -> nNodesNew < pData -> nNodesExt ) ; } if ( pData -> fVerbose ) printf ( " \n " , p -> nDivs1 , p -> nDivs2 , p -> nDivs3 ) ; if ( pData -> nNodesNew ) Fxu_CreateCovers ( p , pData ) ; Fxu_MatrixDelete ( p ) ; if ( pData -> nNodesNew == pData -> nNodesExt ) printf ( " \n " ) ; return pData -> nNodesNew ; }
Function
Synopsis    [Performs fast_extract on a set of covers.]
Function Synopsis [ Performs fast_extract on a set of covers . ]
// create the matrix //    if ( pData->fVerbose ) //        printf( "Memory usage after construction: Total = %d. Peak = %d.\n", s_MemoryTotal, s_MemoryPeak ); //Fxu_MatrixPrint( NULL, p ); //Fxu_Select( p, &pSingle, &pDouble ); // use the complement // select the best single and double // create the new covers //    printf( "Memory usage after deallocation:   Total = %d. Peak = %d.\n", s_MemoryTotal, s_MemoryPeak );