Closed Dharmesh946 closed 3 months ago
Hi Dharmesh, Thanks for your valuable feedback and suggestions. For the following issues:
double
data type Overflow issue:
Yes, it does exist when accumulate the path cost, double
lost its precision: check this stackoverflow linkfree
is not a good name for variable, should be renamed.I will modify and test the code according to the above suggestions, and update the code.
Best regards, Yong Yang
Thanks for your comment.
I overlooked the loss of precision but it may also be a concern (but I think that it might be negligible). My issue was more about overflow (dual variables exceeding their type range, if we want to use integral types).
Regards
Updated code.
Integer type for cost in not suggested due to the overflow issue, always use double for cost.
During algorithm execution, according to
cost
nature and range of values in assigncost, some variables can overflow, noticeablyd
,v
.For instance, if
cost
isstd::uintxx_t
I observed that some negative values can occurred when reducing cost. On the tests I did, it happened to work anyway due to modulo arithmetic with integers but I'm not sure that larger overflows can not occur, leading failure in the algorithm.Even if
cost
isdouble
or the largest possible integer, some computations may overflow (typically the final total cost).Besides
BIG
is not large enough. Why not set it tostd::numeric_limits<cost>::max()
?I don't understand the algorithm (neither from the code, nor the original paper) and I'm enable yet to determine if it has properties that limits the range of possible internal values according to input costs range.
Could it be possible to do this analysis and improve the computation safety (wrt overflows)?
Btw,
free
could be holding booleans? Am I right? And it should be rename as it collisions with a langage keyword.