Implement non-empty clause counting whi…#129
Conversation
…ch fixes an empty clause error when having only one tool in the workflow
|
@vedran-kasalica I am currently not sure whether some comparable can happen in other situations since both |
…mat and warn if empty clauses are found.
|
@vedran-kasalica I now added a clause counting function based on DIMACS format that counts the non-empty clauses and warns if one was found. Using this function, minisat is more forgiving and ignores the empty clauses since the correct count is provided. |
|
Woop, still working on that one. Something is still wrong |
…mat, warn if empty clauses are found and dump the respective clause number.
|
@vedran-kasalica: behaviour stabilised and checks are passing. Skipped one line in the CNF file which made the count wrong. Ready for review |
0 for empty constraint in connected modules whi…| * @param cnfEncoding the CNF encoding | ||
| * @return the count of non-empty clauses | ||
| */ | ||
| public static int countCNFClauses(InputStream cnfEncoding) { |
There was a problem hiding this comment.
Have you compared the performance of this method against countLines? I’m concerned that using hasNextInt may slow down solving when dealing with 1M+ clauses, since it relies on regex matching (e.g., nextInt). In countLines I used byte-wise comparison for efficiency. Could we reuse countLines and extend it for this case?
There was a problem hiding this comment.
Just did that:
I tested the above JSON config with maximum workflow length 20 and in workflow length 4 and 11 we get
for the countLines variant
Total problem setup time: 3.019 sec (1258226 clauses).
...
Total problem setup time: 9.667 sec (4030028 clauses).
and for the countCNFClauses variant
Total problem setup time: 4.999 sec (1258203 clauses).
...
Total problem setup time: 17.289 sec (4030004 clauses)
so it definitely is slower to use countCNFClauses
There was a problem hiding this comment.
Thanks for testing. Do you think it's doable to update countLines to fix the bug?
There was a problem hiding this comment.
Let me take a short look...
There was a problem hiding this comment.
Well, if I get that correctly, countLines actually does more or less nothing different (concerning complexity class) since it regexes for \n. In order to recognise in a stable way that a clause has ended, we need the pattern " " >> "0" >> _space where space may, but does not have to be a newline (according to DIMACS CNF spec on sat4J). To implement the desired behaviour in countLines, we would have to scan line by line. But a line could have n clause endings with n being arbitrary. So the implementation would be more complex (but still doable)
What we can do is to assume that if a line ends with 0, it is a clause and if it's length is 2, it's an empty clause which is not counted. I can implement that easily and test it. But I would propose to not call this function countLines, then.
I will implement and test that.
There was a problem hiding this comment.
Small correction:
Usually each clause is listed on a separate line, using spaces between each of the literals and the final zero.
Sometimes long clauses use multiple lines.
So we can assume that a clause end always at the end of the line.
There was a problem hiding this comment.
Okay, the new variant has the following timings for depth 4 and 11:
Total problem setup time: 3.06 sec (1258226 clauses).
Total problem setup time: 9.072 sec (4030007 clauses).
This is comparable to countLines but there is no guarantee that the count result is really a count of clauses conforming to the format specification.
There was a problem hiding this comment.
If we want to make sure that it is a list of numbers, we have to introduce more checks and will have more or less the performance of countCNFClauses
…ways end with ` 0`, followed by newline.
…x check can be optionally chosen.
|
Hi @vedran-kasalica, after thinking a bit about a "good" solution, I have the following proposal. We have |
Hi @eladrion, thanks for checking this. If the new 2-parameter The following comment is more of a discussion-, rather than an action-point. |
|
Hi @vedran-kasalica IIRC, the |
|
I separated the functionality a bit now to resolve the counter-intuition and we now have |
@eladrion thank you, looks good! Feel free to merge the PR. Should we make it part of the 2.5.3 release? |
|
Hi @vedran-kasalica, yes, we should introduce this in 2.5.3 since it is a functionality flaw and resolved. I will merge. |



…ch fixes an empty clause error when having only one tool in the workflow
Pull Request Overview
Fixes #119 which is introduced since APE generates an empty clause which is not accepted by minisat and thus not counted as clause. Hence, the computed count of clauses by APE does not match the ones recognised by minisat.
Related Issue
#119
Changes Introduced
Since (in the case of a workflow of length 1) the output of op 1 cannot be reused,
connectedModulesseemingly yields an empty list of CNF literals. Thus, we check whether the constraints are empty and only set a clause delimiter (0) if there are constraints.How Has This Been Tested?
Successfully tested locally with config_bug119.json
Checklist