Sat4J耗尽堆空间

时间:2015-05-27 15:51:42

标签: heap sat4j

我正在尝试使用SAT求解器SAT4J来解决部分加权最大可满足性问题。

我的.wcnf文件很大,它包含大约一百万个约束。

当我运行求解器时 我得到以下内容作为输出(OutOfMemoryError:Java堆空间)的一部分:

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at org.sat4j.minisat.constraints.cnf.WLClause.<init>(WLClause.java:67)
at org.sat4j.minisat.constraints.cnf.LearntWLClause.<init>(LearntWLClause.java:38)
at org.sat4j.pb.constraints.UnitBinaryWLClauseConstructor.constructLearntClause(UnitBinaryWLClauseConstructor.java:66)
at org.sat4j.pb.constraints.AbstractPBClauseCardConstrDataStructure.constructLearntClause(AbstractPBClauseCardConstrDataStructure.java:197)
at org.sat4j.pb.constraints.AbstractPBClauseCardConstrDataStructure.createUnregisteredClause(AbstractPBClauseCardConstrDataStructure.java:75)
at org.sat4j.minisat.core.Solver.analyze(Solver.java:614)
at org.sat4j.minisat.core.Solver.search(Solver.java:1245)
at org.sat4j.minisat.core.Solver.isSatisfiable(Solver.java:2018)
at org.sat4j.tools.SolverDecorator.isSatisfiable(SolverDecorator.java:114)
at org.sat4j.tools.SolverDecorator.isSatisfiable(SolverDecorator.java:114)
at org.sat4j.pb.PseudoOptDecorator.admitABetterSolution(PseudoOptDecorator.java:177)
at org.sat4j.pb.PseudoOptDecorator.admitABetterSolution(PseudoOptDecorator.java:170)
at org.sat4j.ILauncherMode$2.solve(ILauncherMode.java:311)
at org.sat4j.AbstractLauncher.solve(AbstractLauncher.java:278)
at org.sat4j.AbstractLauncher.run(AbstractLauncher.java:245)
at org.sat4j.maxsat.GenericOptLauncher.main(GenericOptLauncher.java:229)

也就是说,堆空间错误。如何增加堆空间的大小以及将其增加到什么值?

这就是我在约束文件constraints.wcnf上调用sat4j求解器的方法:

/usr/bin/java -jar sat4j-maxsat.jar constraints.wcnf

由于

1 个答案:

答案 0 :(得分:2)

只需使用

java -Xms2g -Xmx2g -jar sat4j-maxsat.jar constraints.wcnf

例如使用2Gb的堆内存。