Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

from __future__ import division 

from __future__ import absolute_import 

 

from libensemble.alloc_funcs.support import \ 

avail_worker_ids, sim_work, gen_work, count_gens 

 

 

def give_sim_work_first(W, H, sim_specs, gen_specs, persis_info): 

""" 

This allocation function gives (in order) entries in ``H`` to idle workers 

to evaluate in the simulation function. The fields in ``sim_specs['in']`` 

are given. If all entries in `H` have been given a be evaluated, a worker 

is told to call the generator function, provided this wouldn't result in 

more than ``gen_specs['num_active_gen']`` active generators. 

 

:See: 

``/libensemble/tests/regression_tests/test_fast_alloc.py`` 

""" 

 

Work = {} 

gen_count = count_gens(W) 

 

for i in avail_worker_ids(W): 

if persis_info['next_to_give'] < len(H): 

 

# Give sim work if possible 

sim_work(Work, i, sim_specs['in'], [persis_info['next_to_give']]) 

persis_info['next_to_give'] += 1 

 

elif gen_count < gen_specs.get('num_active_gens', gen_count+1): 

 

# Give gen work 

persis_info['total_gen_calls'] += 1 

gen_count += 1 

gen_work(Work, i, gen_specs['in'], persis_info[i], []) 

 

return Work, persis_info