Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support The R Optimization Infrastructure (ROI) #16

Open
dirkschumacher opened this issue May 9, 2017 · 4 comments
Open

Support The R Optimization Infrastructure (ROI) #16

dirkschumacher opened this issue May 9, 2017 · 4 comments

Comments

@dirkschumacher
Copy link

If you support ROI as a solver interface, users can use a number of different solvers out of the box. Currently plugins for the ILP solvers GLPK, symphony, lpsolve and cplex are on CRAN.

I am also currently working on CBC as a ROI plugin.

There are also two ROI plugins for Gurobi on Github.

@jeffreyhanson
Copy link
Contributor

Hi,

Thanks for getting in touch about ROI!

Yeah, I think it would be great if we could integrate ROI into prioritizr so we could get access to lots of different solvers.

At the moment, we're using an OptimizationProblem class for storing the model matrix, rhs, objective, etc.

Is there an equivalent class in ROI that we could convert our OptimizationProblem objects to, and then use the solvers offered in RIO to solve the problems?

Cheers,

Jeff

@dirkschumacher
Copy link
Author

dirkschumacher commented May 13, 2017

Hey Jeff,

there is a class called ROI::OP. Here is a simple, arbitrary example :)

library(ROI)
library(ROI.plugin.glpk)

# max: x1 + x2 + x3 + x4
# s.t. x1 + x2 + x3 + x4 <= 4
# 0 <= x1 <= 0
# 0 <= x2 <= 1
# 0 <= x3 <= 1
# 0 <= x4 <= 0

bounds <- ROI::V_bound( # <- sparse bound encoding
  ui = c(1, 2, 3, 4),
  ub = c(0, 1, 1, 0)
)
constraints <- ROI::L_constraint(L = matrix(c(1, 1, 1, 1), ncol = 4) # <- can be sparse,
                                 dir = "<=",
                                 rhs = 4)

op <- ROI::OP(c(1, 1, 1, 1), # <- can be sparse
              constraints,
              bounds = bounds,
              types = c("I", "I", "I", "I"),
              max = TRUE)
result <- ROI::ROI_solve(op, "glpk") # here you can use different solvers
result$solution

Florian Schwendinger is also working on a Gurobi plugin: https://r-forge.r-project.org/scm/viewvc.php/pkg/ROI.plugin.gurobi/?root=roi

@jeffreyhanson
Copy link
Contributor

Thank you very much for the demo and the heads up on Gurobi support.

It looks like it would be pretty straight forward to implement this. I'd really like to implement this. I'm a bit busy at the moment though, so it might take a while before I get to it.

@jeffreyhanson
Copy link
Contributor

I'm disappointed that I never got around to implementing ROI. I just wanted to say it's still on the cards. Do you know if there are any plans to make the gurobi plugin available on CRAN?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants