Exercise 17: Implement SolveConditionsSeptember 12, 2008
SummaryInput:
  | A rule, with 1 or more conditions. |
  | A hash to be used to store variable values. Initially it is only populated with the values of variables that could be determined by comparing the rule conclusion to what is to be derived. |
Output:
  | A list of hashes. Each hash represents a complete set of variable values that satisfy all conditions. |
Step 1:
Iteratively solve all conditions that have only variables with known values. If any of the conditions fails, then return an empty list.
Step 2:
Iteratively solve all conditions with a single unresolved variable using
SolveCondition. For each hash returned from
SolveCondition, recurse. Add each hash returned from our recurse to our output.
Step 3:
Iteratively solve all conditions with two unresolved variables. If a condition fails to solve, then try the next one, so on and so forth. If none of the two-variable conditions resolve, then return an empty list.
Exercise 16: Implement SolveConditionSeptember 12, 2008
SummaryInputs:
  | A rule condition with 1 or more variable tokens. |
  | A hash which defines the values of zero or more variables. |
  | The current token position. |
Outputs:
  | A list of hashes. Each hash represents a set of variable values that satisfies the condition. |
Algorithm:
  | Tokens are processed from left to right. |
  | Non-variable tokens are skipped over. |
  | Each variable which is found to exist in the variable hash should have its value substituted. |
  | Each unknown variable token needs to be solved. This list of possible entities is used to permute the variable hash into N new hashes. For each hash, the function recurses. |
 |   | This subroutine should not be called for relationships with two variables. |
  | The output of a recurse is a list of hashes. Each of these hashes represents part of the final output of the function. |
Exercise 15: Implement SolveAssignmentVariable and SolveRelationshipVariableSeptember 12, 2008
SolveAssignmentVariable Summary  | If the variable is within the path, use SolvePathVariable. Once solved, if the path is free of variables and the value is known, ensure the value matches. |
  | If the variable is the value of the assignment, then simply look it up. |
SolveRelationshipVariable Summary  | If there is only one variable, then use the appropriate entity's relation index to return all possibilities. |
  | If there are two variables, then this subroutine should not have been called. |
Input:
An assignment and a position within that assignment.
Output:
A list of entities.
older >>