env_client module¶

Client to play multi-armed bandits problem against. Many distribution of arms are supported, default to Bernoulli.

Usage:

env_client.py [–markovian | –dynamic] [–port=<PORT>] [–host=<HOST>] [–speed=<SPEED>] <json_configuration> env_client.py (-h|–help) env_client.py –version

Options:

-h –help Show this screen. –version Show version. –markovian Whether to use a Markovian MAB problem (default is simple MAB problems). –dynamic Whether to use a Dynamic MAB problem (default is simple MAB problems). –port=<PORT> Port to use for the TCP connection [default: 10000]. –host=<HOST> Address to use for the TCP connection [default: 0.0.0.0]. –speed=<SPEED> Speed of emission, in milliseconds [default: 1000].

env_client.default_configuration = {'arm_type': 'Bernoulli', 'params': {(0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9)}}¶

Example of configuration to pass from the command line. '{"arm_type": "Bernoulli", "params": (0.1, 0.5, 0.9)}'

env_client.read_configuration_env(a_string)[source]¶

Return a valid configuration dictionary to initialize a MAB environment, from the input string.

env_client.send_message(sock, message)[source]¶

Send this message to the socket.

env_client.client(env, host, port, speed)[source]¶

Launch a client that:

  • uses sockets to listen to input and reply

  • create a MAB environment from a JSON configuration (exactly like main.py when it reads configuration.py)

  • then receives choice arm from the network, pass it to the MAB environment, listens to his reward = draw(arm) feedback, and sends this back to the network.

env_client.transform_str(params)[source]¶

Like a safe exec() on a dictionary that can contain special values:

  • strings are interpreted as variables names (e.g., policy names) from the current globals() scope,

  • list are transformed to tuples to be constant and hashable,

  • dictionary are recursively transformed.

env_client.main(arguments)[source]¶

Take arguments, construct the learning policy and starts the server.