MCPcopy Create free account
hub / github.com/Z3Prover/z3 / cube

Method cube

src/api/java/Solver.java:422–465  ·  view source on GitHub ↗

Return a sequence of cubes (conjunctions of literals) for partitioning the search space. Each cube represents a partial assignment that can be used as a starting point for parallel solving. This is primarily useful for cube-and-conquer parallel SAT solving strategies, where different cubes can be so

(Expr<?>[] vars, int cutoff)

Source from the content-addressed store, hash-verified

420 * @throws Z3Exception
421 **/
422 public java.util.Iterator<BoolExpr[]> cube(Expr<?>[] vars, int cutoff)
423 {
424 ASTVector cubeVars = new ASTVector(getContext());
425 if (vars != null) {
426 for (Expr<?> v : vars) {
427 cubeVars.push(v);
428 }
429 }
430
431 return new java.util.Iterator<BoolExpr[]>() {
432 private BoolExpr[] nextCube = computeNext();
433
434 private BoolExpr[] computeNext() {
435 ASTVector result = new ASTVector(getContext(),
436 Native.solverCube(getContext().nCtx(), getNativeObject(),
437 cubeVars.getNativeObject(), cutoff));
438 BoolExpr[] cube = result.ToBoolExprArray();
439
440 // Check for termination conditions
441 if (cube.length == 1 && cube[0].isFalse()) {
442 return null; // No more cubes
443 }
444 if (cube.length == 0) {
445 return null; // Search space exhausted
446 }
447 return cube;
448 }
449
450 @Override
451 public boolean hasNext() {
452 return nextCube != null;
453 }
454
455 @Override
456 public BoolExpr[] next() {
457 if (nextCube == null) {
458 throw new java.util.NoSuchElementException();
459 }
460 BoolExpr[] current = nextCube;
461 nextCube = computeNext();
462 return current;
463 }
464 };
465 }
466
467 /**
468 * Set an initial value for a variable to guide the solver's search heuristics.

Callers

nothing calls this directly

Calls 3

pushMethod · 0.95
computeNextMethod · 0.95
getContextMethod · 0.80

Tested by

no test coverage detected