Closed Khaled9015 closed 3 years ago
There are variables in your environment that interfere with your defined model variables: x.
That refers to global variables/objects in your R (RStudio) environment. If you manually clear the workspace and run your model the warning should not appear. Here are a couple of helpful links:
https://community.rstudio.com/t/how-to-clear-the-r-environment/14303/6)
https://stackoverflow.com/questions/8813753/what-is-the-difference-between-gc-and-rm
Thanks it worked
rm(list=ls()) gc()
library(dplyr) library(ROI) library(ROI.plugin.glpk) library(ompr) library(ompr.roi)
result <- MIPModel() %>% add_variable(x, type = "integer") %>% add_variable(y, type = "continuous", lb = 0) %>% set_bounds(x, lb = 0) %>% set_objective(x + y, "max") %>% add_constraint(x + y <= 11.25) %>% solve_model(with_ROI(solver = "glpk")) get_solution(result, x) get_solution(result, y)
It seems to be fixed
When I run this simple example:-
library(magrittr) library(ompr) library(ROI) library(ROI.plugin.glpk) model <- MIPModel() %>% add_variable( x, type = "continuous") %>% set_objective(x, sense = "max") %>% add_constraint(x <= 5) model model %>% solve_model(with_ROI(solver = "glpk", verbose = TRUE))
I get this error:
There are variables in your environment that interfere with your defined model variables: x. This can lead to unexpected behaviour.There are variables in your environment that interfere with your defined model variables: x. This can lead to unexpected behaviour.There are variables in your environment that interfere with your defined model variables: x. This can lead to unexpected behaviour.Mixed integer linear optimization problem Variables: Continuous: 1 Integer: 0 Binary: 0 Model sense: maximize Constraints: 1