-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in get_solution() in case there is only one variable #198
Comments
Located the issue in the definition of extract_solution(). Return type of var_index <- do.call(rbind, regmatches(solution_names, rexp_c)) is not a matrix in case there is only one element in regmatches(solution_names, rexp_c). Thus the line result_df <- as.data.frame(var_index[, seq_len(ncol(var_index))[-1]]) trips as ncol is not define for non-matrix |
Ah interesting. Thanks a lot! |
Seems to be a bug in dirkschumacher/ompr.roi#19 |
Thanks a lot. |
Oh you are quick. I was preparing a PR. I started using your package recently. It is very good. |
Thanks for reporting the bug. I am slowly restarting my OS work again after a temoral leave, so I thought this is a good start ;) |
library(tidyverse)
#> -- Attaching packages ---------- tidyverse 1.2.1 --
#> v ggplot2 2.2.1 v purrr 0.2.4
#> v tibble 1.4.2 v dplyr 0.7.4
#> v tidyr 0.8.0 v stringr 1.3.0
#> v readr 1.1.1 v forcats 0.3.0
#> -- Conflicts ------------- tidyverse_conflicts() --
#> x dplyr::filter() masks stats::filter()
#> x dplyr::lag() masks stats::lag()
library(ompr)
library(ompr.roi)
library(ROI.plugin.glpk)
n <- 1; W <- 2
v <- runif(n);w <- runif(n)
model <- MIPModel() %>%
add_variable(x[i], i = 1:n, type = "binary") %>%
set_objective(sum_expr(v[i] * x[i], i = 1:n)) %>%
add_constraint(sum_expr(w[i] * x[i], i = 1:n) <= W)
result <- solve_model(model, with_ROI(solver = "glpk", verbose = FALSE))
solution <- get_solution(result, x[i])
#> Warning in seq_len(ncol(var_index)): first element used of 'length.out'
#> argument
#> Error in seq_len(ncol(var_index)): argument must be coercible to non-negative integer
The text was updated successfully, but these errors were encountered: