Commit 8461e372 authored by Daniel Le Berre's avatar Daniel Le Berre
Browse files

fix for Eclipse p2 bug #28

parent b7b13afe
Pipeline #20603 passed with stages
in 51 minutes and 19 seconds
......@@ -30,6 +30,7 @@
package org.sat4j.pb.reader;
import java.io.IOException;
import java.text.ParseException;
import org.sat4j.core.VecInt;
import org.sat4j.pb.IPBSolver;
......@@ -43,8 +44,8 @@ import org.sat4j.specs.IVecInt;
public class OPBEclipseReader2007 extends OPBReader2007 {
/**
*
*/
*
*/
private static final long serialVersionUID = 1L;
private final IVecInt varExplain = new VecInt();
......@@ -68,6 +69,12 @@ public class OPBEclipseReader2007 extends OPBReader2007 {
protected void endListOfVariables() {
}
@Override
protected void readMetaData() throws IOException, ParseFormatException {
super.readMetaData();
startsMapping();
}
/**
* read the list for variables explanation (if any) calls
* beginListOfVariables and endListOfVariables
......@@ -76,8 +83,8 @@ public class OPBEclipseReader2007 extends OPBReader2007 {
* @throws ParseException
*/
@Override
protected void readVariablesExplanation() throws IOException,
ParseFormatException {
protected void readVariablesExplanation()
throws IOException, ParseFormatException {
char c;
StringBuilder var = new StringBuilder();
......
......@@ -715,7 +715,7 @@ public class OPBReader2005 extends Reader implements Serializable {
mapping = null;
readMetaData();
skipComments();
if (mapping != null) {
readVariablesExplanation();
}
......
package org.sat4j.pb;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import org.junit.Test;
import org.sat4j.pb.reader.OPBEclipseReader2007;
import org.sat4j.reader.ParseFormatException;
import org.sat4j.reader.Reader;
import org.sat4j.specs.ContradictionException;
import org.sat4j.specs.TimeoutException;
public class TestEclipseBugP228 {
private static final String OPB_FILE = "* #variable= 6 #constraint= 3 \n"
+ "*\n" + "\n" + "explain: x1 x2 x3 x4 x5 ;\n" + "\n"
+ "* P 1.0.0 requires either PP 1.0.0 \n" + "-1 x2 +1 x1 >= 0;\n"
+ "* 1223597333557 0.0.0.1223597333557 requires either P 1.0.0 \n"
+ "-1 x3 +1 x2 >= 0;\n" + "+1 x3 = 1;\n";
@Test
public void testExplain() throws ParseFormatException,
ContradictionException, IOException, TimeoutException {
IPBSolver solver = SolverFactory.newEclipseP2();
Reader reader = new OPBEclipseReader2007(solver);
reader.parseInstance(new ByteArrayInputStream(OPB_FILE.getBytes()));
assertTrue(solver.isSatisfiable());
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment