public class OPBReader2005 extends Reader implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
protected IVec<java.math.BigInteger> |
coeffs |
protected java.math.BigInteger |
d |
protected boolean |
hasObjFunc |
protected boolean |
hasVariablesExplanation |
protected IVecInt |
lits |
protected int |
nbConstr |
protected int |
nbConstraintsRead |
protected int |
nbVars |
protected java.lang.String |
operator |
protected IPBSolver |
solver |
Constructor and Description |
---|
OPBReader2005(IPBSolver solver) |
Modifier and Type | Method and Description |
---|---|
protected void |
beginConstraint()
callback called before we read a constraint
|
protected void |
beginObjective()
callback called before we read the objective function
|
protected void |
checkId(java.lang.StringBuffer s) |
protected void |
constraintRelOp(java.lang.String relop)
callback called when we read the relational operator of a constraint
|
protected void |
constraintRightTerm(java.math.BigInteger val)
callback called when we read the right term of a constraint (also known
as the degree)
|
java.lang.String |
decode(int[] model)
Produce a model using the reader format.
|
void |
decode(int[] model,
java.io.PrintWriter out)
Produce a model using the reader format on a provided printwriter.
|
protected void |
endConstraint() |
protected void |
endObjective()
callback called after we've read the objective function
|
protected boolean |
eof()
return true iff we've reached EOF
|
protected boolean |
eol() |
protected char |
get()
get the next character from the stream
|
IVec<java.math.BigInteger> |
getCoeffs() |
IVecInt |
getListOfVariables() |
ObjectiveFunction |
getObjectiveFunction() |
IVecInt |
getVars() |
protected boolean |
isGoodFirstCharacter(char c) |
protected boolean |
isGoodFollowingCharacter(char c) |
protected void |
metaData(int nbvar,
int nbconstr)
callback called when we get the number of variables and the expected
number of constraints
|
void |
parse()
parses the file and uses the callbacks to send to send the data back to
the program
|
IProblem |
parseInstance(java.io.InputStream in)
Read a file from a stream.
|
protected IProblem |
parseInstance(java.io.LineNumberReader input) |
IProblem |
parseInstance(java.io.Reader input)
Read a file from a reader.
|
protected void |
putback(char c)
put back a character into the stream (only one chr can be put back)
|
protected void |
readConstraint()
read a constraint calls beginConstraint, constraintTerm and endConstraint
|
protected boolean |
readIdentifier(java.lang.StringBuffer s)
read an identifier from stream and store it in s
|
void |
readInteger(java.lang.StringBuffer s)
read a integer from file
|
protected void |
readMetaData()
read the first comment line to get the number of variables and the number
of constraints in the file calls metaData with the data that was read
|
protected void |
readObjective()
read the objective line (if any) calls beginObjective, objectiveTerm and
endObjective
|
protected void |
readTerm(java.lang.StringBuffer coeff,
java.lang.StringBuffer var)
read a term into coeff and var
|
protected void |
readVariablesExplanation() |
java.lang.String |
readWord()
read a word from file
|
protected void |
skipSpaces()
skip white spaces
|
protected int |
translateVarToId(java.lang.String var) |
isVerbose, parseInstance, setVerbosity
protected final IPBSolver solver
protected final IVecInt lits
protected final IVec<java.math.BigInteger> coeffs
protected java.math.BigInteger d
protected java.lang.String operator
protected boolean hasObjFunc
protected boolean hasVariablesExplanation
protected int nbVars
protected int nbConstr
protected int nbConstraintsRead
public OPBReader2005(IPBSolver solver)
protected void metaData(int nbvar, int nbconstr)
nbvar
- the number of variablesnbconstr
- the number of contraintsprotected void beginObjective()
protected void endObjective()
protected void beginConstraint()
protected void endConstraint() throws ContradictionException
ContradictionException
protected int translateVarToId(java.lang.String var) throws ParseFormatException
ParseFormatException
protected void constraintRelOp(java.lang.String relop)
relop
- the relational oerator (>= or =)protected void constraintRightTerm(java.math.BigInteger val)
val
- the degree of the constraintprotected char get() throws java.io.IOException
java.io.IOException
public IVecInt getVars()
public IVec<java.math.BigInteger> getCoeffs()
protected void putback(char c)
protected boolean eof()
protected boolean eol()
protected void skipSpaces() throws java.io.IOException
java.io.IOException
public java.lang.String readWord() throws java.io.IOException
java.io.IOException
public void readInteger(java.lang.StringBuffer s) throws java.io.IOException
s
- a StringBuffer to store the integer that was readjava.io.IOException
protected boolean readIdentifier(java.lang.StringBuffer s) throws java.io.IOException, ParseFormatException
java.io.IOException
ParseFormatException
protected boolean isGoodFirstCharacter(char c)
protected boolean isGoodFollowingCharacter(char c)
protected void checkId(java.lang.StringBuffer s) throws ParseFormatException
ParseFormatException
protected void readMetaData() throws java.io.IOException, ParseFormatException
java.io.IOException
ParseException
ParseFormatException
protected void readTerm(java.lang.StringBuffer coeff, java.lang.StringBuffer var) throws java.io.IOException, ParseFormatException
coeff
- the coefficient of the variablevar
- the identifier we readjava.io.IOException
ParseException
ParseFormatException
protected void readVariablesExplanation() throws java.io.IOException, ParseFormatException
java.io.IOException
ParseFormatException
protected void readObjective() throws java.io.IOException, ParseFormatException
java.io.IOException
ParseException
ParseFormatException
protected void readConstraint() throws java.io.IOException, ParseFormatException, ContradictionException
ParseException
java.io.IOException
ContradictionException
ParseFormatException
public void parse() throws java.io.IOException, ParseFormatException, ContradictionException
java.io.IOException
ParseException
ContradictionException
ParseFormatException
public IProblem parseInstance(java.io.Reader input) throws ParseFormatException, ContradictionException
Reader
parseInstance
in class Reader
input
- a stream containing the benchmark.ParseFormatException
- if an error occurs during parsing.ContradictionException
- if the problem is found trivially inconsistent.Reader.parseInstance(InputStream)
protected IProblem parseInstance(java.io.LineNumberReader input) throws ParseFormatException, ContradictionException
public java.lang.String decode(int[] model)
Reader
public void decode(int[] model, java.io.PrintWriter out)
Reader
public ObjectiveFunction getObjectiveFunction()
public IVecInt getListOfVariables()
public IProblem parseInstance(java.io.InputStream in) throws ParseFormatException, ContradictionException, java.io.IOException
Reader
parseInstance
in class Reader
in
- a stream containing the benchmark.ParseFormatException
- if an error occurs during parsing.ContradictionException
- if the problem is found trivially inconsistent.java.io.IOException
- if an I/O error occurs.