Skip to content

Commit

Permalink
Split instances of Flatzinc in 2 to limit test failures when run by G…
Browse files Browse the repository at this point in the history
…ithub Action
  • Loading branch information
cprudhom committed Aug 23, 2023
1 parent 6597b23 commit 7f3bc75
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@ private void logPerf(Flatzinc fzn) {
fzn.getModel().getName(), fzn.getModel().getSolver().getTimeCount()));
}

@DataProvider()
public Object[][] instances() {
public Object[][] getInstances(String name) {
List<Object[]> parameters = new ArrayList<>();
try (BufferedReader br = Files.newBufferedReader(
Paths.get(Objects.requireNonNull(this.getClass().getResource(
ROOT + "instances.csv")).getPath()))) {
ROOT + name)).getPath()))) {
// read the file line by line
String line;
while ((line = br.readLine()) != null) {
Expand All @@ -89,12 +88,49 @@ public Object[][] instances() {
return parameters.toArray(new Object[0][0]);
}

@Test(groups = "mzn", dataProvider = "instances", timeOut = 60000, priority = 2)
@DataProvider()
public Object[][] instances() {
return getInstances("instances.csv");
}

@Test(groups = "mzn", dataProvider = "instances", timeOut = 60_000, priority = 2)
public void testThemAll(String path, int solutions, Integer bst, int nodes, int failures) throws SetUpException {
String file = Objects.requireNonNull(this.getClass().getResource(path)).getFile();
String[] args = new String[]{
file,
"-limit", "[50s]", // but, problems are expected to end within 30s max
"-limit", "[50s]", // but, problems are expected to end within 15s max
"-lvl", LEVEL,
"-p", "1"
};
Flatzinc fzn = new Flatzinc();
fzn.setUp(args);
fzn.createSolver();
fzn.buildModel();
fzn.configureSearch();
//fzn.getModel().displayVariableOccurrences();
//fzn.getModel().displayPropagatorOccurrences();
fzn.solve();
Assert.assertEquals(fzn.getModel().getSolver().getSearchState(), SearchState.TERMINATED, "Unexpected search state");
if (bst != null) {
Assert.assertEquals(fzn.getModel().getSolver().getObjectiveManager().getBestSolutionValue(), bst, "Unexpected best solution");
}
Assert.assertEquals(fzn.getModel().getSolver().getSolutionCount(), solutions, "Unexpected number of solutions");
Assert.assertEquals(fzn.getModel().getSolver().getNodeCount(), nodes, "Unexpected number of nodes");
Assert.assertEquals(fzn.getModel().getSolver().getFailCount(), failures, "Unexpected number of failures");
logPerf(fzn);
}

@DataProvider()
public Object[][] hardInstances() {
return getInstances("hard_instances.csv");
}

@Test(groups = "mzn", dataProvider = "hardInstances", timeOut = 120_000, priority = 2)
public void testHardInstances(String path, int solutions, Integer bst, int nodes, int failures) throws SetUpException {
String file = Objects.requireNonNull(this.getClass().getResource(path)).getFile();
String[] args = new String[]{
file,
"-limit", "[110s]", // but, problems are expected to end within 30s max
"-lvl", LEVEL,
"-p", "1"
};
Expand Down
8 changes: 8 additions & 0 deletions parsers/src/test/resources/flatzinc/hard_instances.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#year,name,solutions,best,nodes,fails
2020,skill_allocation+mzn_1m_1.fzn,1,2,6196,6195
2020,stable-goods-solution+s-d6.fzn,13,6264,144303,144278
2018,rotating-workforce+ex1479.fzn,1,_,128979,128877
2016,tpp+6_3_20_1.fzn,65,131,2813024,2812895
2012,still-life-wastage+still-life+09.fzn,6,43,109396,109385
2012,still-life-wastage+still-life+10.fzn,8,54,164569,164554
2012,tpp+tpp+tpp_5_5_20_1.fzn,54,115,3215964,3215857
14 changes: 7 additions & 7 deletions parsers/src/test/resources/flatzinc/instances.csv
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
2020,p1f-pjs+10_new.fzn,27,300,11713,11660
2020,pentominoes+02.fzn,1,_,79,64
2020,radiation-i8-9.fzn,1,917,1097,1096
2020,skill_allocation+mzn_1m_1.fzn,1,2,6196,6195
#2020,skill_allocation+mzn_1m_1.fzn,1,2,6196,6195
2020,soccer+xIGData_22_12_22_5.fzn,1,_,4031,3725
2020,stable-goods-solution+s-d6.fzn,13,6264,144303,144278
#2020,stable-goods-solution+s-d6.fzn,13,6264,144303,144278
2019,amaze3+2012-03-19.fzn,1,_,68704,68687
2019,ccmcp+3_20_0_25_5.fzn,22,1247,113086,113043
2019,fm3_3.fzn,322,165922,6867,6224
Expand All @@ -24,11 +24,11 @@
2019,zephyrus+12_6_6_3.fzn,1,780,62511,62510
2018,oocsp_racks+050_r1.fzn,1,_,9,4
2018,oocsp_racks+050_r1n.fzn,1,_,9,4
2018,rotating-workforce+ex1479.fzn,1,_,128979,128877
#2018,rotating-workforce+ex1479.fzn,1,_,128979,128877
2018,test-scheduling+t30m10r3-15.fzn,1,2785,7684,7683
2017,group+u12g1pref0.fzn,13,207,819,794
2017,tcgc2+k10_34.fzn,2,433,429538,429535
2016,tpp+6_3_20_1.fzn,65,131,2813024,2812895
#2016,tpp+6_3_20_1.fzn,65,131,2813024,2812895
2016,mapping_mesh4x4_1.fzn,16,679,6775,6744
2016,mapping_ring_1.fzn,4,1685,2000,1993
2016,nfc_12_2_5.fzn,1,1074,3792,3791
Expand Down Expand Up @@ -59,9 +59,9 @@
2012,ship-schedule+ship-schedule.cp+6ShipsMixed.fzn,237,301650,16082,15609
2012,solbat+sb+sb_12_12_5_1.fzn,1,_,1315,1284
2012,solbat+sb+sb_14_14_6_0.fzn,1,_,383,352
2012,still-life-wastage+still-life+09.fzn,6,43,109396,109385
2012,still-life-wastage+still-life+10.fzn,8,54,164569,164554
2012,tpp+tpp+tpp_5_5_20_1.fzn,54,115,3215964,3215857
#2012,still-life-wastage+still-life+09.fzn,6,43,109396,109385
#2012,still-life-wastage+still-life+10.fzn,8,54,164569,164554
#2012,tpp+tpp+tpp_5_5_20_1.fzn,54,115,3215964,3215857
#2020,bnn+cellda_y_10s.fzn,1,6,16582,16581
#2019,foxgeesecorn+54.fzn,1,_,68704,68687
#2018,steiner-tree+es10fst03.stp.fzn,2,26003678,90150,90147

0 comments on commit 7f3bc75

Please sign in to comment.