hynet.distributed package

Submodules

hynet.distributed.client module

hynet optimization client for distributed computation.

hynet.distributed.client.start_optimization_client(server_ip, port=None, authkey=None, num_workers=None, verbose=True)[source]

Create, connect, and start a hynet optimization client.

Note that this call is blocking until the hynet optimization server, to which the client is connected, is shut down.

Parameters:
  • server_ip (str) – IP address of the hynet optimization server.
  • port (int, optional) – TCP port of the hynet optimization server.
  • authkey (str, optional) – Authentication key for the hynet optimization server.
  • num_workers (int, optional) – Number of worker processes that should run in parallel. If more than one worker is started, it is recommended to disable the internal parallel processing, see parallelize in hynet.config.
  • verbose (bool, optional) – If True (default), some information on activity of the client is printed to the standard output.

hynet.distributed.server module

hynet optimization server for distributed computation.

class hynet.distributed.server.OptimizationJob(data, solver=None, solver_type=<SolverType.QCQP: 'QCQP'>)[source]

Bases: object

Represents a hynet optimization job.

Customization: To customize the job processing, derive from this class and override process.

Parameters:
  • data (Scenario or SystemModel or QCQP) – Scenario (to solve its OPF), a problem builder (an object of a derived class of SystemModel like OPFModel), or a QCQP specification.
  • solver (SolverInterface, optional) – Solver for the provided problem. The default automatically selects an appropriate solver of the specified solver type. Please make sure that the selected solver is installed on all client machines.
  • solver_type (SolverType, optional) – Solver type for the automatic solver selection (default SolverType.QCQP). It is ignored if solver is not None.
process()[source]

Process the optimization job and return the result (or exception).

class hynet.distributed.server.OptimizationServer(port, authkey, local)[source]

Bases: object

hynet optimization server for distributed computation.

This server manages the distributed computation of a set of hynet optimization problems (OPF or QCQPs) on hynet optimization clients.

calc_jobs(job_list, solver=None, show_progress=True)[source]

Calculate the list of hynet optimization jobs and return the results.

The provided list of jobs is processed by distributing them to the connected hynet optimization clients, collecting the results, and returning an array of results that corresponds with the provided array of jobs. Note that if there are no clients connected, this method will wait until a client is connected to process the jobs.

Parameters:
  • job_list (array-like) – List of hynet optimization jobs (OptimizationJob) or problem specifications (Scenario [issues an OPF computation], SystemModel, or QCQP).
  • solver (SolverInterface, optional) – If provided, this solver is used for problem specifications (Scenario, SystemModel, or QCQP). It is ignored for job specifications (OptimizationJob).
  • show_progress (bool, optional) – If True (default), the progress is reported to the standard output.
Returns:

results – Array containing the optimization results.

Return type:

numpy.ndarray

shutdown()[source]

Stop the hynet optimization server and all connected clients.

start_clients(client_list, server_ip, ssh_user=None, ssh_port=None, num_workers=None, log_file=None, suppress_output=True)[source]

Automated start of hynet optimization clients.

This method provides an automatic start of hynet optimization clients via SSH if the server can connect to the clients via ssh [client] (e.g. by configuring SSH keys; please be aware of the related aspects of system security). hynet must be properly installed on all client machines.

This function uses SSH to run the hynet package with the sub-command client and corresponding command line arguments (python -m hynet client ...) on every client machine. To customize the SSH and Python command, see hynet.config.

Parameters:
  • client_list (array-like) – List of strings containing the host names or IP addresses of the client machines.
  • server_ip (str) – IP address the hynet optimization server.
  • ssh_user (str, optional) – The user name for the SSH login on the client machines. By default, this is set to the current user name (getpass.getuser()).
  • ssh_port (int, optional) – Port on which SSH is running on the client machines.
  • num_workers (int, optional) – Number of worker processes that should run in parallel on every client machine.
  • log_file (str, optional) – Log file on the client machines to capture the output.
  • suppress_output (bool, optional) – If True (default), the activity output of the optimization clients is suppressed.
hynet.distributed.server.start_optimization_server(port=None, authkey=None, local=False)[source]

Create, start, and return a hynet optimization server.

Parameters:
  • port (int, optional) – TCP port on which the hynet optimization server shall be running.
  • authkey (str, optional) – Authentication key that must be presented by hynet optimization clients to connect to the server.
  • local (bool, optional) – If True (default is False), the optimization server processes all jobs on the local machine and connections of clients are not accepted. In case that some code is designed to utilize distributed computation, but the the server cluster is not available, this local mode supports the computation on the local machine without the client management overhead.
Returns:

server – The hynet optimization server.

Return type:

OptimizationServer

Module contents

Distributed computation functionality in hynet.