Search in sources :

Example 1 with BasicProverEnvironment

use of org.sosy_lab.java_smt.api.BasicProverEnvironment in project java-smt by sosy-lab.

the class SolverConcurrencyTest method testConcurrentStack.

/**
 * Test solving of large formula on concurrent stacks in one context (Stacks are not created in
 * the Threads).
 */
@Test
public void testConcurrentStack() throws InvalidConfigurationException, InterruptedException {
    requireConcurrentMultipleStackSupport();
    SolverContext context = initSolver();
    FormulaManager mgr = context.getFormulaManager();
    IntegerFormulaManager imgr = mgr.getIntegerFormulaManager();
    BooleanFormulaManager bmgr = mgr.getBooleanFormulaManager();
    HardIntegerFormulaGenerator gen = new HardIntegerFormulaGenerator(imgr, bmgr);
    ConcurrentLinkedQueue<BasicProverEnvironment<?>> proverList = new ConcurrentLinkedQueue<>();
    for (int i = 0; i < NUMBER_OF_THREADS; i++) {
        BooleanFormula instance = gen.generate(INTEGER_FORMULA_GEN.getOrDefault(solver, 9));
        BasicProverEnvironment<?> pe = context.newProverEnvironment();
        pe.push(instance);
        proverList.add(pe);
    }
    assertConcurrency("testConcurrentStack", () -> {
        BasicProverEnvironment<?> stack = proverList.poll();
        assertWithMessage("Solver %s failed a concurrency test", solverToUse()).that(stack.isUnsat()).isTrue();
    });
    closeSolver(context);
}
Also used : SolverContext(org.sosy_lab.java_smt.api.SolverContext) BasicProverEnvironment(org.sosy_lab.java_smt.api.BasicProverEnvironment) BooleanFormulaManager(org.sosy_lab.java_smt.api.BooleanFormulaManager) BitvectorFormulaManager(org.sosy_lab.java_smt.api.BitvectorFormulaManager) FormulaManager(org.sosy_lab.java_smt.api.FormulaManager) IntegerFormulaManager(org.sosy_lab.java_smt.api.IntegerFormulaManager) BooleanFormulaManager(org.sosy_lab.java_smt.api.BooleanFormulaManager) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) IntegerFormulaManager(org.sosy_lab.java_smt.api.IntegerFormulaManager) BooleanFormula(org.sosy_lab.java_smt.api.BooleanFormula) Test(org.junit.Test)

Aggregations

ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)1 Test (org.junit.Test)1 BasicProverEnvironment (org.sosy_lab.java_smt.api.BasicProverEnvironment)1 BitvectorFormulaManager (org.sosy_lab.java_smt.api.BitvectorFormulaManager)1 BooleanFormula (org.sosy_lab.java_smt.api.BooleanFormula)1 BooleanFormulaManager (org.sosy_lab.java_smt.api.BooleanFormulaManager)1 FormulaManager (org.sosy_lab.java_smt.api.FormulaManager)1 IntegerFormulaManager (org.sosy_lab.java_smt.api.IntegerFormulaManager)1 SolverContext (org.sosy_lab.java_smt.api.SolverContext)1