Closed kstegeman closed 2 years ago
When running the full model:
# next the MILP model is created
model <- MIPModel() %>%
# 1 if i gets assigned to facility j
add_variable(x[i, j], i = 1:n, j = 1:m, type = "binary") %>%
# 1 if facility j is a collection point
add_variable(y[j], j = 1:m, type = "binary") %>%
# 1 if facility j is a pick-up point
add_variable(u[j], j = 1:m, type = "binary") %>%
#C1
add_variable(C1[j], j=1:m, type = "continuous") %>%
#C
add_variable(C2[j], j=1:m, type = "continuous") %>%
# minimize the total cost
set_objective(
(sum
(ifelse((1-sum_expr(x[i,j], i = 1:n))>= 1,kR, 0))
)+
S*sum_expr(y[j], j = 1:m) +
a*sum_expr(C1[j], j = 1:m) +
T*sum_expr(u[j], j = 1:m) +
b*sum_expr(C2[j], j = 1:m), "min")
It gives me the following error Error in check_for_unknown_vars_impl(model, the_ast) : The expression contains a variable that is not part of the model.
However I'm positive I have defined all variables and parameters
When trying to model the MIP, I cannot add my variable y and I don't know why this is happening
model <- MIPModel() %>% add_variable(x[i, j], i = 1:n, j = 1:m, type = "binary")
add_variable(y[j], j = 1:m, type = "binary")
I have not piped it currently. Adding variable x is no problem, for y it gives me the following error: Error in addvariable(.model = .model, .variable = lazyeval::as.lazy(substitute(.variable), : object 'y' not found