njtierney / maxcovr

Tools in R to make it easier to solve the Maximal Coverage Location Problem
https://maxcovr.njtierney.com/
GNU General Public License v3.0
43 stars 12 forks source link

Error: Column `facility_chosen` must be a 1d atomic vector or a list #74

Open huanfachen opened 5 years ago

huanfachen commented 5 years ago

I tried testing the example of max_coverage() function, as follows:

require(maxcovr)
require(dplyr)
york_selected <- york %>% filter(grade == "I")
york_unselected <- york %>% filter(grade != "I")
# Try to call max_coverage with gurobi solver
system.time(
    res_max_cov <- max_coverage(existing_facility = york_selected,
                 proposed_facility = york_unselected,
                 user = york_crime,
                 distance_cutoff = 100,
                 n_added = 20,
                 solver = "gurobi")
)

It was shown that the gurobi solver ran successfully (gap 0.0%). Then I got this error.

# Error: Column `facility_chosen` must be a 1d atomic vector or a list

The output of sessionInfo() is:

R version 3.3.3 (2017-03-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] dplyr_0.7.4        bindrcpp_0.2       maxcovr_0.1.3.9100

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.16     rstudioapi_0.7   knitr_1.15.1     bindr_0.1        magrittr_1.5     hms_0.3         
 [7] devtools_1.13.3  lattice_0.20-34  R6_2.2.0         rlang_0.2.0      httr_1.3.1       tools_3.3.3     
[13] grid_3.3.3       lpSolve_5.6.13   utf8_1.1.3       cli_1.0.0        DBI_0.7          git2r_0.18.0    
[19] withr_2.0.0      assertthat_0.2.0 rprojroot_1.2    digest_0.6.12    tibble_1.4.2     crayon_1.3.4    
[25] Matrix_1.2-8     readr_1.1.1      Rglpk_0.6-3      base64enc_0.1-3  curl_2.3         slam_0.1-40     
[31] memoise_1.0.0    glue_1.1.1       gurobi_6.5-2     pillar_1.2.1     backports_1.0.5  pkgconfig_2.0.1 

I assume that this problem arises because of the new dplyr package. Can anyone help solve this problem? Thanks!

huanfachen commented 5 years ago

Update: I tried different solvers for this example. when the default solver (i.e. "glpk") is used, there is no error. Is it because different solvers generated different results?

njtierney commented 5 years ago

Hi there!

Thanks for reporting this and providing an example. I think that this is a bug to do with the internals / table or summary options. Let me have a closer look.