oTree Forum >

Issues when using set_group_matrix()

#1 by FredLau97

Hey,

I am currently running into an issue when using the set_group_matrix() method, to create my own groups.

I have implemented a WaitPage, that is set to wait for all groups, and has the after_all_players_arrive method defined under the subsession class.

The application consists of 3 rounds. When the first pass through the WaitPage happens, the groups get created correctly, and no issues occur. Each round ends with a wait page, to make sure the two members of the group proceeds together to the next round. However, in the next round, the groups will get reset to their original grouping, and dissolve the groups set by the set_group_matrix() method.

Is there anyway to prevent the reset of the groups in each new round?

Image attached shows first the correct groups in round 1, and then the original groups on the next line.

Best,
Fred

#2 by Chris_oTree

oTree creates groups for all rounds when the session is created. Changing the grouping matrix in one round does not affect the group matrix in other rounds. If you want that, one way is to call set_group_matrix, which can be done from a WaitPage with wait_for_all_groups=True. Or are you using group_by_arrival_time?

#3 by FredLau97

I am doing it from a WaitPage with wait_for_all_groups=True.

So the issue is that set_group_matrix() only works on a single round basis?
Is it then possible to just loop through all the rounds from the WaitPage and set the groups accordingly in all preceeding rounds?

#4 by Chris_oTree

yes:

for s in subsession.in_rounds(1, C.NUM_ROUNDS):
	s.set_group_matrix(your_matrix)

Write a reply

Set forum username