Commit 97043f8d authored by Daniel Le Berre's avatar Daniel Le Berre
Browse files

Moved set/get id to IConstr

parent b80e750c
......@@ -330,28 +330,4 @@ public interface Constr extends IConstr {
* @see #canBePropagatedMultipleTimes()
*/
int getAssertionLevel(IVecInt trail, int decisionLevel);
/**
* Get a unique id for this constraint.
*
* @return a unique integral id for the constraint.
* @throws UnsupportedOperationException
* if no such identifier is available
* @since 3.0
*/
default int getId() {
throw new UnsupportedOperationException();
}
/**
* Allow the user to give a specific id to the constraint.
*
* The constraint may ignore it.
*
* @param nbConstraintsRead
* @since 3.0
*/
default void setId(int nbConstraintsRead) {
// do nothing
}
}
......@@ -106,4 +106,28 @@ public interface IConstr {
* rebuilding it.
*/
String dump();
/**
* Get a unique id for this constraint.
*
* @return a unique integral id for the constraint.
* @throws UnsupportedOperationException
* if no such identifier is available
* @since 3.0
*/
default int getId() {
throw new UnsupportedOperationException();
}
/**
* Allow the user to give a specific id to the constraint.
*
* The constraint may ignore it.
*
* @param nbConstraintsRead
* @since 3.0
*/
default void setId(int nbConstraintsRead) {
// do nothing
}
}
......@@ -69,7 +69,6 @@ import org.sat4j.pb.IPBSolver;
import org.sat4j.pb.ObjectiveFunction;
import org.sat4j.reader.ParseFormatException;
import org.sat4j.reader.Reader;
import org.sat4j.specs.Constr;
import org.sat4j.specs.ContradictionException;
import org.sat4j.specs.IConstr;
import org.sat4j.specs.IProblem;
......@@ -186,7 +185,7 @@ public class OPBReader2005 extends Reader implements Serializable {
constr = this.solver.addAtLeast(this.lits, this.coeffs, this.d);
}
this.nbConstraintsRead++;
((Constr) constr).setId(this.nbConstraintsRead);
constr.setId(this.nbConstraintsRead);
}
/**
......
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