nip.parameters.update_schedule.AlternatingPeriodicUpdateSchedule#

class nip.parameters.update_schedule.AlternatingPeriodicUpdateSchedule(period: int, first_agent_num_rounds: int, first_agent: bool = True)[source]#

A periodic schedule for alternating updates between two agents.

This schedule is to be used in pairs, where one agent is updated in the first part of the cycle and the other agent is updated in the second part of the cycle.

The first agent is updated for the first first_agent_num_iterations iterations of each cycle. The second agent is updated for the remaining iterations of the cycle.

The first agent should have a schedule with first_agent=True, and the second agent should have a schedule with first_agent=False.

Parameters:
  • period (int) – The length of the cycle.

  • first_agent_num_iterations (int) – The number of iterations to update the first agent in each cycle.

  • first_agent (bool, default=True) – Whether this schedule is for the first agent in the cycle. Otherwise, it is for the second agent.

Methods Summary

__init__(period, first_agent_num_rounds[, ...])

__repr__()

Return repr(self).

_get_arguments_dict()

Get the constructor arguments of the schedule as a dictionary.

_get_param_class_from_dict(param_dict)

Try to get the parameter class from a dictionary of serialised parameters.

from_dict(params_dict[, ignore_extra_keys])

Create an agent update schedule from a dictionary.

to_dict()

Convert the agent update schedule to a dictionary.

Methods

__init__(period: int, first_agent_num_rounds: int, first_agent: bool = True)[source]#
__repr__() str[source]#

Return repr(self).

_get_arguments_dict() dict[source]#

Get the constructor arguments of the schedule as a dictionary.

Returns:

arguments (dict) – A dictionary of the arguments of the schedule.

classmethod _get_param_class_from_dict(param_dict: dict) type[ParameterValue] | None[source]#

Try to get the parameter class from a dictionary of serialised parameters.

Parameters:

param_dict (dict) – A dictionary of parameters, which may have come from a to_dict method. This dictionary may contain a _type key, which is used to determine the class of the parameter.

Returns:

param_class (type[ParameterValue] | None) – The class of the parameter, if it can be determined.

Raises:

ValueError – If the class specified in the dictionary is not a valid parameter class.

classmethod from_dict(params_dict: dict, ignore_extra_keys: bool = False) AgentUpdateSchedule[source]#

Create an agent update schedule from a dictionary.

Parameters:
  • params_dict (dict) – A dictionary of the agent update schedule.

  • ignore_extra_keys (bool, default=False) – If True, ignore keys in the dictionary that do not correspond to fields in the parameters object.

Returns:

schedule (AgentUpdateSchedule) – The agent update schedule.

to_dict() dict[source]#

Convert the agent update schedule to a dictionary.

Returns:

as_dict (dict) – A dictionary representation of the agent update schedule.