good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Viterbi applicationby azheid (Sexton) |
on Apr 06, 2014 at 19:56 UTC ( [id://1081331]=perlquestion: print w/replies, xml ) | Need Help?? |
azheid has asked for the wisdom of the Perl Monks concerning the following question: Monks, I am having trouble coding the Forward Dynamic programming algorithm. I have recently updated this post to account for new information. User kcott helped me simplify the code that I had written already to make it easier to read and use. The content of this post now reflects his advice and changes. My problem is still unsolved however, and I continue to ask for help The forward dynamic programming algorithm finds the shortest path in a connected unidirectional graph. I am playing with an NP-complete problem that can be searched with the A* algorithm, however to improve the efficiency of A*, I need to optimize the estimation function. The Forward Dynamic programming algorithm will solve the problem if I can implement it correctly. The chunk of code below sets up an identical data structure to the program I am working on. Please help me by showing how I would implement the forward dynamic programming algorithm to find the shortest path through the data. **Disclaimer** This is not homework. You are not helping me cheat. I am a biology Ph.D. candidate who enjoys playing with perl and DNA sequence data. I have just enough coding experience to hang myself with a short rope.
The @distance_matrix can be interpreted as a classic trellis diagram of nodes and paths. The $i dimension is the number of horizontal slices of a trellis graph. The $j dimension is the number of nodes for each $i slice. The $k dimension is the distance cost to the next slice nodes. In this example, all nodes of each trellis slice are connected to all nodes in adjacent slices. I have tried and failed to write a working piece of code for several days now and I need a push in the right direction. I know the min_dist subroutine is not even close to being correct. I am not sure how to write it correctly. The following website describes the algorithm I want to implement. http://www.cob.sjsu.edu/facstaff/davis_r/courses/QBAreader/dynprog.html
Back to
Seekers of Perl Wisdom
|
|