I'm using ompr package to develop BIN PACKING problem as staed in the following link:
https://developers.google.com/optimization/bin/bin_packing
This is the code I run:
# Import lpSolve package
library(lpSolve)
#Import required packages
library(dplyr)
library(ROI)
library(ROI.plugin.symphony)
library(ompr)
library(ompr.roi)
#Set weights
w <- c(48, 30, 19, 36, 36, 27, 42, 42, 36, 24, 30)
#Set bins' capacities
k <- c(100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100)
#Set number of available Bins
m <- length(w)
#Set number of Items
n <- length(w)
#Build model
Model <- MIPModel() %>% #define variables
add_variable(y[j], j = 1:m, type = "binary") %>%
add_variable(x[i][j], i = 1:n , j = 1:m, type = "binary") %>%
set_objective(sum_expr(y[j], j = 1:m), "min") %>% #define objective function
add_constraint(sum_expr(w[i] * x[i, j], i = 1:n) <= k[j] * y[j], j = 1:m) %>% #define constraints
add_constraint(sum_expr(x[i, j], j = 1:m) == 1 , i = 1:n) %>%
solve_model(with_ROI(solver = "symphony", verbosity = 1))
``
End this is the error I get:
Error in `[[<-`(`*tmp*`, var_name, value = var) :
index not found at level 1
What does it mean ? How can I address this issue?