dpmcsuss/iGraphMatch

lapmod cost matrix

bkj opened this issue · 1 comments

bkj commented

Is this line correct?
https://github.com/dpmcsuss/iGraphMatch/blob/master/R/rlapjv.R#L64

The cost matrix transformation for lapjv looks like:

cost <- rbind(
  cbind(
    as.matrix(cost), 
    m + m * stats::runif(n)
  ),
  m + m * stats::runif(n + 1)
)

which adds a column to the left and a row to the bottom.

But the transformation for lapmod looks like:

cost <- rbind2(
  cbind2(
    cost, 
    sign * 1e5 * (m * ceiling(stats::runif(n))),
    c(pad_vec, - sign * 1e5 * m)
  )
)

which adds two columns to the left, and seems to call an rbind2 that doesn't do anything.

(I haven't yet dug into precisely what this transformation does, or the changes you made to lapmod, but figured I'd ask this first.)

Good catch. That does look like an error.

It should be

    cost <- rbind2(
        cbind2(
            cost,
            sign * 1e5 * (m * ceiling(stats::runif(n)))
        ),
        c(pad_vec, - sign * 1e5 * m)
    )

I'll check if it is causing any issues. I kind of doubt it but it's surprising it even works ....

In terms of what this is doing, it is supposed to help avoid some issues with these algorithms stalling but it's been so long I don't really remember the details. By adding very large entries I think it kind of ensures that no row/column is ever completely zeroed out but I'm definitely not an expert of these implementations.