Skip to content

Commit 2c45f9d

Browse files
committed
Adding conflict limit and timeout to &simap.
1 parent 40ea8a7 commit 2c45f9d

File tree

2 files changed

+43
-24
lines changed

2 files changed

+43
-24
lines changed

src/aig/gia/giaSatLut.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,7 @@ void Gia_ManLutSat( Gia_Man_t * pGia, int LutSize, int nNumber, int nImproves, i
12331233
SeeAlso []
12341234
12351235
***********************************************************************/
1236-
Vec_Int_t * Gia_RunKadical( char * pFileNameIn, char * pFileNameOut, int TimeOut, int fVerbose )
1236+
Vec_Int_t * Gia_RunKadical( char * pFileNameIn, char * pFileNameOut, int nBTLimit, int TimeOut, int fVerbose )
12371237
{
12381238
extern Vec_Int_t * Exa4_ManParse( char *pFileName );
12391239
int fVerboseSolver = 0;
@@ -1245,10 +1245,18 @@ Vec_Int_t * Gia_RunKadical( char * pFileNameIn, char * pFileNameOut, int TimeOut
12451245
char * pKadical = "kadical";
12461246
#endif
12471247
char Command[1000], * pCommand = (char *)&Command;
1248-
if ( TimeOut )
1249-
sprintf( pCommand, "%s -t %d %s %s > %s", pKadical, TimeOut, fVerboseSolver ? "": "-q", pFileNameIn, pFileNameOut );
1250-
else
1251-
sprintf( pCommand, "%s %s %s > %s", pKadical, fVerboseSolver ? "": "-q", pFileNameIn, pFileNameOut );
1248+
if ( nBTLimit ) {
1249+
if ( TimeOut )
1250+
sprintf( pCommand, "%s -c %d -t %d %s %s > %s", pKadical, nBTLimit, TimeOut, fVerboseSolver ? "": "-q", pFileNameIn, pFileNameOut );
1251+
else
1252+
sprintf( pCommand, "%s -c %d %s %s > %s", pKadical, nBTLimit, fVerboseSolver ? "": "-q", pFileNameIn, pFileNameOut );
1253+
}
1254+
else {
1255+
if ( TimeOut )
1256+
sprintf( pCommand, "%s -t %d %s %s > %s", pKadical, TimeOut, fVerboseSolver ? "": "-q", pFileNameIn, pFileNameOut );
1257+
else
1258+
sprintf( pCommand, "%s %s %s > %s", pKadical, fVerboseSolver ? "": "-q", pFileNameIn, pFileNameOut );
1259+
}
12521260
#ifdef __wasm
12531261
if ( 1 )
12541262
#else
@@ -1266,7 +1274,7 @@ Vec_Int_t * Gia_RunKadical( char * pFileNameIn, char * pFileNameOut, int TimeOut
12661274
else if ( vRes == NULL && TimeOut == 0 )
12671275
printf( "The problem has no solution. " );
12681276
else if ( vRes == NULL )
1269-
printf( "The problem has no solution or timed out after %d sec. ", TimeOut );
1277+
printf( "The problem has no solution or reached a resource limit after %d sec. ", TimeOut );
12701278
Abc_PrintTime( 1, "SAT solver time", Abc_Clock() - clkTotal );
12711279
}
12721280
return vRes;
@@ -1527,7 +1535,7 @@ int Gia_ManDumpCnf( char * pFileName, Vec_Str_t * vStr, int nVars )
15271535
fclose( pFile );
15281536
return 1;
15291537
}
1530-
int Gia_ManSimpleMapping( Gia_Man_t * p, int nBTLimit, int nBound, int fVerbose )
1538+
int Gia_ManSimpleMapping( Gia_Man_t * p, int nBound, int nBTLimit, int nTimeout, int fVerbose )
15311539
{
15321540
char * pFileNameI = (char *)"__temp__.cnf";
15331541
char * pFileNameO = (char *)"__temp__.out";
@@ -1540,11 +1548,12 @@ int Gia_ManSimpleMapping( Gia_Man_t * p, int nBTLimit, int nBound, int fVerbose
15401548
return 0;
15411549
}
15421550
if ( fVerbose )
1543-
printf( "SAT variables = %d. SAT clauses = %d. Cardinality bound = %d.\n", nVars, Vec_StrCountEntry(vStr, '\n'), nBound );
1551+
printf( "SAT variables = %d. SAT clauses = %d. Cardinality bound = %d. Conflict limit = %d. Timeout = %d.\n",
1552+
nVars, Vec_StrCountEntry(vStr, '\n'), nBound, nBTLimit, nTimeout );
15441553
//char pFileName[100]; sprintf( pFileName, "temp%02d.cnf", nBound/2 );
15451554
//Gia_ManDumpCnf( pFileName, vStr, nVars );
15461555
Vec_StrFree( vStr );
1547-
Vec_Int_t * vRes = Gia_RunKadical( pFileNameI, pFileNameO, 0, 1 );
1556+
Vec_Int_t * vRes = Gia_RunKadical( pFileNameI, pFileNameO, nBTLimit, nTimeout, 1 );
15481557
unlink( pFileNameI );
15491558
//unlink( pFileNameO );
15501559
if ( vRes == NULL )

src/base/abci/abc.c

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44383,13 +44383,27 @@ int Abc_CommandAbc9Of( Abc_Frame_t * pAbc, int argc, char ** argv )
4438344383
int Abc_CommandAbc9Simap( Abc_Frame_t * pAbc, int argc, char ** argv )
4438444384
{
4438544385
extern void Mio_IntallSimpleLibrary();
44386-
extern int Gia_ManSimpleMapping( Gia_Man_t * p, int nBTLimit, int nBound, int fVerbose );
44387-
int c, nBTLimit = 0, nBound = 0, fVerbose = 0;
44386+
extern int Gia_ManSimpleMapping( Gia_Man_t * p, int nBound, int nBTLimit, int nTimeout, int fVerbose );
44387+
int c, nBTLimit = 0, nBound = 0, nTimeout = 0, fVerbose = 0;
4438844388
Extra_UtilGetoptReset();
44389-
while ( ( c = Extra_UtilGetopt( argc, argv, "CBvh" ) ) != EOF )
44389+
while ( ( c = Extra_UtilGetopt( argc, argv, "BCTvh" ) ) != EOF )
4439044390
{
4439144391
switch ( c )
4439244392
{
44393+
case 'B':
44394+
if ( globalUtilOptind >= argc )
44395+
{
44396+
Abc_Print( -1, "Command line switch \"-N\" should be followed by a positive integer.\n" );
44397+
goto usage;
44398+
}
44399+
nBound = atoi(argv[globalUtilOptind]);
44400+
globalUtilOptind++;
44401+
if ( nBound < 0 )
44402+
{
44403+
Abc_Print( -1, "Bound on a solution should be a positive integer.\n" );
44404+
goto usage;
44405+
}
44406+
break;
4439344407
case 'C':
4439444408
if ( globalUtilOptind >= argc )
4439544409
{
@@ -44404,20 +44418,15 @@ int Abc_CommandAbc9Simap( Abc_Frame_t * pAbc, int argc, char ** argv )
4440444418
goto usage;
4440544419
}
4440644420
break;
44407-
case 'B':
44421+
case 'T':
4440844422
if ( globalUtilOptind >= argc )
4440944423
{
44410-
Abc_Print( -1, "Command line switch \"-N\" should be followed by a positive integer.\n" );
44424+
Abc_Print( -1, "Command line switch \"-T\" should be followed by a positive integer.\n" );
4441144425
goto usage;
4441244426
}
44413-
nBound = atoi(argv[globalUtilOptind]);
44427+
nTimeout = atoi(argv[globalUtilOptind]);
4441444428
globalUtilOptind++;
44415-
if ( nBound < 0 )
44416-
{
44417-
Abc_Print( -1, "Bound on a solution should be a positive integer.\n" );
44418-
goto usage;
44419-
}
44420-
break;
44429+
break;
4442144430
case 'v':
4442244431
fVerbose ^= 1;
4442344432
break;
@@ -44432,15 +44441,16 @@ int Abc_CommandAbc9Simap( Abc_Frame_t * pAbc, int argc, char ** argv )
4443244441
return 1;
4443344442
}
4443444443
Mio_IntallSimpleLibrary();
44435-
if ( !Gia_ManSimpleMapping( pAbc->pGia, nBTLimit, nBound, fVerbose ) )
44444+
if ( !Gia_ManSimpleMapping( pAbc->pGia, nBound, nBTLimit, nTimeout, fVerbose ) )
4443644445
printf( "Simple mapping has failed.\n" );
4443744446
return 0;
4443844447

4443944448
usage:
44440-
Abc_Print( -2, "usage: &simap [-CB num] [-vh]\n" );
44449+
Abc_Print( -2, "usage: &simap [-BCT num] [-vh]\n" );
4444144450
Abc_Print( -2, "\t performs simple mapping of the AIG\n" );
44442-
Abc_Print( -2, "\t-C num : the conflict limit [default = %d]\n", nBTLimit );
4444344451
Abc_Print( -2, "\t-B num : the bound on the solution size [default = %d]\n", nBound );
44452+
Abc_Print( -2, "\t-C num : the conflict limit [default = %d]\n", nBTLimit );
44453+
Abc_Print( -2, "\t-T num : runtime limit in seconds [default = %d]\n", nTimeout );
4444444454
Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
4444544455
Abc_Print( -2, "\t-h : prints the command usage\n");
4444644456
return 1;

0 commit comments

Comments
 (0)