3

I've been using GLPK to solve some mixed integer programming problems. Here's a sample input file in MathProg format:

set REACTIONS;
set REACTANTS;
param Ys {i in REACTANTS, j in REACTIONS};
param Gamma {i in REACTANTS, j in REACTIONS};
param eps;
param delt;
var w {i in REACTANTS} >=-delt <=delt;
var R0 {i in REACTIONS} >=0 <=1, integer;
var Rn {i in REACTIONS} >=0 <=1, integer;
minimize z:  sum{i in REACTIONS} -Rn[i];
s.t. const1{i in REACTIONS} : sum{k in REACTANTS} w[k]*Gamma[k,i] <= delt*(1-R0[i]);
s.t. const2{i in REACTIONS} : -sum{k in REACTANTS} w[k]*Gamma[k,i] <= delt*(1-R0[i]);
s.t. const3{i in REACTIONS} : Rn[i] <= 1-R0[i];
s.t. const5{i in REACTIONS} : sum{k in REACTANTS} w[k]*Gamma[k,i] <= delt*(1-Rn[i])-eps;
s.t. const6{i in REACTIONS, j in REACTIONS: i <> j} : sum{k in REACTANTS} w[k]*(Ys[k,i]-Ys[k,j]) <= delt*(1-Rn[i]+Rn[j]+R0[j]);
data;
set REACTIONS:= 1 2 3 4 5 6;
set REACTANTS:= 1 2 3 4 5 6;
param Ys:   1   2   3   4   5   6:=
1    1  0   0   0   0   0
2    1  0   0   0   0   0
3    0  1   1   0   0   0
4    0  0   0   1   0   0
5    0  0   0   1   0   0
6    0  0   0   0   1   1;
param Gamma:    1   2   3   4   5   6:=
1    -1 1   0   0   0   1
2    -1 1   1   0   0   0
3    1  -1  -1  0   0   0
4    0  0   1   -1  1   0
5    0  0   0   -1  1   1
6    0  0   0   1   -1  -1;
param eps:=0.1;
param delt:=10;
end;

I've been running into performance problems for bigger problems of this type, and since SCIP claims to be several times faster than GLPK for MIP, it seems worth investigating. However, I haven't been able to make head or tail of the documentation when it comes to input file formats. SCIP's homepage says that it supports AMPL format, and the GLPK's homepagesays that MathProg is a subset of AMPL. Trying to feed the above file into SCIP 3.1.0 via scip -f file.nl returns the following error:

read problem <file.nl>
============

no reader for input file <file.nl> available

I'm not sure whether this is because I've failed to build SCIP with AMPL support, or something else. I found this blog post on building SCIP with AMPL support, but the instructions seem to be outdated as the source zip of SCIP 3.1.0 doesn't contain an interfaces folder.

So, I have two questions:

  1. Is it possible to get SCIP to recognise my MathProg input as is?
  2. If not, can anyone advise on how to convert it to a recognised format? An automated method would be preferable, as I don't really want to have to learn yet another format, but a manual method would be better than nothing.

Thanks for any help and apologies for my ignorance!

Kitserve
  • 115
  • 9
  • 1
    the tarball does have an `interfaces`-directory. It in located in the main SCIP-directory aka the SCIP-subdirectory of the SCIP Optimization Suite, if you downloaded the latter. – Gregor Jul 10 '14 at 08:12
  • Thanks, not sure how I managed to miss that! Unfortunately, scipampl didn't recognise the MathProg data as valid AMPL, so I presume that the relationship between MathProg and AMPL is more complicated than I'd hoped. – Kitserve Jul 14 '14 at 21:43
  • scipampl is an AMPL solver, so it accept input in .nl format (https://en.wikipedia.org/wiki/Nl_(format)). I don't think MathProg supports that. – vitaut Oct 13 '14 at 04:01

1 Answers1

3

As I indicated in my comment above, the Ampl-interface is still included in the SCIP-distribution, and you should be able to compile it and read your problem as documented in the excellent blog post you cite.

If you feel tempted to try different file formats, I see two options for you:

  1. use glpk for translating your problem into a file format that is recognizable by SCIP. I found methods glp_write_mps() and glp_write_lp. SCIP can read both .lp and .mps-files. Make sure that you use exactly these file extensions, because SCIP doesn't recognize files in .lp-format but ending with .txt instead.
  2. Use Zimpl to formulate your problems instead. The two formats of Zimpl and Ampl are strikingly similar, see the documentation for examples and further reference. Problem descriptions in Zimpl can be translated into .lp-format or read directly by SCIP, if you compile SCIP with the ZIMPL=true-option, which is the default.
Gregor
  • 1,333
  • 9
  • 16
  • 2
    Marking as accepted as this was useful information, although it didn't quite get me to a solution. One of colleagues found the answer I was looking for: `glpsol` includes an option to convert MathProg to .lp format, which is accepted by SCIP. In case it's useful to anyone else, here's how: ``glpsol --check --wlp newfilename.lp --math oldfilename.glpk`` – Kitserve Jul 14 '14 at 21:45
  • Thanks for posting the solution. I am not that used to glpk, when I downloaded it to answer your question, I thought the only access would be to include the library into own projects, which I figured you must have already written. I didn't quite understand that there is a standalone-executable `glpsol`, neither did the manual give me a hint about that. – Gregor Jul 15 '14 at 14:08