|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.opencyc.constraintsolver.ForwardCheckingSearcher
The ForwardCheckingSearcher object to perform forward checking search for one or more solutions to the ConstraintProblem.
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.
UnitTest#testConstraintProblem
Field Summary | |
protected static int |
ASK_ALL_OR_INDIV_THRESHOLD
When instantiating a rule having one variable left to instantiate for subsequent asking the KB, this parameter sets the threshold beyond which a variable is used in the ask -- returning what bindings are known (or proven) in the KB. |
protected ConstraintProblem |
constraintProblem
Reference to the parent ConstraintProblem object. |
protected java.util.ArrayList |
constraintRules
Reference to the collection of the constraint rules used in the search for solution(s). |
protected int |
nbrSteps
Number of search steps performed during the search for solution(s). |
protected Solution |
solution
Reference to the Solution for the parent ConstraintProblem object. |
protected ValueDomains |
valueDomains
Reference to the ValueDomains object for the parent ConstraintProblem object. |
protected int |
verbosity
Sets verbosity of the constraint solver output. |
Constructor Summary | |
ForwardCheckingSearcher(ConstraintProblem constraintProblem)
Constructs a new FowardCheckingSearcher object. |
Method Summary | |
protected java.util.ArrayList |
askWithVariable(CycList instantiatedRule,
CycVariable variable)
Returns a list of bindings for single unbound variable left in the rule. |
protected boolean |
checkForwardDifferentRule(ConstraintRule rule,
java.util.ArrayList remainingRuleVariables,
int level,
Binding currentBinding)
Applies the all-different constraint rule to the remaining domains and returns true iff no domains are wiped out. |
protected boolean |
checkForwardInstantiatedRule(CycList instantiatedRule,
java.util.ArrayList remainingRuleVariables,
java.util.ArrayList bindings,
int level,
Binding currentBinding)
Recurses to instantiate the rule in the constraint problem microtheory with all remaining variables as bindings. |
protected boolean |
checkForwardNonEvaluatableRule(ConstraintRule rule,
int level,
Binding currentBinding)
Performs forward checking of the given non-evaluatable rule to restrict the domains of remaining variables. |
protected boolean |
checkForwardRule(ConstraintRule rule,
java.util.ArrayList remainingRuleVariables,
int level,
Binding currentBinding)
Performs forward checking of the given rule to restrict the domains of remaining variables. |
protected boolean |
checkForwardRules(java.util.ArrayList remainingVariables,
int level,
Binding currentBinding)
Performs forward checking of applicable rules to restrict the domains of remaining variables. |
protected int |
constraintDegree(CycVariable variable,
java.util.ArrayList variables)
Returns the number of constraint rules applicable to variable and one or more of the other variables. |
protected void |
markPermittedRemainingBindings(CycList instantiatedRule,
java.util.ArrayList remainingVariables,
java.util.ArrayList bindings,
Binding currentBinding,
ConstraintRule currentRule)
Recurses to instantiate the constraint rule in the constraint problem KB microtheory with all remaining variables as bindings, marking the domain values as permitted with Boolean true. |
protected void |
restore(java.util.ArrayList remainingVariables,
int level)
Restores the eliminated value choices for constraint variables due to a backtrack in the search. |
boolean |
search(java.util.ArrayList variables,
int level)
Performs a depth-first search of the solution space, using forward checking to prune alternatives. |
protected CycVariable |
selectVariable(java.util.ArrayList variables)
From the list of variables, heuristically chooses the one most likely to narrow the remaining search space. |
void |
setVerbosity(int verbosity)
Sets verbosity of the constraint solver output. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected int verbosity
protected ConstraintProblem constraintProblem
protected java.util.ArrayList constraintRules
protected Solution solution
protected ValueDomains valueDomains
protected static final int ASK_ALL_OR_INDIV_THRESHOLD
protected int nbrSteps
Constructor Detail |
public ForwardCheckingSearcher(ConstraintProblem constraintProblem)
constraintProblem
- the parent constraint problemMethod Detail |
public void setVerbosity(int verbosity)
verbosity
- 0 --> quiet ... 9 -> maximum diagnostic inputpublic boolean search(java.util.ArrayList variables, int level) throws java.io.IOException, CycApiException
variables
- is the ArrayList of remaining variables to solvelevel
- is the current depth of the searchprotected CycVariable selectVariable(java.util.ArrayList variables)
variables
- the ArrayList of variables from which the choice is madeprotected boolean checkForwardRules(java.util.ArrayList remainingVariables, int level, Binding currentBinding) throws java.io.IOException, CycApiException
remainingVariables
- the ArrayList of variables for which no domain
values have yet been boundcurrentBinding
- the current variable and bound valueprotected boolean checkForwardRule(ConstraintRule rule, java.util.ArrayList remainingRuleVariables, int level, Binding currentBinding) throws java.io.IOException, CycApiException
rule
- the constraint ruleremainingRuleVariables
- the ArrayList of rule variables for which no domain
values have yet been boundlevel
- the current level of solution search depthcurrentBinding
- the current variable and bound valueprotected boolean checkForwardNonEvaluatableRule(ConstraintRule rule, int level, Binding currentBinding) throws java.io.IOException, CycApiException
rule
- the constraint rulelevel
- the current level of solution search depthcurrentBinding
- the current variable and bound valueprotected void markPermittedRemainingBindings(CycList instantiatedRule, java.util.ArrayList remainingVariables, java.util.ArrayList bindings, Binding currentBinding, ConstraintRule currentRule) throws java.io.IOException, CycApiException
instantiatedRule
- the constraint ruleremainingVariables
- the variables left to instantiate in the constraint rulebindings
- the instantiated values for variables already instantiated in the
constraint ruleprotected java.util.ArrayList askWithVariable(CycList instantiatedRule, CycVariable variable) throws java.io.IOException, CycApiException
instantiatedRule
- the rule in CycList form which has a single
unbound variablevariable
- the variable for which bindings are soughtprotected boolean checkForwardDifferentRule(ConstraintRule rule, java.util.ArrayList remainingRuleVariables, int level, Binding currentBinding)
rule
- the all-different constraint ruleremainingRuleVariables
- the variables left to instantiate in the constraint rulelevel
- the current level of solution search depthcurrentBinding
- the current variable and bound valueprotected boolean checkForwardInstantiatedRule(CycList instantiatedRule, java.util.ArrayList remainingRuleVariables, java.util.ArrayList bindings, int level, Binding currentBinding) throws java.io.IOException
rule
- the instantiated constraint ruleremainingRuleVariables
- the variables left to instantiate in the constraint rulebindings
- the list of bindings instantiated so farlevel
- the current level of solution search depthcurrentBinding
- the current variable and bound valueprotected void restore(java.util.ArrayList remainingVariables, int level)
protected int constraintDegree(CycVariable variable, java.util.ArrayList variables)
variable
- the variable which must be used in the counted constraint rulesvariables
- the counted constraint rules must use only these variables and no others.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |