org.sat4j.pb.reader
Class OPBReader2005

java.lang.Object
  extended by org.sat4j.reader.Reader
      extended by org.sat4j.pb.reader.OPBReader2005
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
OPBReader2006

public class OPBReader2005
extends Reader
implements java.io.Serializable

Based on the "Official" reader for the Pseudo Boolean evaluation 2005. http://www.cril.univ-artois.fr/PB05/parser/SimpleParser.java provided by Olivier Roussel and Vasco Manquinho. Modified to comply with SAT4J architecture by Mederic Baron Updated since then by Daniel Le Berre

Author:
or, vm, mederic baron, leberre
See Also:
Serialized Form

Field Summary
protected  boolean hasVariablesExplanation
           
protected  int nbConstr
           
protected  int nbConstraintsRead
           
protected  int nbVars
           
protected  IPBSolver solver
           
 
Constructor Summary
OPBReader2005(IPBSolver solver)
           
 
Method Summary
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)
           
 void decode(int[] model, java.io.PrintWriter out)
           
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.Reader input)
           
protected  void putback(char c)
          put back a character into the stream (only one chr can be put back)
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 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)
           
 
Methods inherited from class org.sat4j.reader.Reader
isVerbose, parseInstance, parseInstance, setVerbosity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

solver

protected final IPBSolver solver

hasVariablesExplanation

protected boolean hasVariablesExplanation

nbVars

protected int nbVars

nbConstr

protected int nbConstr

nbConstraintsRead

protected int nbConstraintsRead
Constructor Detail

OPBReader2005

public OPBReader2005(IPBSolver solver)
Method Detail

metaData

protected void metaData(int nbvar,
                        int nbconstr)
callback called when we get the number of variables and the expected number of constraints

Parameters:
nbvar - the number of variables
nbconstr - the number of contraints

beginObjective

protected void beginObjective()
callback called before we read the objective function


endObjective

protected void endObjective()
callback called after we've read the objective function


beginConstraint

protected void beginConstraint()
callback called before we read a constraint


endConstraint

protected void endConstraint()
                      throws ContradictionException
Throws:
ContradictionException

translateVarToId

protected int translateVarToId(java.lang.String var)

constraintRelOp

protected void constraintRelOp(java.lang.String relop)
callback called when we read the relational operator of a constraint

Parameters:
relop - the relational oerator (>= or =)

constraintRightTerm

protected void constraintRightTerm(java.math.BigInteger val)
callback called when we read the right term of a constraint (also known as the degree)

Parameters:
val - the degree of the constraint

get

protected char get()
            throws java.io.IOException
get the next character from the stream

Throws:
java.io.IOException

getVars

public IVecInt getVars()

getCoeffs

public IVec<java.math.BigInteger> getCoeffs()

putback

protected void putback(char c)
put back a character into the stream (only one chr can be put back)


eof

protected boolean eof()
return true iff we've reached EOF


eol

protected boolean eol()

skipSpaces

protected void skipSpaces()
                   throws java.io.IOException
skip white spaces

Throws:
java.io.IOException

readWord

public java.lang.String readWord()
                          throws java.io.IOException
read a word from file

Returns:
the word we read
Throws:
java.io.IOException

readInteger

public void readInteger(java.lang.StringBuffer s)
                 throws java.io.IOException
read a integer from file

Parameters:
s - a StringBuffer to store the integer that was read
Throws:
java.io.IOException

readIdentifier

protected boolean readIdentifier(java.lang.StringBuffer s)
                          throws java.io.IOException,
                                 ParseFormatException
read an identifier from stream and store it in s

Returns:
the identifier we read or null
Throws:
java.io.IOException
ParseFormatException

isGoodFirstCharacter

protected boolean isGoodFirstCharacter(char c)

isGoodFollowingCharacter

protected boolean isGoodFollowingCharacter(char c)

checkId

protected void checkId(java.lang.StringBuffer s)
                throws ParseFormatException
Throws:
ParseFormatException

readMetaData

protected void readMetaData()
                     throws java.io.IOException,
                            ParseFormatException
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

Throws:
java.io.IOException
ParseException
ParseFormatException

readTerm

protected void readTerm(java.lang.StringBuffer coeff,
                        java.lang.StringBuffer var)
                 throws java.io.IOException,
                        ParseFormatException,
                        ContradictionException
read a term into coeff and var

Parameters:
coeff - the coefficient of the variable
var - the identifier we read
Throws:
java.io.IOException
ParseException
ParseFormatException
ContradictionException

readVariablesExplanation

protected void readVariablesExplanation()
                                 throws java.io.IOException,
                                        ParseFormatException
Throws:
java.io.IOException
ParseFormatException

parse

public void parse()
           throws java.io.IOException,
                  ParseFormatException,
                  ContradictionException
parses the file and uses the callbacks to send to send the data back to the program

Throws:
java.io.IOException
ParseException
ContradictionException
ParseFormatException

parseInstance

public final IProblem parseInstance(java.io.Reader input)
                             throws ParseFormatException,
                                    ContradictionException
Specified by:
parseInstance in class Reader
Throws:
ParseFormatException
ContradictionException

decode

public java.lang.String decode(int[] model)
Specified by:
decode in class Reader

decode

public void decode(int[] model,
                   java.io.PrintWriter out)
Specified by:
decode in class Reader

getObjectiveFunction

public ObjectiveFunction getObjectiveFunction()

getListOfVariables

public IVecInt getListOfVariables()


Copyright © 2009 Centre de Recherche en Informatique de Lens (CRIL). All Rights Reserved.