Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/maven/org.antlr-antlr4-maven-pl…
Browse files Browse the repository at this point in the history
…ugin-4.9.2
  • Loading branch information
cprudhom authored May 5, 2021
2 parents cdd4a85 + db22327 commit c5330a7
Show file tree
Hide file tree
Showing 305 changed files with 580,163 additions and 5,785 deletions.
40 changes: 40 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG]"
labels: bug
assignees: ''

---

<!--
Please consider the following before submitting an issue:
- Issues are reserved for BUG reports and FEATURE requests, DO NOT create issues for questions or support requests. See [Choco-solver community](https://choco-solver.org/community/) for such purpose.
- Bug reports MUST be submitted with a [Minimal Working Example](https://stackoverflow.com/help/mcve).
-->
**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Possible solution**
Optionally, suggest a fix/reason for the bug or ideas how to implement the addition or change.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Environment (please complete the following information):**
- Choco-solver version: [e.g. 4.10.6]
- JRE : [e.g. 8]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
File renamed without changes.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ env:
- TEST_SUITE="1s"
- TEST_SUITE="10s"
- TEST_SUITE="checker"
- TEST_SUITE="expl"
- TEST_SUITE="mzn"
- TEST_SUITE="xcsp"
- TEST_SUITE="dimacs"
Expand Down
39 changes: 0 additions & 39 deletions ISSUE_TEMPLATE.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@
import gnu.trove.list.array.TFloatArrayList;
import org.chocosolver.parser.SetUpException;
import org.chocosolver.solver.Model;
import org.chocosolver.solver.search.strategy.Search;
import org.chocosolver.solver.variables.IntVar;
import org.testng.Assert;
import org.testng.annotations.Test;

import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;

/**
* <br/>
Expand Down Expand Up @@ -61,26 +66,41 @@ public void solveIt(Model s, boolean optimize) {
times.add(s.getSolver().getTimeCount());
}

@Test(groups="1s", timeOut=60000)
@Test(groups = "1s", timeOut = 60000)
public void testMain() throws IOException, SetUpException {
KnapsackTest ks = new KnapsackTest();
ks.solveIt(ks.modelIt("k10", 10), true);
ks.solveIt(ks.modelIt("k20", 13), true);
}


@Test(groups="1s", timeOut=60000)
@Test(groups = "1s", timeOut = 60000)
public void testALL0() throws IOException, SetUpException {
times.clear();
KnapsackTest ks = new KnapsackTest();
for (int i = 0; i < 1; i++) {
Model s = ks.modelIt("k0", 10);
ks.solveIt(s, true);
Assert.assertEquals(s.getSolver().getBestSolutionValue().intValue(), 7513, "obj val");
Assert.assertEquals(s.getSolver().getBestSolutionValue().intValue(), 7546, "obj val");
}
}

@Test(groups="1s", timeOut=60000)
@Test(groups = "10s", timeOut = 120_000)
public void testALL02() throws IOException, SetUpException {
times.clear();
KnapsackTest ks = new KnapsackTest();
for (int i = 0; i < 20; i++) {
Model s = ks.modelIt("k0", 8);
List<IntVar> scope = Arrays.asList(s.retrieveIntVars(true));
Collections.shuffle(scope, new Random(i));
s.getSolver().setSearch(Search.inputOrderUBSearch(scope.toArray(new IntVar[0])));
ks.solveIt(s, true);
Assert.assertEquals(s.getSolver().getBestSolutionValue().intValue(), 7546, "obj val");
s.getSolver().printShortStatistics();
}
}

@Test(groups = "1s", timeOut = 60000)
public void testALL5() throws IOException, SetUpException {
KnapsackTest ks = new KnapsackTest();
for (int i = 0; i < 1; i++) {
Expand All @@ -92,7 +112,7 @@ public void testALL5() throws IOException, SetUpException {
}
}

@Test(groups="1s", timeOut=60000)
@Test(groups = "1s", timeOut = 60000)
public void testALL10() throws IOException, SetUpException {
KnapsackTest ks = new KnapsackTest();
for (int i = 0; i < 1; i++) {
Expand All @@ -104,7 +124,7 @@ public void testALL10() throws IOException, SetUpException {
}
}

@Test(groups="1s", timeOut=60000)
@Test(groups = "1s", timeOut = 60000)
public void testOPT13() throws IOException, SetUpException {
KnapsackTest ks = new KnapsackTest();
Model s = ks.modelIt("k20", 13);
Expand All @@ -114,7 +134,7 @@ public void testOPT13() throws IOException, SetUpException {
Assert.assertEquals(s.getSolver().getNodeCount(), 15, "nb nod");
}

@Test(groups="1s", timeOut=60000)
@Test(groups = "1s", timeOut = 60000)
public void testOPT14() throws IOException, SetUpException {
KnapsackTest ks = new KnapsackTest();
Model s = ks.modelIt("k20", 14);
Expand All @@ -124,7 +144,7 @@ public void testOPT14() throws IOException, SetUpException {
Assert.assertEquals(s.getSolver().getNodeCount(), 16, "nb nod");
}

@Test(groups="1s", timeOut=60000)
@Test(groups = "1s", timeOut = 60000)
public void testOPT15() throws IOException, SetUpException {
KnapsackTest ks = new KnapsackTest();
Model s = ks.modelIt("k20", 15);
Expand Down
2 changes: 1 addition & 1 deletion parsers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4</artifactId>
<version>4.9.1</version>
<version>4.9.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
Expand Down
3 changes: 2 additions & 1 deletion parsers/src/main/java/org/chocosolver/parser/RegParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ private static void makeComplementarySearch(Model m) {
// do not enumerate on the complementary search (greedy assignment)
if (k > 0) {
solver.setSearch(solver.getSearch(),
Search.lastConflict(Search.domOverWDegSearch(Arrays.copyOf(ovars, k))));
//Search.lastConflict(Search.domOverWDegSearch(Arrays.copyOf(ovars, k))));
Search.inputOrderLBSearch(Arrays.copyOf(ovars, k)));
}
}
}
Expand Down
70 changes: 47 additions & 23 deletions parsers/src/test/java/org/chocosolver/mps/ParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@
*/
package org.chocosolver.mps;

import org.chocosolver.parser.mps.MPS;
import org.chocosolver.parser.SetUpException;
import org.chocosolver.parser.mps.MPS;
import org.chocosolver.solver.search.SearchState;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import java.io.BufferedReader;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

/**
* <p> Project: choco-parsers.
Expand All @@ -28,34 +31,46 @@
*/
public class ParserTest {


@Test(groups = "1s", timeOut = 60000)
public void test1() throws Exception {
ClassLoader cl = this.getClass().getClassLoader();
String file = cl.getResource("mps/example1.mps").getFile();
run(file);
}
private static final String ROOT = "/mps/";
private static final String COMMENT = "#";
private static final String DELIMITER = ",";

@DataProvider(name = "small")
public Object[][] mps() throws IOException {
ClassLoader cl = this.getClass().getClassLoader();
String folder = cl.getResource("mps").getFile();
return Files.walk(Paths.get(folder))
.filter(Files::isRegularFile)
.map(f -> new Object[]{f.toString()})
.toArray(Object[][]::new);
public Object[][] mps() {
List<Object[]> parameters = new ArrayList<>();
try (BufferedReader br = Files.newBufferedReader(
Paths.get(this.getClass().getResource(
ROOT + "instances.csv").getPath()))) {
// read the file line by line
String line;
while ((line = br.readLine()) != null) {
if (line.startsWith(COMMENT))
continue;
// convert line into columns
String[] columns = line.split(DELIMITER);
parameters.add(new Object[]{
ROOT + columns[0], // path
Integer.parseInt(columns[1]), // solutions
Double.parseDouble(columns[2]), // best
Integer.parseInt(columns[3]), // nodes
Integer.parseInt(columns[4]), // failures
Boolean.parseBoolean(columns[5]) // failures
});
}

}
} catch (IOException ex) {
ex.printStackTrace();
}
return parameters.toArray(new Object[0][0]);

@Test(groups = "mps", timeOut = 120000, dataProvider = "small")
public void test2(String file) throws IOException, SetUpException {
run(file);
}

private void run(String file) throws SetUpException {
@Test(groups = "mps", timeOut = 120000, dataProvider = "small")
public void test1(String path, int solutions, Double bst, int nodes, int failures, boolean comp) throws SetUpException {
String file = this.getClass().getResource(path).getFile();
String[] args = new String[]{
file,
"-limit", "[60s]",
"-limit", "[30s]",
"-stat",
"-prec", "1.0E-4D",
"-ninf", "-999.D",
Expand All @@ -68,8 +83,17 @@ private void run(String file) throws SetUpException {
mps.buildModel();
mps.configureSearch();
mps.solve();
Assert.assertTrue(mps.getModel().getSolver().getSearchState().equals(SearchState.TERMINATED)
|| mps.getModel().getSolver().getSolutionCount()>0);
if(comp){
Assert.assertEquals(mps.getModel().getSolver().getSearchState(), SearchState.TERMINATED, "Unexpected search state");
Assert.assertEquals(mps.getModel().getSolver().getNodeCount(), nodes, "Unexpected number of nodes");
Assert.assertEquals(mps.getModel().getSolver().getFailCount(), failures, "Unexpected number of failures");
}
Assert.assertEquals(mps.getModel().getSolver().getSolutionCount(), solutions, "Unexpected number of solutions");
if (mps.getModel().getSolver().getObjectiveManager().getBestSolutionValue() instanceof Integer) {
Assert.assertEquals(mps.getModel().getSolver().getObjectiveManager().getBestSolutionValue(), bst.intValue(), "Unexpected best solution");
} else {
Assert.assertEquals(mps.getModel().getSolver().getObjectiveManager().getBestSolutionValue(), bst, "Unexpected best solution");
}
}

}
12 changes: 6 additions & 6 deletions parsers/src/test/resources/dimacs/instances.csv
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#name,sat,nodes,fails
hole6.cnf,false,5813,5762
par8-1-c.cnf,true,41,39
quinn.cnf,true,5,2
zebra_v155_c1135.cnf,true,36531,36184
ais6.cnf,true,24,17
hole6.cnf,false,5723,5677
par8-1-c.cnf,true,44,39
quinn.cnf,true,4,1
zebra_v155_c1135.cnf,true,23382,23093
ais6.cnf,true,43,34
qg1-07.cnf,true,1117,1084
bmc-ibm-2.cnf,true,64664,62511
aim-50-1_6-yes1-4.cnf,true,4856,4774
aim-50-1_6-yes1-4.cnf,true,57615,57029
8 changes: 4 additions & 4 deletions parsers/src/test/resources/flatzinc/instances.csv
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
2019,amaze3+2012-03-19.fzn,1,_,68704,68687
2018,oocsp_racks+050_r1.fzn,1,_,9,4
2018,rotating-workforce+ex1479.fzn,1,_,128979,128877
2018,steiner-tree+es10fst03.stp.fzn,2,26003678,88211,88208
2018,steiner-tree+es10fst03.stp.fzn,2,26003678,90342,90339
2018,test-scheduling+t30m10r3-15.fzn,1,2785,7684,7683
2017,group+u12g1pref0.fzn,13,297,819,794
2017,tcgc2+k10_34.fzn,2,433,429538,429535
Expand All @@ -32,9 +32,9 @@
2012,pattern-set-mining-k2+pattern_set_mining_k2+audiology.fzn,38,54,212187,212112
2012,radiation+radiation+m06_15_15.fzn,1,711,307742,307741
2012,ship-schedule+ship-schedule.cp+5Ships.fzn,359,483650,3139,2422
2012,ship-schedule+ship-schedule.cp+6ShipsMixed.fzn,237,301650,16101,15628
2012,ship-schedule+ship-schedule.cp+6ShipsMixed.fzn,237,301650,16089,15616
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,26,46,3473,3422
2012,still-life-wastage+still-life+10.fzn,27,56,32548,32495
2012,still-life-wastage+still-life+09.fzn,8,46,3564,3549
2012,still-life-wastage+still-life+10.fzn,9,56,32568,32551
2012,tpp+tpp+tpp_5_5_20_1.fzn,54,115,3215963,3215856
Loading

0 comments on commit c5330a7

Please sign in to comment.