Package datk :: Package core :: Module distalgs :: Class Algorithm
[hide private]
[frames] | no frames]

Class Algorithm

source code

Known Subclasses:

Abstract superclass for a distributed algorithm.

Instance Methods [hide private]
 
__init__(self, network=None, params={}, name=None) source code
 
msgs_i(self, p)
Determines what messages a Process, p, will send.
source code
 
trans_i(self, p, msgs)
Determines what state transition a Process, p, will perform, having received messages, msgs
source code
 
halt_i(self, p)
Returns True iff Process p has halted execution of the algorithm
source code
 
cleanup_i(self, p)
Determines what final state transition a Process, p, will perform, after the algorithm terminates.
source code
 
cleanup(self)
Calls cleanup_i on all processes
source code
 
__call__(self, network, params={})
Same as run, allows an algorithm, A, to be executed like this: A()
source code
 
run(self, network, params={})
Executes the algorithm on the network
source code
 
halt(self) source code
 
print_algorithm_terminated(self) source code
 
count_msg(self, message_count) source code
 
set(self, process, state, value) source code
 
increment(self, process, state, inc=1) source code
 
has(self, process, state) source code
 
get(self, process, state) source code
 
delete(self, process, state) source code
 
output(self, process, key, val)
Sets the publicly visible value of process.state[key] to val
source code
Class Variables [hide private]
  DEFAULT_PARAMS = {'draw': False, 'verbosity': 1}
  DEFAULT = 2
  QUIET = 1
  SILENT = 0
  VERBOSE = 3
Method Details [hide private]

__init__(self, network=None, params={}, name=None)
(Constructor)

source code 
Parameters:
  • network - [Optional] network. If specified, algorithm is immediately executed on network.
  • params - [Optional] runtime parameters.
  • name - [Optional] name of the Algorithm instance. Defaults to class name.

run(self, network, params={})

source code 

Executes the algorithm on the network

Parameters:
  • network - the parameter to run in
  • params - runtime parameters

output(self, process, key, val)

source code 

Sets the publicly visible value of process.state[key] to val

This command is verbose if Algorithm's verbosity is >= DEFAULT

Parameters:
  • key - The state variable to set
  • val - The value to assign to it