|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.opencyc.constraintsolver.ConstraintProblem
ConstraintRule object to model the attributes and behavior of a constraint problem.
A ProblemParser object is created to parse the input constraint problem
representation.
A ValueDomains object is created to model the variables and their value domains.
A VariableDomainPopulator object is created to model variables whose value domain
cardinality exceeds a threshold for special case processing.
Copyright 2001 Cycorp, Inc., license is open source GNU LGPL.
THIS SOFTWARE AND KNOWLEDGE BASE CONTENT ARE PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENCYC ORGANIZATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE AND KNOWLEDGE BASE CONTENT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Field Summary | |
protected ArgumentTypeConstrainer |
argumentTypeConstrainer
ArgumentTypeConstrainer for this ConstraintProblem. |
protected java.util.ArrayList |
constraintRules
Collection of the constraint rules used in the search for solution(s). |
static int |
DEFAULT_VERBOSITY
The default verbosity of this object's output. |
protected java.util.ArrayList |
domainPopulationRules
Collection of the rules which populate variable domains. |
protected ForwardCheckingSearcher |
forwardCheckingSearcher
ForwardCheckingSearcher for this ConstraintProblem. |
CycFort |
mt
The OpenCyc microtheory in which the constraint rules should be asked. |
protected int |
nbrAsks
Number of KB asks performed during the search for solution(s). |
java.lang.Integer |
nbrSolutionsRequested
The number of solutions requested. |
protected NodeConsistencyAchiever |
nodeConsistencyAchiever
NodeConsistencyAchiever for this ConstraintProblem. |
protected CycList |
problem
The input problem CycList. |
protected ProblemParser |
problemParser
ProblemParser object for this ConstraintProblem. |
boolean |
randomizeInput
When true randomizes the order of the variables and domain values before beginning the search for a solution. |
protected RuleEvaluator |
ruleEvaluator
RuleEvaluator for this ConstraintProblem. |
protected java.util.ArrayList |
simplifiedRules
Collection of the simplified constraint rules derived from the input problem CycList. |
protected Solution |
solution
Solution for this ConstraintProblem. |
protected ValueDomains |
valueDomains
ValueDomains object for this ConstraintProblem. |
protected java.util.ArrayList |
variables
Collection of the constraint variables as CycVariable objects. |
protected int |
verbosity
Sets verbosity of this object's output. |
Constructor Summary | |
ConstraintProblem()
Constructs a new ConstraintProblem object, creating a new CycAccess object. |
|
ConstraintProblem(CycAccess cycAccess)
Constructs a new ConstraintProblem object given an existing connection to the OpenCyc server. |
Method Summary | |
protected java.util.ArrayList |
buildDomainPopulationRules(Solution solution,
java.util.ArrayList variables)
Builds a list of domain population rules from the given partial solution object. |
protected CycList |
buildSolutionConstraint(Solution solution)
Builds a constraint expression from the given partial solution object. |
void |
displayConstraintRules()
Displays the input constraint rules. |
void |
displayVariablesAndDomains()
Displays the variables and their value domains. |
int |
getNbrConstraintRules()
Returns the number of constraint ConstraintRule objects derived from the input problem. |
int |
getNbrDomainPopulationRules()
Returns the number of variable domain populating ConstraintRule objects derived from the input problem. |
int |
getNbrVariables()
Returns the number of Variable objects derived from the input problem. |
protected static CycAccess |
initializeCycAccess()
Creates a CycAccess object to connect to the OpenCyc server and provide api services. |
void |
setVerbosity(int verbosity)
Sets verbosity of this object's output. |
java.util.ArrayList |
solve(CycList problem)
Solves a constraint problem and return a list of solutions if one or more was found, otherwise returns null. |
java.util.ArrayList |
solve(java.lang.String problemString)
Solves a constraint problem and return a list of solutions if one or more was found, otherwise returns null. |
java.util.ArrayList |
solveUsingPartialSolution(Solution solution,
java.util.ArrayList variables,
java.util.ArrayList constraintRules)
Solves a constraint problem and return a list of solutions if one or more was found, otherwise returns null. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected ValueDomains valueDomains
protected NodeConsistencyAchiever nodeConsistencyAchiever
protected RuleEvaluator ruleEvaluator
protected ArgumentTypeConstrainer argumentTypeConstrainer
protected Solution solution
protected ForwardCheckingSearcher forwardCheckingSearcher
public CycFort mt
public boolean randomizeInput
public java.lang.Integer nbrSolutionsRequested
public static final int DEFAULT_VERBOSITY
protected int verbosity
protected java.util.ArrayList domainPopulationRules
protected java.util.ArrayList constraintRules
protected java.util.ArrayList simplifiedRules
protected ProblemParser problemParser
protected java.util.ArrayList variables
protected int nbrAsks
protected CycList problem
Constructor Detail |
public ConstraintProblem()
public ConstraintProblem(CycAccess cycAccess)
cycAccess
- the CycAccess object to use for this constraint problemMethod Detail |
protected static CycAccess initializeCycAccess()
public java.util.ArrayList solveUsingPartialSolution(Solution solution, java.util.ArrayList variables, java.util.ArrayList constraintRules) throws java.io.IOException, CycApiException
solution
- the partial solutionvariables
- the list of variables present in this constraint problemconstraintRules
- a list of constraint rules to further restrict the partial solution.protected java.util.ArrayList buildDomainPopulationRules(Solution solution, java.util.ArrayList variables) throws java.io.IOException, CycApiException
(#$elementOf ?var1 (#$TheSet value1_1 ... value1_N))
...
(#$elementOf ?varM (#$TheSet valueM_1 ... valueM_N))
solution
- the partial solutionvariables
- the list of variables present in this constraint problemprotected CycList buildSolutionConstraint(Solution solution) throws java.io.IOException, CycApiException
(#$or (#$and (#$equals ?var1 value1_1) ... (#$equals ?varN value1_N))
...
(#$and (#$equals ?var1 valueM_1) ... (#$equals ?varN valueM_N)))
solution
- a partial solutionpublic java.util.ArrayList solve(java.lang.String problemString) throws CycApiException
problem
- a constraint problem in the form of an OpenCyc query stringpublic java.util.ArrayList solve(CycList problem)
problem
- a constraint problem in the form of an OpenCyc query CycListpublic int getNbrDomainPopulationRules()
public int getNbrConstraintRules()
public int getNbrVariables()
public void displayConstraintRules()
public void displayVariablesAndDomains()
public void setVerbosity(int verbosity)
verbosity
- 0 --> quiet ... 9 -> maximum diagnostic input
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |