#NEWLINE# def simulate_run( run , maker , train_data , test_data ) : #NEWLINE# #INDENT# 'Simulate portfolio execution on a train/test split.' #NEWLINE# split_id = uuid . uuid4 ( ) #NEWLINE# budget = test_data . common_budget #NEWLINE# suite = borg . fake . FakeSuite ( test_data ) #NEWLINE# solver = maker ( suite , train_data , test_data ) #NEWLINE# rows = [ ] #NEWLINE# for ( i , instance_id ) in enumerate ( test_data . run_lists ) : #NEWLINE# #INDENT# logger . info ( 'simulating run %i/%i on %s' , i , len ( test_data ) , instance_id ) #NEWLINE# with suite . domain . task_from_path ( instance ) as instance : #NEWLINE# #INDENT# with borg . accounting ( ) as accountant : #NEWLINE# #INDENT# answer = solver . start ( instance ) . run_then_stop ( budget ) #NEWLINE# #UNINDENT# succeeded = suite . domain . is_final ( instance , answer ) #NEWLINE# cpu_cost = accountant . total . cpu_seconds #NEWLINE# logger . info ( '%s %s on %s (%.2f CPU s)' , maker . name , ( 'succeeded' if succeeded else 'failed' ) , os . path . basename ( instance ) , cpu_cost ) #NEWLINE# success_str = ( 'TRUE' if succeeded else 'FALSE' ) #NEWLINE# rows . append ( [ run [ 'category' ] , maker . name , budget , cpu_cost , success_str , split_id ] ) #NEWLINE# #UNINDENT# #UNINDENT# return rows