Get variable values from a solution
get_solution(solution, expr) get_solution_(solution, expr) get_solution_(solution, expr)
a data.frame. One row for each variable instance and a column for each index. Unless it is a single variable, then it returns a single number.
## Not run: ------------------------------------ # library(magrittr) # result <- MIPModel() %>% # add_variable(x[i], i = 1:5) %>% # add_variable(y[i, j], i = 1:5, j = 1:5) %>% # add_constraint(x[i] >= 1, i = 1:5) %>% # set_bounds(x[i], lb = 3, i = 1:3) %>% # set_objective(0) %>% # solve_model(with_ROI("glpk")) # solution <- get_solution(result, x[i]) # solution2 <- get_solution(result, y[i, 1]) # solution3 <- get_solution(result, y[i, j]) ## ---------------------------------------------