meelgroup / approxmc

Approximate Model Counter
Other
70 stars 26 forks source link

I try to use pyapproxmc but adding clauses takes very long time #43

Closed ImposterMido closed 10 months ago

ImposterMido commented 10 months ago

I have a cnf file containing the instance i want to use pyapproxmc but adding clause one by one or write a code to add clauses from the cnf file takes a very long time how can u do it so it can add all clauses to count from cnf file in reasonable time noting that number of clauses are 250k so i can use pyapproxmc in python easily thanks in advance !

ImposterMido commented 10 months ago

Sorry for wrong empty comment due mistake while typing my problem !

ImposterMido commented 10 months ago

Did you get my idea sir and is there any solution for this problem it seems an easy issue to be solved waiting for your kind and quick reply !

msoos commented 10 months ago

Hi,

Firstly, please never call me sir. Secondly, I have added a new interface to the python package. You need to wait 20 minutes and then it will appear in pypi. You can then add many closes at once using the add_clauses function. Please read the documentation:

"add_clauses(clauses)\n\
Add iterable of clauses to the solver.\n\
\n\
:param clauses: List of clauses. Each clause contains literals (ints)\n\
    Alternatively, this can be a flat array.array or other contiguous\n\
    buffer (format 'i', 'l', or 'q') of zero separated and terminated\n\
    clauses of literals (ints).\n\
:type clauses: <list> or <array.array>\n\
:return: None\n\

This allows you to push in many clauses in one go. Should be a lot faster. Can't make it any faster than that, please don't ask. If you find a bug, please do report it. I consider this issue closed, as this fixes the underlying issue of slow adding of clauses. Please do NOT respond to this issue. If you have found a bug, please open another issue.

Mate