Hi,
I wanted to samples each rounds clients by id’s, meaning that if i’m using 20% of clients and i have 100 clients i want to start with 0 to 19 first clients and so on. I’m not sure if it should be on the configure_fit function on my custom strategy or it should be on the client manager… Do you have already made examples with my problem ?
Kind regards,
Mr. Sunshine.
Okay, i think i’ve answered my self.
The function configure_fit strategy side calls on the client_manager.sample(), this function can take a criteron that invalidate clients.
I’ve implemented my own criteron for having a deterministic layout.
class DeterministicCriteron(Criterion):
def __init__(self):
self.round = 0
self.num_clients = 100
self.ids = 0
self.mapping = {}
def select(self, client: ClientProxy) -> bool:
"""Decide whether a client should be eligible for sampling or not."""
plage_min = self.round * 20
plage_max = plage_min + 19
if client.cid not in self.mapping:
identifiant = self.ids
self.mapping[client.cid] = identifiant
self.ids += 1
eligible = plage_min <= self.mapping[client.cid] <= plage_max
return eligible
def update(self):
self.round = (self.round + 1) % 5
It’s only a draft right now. I should have more variable in my init to be compatible with more than my fraction fit
Hope it can be usefull to anyone reading.
Hi, yes, that should work, assuming that the clients have cids attributes.