Skip to content

Commit

Permalink
Reduced the maximum integer for Concorde to avoid overflows (reported…
Browse files Browse the repository at this point in the history
… by sarwanpasha).
  • Loading branch information
mhahsler committed Apr 17, 2020
1 parent e37b084 commit 1c20718
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Fixed Linkern file management on Windows.
* Converting distances that only contain 0 and Inf (e.g., from an adjacency matrix)
is now fixed for Concorde and Linkern.
* Reduced the maximum integer for Concorde to avoid overflows (reported by sarwanpasha).

# TSP 1.1-9 (02/02/2020)

Expand Down
7 changes: 5 additions & 2 deletions R/tsp_concorde.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ tsp_concorde <- function(x, control = NULL){

## check x
if(inherits(x, "TSP")){
if(n_of_cities(x) < 10) MAX <- 2^15 - 1 else MAX <- 2^31 - 1
#if(n_of_cities(x) < 10) MAX <- 2^15 - 1 else MAX <- 2^31 - 1
### MFH: concorde may overflow with 2^31-1
if(n_of_cities(x) < 10) MAX <- 2^15 - 1 else MAX <- 2^28 - 1
x <- .prepare_dist_concorde(x, MAX, control$precision)

}else if(inherits(x, "ETSP")) {
Expand Down Expand Up @@ -140,7 +142,8 @@ tsp_linkern <- function(x, control = NULL){
## check x
if(inherits(x, "TSP")) {

MAX <- 2^31 - 1
#MAX <- 2^31 - 1
MAX <- 2^28 - 1
x <- .prepare_dist_concorde(x, MAX, control$precision)

}else if(inherits(x, "ETSP")) {
Expand Down
4 changes: 2 additions & 2 deletions man/Concorde.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ concorde_help()
data("USCA312")
## run concorde only with fast cuts (-V)
solve_TSP(USCA312, method = "concorde", control = list(clo = "-V"))
## run concorde in verbose mode (-v) with fast cuts only (-V)
solve_TSP(USCA312, method = "concorde", control = list(clo = "-v -V"))
}
}
\keyword{documentation}% at least one, from doc/KEYWORDS

0 comments on commit 1c20718

Please sign in to comment.