[R-SIG-Finance] Mixed integer programming
Hannu Kahra
hk@hr@ @end|ng |rom gm@||@com
Tue Feb 19 13:38:16 CET 2019
I forgot to mention that I am using the ompr package. An example is given
here
https://blog.revolutionanalytics.com/2016/12/mixed-integer-programming-in-r-with-the-ompr-package.html
-Hannu
On Tue, Feb 19, 2019 at 2:10 PM Hannu Kahra <hkahra using gmail.com> wrote:
> 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