org.sat4j.reader
Class CSPReader

java.lang.Object
  extended by org.sat4j.reader.Reader
      extended by org.sat4j.reader.CSPReader
All Implemented Interfaces:
ICSPCallback
Direct Known Subclasses:
CSPExtSupportReader, CSPSupportReader

public class CSPReader
extends Reader
implements ICSPCallback

This class is a CSP to SAT translator that is able to read a CSP problem using the First CSP solver competition input format and that translates it into clausal and cardinality (equality) constraints. That code has not been tested very thoroughly yet and was written very quickly to meet the competition deadline :=)) There is plenty of room for improvement.

Author:
leberre

Field Summary
protected  Relation[] relations
           
 
Constructor Summary
CSPReader(ISolver solver)
           
 
Method Summary
 void addConstantParameter(String arg0, int arg1)
           
 void addDomainValue(int arg0)
           
 void addDomainValue(int begin, int end)
           
 void addEffectiveParameter(int arg0)
           
 void addEffectiveParameter(String arg0)
           
 void addFormalParameter(String name, String type)
           
 void addIntegerItem(int arg0)
           
 void addRelationTuple(int[] tuple)
           
 void addVariable(String idvar, String iddomain)
           
 void addVariableItem(String arg0)
           
 void addVariableToConstraint(String arg0)
           
 void beginConstraint(String name, int arity)
           
 void beginConstraintsSection(int arg0)
           
 void beginDomain(String id, int size)
           
 void beginDomainsSection(int nbdomain)
           
 void beginInstance(String arg0)
           
 void beginParameterList()
           
 void beginPredicate(String name)
           
 void beginPredicatesSection(int arg0)
           
 void beginRelation(String name, int arity, int nbTuples, boolean isSupport)
           
 void beginRelationsSection(int nbrel)
           
 void beginVariablesSection(int expectedNumberOfVariables)
           
 void constraintExpression(String arg0)
           
 void constraintReference(String ref)
           
 String decode(int[] model)
           
 void decode(int[] model, PrintWriter out)
           
 void endConstraint()
           
 void endConstraintsSection()
           
 void endDomain()
           
 void endDomainsSection()
           
 void endInstance()
           
 void endParamaterList()
           
 void endPredicate()
           
 void endPredicatesSection()
           
 void endRelation()
           
 void endRelationsSection()
           
 void endVariablesSection()
           
protected  void manageAllowedTuples(int relnum, int arity, int nbtuples)
           
 IProblem parseInstance(Reader in)
           
 void predicateExpression(String expr)
           
 
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

relations

protected Relation[] relations
Constructor Detail

CSPReader

public CSPReader(ISolver solver)
Method Detail

parseInstance

public final IProblem parseInstance(Reader in)
                             throws ParseFormatException,
                                    ContradictionException,
                                    IOException
Specified by:
parseInstance in class Reader
Throws:
ParseFormatException
ContradictionException
IOException

decode

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

decode

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

manageAllowedTuples

protected void manageAllowedTuples(int relnum,
                                   int arity,
                                   int nbtuples)

beginInstance

public void beginInstance(String arg0)
Specified by:
beginInstance in interface ICSPCallback

beginDomainsSection

public void beginDomainsSection(int nbdomain)
Specified by:
beginDomainsSection in interface ICSPCallback

beginDomain

public void beginDomain(String id,
                        int size)
Specified by:
beginDomain in interface ICSPCallback

addDomainValue

public void addDomainValue(int arg0)
Specified by:
addDomainValue in interface ICSPCallback

addDomainValue

public void addDomainValue(int begin,
                           int end)
Specified by:
addDomainValue in interface ICSPCallback

endDomain

public void endDomain()
Specified by:
endDomain in interface ICSPCallback

endDomainsSection

public void endDomainsSection()
Specified by:
endDomainsSection in interface ICSPCallback

beginVariablesSection

public void beginVariablesSection(int expectedNumberOfVariables)
Specified by:
beginVariablesSection in interface ICSPCallback

addVariable

public void addVariable(String idvar,
                        String iddomain)
Specified by:
addVariable in interface ICSPCallback

endVariablesSection

public void endVariablesSection()
Specified by:
endVariablesSection in interface ICSPCallback

beginRelationsSection

public void beginRelationsSection(int nbrel)
Specified by:
beginRelationsSection in interface ICSPCallback

beginRelation

public void beginRelation(String name,
                          int arity,
                          int nbTuples,
                          boolean isSupport)
Specified by:
beginRelation in interface ICSPCallback

addRelationTuple

public void addRelationTuple(int[] tuple)
Specified by:
addRelationTuple in interface ICSPCallback

endRelation

public void endRelation()
Specified by:
endRelation in interface ICSPCallback

endRelationsSection

public void endRelationsSection()
Specified by:
endRelationsSection in interface ICSPCallback

beginPredicatesSection

public void beginPredicatesSection(int arg0)
Specified by:
beginPredicatesSection in interface ICSPCallback

beginPredicate

public void beginPredicate(String name)
Specified by:
beginPredicate in interface ICSPCallback

addFormalParameter

public void addFormalParameter(String name,
                               String type)
Specified by:
addFormalParameter in interface ICSPCallback

predicateExpression

public void predicateExpression(String expr)
Specified by:
predicateExpression in interface ICSPCallback

endPredicate

public void endPredicate()
Specified by:
endPredicate in interface ICSPCallback

endPredicatesSection

public void endPredicatesSection()
Specified by:
endPredicatesSection in interface ICSPCallback

beginConstraintsSection

public void beginConstraintsSection(int arg0)
Specified by:
beginConstraintsSection in interface ICSPCallback

beginConstraint

public void beginConstraint(String name,
                            int arity)
Specified by:
beginConstraint in interface ICSPCallback

constraintReference

public void constraintReference(String ref)
Specified by:
constraintReference in interface ICSPCallback

addVariableToConstraint

public void addVariableToConstraint(String arg0)
Specified by:
addVariableToConstraint in interface ICSPCallback

addEffectiveParameter

public void addEffectiveParameter(String arg0)
Specified by:
addEffectiveParameter in interface ICSPCallback

addEffectiveParameter

public void addEffectiveParameter(int arg0)
Specified by:
addEffectiveParameter in interface ICSPCallback

beginParameterList

public void beginParameterList()
Specified by:
beginParameterList in interface ICSPCallback

addIntegerItem

public void addIntegerItem(int arg0)
Specified by:
addIntegerItem in interface ICSPCallback

addVariableItem

public void addVariableItem(String arg0)
Specified by:
addVariableItem in interface ICSPCallback

endParamaterList

public void endParamaterList()
Specified by:
endParamaterList in interface ICSPCallback

addConstantParameter

public void addConstantParameter(String arg0,
                                 int arg1)
Specified by:
addConstantParameter in interface ICSPCallback

constraintExpression

public void constraintExpression(String arg0)
Specified by:
constraintExpression in interface ICSPCallback

endConstraint

public void endConstraint()
Specified by:
endConstraint in interface ICSPCallback

endConstraintsSection

public void endConstraintsSection()
Specified by:
endConstraintsSection in interface ICSPCallback

endInstance

public void endInstance()
Specified by:
endInstance in interface ICSPCallback


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