Comments (2)
Hi @fransab,
The documentation should say (see the list of expected arguments and their types) that the input parameters to MUSX
and OptUx
should be weighted formulas. Namely, MUSX
expects to get a WCNF
object while OptUx
wants WCNFPlus
object. To make your example work, you can make a tiny modification (a call to .weighted()
, which will create a weighted variant of the formula for you):
>>> from pysat.examples.musx import MUSX
>>> cnf = CNF(from_clauses=[[1, 2], [-1], [-2]])
>>> musx = MUSX(cnf.weighted(), verbosity=0)
>>> musx.compute()
[1, 2, 3]
>>> musx.delete()
>>> with OptUx(cnf.weighted()) as optux:
... for mus in optux.enumerate():
... print('mus {0} has cost {1}'.format(mus, optux.cost))
...
mus [1, 2, 3] has cost 3
Note that you can call either of these tools on an unweighted *.cnf
file because the script will call .weighted()
for you after parsing the file.
As for the WCNF file you are creating, it is incorrect. If you want each clause to be considered as a culprit for unsatisfiability then each clause should be marked as soft. This means you should set the top weight (in the preamble) to the sum of weights for all soft clauses + 1, i.e. it should be 4 rather than 1. Currently, all the clauses in the file are made hard, hence the cores MUSX and OptUx are getting are empty.
I hope this helps,
Alexey
from pysat.
Thanks for your help @alexeyignatiev .
I guess it would be nice for these MUS extractors to directly support formulas in CNF formulas, given the minimal modification required, unless specific situations could return an unwanted result ?
Sorry for my misunderstanding of the WCNF format and thanks for your clarification, I understand why it works now.
Francesco
from pysat.
Related Issues (20)
- Docs: `BeyondNP` link is broken HOT 2
- Obtaining cores with solve_limited HOT 2
- How to use a custom SAT solver within PySAT? HOT 1
- Incorrect sign convention in CryptoMinisat core HOT 2
- Release version mismatch between pypi and github HOT 4
- Very slow useless (?) deepcopy in from_clauses HOT 4
- Clausification of nested Implication fails HOT 15
- Method to get list of clauses after propagation? HOT 2
- Atom constructor reuses wrong object from store HOT 2
- Retrieve partial solution HOT 1
- (p ↔ p) simplifies to p HOT 6
- simplified fails with XOr HOT 6
- solve returns false, but the formula is satisfiable HOT 6
- `ITotalizer` does not accept an `IDPool HOT 2
- the s->prop_check(a, p, save_phase) in solvers/pysolvers.cc HOT 3
- Obtaining equisatisfiable CNF HOT 1
- cryptosat solver is listed, but can't be used HOT 5
- using pbenc or atmost function from cadical195 do not yield expected result HOT 4
- Trying to set incremental mode, but not compiled properly for this. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pysat.