-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import numpy as np | ||
from irace import irace | ||
import pandas as pd | ||
from multiprocessing import Process, Queue | ||
from threading import Timer, Thread | ||
from time import sleep | ||
|
||
import json | ||
def target_runner(experiment, scenario): | ||
raise ValueError() | ||
return dict(cost=experiment['configuration']['one']) | ||
|
||
|
||
params = ''' | ||
one "" r (0, 1) | ||
''' | ||
|
||
defaults = pd.DataFrame(data=dict( | ||
one=[0.6] | ||
)) | ||
|
||
scenario = dict( | ||
instances = np.arange(10), | ||
maxExperiments = 96, | ||
debugLevel = 0, | ||
parallel = 1, | ||
logFile = "" | ||
) | ||
|
||
killed = False | ||
|
||
irace_exit = Queue() | ||
def test_no_hang(): | ||
p = Process(target=start_irace) | ||
p.start() | ||
Timer(1, kill_process, args=(p,)).start() | ||
sleep(2) | ||
assert not killed | ||
|
||
def kill_process(p): | ||
if p.is_alive(): | ||
p.terminate() | ||
global killed | ||
killed = True | ||
|
||
def start_irace(): | ||
tuner = irace(scenario, params, target_runner) | ||
tuner.set_initial(defaults) | ||
best_conf = tuner.run() | ||
|
||
if __name__ == '__main__': | ||
test_no_hang() |