conroylau / lpinfer

lpinfer: An R Package for Inference in Linear Programs
GNU General Public License v3.0
3 stars 5 forks source link

Change PSDTol setting in Gurobi #99

Closed a-torgovitsky closed 4 years ago

a-torgovitsky commented 4 years ago
library("lpinfer")
source("~/R/x86_64-pc-linux-gnu-library/3.6/lpinfer/example/dgp_mixedlogit.R")

dgp <- mixedlogit_dgp(dimw = 16, dimv = 100)

lpm <- lpmodel(A.obs = mixedlogit_Aobs(dgp),
               beta.obs = function(d) mixedlogit_betaobs(d, dgp),
               A.shp = rep(1, nrow(dgp$vdist)),
               beta.shp = 1,
               A.tgt = mixedlogit_Atgt_dfelast(dgp, w2eval = 1, eeval = -1))

estbounds(data = df, lpmodel = lpm, norm = 2, kappa = .1, solver = "gurobi")

yields

Error: Error 10020: Objective Q not PSD (diagonal adjustment of 3.5e-06 would be required). Set NonConvex parameter to 2 to solve model.

This is a Gurobi error that the objective matrix is close to being not PSD. However, we know it is always PSD by construction (please double-check this in the code!). So this is due to some numerical tolerance issues.

This behavior can be controlled with the PSDTol parameter in Gurobi, see here https://www.gurobi.com/documentation/9.0/refman/psdtol.html. I think we should set it to its max value of Infinity. Please check that this would solve the current problem.

conroylau commented 4 years ago

The objective matrix Q in the code is (A{\rm obs})'(A{\rm obs}) and hence it is PSD. After setting PSDTol = Inf in the Gurobi optimizer, the following output is obtained with the above code:

Estimated bounds: [0.06752, 0.80799] 

Thanks!