org.sat4j.reader
Class CSPReader
java.lang.Object
org.sat4j.reader.Reader
org.sat4j.reader.CSPReader
- All Implemented Interfaces:
- org.sat4j.csp.xml.ICSPCallback
- Direct Known Subclasses:
- CSPExtSupportReader, CSPSupportReader
public class CSPReader
- extends Reader
- implements org.sat4j.csp.xml.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 thoroughtly yet and was written very
quickly to meet the competition deadline :=)) There is plenty of room for
improvement.
- Author:
- leberre
|
Method Summary |
void |
addConstantParameter(java.lang.String arg0,
int arg1)
|
void |
addDomainValue(int arg0)
|
void |
addDomainValue(int begin,
int end)
|
void |
addEffectiveParameter(int arg0)
|
void |
addEffectiveParameter(java.lang.String arg0)
|
void |
addFormalParameter(java.lang.String name,
java.lang.String type)
|
void |
addIntegerItem(int arg0)
|
void |
addRelationTuple(int[] tuple)
|
void |
addVariable(java.lang.String idvar,
java.lang.String iddomain)
|
void |
addVariableItem(java.lang.String arg0)
|
void |
addVariableToConstraint(java.lang.String arg0)
|
void |
beginConstraint(java.lang.String name,
int arity)
|
void |
beginConstraintsSection(int arg0)
|
void |
beginDomain(java.lang.String id,
int size)
|
void |
beginDomainsSection(int nbdomain)
|
void |
beginInstance(java.lang.String arg0)
|
void |
beginParameterList()
|
void |
beginPredicate(java.lang.String name)
|
void |
beginPredicatesSection(int arg0)
|
void |
beginRelation(java.lang.String name,
int arity,
int nbTuples,
boolean isSupport)
|
void |
beginRelationsSection(int nbrel)
|
void |
beginVariablesSection(int nbvars)
|
void |
constraintExpression(java.lang.String arg0)
|
void |
constraintReference(java.lang.String ref)
|
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. |
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(java.io.Reader in)
|
void |
predicateExpression(java.lang.String expr)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
relations
protected Relation[] relations
CSPReader
public CSPReader(ISolver solver)
parseInstance
public final IProblem parseInstance(java.io.Reader in)
throws ParseFormatException,
ContradictionException,
java.io.IOException
- Specified by:
parseInstance in class Reader
- Throws:
ParseFormatException
ContradictionException
java.io.IOException
decode
public void decode(int[] model,
java.io.PrintWriter out)
- Description copied from class:
Reader
- Produce a model using the reader format on a provided printwriter.
- Specified by:
decode in class Reader
- Parameters:
model - a model using the Dimacs format.out - the place where to display the model
decode
public java.lang.String decode(int[] model)
- Description copied from class:
Reader
- Produce a model using the reader format.
- Specified by:
decode in class Reader
- Parameters:
model - a model using the Dimacs format.
- Returns:
- a human readable view of the model.
manageAllowedTuples
protected void manageAllowedTuples(int relnum,
int arity,
int nbtuples)
beginInstance
public void beginInstance(java.lang.String arg0)
- Specified by:
beginInstance in interface org.sat4j.csp.xml.ICSPCallback
beginDomainsSection
public void beginDomainsSection(int nbdomain)
- Specified by:
beginDomainsSection in interface org.sat4j.csp.xml.ICSPCallback
beginDomain
public void beginDomain(java.lang.String id,
int size)
- Specified by:
beginDomain in interface org.sat4j.csp.xml.ICSPCallback
addDomainValue
public void addDomainValue(int arg0)
- Specified by:
addDomainValue in interface org.sat4j.csp.xml.ICSPCallback
addDomainValue
public void addDomainValue(int begin,
int end)
- Specified by:
addDomainValue in interface org.sat4j.csp.xml.ICSPCallback
endDomain
public void endDomain()
- Specified by:
endDomain in interface org.sat4j.csp.xml.ICSPCallback
endDomainsSection
public void endDomainsSection()
- Specified by:
endDomainsSection in interface org.sat4j.csp.xml.ICSPCallback
beginVariablesSection
public void beginVariablesSection(int nbvars)
- Specified by:
beginVariablesSection in interface org.sat4j.csp.xml.ICSPCallback
addVariable
public void addVariable(java.lang.String idvar,
java.lang.String iddomain)
- Specified by:
addVariable in interface org.sat4j.csp.xml.ICSPCallback
endVariablesSection
public void endVariablesSection()
- Specified by:
endVariablesSection in interface org.sat4j.csp.xml.ICSPCallback
beginRelationsSection
public void beginRelationsSection(int nbrel)
- Specified by:
beginRelationsSection in interface org.sat4j.csp.xml.ICSPCallback
beginRelation
public void beginRelation(java.lang.String name,
int arity,
int nbTuples,
boolean isSupport)
- Specified by:
beginRelation in interface org.sat4j.csp.xml.ICSPCallback
addRelationTuple
public void addRelationTuple(int[] tuple)
- Specified by:
addRelationTuple in interface org.sat4j.csp.xml.ICSPCallback
endRelation
public void endRelation()
- Specified by:
endRelation in interface org.sat4j.csp.xml.ICSPCallback
endRelationsSection
public void endRelationsSection()
- Specified by:
endRelationsSection in interface org.sat4j.csp.xml.ICSPCallback
beginPredicatesSection
public void beginPredicatesSection(int arg0)
- Specified by:
beginPredicatesSection in interface org.sat4j.csp.xml.ICSPCallback
beginPredicate
public void beginPredicate(java.lang.String name)
- Specified by:
beginPredicate in interface org.sat4j.csp.xml.ICSPCallback
addFormalParameter
public void addFormalParameter(java.lang.String name,
java.lang.String type)
- Specified by:
addFormalParameter in interface org.sat4j.csp.xml.ICSPCallback
predicateExpression
public void predicateExpression(java.lang.String expr)
- Specified by:
predicateExpression in interface org.sat4j.csp.xml.ICSPCallback
endPredicate
public void endPredicate()
- Specified by:
endPredicate in interface org.sat4j.csp.xml.ICSPCallback
endPredicatesSection
public void endPredicatesSection()
- Specified by:
endPredicatesSection in interface org.sat4j.csp.xml.ICSPCallback
beginConstraintsSection
public void beginConstraintsSection(int arg0)
- Specified by:
beginConstraintsSection in interface org.sat4j.csp.xml.ICSPCallback
beginConstraint
public void beginConstraint(java.lang.String name,
int arity)
- Specified by:
beginConstraint in interface org.sat4j.csp.xml.ICSPCallback
constraintReference
public void constraintReference(java.lang.String ref)
- Specified by:
constraintReference in interface org.sat4j.csp.xml.ICSPCallback
addVariableToConstraint
public void addVariableToConstraint(java.lang.String arg0)
- Specified by:
addVariableToConstraint in interface org.sat4j.csp.xml.ICSPCallback
addEffectiveParameter
public void addEffectiveParameter(java.lang.String arg0)
- Specified by:
addEffectiveParameter in interface org.sat4j.csp.xml.ICSPCallback
addEffectiveParameter
public void addEffectiveParameter(int arg0)
- Specified by:
addEffectiveParameter in interface org.sat4j.csp.xml.ICSPCallback
beginParameterList
public void beginParameterList()
- Specified by:
beginParameterList in interface org.sat4j.csp.xml.ICSPCallback
addIntegerItem
public void addIntegerItem(int arg0)
- Specified by:
addIntegerItem in interface org.sat4j.csp.xml.ICSPCallback
addVariableItem
public void addVariableItem(java.lang.String arg0)
- Specified by:
addVariableItem in interface org.sat4j.csp.xml.ICSPCallback
endParamaterList
public void endParamaterList()
- Specified by:
endParamaterList in interface org.sat4j.csp.xml.ICSPCallback
addConstantParameter
public void addConstantParameter(java.lang.String arg0,
int arg1)
- Specified by:
addConstantParameter in interface org.sat4j.csp.xml.ICSPCallback
constraintExpression
public void constraintExpression(java.lang.String arg0)
- Specified by:
constraintExpression in interface org.sat4j.csp.xml.ICSPCallback
endConstraint
public void endConstraint()
- Specified by:
endConstraint in interface org.sat4j.csp.xml.ICSPCallback
endConstraintsSection
public void endConstraintsSection()
- Specified by:
endConstraintsSection in interface org.sat4j.csp.xml.ICSPCallback
endInstance
public void endInstance()
- Specified by:
endInstance in interface org.sat4j.csp.xml.ICSPCallback
Copyright © 2007 Centre de Recherche en Informatique de Lens (CRIL). All Rights Reserved.