Commit 0b87fb1a authored by Mathieu Giraud's avatar Mathieu Giraud

core/dynprog.{h,cpp}: backtrack(), mark 'marked_pos_i' when we reach 'marked_pos_j'

parent aaea134e
......@@ -119,7 +119,9 @@ double Cost::toPValue(const int score)
}
DynProg::DynProg(const string &x, const string &y, DynProgMode mode, const Cost& cost, const bool reverse_x, const bool reverse_y)
DynProg::DynProg(const string &x, const string &y, DynProgMode mode, const Cost& cost,
const bool reverse_x, const bool reverse_y,
const int marked_pos_j)
{
this -> x = reverse_x ? reverse(x) : x ;
this -> y = reverse_y ? reverse(y) : y ;
......@@ -127,6 +129,9 @@ DynProg::DynProg(const string &x, const string &y, DynProgMode mode, const Cost&
this -> reverse_x = reverse_x ;
this -> reverse_y = reverse_y ;
this -> marked_pos_j = marked_pos_j;
this -> marked_pos_i = 0;
m = x.size();
n = y.size();
// cout << "Dynprog " << x << "(" << m << ") / " << y << "(" << n << ")" << endl ;
......@@ -427,6 +432,11 @@ void DynProg::backtrack()
while (1) {
if (j == marked_pos_j)
{
marked_pos_i = i ;
}
if ((i<0) || (j<0))
{
cout << "Invalid backtrack: " << i << "," << j << endl ;
......
......@@ -119,9 +119,14 @@ class DynProg
int best_j ; /* Start at 1 */
int first_i ; /* Start at 1 */
int first_j ; /* Start at 1 */
string str_back ;
int marked_pos_i ; // To be computed (in x)
int marked_pos_j ; // Given (in y)
DynProg(const string &x, const string &y, DynProgMode mode, const Cost &c, const bool reverse_x=false, const bool reverse_y=false);
DynProg(const string &x, const string &y, DynProgMode mode, const Cost &c,
const bool reverse_x=false, const bool reverse_y=false,
const int marked_pos_j=0);
~DynProg();
void init();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment