r-opt / rmpk

Mixed Integer Linear and Quadratic Programming in R
https://r-opt.github.io/rmpk/
Other
45 stars 4 forks source link

There seems to be a bug atm in the package #45

Closed dirkdegel closed 4 years ago

dirkdegel commented 4 years ago

Hi Dirk,

I'm just looking into the package. I tried a the example from the read me page and the following minimal example:

library(rmpk)
library(ROI.plugin.lpsolve)
#library(rmpk.glpk)

# Optimal solution: $x = (7, 8)$, $z = 37$

#solver <- rmpk::ROI_solver("lpsolve", control = list())
solver <- rmpk::ROI_solver("lpsolve")
#solver <- GLPK()

model_rmpk_MIP <- rmpk::MIPModel(solver)
#x_1 <- model_rmpk_MIP$add_variable(type = "continuous", lower_bound = 0, upper_bound = 100)
#x_2 <- model_rmpk_MIP$add_variable(type = "continuous", lower_bound = 0, upper_bound = 100)
x_1 <- model_rmpk_MIP$add_variable(type = "continuous", lb = 0, ub = 100)
x_2 <- model_rmpk_MIP$add_variable(type = "continuous", lb = 0, ub = 100)
model_rmpk_MIP$set_objective(3 * x_1 + 2 * x_2, "max")
model_rmpk_MIP$add_constraint(2 * x_1 + 1 * x_2 <= 22)
model_rmpk_MIP$add_constraint(1 * x_1 + 2 * x_2 <= 23)
model_rmpk_MIP$add_constraint(4 * x_1 + 1 * x_2 <= 40)

model_rmpk_MIP$optimize()
model_rmpk_MIP$get_variable_value(x_1)
model_rmpk_MIP$get_variable_value(x_2)

In both cases I get the error massage:

Error: argument "name" is missing, with no default

Do you have any idea what's going wrong. I'm trying to get my head around how everything works with the optimizing packages like ompr, ROI, and the solvers itself.

Cheers Dirk

dirkschumacher commented 4 years ago

I changed the api recently. You currently need to add a name to each variable.

x_1 <- model_rmpk_MIP$add_variable("x1", type = "continuous", lb = 0, ub = 100)
dirkdegel commented 4 years ago

Thanks for the quick reply. Please let me know if there are things where a newbie can help.

dirkschumacher commented 4 years ago

Appreciate the offer. I will try to get to a point where it will be easier to contribute and will post issues. I am currently testing different implementations of solver interfaces.

In general any feedback, opinions or tests are always welcome