Updated script for miplib2017
Chris Matrakidis <[email protected]> Mon, 5 Oct 2020 18:16:22 +0300
| Newsgroups | gmane.comp.gnu.glpk |
|---|---|
| Message-ID | <CAEaJ3S6NtVofzmNCio1XQYhx1h6m8yqwxoKBJURC5aLz0X4ROA@mail.gmail.com> |
Domingo mentioned looking at miplib2017 problems, which reminded me of this: I noticed some time ago that the current script offered with miplib2017 suffers from accuracy loss when checking the results, because it was parsing the solution file in printable form, which rounds values a bit. An example miplib result file is in http://plato.asu.edu/ftp/milp_res1/benchmark.glpk.1threads.7200s.res where in the last column many solutions are reported as "fail" or "error". I made an updated version that also uses a solution file in printable form, that offers more digits of accuracy (attached) and seems to work a lot better with a subset of miplib problems I used for testing. Best Regards, Chris Matrakidis
run_glpk.sh
(application/x-shellscript, 2.4 KB)
#* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#* *
#* This file is part of the test engine for MIPLIB2017 *
#* *
#* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
SOLVER=$1
BINNAME=$2
NAME=$3
TIMELIMIT=$4
MEMLIMIT=$5 # The memory limit (in MB) # currently unused
SOLFILE=$6
THREADS=$7
MIPGAP=$8
echo > $SOLFILE
# set threads to given value
# nothing to be done for GLPK
# turn on feability pump and cuts
PARAMETERS="--fpump --cuts"
# set mipgap to given value
PARAMETERS=$PARAMETERS" --mipgap $MIPGAP"
# set timing to wall-clock time and pass time limit
PARAMETERS=$PARAMETERS" --tmlim $TIMELIMIT"
# set the available memory
PARAMETERS=$PARAMETERS" --memlim $MEMLIMIT"
# use deterministic mode (warning if not possible)
# nothing to be done for GLPK
# check for lp format
LP=`echo $NAME | grep "\.lp"`
if test $LP
then
PARAMETERS=$PARAMETERS" --lp"
fi
# run GLPK
$BINNAME $PARAMETERS $NAME -o $SOLFILE.1 -w $SOLFILE.2
if test -e $SOLFILE.1 && test -e $SOLFILE.2
then
# translate GLPK solution format into format for solution checker. The
# SOLFILE format is a very simple format where in each line we have a
# <variable, value> pair, separated by spaces. A variable name of
# =obj= is used to store the objective value of the solution, as
# computed by the solver. A variable name of =infeas= can be used to
# indicate that an instance is infeasible.
awk '
BEGIN {
start = 0;
}
/INTEGER UNDEFINED/ {
exit;
}
/INTEGER EMPTY/ {
printf ("=infeas=\n");
exit;
}
/^Integer feasibility conditions:/ {
start = 0;
}
/^[\-0-9 ]/{
if( start && FNR == NR )
{
a[$1] = $2;
if ( $3 == "" )
getline;
}
if( FNR != NR )
{
if ( FNR == 1 )
rows = $1;
if ( FNR == 2 )
printf ("=obj= %s\n", $2);
if ( FNR > rows + 2 )
printf ("%s %s \n", a[FNR - rows - 2], $1);
}
}
/Column name/ {
start = 1;
}
/^s/ {
printf ("=obj= %s\n", $6);
}
/^j/ {
printf ("%s %s \n", a[$2], $3);
}' $SOLFILE.1 $SOLFILE.2 > $SOLFILE
rm $SOLFILE.1 $SOLFILE.2
fi