Method and apparatus for transparent backtracking
First Claim
1. A computerized method of backtracking in a program executable in a memory medium of a computer system comprising:
- instantiating a choice point in said executable program in said memory medium, said choice point identifying a point of decision in said program, at least one alternative being associated with said choice point;
examining said choice point to find said at least one alternative;
generating a failure exception in said program associated with said choice point when said at least one alternative is invalid;
specifying a catch point associated with a point of execution in said program wherein said failure exception is generated.
3 Assignments
0 Petitions
Accused Products
Abstract
A technique is used in embodiments of the invention such that backtracking programs can be written in a general purpose computer language (e.g., C++ or Java) without requiring the control structure of the program to reflect the structure of the decision tree. A data state and a control state are restored during backtracking. For restoring the data state, embodiments of the invention keep track of the changes made to variables and the point in execution at which the changes are made. When backtracking occurs, the data state can be restored by undoing the changes to the desired point in execution. For restoring the control state, the method of the invention provides a "failure" exception state that is invoked upon failure in the program (e.g., a failure to find a solution in a search program).. The failure exception is "caught" by catch points established in the execution stack. The failure exception is passed up the execution stack until a point is reached prior to the failure at which execution should be re-initiated. Since the control structure of the search program need not have the same form as the decision tree, part of the control state for the desired decision point may no longer exist on the execution stack, so the catch point may not be directly associated with the desired point but merely preceed it. The remaining part of the control state is restored by re-executing the program in a special re-execution mode until the desired state is achieved and another alternative may be chosen.
32 Citations
21 Claims
-
1. A computerized method of backtracking in a program executable in a memory medium of a computer system comprising:
-
instantiating a choice point in said executable program in said memory medium, said choice point identifying a point of decision in said program, at least one alternative being associated with said choice point; examining said choice point to find said at least one alternative; generating a failure exception in said program associated with said choice point when said at least one alternative is invalid; specifying a catch point associated with a point of execution in said program wherein said failure exception is generated. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8)
-
-
9. A backtracking search system executable in a memory medium on a computer system, said search system comprising:
-
a search stack residing in said memory medium, said search stack comprising at least one choice point having a set of alternatives; a model capable of examining said search stack to determine whether said set of alternatives are viable; an execution stack coupled to said model storing the execution state of said system and a plurality of catch points in said memory medium; an engine coupled to said model and said execution stack, said engine capable of reverting said search system to one of said plurality of catch points of said execution stack and reverting said search stack to a choice point having at least one untried alternative. - View Dependent Claims (10, 11, 12, 13)
-
-
14. An article of manufacturing comprising:
-
a computer usable medium having computer readable program code embodied therein for backtracking in a program comprising; computer readable program code configured to cause a computer to instantiate a choice point in an executable program said choice point identifying a point of decision in said program, at least one alternative being associated with said choice point; computer readable program code configured to cause a computer to examine said choice point to find said at least one alternative; computer readable program code configured to cause a computer to generate a failure exception in said program associated with said choice point when said at least one alternative is invalid; and computer readable program code configured to cause a computer to specify a catch point associated with a point of execution in said program wherein said failure exception is generated. - View Dependent Claims (15, 16, 17, 18, 19, 20, 21)
-
Specification