[R-SIG-Finance] Mixed integer programming
Hannu Kahra
hk@hr@ @end|ng |rom gm@||@com
Tue Feb 19 13:10:37 CET 2019
I have tried to replicate Example 5.1 in Luenberger: Investment Science.
Here is the model
model <- MIPModel() %>%
add_variable(x[i], i = 1:7, type = "binary") %>%
set_objective(200*x[1]+30*x[2]+200*x[3]+60*x[4]+50*x[5]+100*x[6]+50*x[7])
%>%
add_constraint(100*x[1]+20*x[2]+150*x[3]+50*x[4]+50*x[5]+150*x[6]+150*x[7]
<= 500)
solve_model(with_ROI("glpk",verbose = TRUE))
I get the following error
Error in UseMethod("solve_model") :
no applicable method for 'solve_model' applied to an object of class
"function"
modelMixed integer linear optimization problem
Variables:
Continuous: 0
Integer: 0
Binary: 7
Model sense: maximize
Constraints: 1
What is wrong? Thank you in advance.
-Hannu
[[alternative HTML version deleted]]
More information about the R-SIG-Finance
mailing list