Closed dirkschumacher closed 2 years ago
library(ompr) library(magrittr) MIPModel() %>% add_variable(x[e], e = 1:3) %>% set_objective(sum_expr(x[e], e = 1:3)) #> Error in sum_expr(x[e], e = 1:3): lazyeval::is_call(ast) is not TRUE MIPModel() %>% add_variable(x[e], e = 1:3) %>% set_objective(sum_expr(x[i], i = 1:3)) #> Mixed integer linear optimization problem #> Variables: #> Continuous: 3 #> Integer: 0 #> Binary: 0 #> Model sense: maximize #> Constraints: 0
Created on 2021-01-25 by the reprex package (v0.3.0)
The reason is R's partial argument matching as described in 4.3.2 of the language definition.
Is fixed in MIPModel2 which will, fingers crossed, become the successor of MIPModel. See #349
MIPModel2
MIPModel
Created on 2021-01-25 by the reprex package (v0.3.0)