-
Notifications
You must be signed in to change notification settings - Fork 0
/
API
110 lines (92 loc) · 3.57 KB
/
API
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
genral:
name it like this, if reading a variable
{request_X, REQUESTING_PID}
sends REQUESTING_PID ! {my_X, self(), X}
if it is a function
{functionName, REQUESTING_PID, ....}
sends REQUESTING_PID ! {functionNameDone, self()}
Node
_______
node_life(POSITION, EDGES, ERROR, PARENT)
%% Param:
%% + POSITION is a list of the positions in each dimension
%% + EDGES is a list of pairs {nodepid, age}
%% + ERROR is a real number
%% + PARENT is a ManagerPID
%%
%% receives:
%% + {position_requesxt, REQUESTING_PID }
%% - Sends REQUESTING_PID ! {my_position, self(), POSITION }
%%
%% + {edges_request, REQUESTING_PID} ->
%% - Sends REQUESTING_PID ! {my_edges, self(), EDGES }
%%
%% + {request_error, REQUESTING_PID} ->
%% - sends REQUESTING_PID ! {my_error, self(), ERROR }
%%
%% + {request_decreased_error, REQUESTING_PID, D} ->
%% - decreases the error by D in the node
%% - returns the decreased error
%% - this is request_error and decrease_error in one
%% - sends REQUESTING_PID ! {my_decreased_error, self(), ERROR*D }
%%
%% + {newEdge, REQUESTING_PID, OTHER_NODEPID} -> %has to be added also in the otherNode
%% - creates a new edge to OTHER_NODE
%% - sends REQUESTING_PID ! {newEdgeDone, self()};
%%
%% + {ageEdges, REQUESTING_PID, MAX_AGE} ->
%% - ages the edges and removes the node if no edges left
%% - might send PARENT ! {removeNode, self(), self()},
%% - sends REQUESTING_PID ! {ageEdgesDone, self()};
%%
%% + {removeEdge, REQUESTING_PID, OTHER_NODE} ->
%% - has to be evoqued in both nodes
%% - removes the edge to OTHER_NODE
%%
%% + {addToError, REQUESTING_PID, DELTA_ERROR} ->
%% - adds DELTA_ERROR to ERROR
%%
%% + {decreaseError, REQUESTING_PID, ALPHA} ->
%% - ERROR <- ERROR * ALPHA
%%
%% + {moveKN, REQUESTING_PID, INPUT, MOVE_K, MOVE_N} ->
%% - sends {moveN, self(), INPUT, MOVE_N} to all neighbors
%% - moves this node MOVE_K towards INPUT
%%
%% + {moveN, REQUESTING_PID, INPUT, MOVE_N} ->
%% - moves this node MOVE_N towards INPUT
%%
%% + {refreshEdge, REQUESTING_PID, OTHER_NODE} -> %has to be called for both nodes
%% - sets the age of the edge to OTHER_NODE to 0 or creates this edge
%%
%% + {request_maxNeighbor, REQUESTING_PID} ->
%% - sends REQUESTING_PID ! {my_maxNeighbor, self(), maxNeighbor(EDGES)},
%%
%% + {request_distance, REQUESTING_PID, INPUT} ->
%% - sends REQUESTING_PID ! {my_distance, self(), distance(POSITION, INPUT)},
%%
_______
------------------------------------------------------------
Winner_Manager
___________________
win_man_life( PARENT, CHILDREN, NODES, NUM_N, NUM_C, DEPTH, INPUT)
%%%%%%%%%%% win_man_life( PARENT, CHILDREN, NODES, NUM_N, NUM_C, DEPTH, INPUT, ERROR_TREE_ROOT)
%% param:
%% PARENT: Father's PID
%% CHILDREN : a list containing the subtree's PIDs
%% NODES : a list containing the nodes' PIDs handled by this manager
%% NUM_N : Number of elements in NODES
%% NUM_C : NUmber of elements in CHILDREN
%% DEPTH : the depth in the tree
%% INPUT : The Pattern (A list of coordinates)
%% ERROR_TREE_ROOT : used just by the winnertree_ROOT (Depth == 0) is the other tree's root PID, to comunicate the winner and the runner for every pattern
%% receives:
%% + tree updates
%% - performs the tree updates
%% sends:
%% - PARENT ! { my_win_and_run , self (), WIN_AND_RUN }
%%
%% Sends distance request to all the nodes in NODES and asks for the sub_winner and sub_runner to the subtrees in CHILDREN
%% Combines all and sends a message to the father comunicating his winner and runner.
needed:
{removeNode, ComingFromPID, NodeToRemovePID}