Commit 6645f219 authored by leberre's avatar leberre
Browse files

Fix issue with Reader for LexicoDecoratorPB

git-svn-id: svn+ssh://svn.forge.ow2.org/svnroot/sat4j/maven/trunk@2530 ba638df5-4473-46d1-82f8-c3ae2a17a6e1
parent 68e1622f
......@@ -31,6 +31,7 @@ package org.sat4j.pb.reader;
import java.io.IOException;
import org.sat4j.pb.ObjectiveFunction;
import org.sat4j.pb.PBSolverHandle;
import org.sat4j.pb.tools.LexicoDecoratorPB;
import org.sat4j.reader.ParseFormatException;
......@@ -96,6 +97,14 @@ public class OPBReader2012 extends OPBReader2010 {
}
}
@Override
public ObjectiveFunction getObjectiveFunction() {
if (this.hasObjFunc && lexico == null) {
return new ObjectiveFunction(getVars(), getCoeffs());
}
return null;
}
@Override
public IProblem parseInstance(final java.io.Reader input)
throws ParseFormatException, ContradictionException {
......
......@@ -43,12 +43,12 @@ import org.sat4j.specs.IVecInt;
import org.sat4j.specs.TimeoutException;
import org.sat4j.tools.LexicoDecorator;
public class LexicoDecoratorPB extends LexicoDecorator<IPBSolver> implements
IPBSolver {
public class LexicoDecoratorPB extends LexicoDecorator<IPBSolver>
implements IPBSolver {
/**
*
*/
*
*/
private static final long serialVersionUID = 1L;
protected List<ObjectiveFunction> objs = new ArrayList<ObjectiveFunction>();
......@@ -64,8 +64,9 @@ public class LexicoDecoratorPB extends LexicoDecorator<IPBSolver> implements
}
public void setObjectiveFunction(ObjectiveFunction obj) {
throw new UnsupportedOperationException();
if (obj != null) {
throw new UnsupportedOperationException();
}
}
public ObjectiveFunction getObjectiveFunction() {
......@@ -81,8 +82,8 @@ public class LexicoDecoratorPB extends LexicoDecorator<IPBSolver> implements
@Override
public void addCriterion(IVecInt literals) {
addCriterion(new ObjectiveFunction(literals, new Vec<BigInteger>(
literals.size(), BigInteger.ONE)));
addCriterion(new ObjectiveFunction(literals,
new Vec<BigInteger>(literals.size(), BigInteger.ONE)));
}
public void addCriterion(IVecInt literals, IVec<BigInteger> coefs) {
......@@ -117,8 +118,9 @@ public class LexicoDecoratorPB extends LexicoDecorator<IPBSolver> implements
if (bigCurrentValue == null) {
throw new ContradictionException("no current value computed!");
}
addExactly(this.objs.get(this.currentCriterion).getVars(), this.objs
.get(this.currentCriterion).getCoeffs(), this.bigCurrentValue);
addExactly(this.objs.get(this.currentCriterion).getVars(),
this.objs.get(this.currentCriterion).getCoeffs(),
this.bigCurrentValue);
}
@Override
......
Markdown is supported
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