This is a quadratic optimization problem. It looks like it has formats including gms, lp, mod, qblib. But they are written in a way with expressions like - 42 b2*b4 - 32 b2*b5, instead of in matrix forms. My questions are
How to read this model to JuMP and solve it with Gurobi? Since the model file is very long, it is hard to create the model in JuMP by creating the variables and objective manually.
Even if there is a way to give the model directly to JuMP, how do I read the files into Julia and convert it into the matrix vector form b'Qb + d'b? So in other words, I would like to create the quadratic coefficient matrix Q and the coefficient vector for the linear term d in Julia. For example, if the file has 3 b1*b1 + 2 b1*b2+ 4 b2*b2 + 5 b1 + b2, then what is the way to read the file in Julia and give me Q=[3 1; 1 4], d=[5; 1]?
Thanks! The downloaded file is named QPLIB_0067.lp.txt. I tried your comment with both QPLIB_0067.lp.txt and QPLIB_0067.lp, but I always got the error read! is not implemented for LP files. What would be the reason for this? I’m using JuMP 0.21 with Julia 1.4.2.
Also, is there a way to delete the constraints in this model, and only keep the objective and the variables? Or construct a new model with the same variables and objective as the one I read in?
Just a note that if you do have access to GAMS for some reason, their CONVERT utility has quite a few target formats, including a JuMP scalar format.
(If there is once off need for a given file or just conversion of QPLib, I could probably help out.)
Thank you! You mean the conversion of .qplib file? I’m manually copying the matrices in the qplib file into Julia. Some files have too many lines (more than 10000) which is not easy to do. Are you aware of a faster way?
I just observed that from the QPLIB website that each instance comes as a .gms GAMS model format file, which can be converted with the GAMS convert tool to a JuMP scalar format.