irace on Windows

295 views
Skip to first unread message

Wasin Padungwech

unread,
Aug 11, 2016, 8:53:22 AM8/11/16
to The irace package: Iterated Racing for Automatic Configuration

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

Leslie Perez Caceres

unread,
Aug 11, 2016, 4:03:00 PM8/11/16
to The irace package: Iterated Racing for Automatic Configuration
Hello Wasin,  

The examples of hook-run and evaluate in the package work only 
on Unix-based systems because they are programmed in bash.

For executing on Windows you need to create a script that can be 
executed on Windows (and then of course make it executable). 

One option would be creating a batch script. I don't have experience 
executing irace on Windows but I know other people have been able to do it.

I have an example (the code I attach below) of a hook-run made in batch that should work on Windows, 
note that you have to adjust the exe variable and the fixed parameters.

Let me know if that works for you!
Leslie.

::##############################################################################
:: 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
::)


Manuel López-Ibáñez

unread,
Aug 12, 2016, 9:13:13 AM8/12/16
to The irace package: Iterated Racing for Automatic Configuration
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.
Reply all
Reply to author
Forward
0 new messages