Re: [R-SIG-Finance] Mixed integer programming

2019-02-19 Thread Hannu Kahra
Hi Eric, thank you very much. Best regards, Hannu On Tue, Feb 19, 2019 at 4:02 PM Eric Berger wrote: > Hi Hannu, > I figured out the problem. The following code works for me. Note that I > generally find it helpful to write function calls with the name of the > package they come from, as in

Re: [R-SIG-Finance] Mixed integer programming

2019-02-19 Thread Eric Berger
Hi Hannu, I figured out the problem. The following code works for me. Note that I generally find it helpful to write function calls with the name of the package they come from, as in ompr::MIPModel() rather than just MIPModel(). This is partly style and partly to avoid issues when functions get

Re: [R-SIG-Finance] Mixed integer programming

2019-02-19 Thread Enrico Schumann
> "Hannu" == Hannu Kahra writes: Hannu> I have tried to replicate Example 5.1 in Luenberger: Investment Science. Hannu> Here is the model Hannu> model <- MIPModel() %>% Hannu> add_variable(x[i], i = 1:7, type = "binary") %>% Hannu>

Re: [R-SIG-Finance] Mixed integer programming

2019-02-19 Thread Hannu Kahra
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 wrote: > I have tried to replicate Example 5.1 in

[R-SIG-Finance] Mixed integer programming

2019-02-19 Thread Hannu Kahra
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]) %>%