Skip to content
This repository was archived by the owner on May 10, 2024. It is now read-only.

Commit eac072a

Browse files
authored
[#110]: Don't search for an UNSAT core unless solver status is INFEASIBLE (#113)
Also adds a test case that is temporarily disabled until [#112] is fixed Signed-off-by: Athinagoras Skiadopoulos <[email protected]>
1 parent 163b44f commit eac072a

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

dcm/src/main/java/com/vmware/dcm/backend/ortools/OrToolsSolver.java

+7
Original file line numberDiff line numberDiff line change
@@ -1003,10 +1003,17 @@ private void addSolvePhase(final MethodSpec.Builder output, final IRContext cont
10031003
}
10041004
output.addStatement("return result");
10051005
output.endControlFlow();
1006+
1007+
output.beginControlFlow("else if (status == CpSolverStatus.INFEASIBLE)");
10061008
output.addStatement("final List<String> failedConstraints = o.findSufficientAssumptions(solver)");
10071009
output.addStatement("throw new $T(status.toString(), failedConstraints)", SolverException.class);
1010+
output.endControlFlow();
1011+
output.beginControlFlow("else");
1012+
output.addStatement("throw new $T(status.toString())", SolverException.class);
1013+
output.endControlFlow();
10081014
}
10091015

1016+
10101017
private static String tableNameStr(final String tableName) {
10111018
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, tableName);
10121019
}

dcm/src/test/java/com/vmware/dcm/ModelTest.java

+26
Original file line numberDiff line numberDiff line change
@@ -2202,6 +2202,32 @@ public void corfuModel() {
22022202
model.solve(Set.of("HOSTS", "STRIPES"));
22032203
}
22042204

2205+
@Test
2206+
@Disabled("Enable when https://github.com/vmware/declarative-cluster-management/issues/112 is fixed")
2207+
public void testSolverTimeLimit() {
2208+
final String modelName = "testSolverTimeLimit";
2209+
2210+
final DSLContext conn = setup();
2211+
conn.execute("CREATE TABLE t1(k integer, controllable__p1 integer, controllable__p2 integer, primary key (k))");
2212+
2213+
final List<String> views = toListOfViews("CREATE VIEW constraint_product AS " +
2214+
"SELECT * FROM t1 " +
2215+
"check (controllable__p1 * controllable__p2) = 12;" +
2216+
"CREATE VIEW constraint_nontrivial_divisor AS " +
2217+
"SELECT * FROM t1 " +
2218+
"check controllable__p1 > 1 and controllable__p2 > 1;"
2219+
);
2220+
2221+
conn.execute("insert into t1 values (1, 2, 6)");
2222+
conn.execute("insert into t1 values (2, 4, 3)");
2223+
2224+
final Model model = buildModel(conn, SolverConfig.OrToolsSolver, views, modelName);
2225+
2226+
model.updateData();
2227+
final Result<? extends Record> fetch = model.solve("T1");
2228+
System.out.println(fetch);
2229+
}
2230+
22052231
/**
22062232
* Splits the supplied SQL by ';'
22072233
*/

0 commit comments

Comments
 (0)