Title: | 'Multi-Solution' Binary Linear Problem Plug-in for the 'R' Optimization Interface |
---|---|
Description: | Enhances the 'R' Optimization Infrastructure ('ROI') package with the possibility to obtain multiple solutions for linear problems with binary variables. The main function is copied (with small modifications) from the relations package. |
Authors: | Kurt Hornik [aut], David Meyer [aut], Florian Schwendinger [aut, cre] |
Maintainer: | Florian Schwendinger <[email protected]> |
License: | GPL-3 |
Version: | 1.0-0 |
Built: | 2024-11-09 03:36:46 UTC |
Source: | https://github.com/r-forge/roi |
## Not run: library(ROI) op <- OP(objective = c(1, 1), constraints = L_constraint(c(1, 1), "==", 1), types = c("B", "B")) x <- ROI_solve(op, solver = "msbinlp", method = "glpk", nsol_max = 2L) x ## 2 optimal solutions found. ## The objective value is: 1.000000e+00 solution(x) ## [[1]] ## [1] 1 0 ## ## [[2]] ## [1] 0 1 ## End(Not run)
## Not run: library(ROI) op <- OP(objective = c(1, 1), constraints = L_constraint(c(1, 1), "==", 1), types = c("B", "B")) x <- ROI_solve(op, solver = "msbinlp", method = "glpk", nsol_max = 2L) x ## 2 optimal solutions found. ## The objective value is: 1.000000e+00 solution(x) ## [[1]] ## [1] 1 0 ## ## [[2]] ## [1] 0 1 ## End(Not run)
Matteo Fischetti and Domenico Salvagnin (2010) Pruning moves. INFORMS Journal on Computing 22.1: 108-119.
## Not run: library(ROI) op <- OP() objective(op) <- L_objective(c(-1, -1, -1, -1, -99)) mat <- simple_triplet_matrix(rep(1:3, 2), c(c(1, 3, 4), c(2, 4, 5)), rep(1, 6)) constraints(op) <- L_constraint(mat, dir = leq(3), rhs = rep.int(1, 3)) types(op) <- rep("B", length(op)) x <- ROI_solve(op, solver = "msbinlp", method = "glpk", nsol_max = 2L) x ## 2 optimal solutions found. ## The objective value is: -1.010000e+02 solution(x) ## [[1]] ## [1] 0 1 1 0 1 ## ## [[2]] ## [1] 1 0 1 0 1 ## End(Not run)
## Not run: library(ROI) op <- OP() objective(op) <- L_objective(c(-1, -1, -1, -1, -99)) mat <- simple_triplet_matrix(rep(1:3, 2), c(c(1, 3, 4), c(2, 4, 5)), rep(1, 6)) constraints(op) <- L_constraint(mat, dir = leq(3), rhs = rep.int(1, 3)) types(op) <- rep("B", length(op)) x <- ROI_solve(op, solver = "msbinlp", method = "glpk", nsol_max = 2L) x ## 2 optimal solutions found. ## The objective value is: -1.010000e+02 solution(x) ## [[1]] ## [1] 0 1 1 0 1 ## ## [[2]] ## [1] 1 0 1 0 1 ## End(Not run)