Changeset 1555


Ignore:
Timestamp:
Dec 19, 2010 11:42:58 PM (9 years ago)
Author:
tkr
Message:

Updates to scripts

Location:
trunk/Cbc/scripts
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/scripts/parse.awk

    r1540 r1555  
    55#*                                                                           *
    66#* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    7 # $Id: parse.awk,v 1.1 2010/10/07 16:14:36 bzfwolte Exp $
     7# $Id: parse.awk,v 1.2 2010/12/14 08:38:22 bzfwolte Exp $
    88
    99function abs(x)
     
    2020}
    2121BEGIN {
    22    printf("------------------+------+-------+-------+--------+---------\n");
    23    printf("Name              | Gap%% | Nodes |  Time | Status | Solution \n");
    24    printf("------------------+------+-------+-------+--------+---------\n");
     22   printf("----------------------------+----------------+----------------+------+-------+-------+--------+---------\n");
     23   printf("Name                        |   Dual Bound   |  Primal Bound  | Gap%% | Nodes |  Time | Status | Solution \n");
     24   printf("----------------------------+----------------+----------------+------+-------+-------+--------+---------\n");
    2525
    2626   infty = +1e+20;
     
    2828   largegap = 1e+04;
    2929
     30   # initialize summary data
     31   nsolved = 0;
     32   nstopped = 0;
     33   nfailed = 0;
     34
    3035   # initialize data to be set in parse_<solver>.awk
    3136   solver = "?";
    3237   solverversion = "?";
    33    lps = "none";
    34    lpsversion = "-";
     38   solverremark = "";
    3539}
    3640# instance name
     
    5660   aborted = 1;
    5761   timeout = 0;
    58    solstatus = "unkown";
     62   solstatus = "none";
     63   read_error = 0;
    5964}
    6065# time
     
    6368/@05/ { timelimit = $2; }
    6469# solution status
     70/Read SOL:/ {
     71   solstatus = "--";
     72}
    6573/Check SOL:/ {
    6674   intcheck = $4;
     
    92100   # determine solving status
    93101   status = "";
    94    if( aborted )
    95       status = "abort";
     102   if( aborted && !read_error)
     103     status = "abort";
     104   else if (aborted && read_error)
     105     status = "noread";
    96106   else if( timeout )
    97       status = "timeout";
     107     status = "stopped";
    98108   else
    99       status = "ok";
     109     status = "ok";
    100110
    101    # compute gap
     111   # determine overall status from solving status and solution status:
     112
     113   # instance solved correctly (including case that no solution was found)
     114   if( status == "ok" && (solstatus == "ok" || solstatus == "--") )
     115      nsolved++;
     116   # incorrect solving process or infeasible solution (including errors with solution checker)
     117   else if( status == "abort" || (solstatus == "fail" || solstatus == "error") )
     118      nfailed++;
     119   # stopped due to imposed limits
     120   else if ( status == "stopped" )
     121      nstopped++;
     122   else
     123     nnoread++;
     124 
     125  # compute gap
    102126   temp = pb;
    103127   pb = 1.0*temp;
     
    125149      gapstr = " Large";
    126150
    127    printf("%-18s %6s %7d %7d %8s %9s\n", prob, gapstr, bbnodes, time, status, solstatus);
     151   printf("%-28s %16.9g %16.9g %6s %7d %7d %8s %9s\n", prob, db, pb, gapstr, bbnodes, time, status, solstatus);
    128152}
    129153END {
    130    printf("------------------+------+-------+-------+--------+---------\n");
     154   printf("----------------------------+----------------+----------------+------+-------+-------+--------+---------\n");
     155   printf("\n");
     156   printf("solved/stopped/noread/failed: %d/%d/%d/%d\n", nsolved, nstopped, nnoread, nfailed);
     157   printf("\n");
    131158   printf("@02 timelimit: %g\n", timelimit);
    132    printf("@01 %s(%s)%s(%s)\n", solver, solverversion, lps, lpsversion);
     159   printf("@01 %s(%s)%s\n", solver, solverversion, solverremark);
    133160}
  • trunk/Cbc/scripts/parse_cbc.awk

    r1540 r1555  
    55#*                                                                           *
    66#* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     7# $Id: parse_cbc.awk,v 1.1 2010/12/09 22:22:28 bzfheinz Exp $
    78
    89# set all solver specific data:
     
    7980}
    8081
     82/errors on input/ {
     83  read_error = 1;
     84}
  • trunk/Cbc/scripts/parse_cbc_sol.awk

    r1540 r1555  
    66#* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    77BEGIN{
    8    printf("\nSolution: \n\n");
    9    infeasible = 0;
     8  infeasible = 0;
     9  nointsol = 0;
    1010}
    11 ($3 != "objective" && $3 != "gap" && $3 != "time"){
    12    if (!infeasible){
    13       printf ("%s %s \n", $2, $3);
    14    }
     11($3 != "objective" && $3 != "gap" && $3 != "time" && $2 != "infeasible"){
     12  if (!infeasible){
     13    printf ("%s %s \n", $2, $3);
     14  }
    1515}
    16 ($3 == "objective" && $1 != "Infeasible"){
    17       printf ("=obj= %s \n", $5);
     16($3 == "objective" && $1 != "Infeasible" && $2 != "infeasible"){
     17  printf ("=obj= %s \n", $5);
    1818}
    1919($3 == "gap"){
    20       printf ("=obj= %s \n", $8);
     20  printf ("=obj= %s \n", $8);
    2121}
    2222($3 == "time"){
    23       printf ("=obj= %s \n", $7);
    24 }   
    25 ($1 == "Infeasible"){
    26    printf ("=infeas= \n");
    27    infeasible = 1;
     23  if ($5 == "integer"){
     24    printf ("=nointsol= \n");
     25    nointsol = 1;
     26  }else{
     27    printf ("=obj= %s \n", $7);
     28  }
     29}
     30($1 == "Infeasible" || $2 == "infeasible"){
     31  printf ("=infeas= \n");
     32  infeasible = 1;
    2833}
    2934
  • trunk/Cbc/scripts/run.sh

    r1540 r1555  
    1 #!/usr/bin/env bash
    21#* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    32#*                                                                           *
     
    54#*                                                                           *
    65#* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    7 # $Id: run.sh,v 1.1 2010/10/12 07:43:55 bzfwolte Exp $
     6# $Id: run.sh,v 1.4 2010/12/14 13:45:18 bzfheinz Exp $
    87
    9 SOLVER=$1
    10 LPS=$2
     8SHELL=$1
     9BINNAME=$2
    1110TSTNAME=$3
    1211TIMELIMIT=$4
    1312HARDMEMLIMIT=$5
     13THREADS=$6
    1414
    15 if test ! -e results
     15# construct paths
     16MIPLIBPATH=`pwd`
     17BINPATH=$MIPLIBPATH/bin
     18CHECKERPATH=$MIPLIBPATH/checker
     19RESULTSPATH=$MIPLIBPATH/results
     20SCRIPTPATH=$MIPLIBPATH/scripts
     21TSTPATH=$MIPLIBPATH/testset
     22
     23# check if the solver link (binary) exists
     24if test ! -e $BINPATH/$BINNAME
    1625then
    17     mkdir results
     26    echo "ERROR: solver link <$BINNAME> does not exist in <bin> folder; see bin/README"
     27    exit;
    1828fi
    1929
    20 OUTFILE=results/check.$SOLVER.$LPS.$TSTNAME.out
    21 RESFILE=results/check.$SOLVER.$LPS.$TSTNAME.res
    22 SOLFILE=results/check.$SOLVER.$LPS.$TSTNAME.sol
     30# check if the test set file/link exists
     31if test ! -e $TSTPATH/$TSTNAME.test
     32then
     33    echo "ERROR: test set file/link <$TSTNAME.test> does not exist in <testset> folder"
     34    exit;
     35fi
    2336
    24 CHECKTOL=-4 # short for 1e-04
     37# grep solver name
     38SOLVER=`echo $BINNAME | sed 's/\([a-zA-Z0-9_-]*\).*/\1/g'`
     39
     40# check if the result folder exist. if not create the result folder
     41if test ! -e $RESULTSPATH
     42then
     43    mkdir $RESULTSPATH
     44fi
     45
     46# construct name of output, results, and temporary solution file 
     47BASENAME=$RESULTSPATH/$TSTNAME.$BINNAME
     48OUTFILE=$BASENAME.out
     49RESFILE=$BASENAME.res
     50SOLFILE=$BASENAME.sol
     51
     52# absolut tolerance for checking linear constraints and objective value
     53LINTOL=1e-4
     54# absolut tolerance for checking integrality constraints
     55INTTOL=1e-4
     56
     57# Note that the MIP gap (gap between primal and dual solution) is not
     58# uniqly defined through all solvers. For example, there is a difference
     59# between SCIP and CPLEX. All solver, however, have the some behaviour in
     60# case of a MIP gap of 0.0.
    2561MIPGAP=0.0
    2662
     63# post system information and current time into the output file
    2764uname -a > $OUTFILE
    2865date >> $OUTFILE
    2966
     67# convert hard memory limit to kilo bytes and post it into the output file
    3068HARDMEMLIMIT=`expr $HARDMEMLIMIT \* 1024`
    3169echo "hard mem limit: $HARDMEMLIMIT k" >> $OUTFILE
    3270
    33 for i in `cat $TSTNAME.test`
     71# loop over all instance names which are listed in the test set file name
     72for i in `cat $TSTPATH/$TSTNAME.test`
    3473do
     74    # check if the current instance exists
    3575    if test -f $i
    3676    then
     
    4181        TIMESTART=`date +"%s"`
    4282        echo @03 $TIMESTART
    43         bash -c " ulimit -v $HARDMEMLIMIT k; ulimit -f 200000; ./run_$SOLVER.sh $SOLVER $LPS $i $TIMELIMIT $SOLFILE $MIPGAP"
     83        $SHELL -c " ulimit -v $HARDMEMLIMIT k; ulimit -f 2000000; $SCRIPTPATH/run_$SOLVER.sh $SOLVER $BINPATH/$BINNAME $i $TIMELIMIT $SOLFILE $THREADS $MIPGAP"
     84        echo
    4485        TIMEEND=`date +"%s"`
    4586        echo @04 $TIMEEND
    4687        echo @05 $TIMELIMIT
    47         if test -f $SOLFILE
     88        # check if a solution file was written
     89        if test -e $SOLFILE
    4890        then
    49             echo ""
    50             # bash -c " ./solchecker $i $SOLFILE $CHECKTOL" 
    51             echo ""
     91            # check if the link to the solution checker exists
     92            if test -f "$CHECKERPATH/bin/solchecker"
     93            then
     94                echo
     95                $SHELL -c " $CHECKERPATH/bin/solchecker $i $SOLFILE $LINTOL $INTTOL" 
     96                echo
     97            else
     98                echo WARNING: solution cannot be checked because solution checker is missing
     99            fi
    52100        fi
    53101        echo -----------------------------
     
    63111date >> $OUTFILE
    64112
    65 if test -f $SOLFILE
     113if test -e $SOLFILE
    66114then
    67115    rm $SOLFILE
    68116fi
    69117
    70 awk -f parse.awk -f parse_$SOLVER.awk $OUTFILE | tee $RESFILE
     118awk -f $SCRIPTPATH/parse.awk -f  $SCRIPTPATH/parse_$SOLVER.awk $OUTFILE | tee $RESFILE
  • trunk/Cbc/scripts/run_cbc.sh

    r1540 r1555  
    1 #!/usr/bin/env bash
    21#* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    32#*                                                                           *
     
    54#*                                                                           *
    65#* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     6# $Id: run_cbc.sh,v 1.1 2010/12/09 22:22:28 bzfheinz Exp $
    77
    88SOLVER=$1
    9 LPS=$2
     9BINNAME=$2
    1010NAME=$3
    1111TIMELIMIT=$4
    1212SOLFILE=$5
    13 MIPGAP=$6
     13THREADS=$6
     14MIPGAP=$7
    1415
    15 $SOLVER -import $NAME -sec $TIMELIMIT -ratio $MIPGAP -solve -solution $SOLFILE
     16TMPFILE=results/check.$SOLVER.tmp
     17
     18if test $THREADS != 0
     19then
     20    $BINNAME -import $NAME -sec $TIMELIMIT -threads $THREADS -ratio $MIPGAP -solve -solution $SOLFILE
     21else
     22    $BINNAME -import $NAME -sec $TIMELIMIT -ratio $MIPGAP -solve -solution $SOLFILE
     23fi
    1624
    1725if test -f $SOLFILE
    1826then
    19     # translate SCIP solution format into format for solution checker.
     27    # translate CBC solution format into format for solution checker.
    2028    #  The SOLFILE format is a very simple format where in each line
    2129    #  we have a <variable, value> pair, separated by spaces.
     
    2331    #  of the solution, as computed by the solver. A variable name of
    2432    #  =infeas= can be used to indicate that an instance is infeasible.
    25     awk -f parse_cbc_sol.awk $SOLFILE
     33    awk '
     34    BEGIN{
     35        infeasible = 0;
     36        nointsol = 0;
     37    }
     38    ($3 != "objective" && $3 != "gap" && $3 != "time" && $2 != "infeasible"){
     39        if (!infeasible){
     40                printf ("%s %s \n", $2, $3);
     41            }
     42    }
     43    ($3 == "objective" && $1 != "Infeasible" && $2 != "infeasible"){
     44        printf ("=obj= %s \n", $5);
     45    }
     46    ($3 == "gap"){
     47        printf ("=obj= %s \n", $8);
     48    }
     49    ($3 == "time"){
     50        if ($5 == "integer"){
     51           printf ("=nointsol= \n");
     52           nointsol = 1;
     53        }else{
     54           printf ("=obj= %s \n", $7);
     55        }
     56    }   
     57    ($1 == "Infeasible" || $2 == "infeasible"){
     58        printf ("=infeas= \n");
     59        infeasible = 1;
     60    }' $SOLFILE | tee $TMPFILE
     61    mv $TMPFILE $SOLFILE
    2662fi
    27 
    28 
Note: See TracChangeset for help on using the changeset viewer.