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

38

39

40

41

42

43

44

#gen_func 

 

from __future__ import division 

from __future__ import absolute_import 

 

import numpy as np 

 

from libensemble.message_numbers import STOP_TAG, PERSIS_STOP 

from libensemble.gen_funcs.support import sendrecv_mgr_worker_msg 

 

 

def persistent_updater_after_likelihood(H, persis_info, gen_specs, libE_info): 

""" 

""" 

ub = gen_specs['ub'] 

lb = gen_specs['lb'] 

n = len(lb) 

comm = libE_info['comm'] 

subbatch_size = gen_specs['subbatch_size'] 

num_subbatches = gen_specs['num_subbatches'] 

 

# Receive information from the manager (or a STOP_TAG) 

batch = -1 

tag = None 

while tag not in [STOP_TAG, PERSIS_STOP]: 

batch += 1 

O = np.zeros(subbatch_size*num_subbatches, dtype=gen_specs['out']) 

if 'w' in vars(): 

O['weight'] = w 

for j in range(num_subbatches): 

for i in range(subbatch_size): 

row = subbatch_size*j + i 

O['x'][row] = persis_info['rand_stream'].uniform(lb,ub,(1,n)) 

O['subbatch'][row] = j 

O['batch'][row] = batch 

O['prior'][row] = np.random.randn() 

O['prop'][row] = np.random.randn() 

 

# Send data and get next assignment 

tag, Work, calc_in = sendrecv_mgr_worker_msg(comm, O) 

if calc_in is not None: 

w = O['prior'] + calc_in['like'] - O['prop'] 

 

return O, persis_info, tag