|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.sat4j.reader.Reader
org.sat4j.reader.CSPReader
public class CSPReader
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.
| Field Summary | |
|---|---|
protected Relation[] |
relations
|
| Constructor Summary | |
|---|---|
CSPReader(ISolver solver)
|
|
| Method Summary | |
|---|---|
void |
addConstantParameter(String arg0,
int arg1)
provides a constant value |
void |
addDomainValue(int arg0)
add a single value to the current domain |
void |
addDomainValue(int begin,
int end)
add the range of values [first..last] to the current domain |
void |
addEffectiveParameter(int arg0)
add an effective parameter which is a simple integer |
void |
addEffectiveParameter(String arg0)
add an effective parameter which is a simple variable to the current constraint |
void |
addFormalParameter(String name,
String type)
add a formal parameter to the current predicate |
void |
addIntegerItem(int arg0)
provides an integer value in a parameter list of a constraint |
void |
addRelationTuple(int[] tuple)
add a single tuple to the current relation |
void |
addVariable(String idvar,
String iddomain)
callback called to define a new variable |
void |
addVariableItem(String arg0)
provides the name of a variable in a parameter list of a constraint |
void |
addVariableToConstraint(String arg0)
declares that a variable is in the constraint scope |
void |
beginConstraint(String name,
int arity)
callback called at the beginning of the declaration of one constraint |
void |
beginConstraintsSection(int arg0)
callback called at the beginning of the constraints declarations |
void |
beginDomain(String id,
int size)
callback called at the beginning of the declaration of one domain |
void |
beginDomainsSection(int nbdomain)
callback called at the beginning of the domains declarations |
void |
beginInstance(String arg0)
signal the beginning of parsing |
void |
beginParameterList()
begins the list tag for parameters of a constraint |
void |
beginPredicate(String name)
callback called at the beginning of the declaration of one predicate |
void |
beginPredicatesSection(int arg0)
callback called at the beginning of the predicates declarations |
void |
beginRelation(String name,
int arity,
int nbTuples,
boolean isSupport)
callback called at the beginning of the declaration of one relation |
void |
beginRelationsSection(int nbrel)
callback called at the beginning of the relations declarations |
void |
beginVariablesSection(int expectedNumberOfVariables)
callback called at the beginning of the variables declarations |
void |
constraintExpression(String arg0)
provide the expression of the current constraint as an expression in a syntac chosen by the solver |
void |
constraintReference(String ref)
provide the definition of the current constraint |
String |
decode(int[] model)
Produce a model using the reader format. |
void |
decode(int[] model,
PrintWriter out)
Produce a model using the reader format on a provided printwriter. |
void |
endConstraint()
ends the definition of the current constraint |
void |
endConstraintsSection()
end the definition of all constraints |
void |
endDomain()
ends the definition of the current domain |
void |
endDomainsSection()
end the definition of all domains |
void |
endInstance()
signal the end of parsing |
void |
endParamaterList()
ends the list tag for parameters of a constraint |
void |
endPredicate()
ends the definition of the current predicate |
void |
endPredicatesSection()
end the definition of all predicates |
void |
endRelation()
ends the definition of the current relation |
void |
endRelationsSection()
end the definition of all relations |
void |
endVariablesSection()
end the definition of all variables |
protected void |
manageAllowedTuples(int relnum,
int arity,
int nbtuples)
|
IProblem |
parseInstance(Reader in)
|
void |
predicateExpression(String expr)
provide the expression of the current predicate |
| 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 |
|---|
protected Relation[] relations
| Constructor Detail |
|---|
public CSPReader(ISolver solver)
| Method Detail |
|---|
public final IProblem parseInstance(Reader in)
throws ParseFormatException,
ContradictionException,
IOException
parseInstance in class ReaderParseFormatException
ContradictionException
IOException
public void decode(int[] model,
PrintWriter out)
Reader
decode in class Readermodel - a model using the Dimacs format.out - the place where to display the modelpublic String decode(int[] model)
Reader
decode in class Readermodel - a model using the Dimacs format.
protected void manageAllowedTuples(int relnum,
int arity,
int nbtuples)
public void beginInstance(String arg0)
ICSPCallback
beginInstance in interface ICSPCallbackarg0 - name of the instancepublic void beginDomainsSection(int nbdomain)
ICSPCallback
beginDomainsSection in interface ICSPCallbacknbdomain - number of domains that will be declared
public void beginDomain(String id,
int size)
ICSPCallback
beginDomain in interface ICSPCallbackid - identifier of the domainsize - number of values in the domainpublic void addDomainValue(int arg0)
ICSPCallback
addDomainValue in interface ICSPCallbackarg0 - value to add to the domain
public void addDomainValue(int begin,
int end)
ICSPCallback
addDomainValue in interface ICSPCallbackbegin - first value to add to the domainend - last value to add to the domainpublic void endDomain()
ICSPCallback
endDomain in interface ICSPCallbackpublic void endDomainsSection()
ICSPCallback
endDomainsSection in interface ICSPCallbackpublic void beginVariablesSection(int expectedNumberOfVariables)
ICSPCallback
beginVariablesSection in interface ICSPCallbackexpectedNumberOfVariables - number of variables that will be declared
public void addVariable(String idvar,
String iddomain)
ICSPCallback
addVariable in interface ICSPCallbackidvar - identifier of the variableiddomain - identifier of the variable domainpublic void endVariablesSection()
ICSPCallback
endVariablesSection in interface ICSPCallbackpublic void beginRelationsSection(int nbrel)
ICSPCallback
beginRelationsSection in interface ICSPCallbacknbrel - number of relations that will be declared
public void beginRelation(String name,
int arity,
int nbTuples,
boolean isSupport)
ICSPCallback
beginRelation in interface ICSPCallbackname - identifier of the relationarity - arity of the relationnbTuples - number of tuples in the relationisSupport - true if tuples represent support, false if tuples represent
conflictspublic void addRelationTuple(int[] tuple)
ICSPCallback
addRelationTuple in interface ICSPCallbacktuple - tuple to add to the relation (contains arity elements)public void endRelation()
ICSPCallback
endRelation in interface ICSPCallbackpublic void endRelationsSection()
ICSPCallback
endRelationsSection in interface ICSPCallbackpublic void beginPredicatesSection(int arg0)
ICSPCallback
beginPredicatesSection in interface ICSPCallbackarg0 - number of predicates that will be declaredpublic void beginPredicate(String name)
ICSPCallback
beginPredicate in interface ICSPCallbackname - identifier of the predicate
public void addFormalParameter(String name,
String type)
ICSPCallback
addFormalParameter in interface ICSPCallbackname - name of the parametertype - type of the parameterpublic void predicateExpression(String expr)
ICSPCallback
predicateExpression in interface ICSPCallbackexpr - the abstract syntax tree representing the expressionpublic void endPredicate()
ICSPCallback
endPredicate in interface ICSPCallbackpublic void endPredicatesSection()
ICSPCallback
endPredicatesSection in interface ICSPCallbackpublic void beginConstraintsSection(int arg0)
ICSPCallback
beginConstraintsSection in interface ICSPCallbackarg0 - number of constraints that will be declared
public void beginConstraint(String name,
int arity)
ICSPCallback
beginConstraint in interface ICSPCallbackname - identifier of the constraintarity - arity of the constraintpublic void constraintReference(String ref)
ICSPCallback
constraintReference in interface ICSPCallbackref - the refererence to the definition of this constraint. May be a
relation, a predicate or the name of a global constraintpublic void addVariableToConstraint(String arg0)
ICSPCallback
addVariableToConstraint in interface ICSPCallbackarg0 - name of the variablepublic void addEffectiveParameter(String arg0)
ICSPCallback
addEffectiveParameter in interface ICSPCallbackarg0 - name of the variable passed as parameterpublic void addEffectiveParameter(int arg0)
ICSPCallback
addEffectiveParameter in interface ICSPCallbackarg0 - value of the parameterpublic void beginParameterList()
ICSPCallback
beginParameterList in interface ICSPCallbackpublic void addIntegerItem(int arg0)
ICSPCallback
addIntegerItem in interface ICSPCallbackarg0 - value of current list itempublic void addVariableItem(String arg0)
ICSPCallback
addVariableItem in interface ICSPCallbackarg0 - name of the current list itempublic void endParamaterList()
ICSPCallback
endParamaterList in interface ICSPCallback
public void addConstantParameter(String arg0,
int arg1)
ICSPCallback
addConstantParameter in interface ICSPCallbackpublic void constraintExpression(String arg0)
ICSPCallback
constraintExpression in interface ICSPCallbackarg0 - the expressionpublic void endConstraint()
ICSPCallback
endConstraint in interface ICSPCallbackpublic void endConstraintsSection()
ICSPCallback
endConstraintsSection in interface ICSPCallbackpublic void endInstance()
ICSPCallback
endInstance in interface ICSPCallback
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||