Verify#
This file contains a method to verify traceback solutions
verify_traceback_path(arr, path)
#
Verify that solution is a valid traceback solution of the DPArray.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dp
|
DPArray
|
A DPArray that should be initialzed according to an optimization problem. A traceback solution is not well defined for non-optimization dynamic programming (i.e. does not use max or min). |
required |
path
|
list of indices
|
A list of indices. For 1D DPArrays, this should be a list of integers. For 2D DPArrays, this should be a list of tuples. |
required |
Return
bool: False if the given path is not correct and True if it is correct. Empty paths will raise a Value Error. Incomplete paths (in which an unexplored predecessor still exists) are incorrect. Paths that contain the index of an unitialized element are incorrect.
Raises:
Type | Description |
---|---|
ValueError
|
Path is empty (length 0). |
Source code in dp/_verify.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|