Communication

class optunity.communication.EvalManager(max_vectorized=100, replacements={})[source]

Bases: object

Constructs an EvalManager object.

Parameters:
  • max_vectorized (int) – the maximum size of a vector evaluation larger vectorizations will be chunked
  • replacements (dict) – a mapping of original:replacement keyword names
add_to_queue(**kwargs)[source]
cv
flush_queue()[source]
get(number)[source]
max_vectorized
pipe_eval(**kwargs)[source]
pmap(f, *args)[source]

Performs vector evaluations through pipes.

Parameters:
  • f (callable) – the objective function (piped_function_eval)
  • args (iterables) – function arguments

The vector evaluation is sent in chunks of size self.max_vectorized.

processed_semaphore
queue
queue_lock
replacements

Keys that must be replaced: keys are current values, values are what must be sent through the pipe.

semaphore
vectorized
optunity.communication.accept_server_connection(server_socket)[source]
optunity.communication.json_decode(data)[source]

Decodes given JSON string and returns its data.

>>> orig = {1: 2, 'a': [1,2]}
>>> data = json_decode(json_encode(orig))
>>> data[str(1)]
2
>>> data['a']
[1, 2]
optunity.communication.json_encode(data)[source]

Encodes given data in a JSON string.

optunity.communication.make_piped_function(mgr)[source]
optunity.communication.open_server_socket()[source]
optunity.communication.open_socket(port, host='localhost')[source]

Opens a socket to host:port and reconfigures internal channels.

optunity.communication.receive()[source]

Reads data from channel.

optunity.communication.send(data)[source]

Writes data to channel and flushes.