Hello,
I am interested in using the irace package and I wonder if you could give me some advice on how to use it on Windows. I have installed irace (version 1.06.997) in R and I am trying to use it with my stand-alone program.
What I did was:
- copying the hook-evaluate, hook-run, tune-conf, and tune-main from the irace folder ("C:\R\library\irace\templates") into my main folder ("D:\irace\tuning") and removing the extension .tmpl
- putting my program (.exe) and a parameter file in the same location ("D:\irace\tuning")
- putting instance files (.txt) in the folder Instances ("D:\irace\tuning\Instances")
When I tried to run irace, it said the following:
> irace.main()
Error: == irace == run program hook 'D:/irace/tuning/hook-run' is not executable
I did not change or use any other command, so I believe the irace was run with the default settings.
Actually, I am not quite know how I can let the irace know the location of my program as well as the appropriate format of inputs
for the program. (Does the irace automatically detect them or do I need to give explicit instructions?)
Thank you very much for your time.
Kind regards,
Wasin
::##############################################################################
:: This script is the command that is executed every run.
:: Check the examples in examples/
::
:: This script is run in the execution directory (execDir, --exec-dir).
::
:: PARAMETERS:
:: %1 is the instance
:: %2 is the candidate configuration number
:: The rest (%* after `shift 2') are parameters to the run
::
:: RETURN VALUE:
:: This script should print one numerical value: the cost that must be minimized.
:: Exit with 0 if no error, with 1 in case of error
::##############################################################################
@echo off
SET "exe=D:\bin\acotsp"
SET "fixed_params=--time 20 --tries 1 --quiet"
SET instance=%1
SHIFT
SET candidate=%1
SHIFT
SET candidate_parameters=%*
SET "stdout=c%candidate%.stdout"
SET "stderr=c%candidate%.stderr"
::if not exist %exe% error "%exe%: not found or not executable (pwd: %(pwd))"
:: If the program just prints a number, we can use 'exec' to avoid
:: creating another process, but there can be no other commands after exec.
::exec %exe %FIXED_PARAMS% -i %instance %candidate_parameters%
:: exit 1
::
:: Otherwise, save the output to a file, and parse the result from it.
:: (If you wish to ignore segmentation faults you can use '{}' around
:: the command.)
%exe% %FIXED_PARAMS% -i %instance% %candidate_parameters% 1>%stdout% 2>%stderr%
::if %errorlevel% neq 0 exit /b %errorlevel%
:: # This may be used to introduce a delay if there are filesystem
:: # issues.
:: SLEEPTIME=1
:: while [ ! -s "%stdout%" ]; do
:: sleep %SLEEPTIME
:: let "SLEEPTIME += 1"
:: done
::
:: This is an example of reading a number from the output.
:: It assumes that the objective value is the first number in
:: the first column of the last line of the output.
::if exist %stdout% (
setlocal EnableDelayedExpansion
set "cmd=findstr /R /N "^^" %stdout% | find /C ":""
for /f %%a in ('!cmd!') do set numberlines=%%a
set /a lastline=%numberlines%-1
for /f "tokens=3" %%F in ('more +%lastline% %stdout%') do set COST=%%F
echo %COST%
::del %stdout% %stderr%
exit 0
::) ELSE (
::exit /b
::)Another alternative is to modify your program to accept a command-line as irace produces it to call hook-run and print just the evaluation cost as irace expects. Then, you can set hookRun to the location of your program. Normally, you do not need a separate hookEvaluate. Cheers, Manuel.