title: R: how to hand over MIP_GAP option to glpk in ROI
body: <p>I am using the glpk solver via the roi package in R to solve a mip model. The integer optimization converges very fast to a solution that is within 0.1% of the true optimum but then takes forever if there are a lot of integers to solve for. </p>
  
  <p>For that reason I want to set the relative mip gap tolerance (as documented here <a href="https://rdrr.io/cran/glpkAPI/man/glpkConstants.html" rel="nofollow noreferrer">https://rdrr.io/cran/glpkAPI/man/glpkConstants.html</a>) to a larger value than default so that the solver converges faster. I am aware that this may yield suboptimal solutions but I want to get a feeling about the approximate solution. </p>
  
  <p>When handing over the mip gap option to glpk I get a warning message and the option is obviously ignored. There is a small illustration example of my code and output:</p>
  
  <pre><code>library(magrittr)
  library(dplyr)
  library(ompr)
  library(ROI)
  library(Rglpk)
  library(ROI.plugin.glpk)
  library(ompr.roi)
  
  #fun &lt;- function(big_M){
  big_M&lt;-1200
    set.seed(123)
    n_h &lt;- 10
    n_l &lt;- 10
    capacities_1 &lt;- matrix(sample(0:1000, n_l*n_h/2, replace=TRUE),ncol =n_h/2,nrow=n_l)
    capacities_2 &lt;- matrix(sample(0:100, n_l*n_h/2, replace=TRUE),ncol =n_h/2,nrow=n_l)
    capacities &lt;- cbind(capacities_1,capacities_2)
    demand &lt;- 0.9*matrix(apply(capacities,1,sum))
    x_min &lt;- 50
    plant_capacities &lt;- 1.1*matrix(apply(capacities,2,sum))
    u &lt;- matrix(sample(1:100, n_l*n_h, replace=TRUE),ncol =n_h,nrow=n_l)*sign(capacities)
    model &lt;-
      MIPModel() %&gt;%
      add_variable(b[l,h], l = 1:n_l, h= 1:n_h, type = "binary") %&gt;%
      add_variable(x[l,h], l = 1:n_l, h = 1:n_h, type = "continuous",lb =0,ub=1200) %&gt;%
      add_constraint(x_min*b[l,h] &lt;= x[l,h], l=1:n_l, h=1:n_h ) %&gt;%
      add_constraint( x[l,h] &lt;= big_M * b[l,h], l=1:n_l, h=1:n_h ) %&gt;%
      set_objective(sum_expr(u[l,h] * x[l,h], l = 1:n_l, h = 1:n_h)) %&gt;%
      add_constraint(sum_expr(x[l,h], l = 1:n_l) &lt;= plant_capacities[h], h = 1:n_h ) %&gt;%
      add_constraint(x[l,h] &lt;= capacities[l,h] , l = 1:n_l, h = 1:n_h ) %&gt;%
      add_constraint(sum_expr(x[l,h], h = 1:n_h) ==demand[l], l = 1:n_l ) %&gt;%
      solve_model(with_ROI("glpk",verbose=TRUE,tm_limit = 1000 * 360,mip_gap = 1e-6))
  
    result_table &lt;- get_solution(model, x[l,h])
  </code></pre>
  
  <p>and this gives me</p>
  
  <pre><code>&lt;SOLVER MSG&gt;  ----
  GLPK Simplex Optimizer, v4.47
  320 rows, 200 columns, 700 non-zeros
        0: obj =  0.000000000e+000  infeas = 2.555e+004 (10)
  *   155: obj =  1.350009700e+006  infeas = 0.000e+000 (0)
  *   212: obj =  1.422776500e+006  infeas = 0.000e+000 (0)
  OPTIMAL SOLUTION FOUND
  GLPK Integer Optimizer, v4.47
  320 rows, 200 columns, 700 non-zeros
  100 integer variables, all of which are binary
  Integer optimization begins...
  +   212: mip =     not found yet &lt;=              +inf        (1; 0)
  +   314: &gt;&gt;&gt;&gt;&gt;  1.387478500e+006 &lt;=  1.388678500e+006 &lt; 0.1% (22; 0)
  +   315: &gt;&gt;&gt;&gt;&gt;  1.388678500e+006 &lt;=  1.388678500e+006   0.0% (9; 13)
  +   315: mip =  1.388678500e+006 &lt;=     tree is empty   0.0% (0; 43)
  INTEGER OPTIMAL SOLUTION FOUND
  &lt;!SOLVER MSG&gt; ----
  Warning message:
  In ROI::ROI_solve(op, solver, ...) :
    the control argument "mip_gap" is not available in solver 'glpk'
  </code></pre>
  
  <p>Handing over the time limit via tm_limit works without problems so I am struggling to understand why it won't accept the mip_gap option. </p>
  
  <p>Any ideas? Thanks a lot.</p>