File: run_cbc.sh

package info (click to toggle)
coinor-cbc 2.9.9%2Brepack1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,848 kB
  • ctags: 5,787
  • sloc: cpp: 104,337; sh: 8,921; xml: 2,950; makefile: 520; ansic: 491; awk: 197
file content (62 lines) | stat: -rwxr-xr-x 1,921 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#*                                                                           *
#*            This file is part of the test engine for MIPLIB2010            *
#*                                                                           *
#* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
# $Id: run_cbc.sh 1854 2013-01-28 00:02:55Z stefan $

SOLVER=$1
BINNAME=$2
NAME=$3
TIMELIMIT=$4
SOLFILE=$5
THREADS=$6
MIPGAP=$7

TMPFILE=results/check.$SOLVER.tmp

if test $THREADS != 0
then
    $BINNAME -import $NAME -sec $TIMELIMIT -threads $THREADS -ratio $MIPGAP -solve -solution $SOLFILE
else
    $BINNAME -import $NAME -sec $TIMELIMIT -ratio $MIPGAP -solve -solution $SOLFILE
fi

if test -f $SOLFILE
then
    # translate CBC 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{
	infeasible = 0;
        nointsol = 0;
    }
    ($3 != "objective" && $3 != "gap" && $3 != "time" && $2 != "infeasible"){
	if (!infeasible){
		printf ("%s %s \n", $2, $3);
	    }
    }
    ($3 == "objective" && $1 != "Infeasible" && $2 != "infeasible"){
	printf ("=obj= %s \n", $5);
    }
    ($3 == "gap"){
	printf ("=obj= %s \n", $8);
    }
    ($3 == "time"){
        if ($5 == "integer"){
           printf ("=nointsol= \n");
           nointsol = 1;
        }else{
           printf ("=obj= %s \n", $7);
        }
    }   
    ($1 == "Infeasible" || $2 == "infeasible"){
	printf ("=infeas= \n");
	infeasible = 1;
    }' $SOLFILE | tee $TMPFILE
    mv $TMPFILE $SOLFILE
fi