当前位置: 动力学知识库 > 问答 > 编程问答 >

java - time taken to parse and simplyify a CNF file

问题描述:

I have just starting to use the Sat4j libraries. Can you direct me how to calculate the time taken to parse and simplify a given CNF input.

i have used

ISolver solver = SolverFactory.newDefault();

Reader reader = new DimacsReader(solver);

IProblem problem = reader.parseInstance(filename.cnf);

boolean check=problem.isSatisfiable();

i wish to calculate the time taken by the reader to parse and isSatisfiable.

if possible kindly direct me to find the information in the image for every cnf file processed

screenshot of the details i look to collect using sat4j lib

Thank you for your time in advance.

网友答案:

I try to embedded your source code in an old fashion way to get the execution time.

Date startDate = Calendar.getInstance().getTime();
long d_StartTime = new Date().getTime();

    ISolver solver = SolverFactory.newDefault();
    Reader reader = new DimacsReader(solver);
    IProblem problem = reader.parseInstance(filename.cnf);

Date endDate = Calendar.getInstance().getTime();
long d_endTime = new Date().getTime();

System.out.format("Milli = %s, ( D_Start : %s, D_End : %s ) \n", (d_endTime - d_StartTime),d_StartTime, d_endTime);

boolean check=problem.isSatisfiable(); 

With this, the time in milliseconds to parse the instance will appear :). I hope this help !

分享给朋友:
您可能感兴趣的文章:
随机阅读: