Greetings, I am having trouble getting the function reformulate_ATSP_as_TSP to work for me. I have provided a simple example of some of the code I've been using. In particular, I'm not sure why I'm getting the error "Error in dimnames(tsp) <- list(lab, lab) : length of 'dimnames' [1] not equal to array extent" since I created the object ATSP with a valid square matrix. Is there something simple I'm missing? The code is below. Thank you for your time.>x = array(0, dim=c(4,4)) > fix(x) > xcol1 col2 col3 col4 [1,] 0 1 2 3 [2,] 1 0 11 5 [3,] 2 4 0 6 [4,] 3 5 6 0> library(TSP) > example = ATSP(x) > example2 = reformulate_ATSP_as_TSP(example, infeasible = 1000, cheap > .0001)Error in dimnames(tsp) <- list(lab, lab) : length of 'dimnames' [1] not equal to array extent -- View this message in context: http://r.789695.n4.nabble.com/ATSP-to-TSP-reformulation-tp3755143p3755143.html Sent from the R help mailing list archive at Nabble.com.
Greetings, I am having trouble getting the function reformulate_ATSP_as_TSP to work for me. I have provided a simple example of some of the code I've been using. In particular, I'm not sure why I'm getting the error "Error in dimnames(tsp) <- list(lab, lab) : length of 'dimnames' [1] not equal to array extent" since I created the object ATSP with a valid square matrix. Is there something simple I'm missing? The code is below. Thank you for your time.>x = array(0, dim=c(4,4)) > fix(x) > xcol1 col2 col3 col4 [1,] 0 1 2 3 [2,] 1 0 11 5 [3,] 2 4 0 6 [4,] 3 5 6 0> library(TSP) > example = ATSP(x) > example2 = reformulate_ATSP_as_TSP(example, infeasible = 1000, cheap > .0001)Error in dimnames(tsp) <- list(lab, lab) : length of 'dimnames' [1] not equal to array extent -- View this message in context: http://r.789695.n4.nabble.com/ATSP-to-TSP-reformulation-tp3777105p3777105.html Sent from the R help mailing list archive at Nabble.com.
Hi Ian, I checked your example again and found the problem in tsp. fix(x) seems to create column names but not row names which exposes a bug in as.ATSP in tsp. This code replicates your error message: library(TSP) x <- rbind(c(1,2,3,4), c(1,0,11,5), c(2,4,0,6), c(3,5,6,0)) colnames(x) <- 1:4 #rownames(x) <- 1:4 atsp <- ATSP(x) tsp <- reformulate_ATSP_as_TSP(atsp) if you uncomment the rownames line then it works. I already fixed the code in tsp to check for missing col/row names in the matrix. This fix will be part of the next release. For now please just add row names to the matrix. Thanks for the bug report! -Michael -- Dr. Michael Hahsler, Visiting Assistant Professor Department of Computer Science and Engineering Lyle School of Engineering Southern Methodist University, Dallas, Texas (214) 768-8878 * mhahsler at lyle.smu.edu * http://lyle.smu.edu/~mhahsler
It worked fabulously. Thank you so much for help and time. -- View this message in context: http://r.789695.n4.nabble.com/ATSP-to-TSP-reformulation-tp3777105p3779476.html Sent from the R help mailing list archive at Nabble.com.