1#!/usr/bin/env bash 2#* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 3#* * 4#* This file is part of the program and library * 5#* SCIP --- Solving Constraint Integer Programs * 6#* * 7#* Copyright (C) 2002-2021 Konrad-Zuse-Zentrum * 8#* fuer Informationstechnik Berlin * 9#* * 10#* SCIP is distributed under the terms of the ZIB Academic License. * 11#* * 12#* You should have received a copy of the ZIB Academic License * 13#* along with SCIP; see the file COPYING. If not email to scip@zib.de. * 14#* * 15#* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 16 17### resets and fills a batch file TMPFILE to run SCIP with 18### sets correct limits, reads in settings, and controls 19### display of the solving process 20 21# environment variables passed as arguments 22INSTANCE=$1 # instance name to solve 23SCIPPATH=$2 # - path to working directory for test (usually, the check subdirectory) 24TMPFILE=$3 # - the batch file to control SCIP 25SETNAME=$4 # - specified basename of settings-file, or 'default' 26SETFILE=$5 # - instance/settings specific set-file 27THREADS=$6 # - the number of LP solver threads to use 28SETCUTOFF=$7 # - should optimal instance value be used as objective limit (0 or 1)? 29FEASTOL=$8 # - feasibility tolerance, or 'default' 30TIMELIMIT=$9 # - time limit for the solver 31MEMLIMIT=${10} # - memory limit for the solver 32NODELIMIT=${11} # - node limit for the solver 33LPS=${12} # - LP solver to use 34DISPFREQ=${13} # - display frequency for chronological output table 35REOPT=${14} # - true if we use reoptimization, i.e., using a difflist file instead if an instance file 36OPTCOMMAND=${15} # - command that should per executed after reading the instance, e.g. optimize, presolve or count 37CLIENTTMPDIR=${16} 38SOLBASENAME=${17} 39VISUALIZE=${18} 40SOLUFILE=${19} # - solu file, only necessary if $SETCUTOFF is 1 41#args=("$@") 42#for ((i=0; i < $#; i++)) { 43# echo "argument $((i+1)): ${args[$i]}" 44#} 45 46# new environment variables after running this script 47# -None 48 49#set solfile 50SOLFILE=$CLIENTTMPDIR/${USER}-tmpdir/$SOLBASENAME.sol 51 52if test -e "$SOLUFILE" 53then 54 OBJECTIVEVAL=`grep "$SHORTPROBNAME " $SOLUFILE | grep -v =feas= | grep -v =inf= | tail -n 1 | awk '{print $3}'` 55else 56 OBJECTIVEVAL="" 57fi 58#echo "Reference value $OBJECTIVEVAL $SOLUFILE" 59# reset TMPFILE 60echo > $TMPFILE 61 62# read in settings (even when using default, see bugzilla 600) 63SETTINGS=$SCIPPATH/../settings/$SETNAME.set 64if test $SETNAME == "default" 65then 66 # create empty settings file 67 test -e $SETTINGS || touch $SETTINGS 68fi 69echo set load $SETTINGS >> $TMPFILE 70 71# set non-default feasibility tolerance 72if test $FEASTOL != "default" 73then 74 echo set numerics feastol $FEASTOL >> $TMPFILE 75fi 76 77# if permutation counter is positive add permutation seed (0 = default) 78if test $p -gt 0 79then 80 echo set randomization permutationseed $p >> $TMPFILE 81fi 82 83# if seed counter is positive add random seed shift 84if test $s -gt 0 85then 86 echo set randomization randomseedshift $(($s + $GLBSEEDSHIFT)) >> $TMPFILE 87else 88 if test $GLBSEEDSHIFT -gt 0 89 then 90 echo set randomization randomseedshift $GLBSEEDSHIFT >> $TMPFILE 91 fi 92fi 93 94# avoid solving LPs in case of LPS=none 95if test "$LPS" = "none" 96then 97 echo set lp solvefreq -1 >> $TMPFILE 98fi 99if test "$OBJECTIVEVAL" != "" 100then 101 #echo "Reference value $OBJECTIVEVAL" 102 echo set misc referencevalue $OBJECTIVEVAL >> $TMPFILE 103fi 104echo set limits time $TIMELIMIT >> $TMPFILE 105echo set limits nodes $NODELIMIT >> $TMPFILE 106echo set limits memory $MEMLIMIT >> $TMPFILE 107echo set lp advanced threads $THREADS >> $TMPFILE 108echo set timing clocktype 1 >> $TMPFILE 109echo set display freq $DISPFREQ >> $TMPFILE 110# avoid switching to dfs - better abort with memory error 111echo set memory savefac 1.0 >> $TMPFILE 112echo set save $SETFILE >> $TMPFILE 113 114if test "$VISUALIZE" = true 115then 116 BAKFILENAME="`basename $TMPFILE .tmp`.dat" 117 echo visualization output set to "$BAKFILENAME" 118 echo set visual bakfilename "$OUTPUTDIR/${BAKFILENAME}" >> $TMPFILE 119fi 120 121if test "$REOPT" = false 122then 123 # read and solve the instance 124 echo read $INSTANCE >> $TMPFILE 125 126 # set objective limit: optimal solution value from solu file, if existent 127 if test $SETCUTOFF = 1 128 then 129 if test $SOLUFILE == "" 130 then 131 echo Exiting test because no solu file can be found for this test 132 exit 133 fi 134 if test ""$OBJECTIVEVAL != "" 135 then 136 echo set limits objective $OBJECTIVEVAL >> $TMPFILE 137 echo set heur emph off >> $TMPFILE 138 fi 139 fi 140 141 echo display parameters >> $TMPFILE 142 echo $OPTCOMMAND >> $TMPFILE 143 echo display statistics >> $TMPFILE 144 echo checksol >> $TMPFILE 145else 146 # read the difflist file 147 cat $INSTANCE >> $TMPFILE 148fi 149 150# currently, the solution checker only supports .mps-files. 151# compare instance name (without .gz) to instance name stripped by .mps. 152#if they are unequal, we have an mps-file 153TMPINSTANCE=`basename $INSTANCE .gz` 154TMPINSTANCEB=`basename $TMPINSTANCE .mps` 155if test "$TMPINSTANCEB" != "$TMPINSTANCE" 156then 157 echo write sol $SOLFILE >> $TMPFILE 158fi 159echo quit >> $TMPFILE 160