## 5 An Integrated Inductive-Deductive Framework for Data Mapping
### Distributed Self-Adaptation in AMA
#### 5.2.3 The Virtual Congress Algorithm  
The _Virtual Congress Algorithm_ (VCA) top-down technique is proposed to manage the global and local domain model updates. VCA provides a high-level collaboration environment in which the system can achieve globally efficient behaviour under dynamic environmental conditions. Instead of re-programming individual nodes, the network is viewed as a virtual congress where nodes are _senators_ who vote for legislating changes to the domain model in response to locally detected environmental conditions. This algorithm is an attractive solution as senators collaboratively decide upon their local knowledge on the behaviour and correctness of the system. Logically related nodes, _chambers_, are granted some power to impute the local changes, _federal decisions_, that is not detected by all nodes in the network. In cluster-based networks, a cluster can be defined as a chamber. A senator may introduce a proposal in the chamber as a _bill_. To prevent overloading the chamber with proposals, each senator must monitor the changes over time using Equation (16) before putting them into a bill. Besides, no two or more identical bills are allowed to be proposed by two different senators. Senators evaluate and study the proposed bill and send their voting results accordingly to the proposing senator. Upon receiving the required number of votes \(\upsilon\), the proposing senator disseminates the bill to the chamber and all nodes implement the new changes that have been agreed on. The value of \(\upsilon\) was empirically estimated to be over \(50\%\) of chamber population because it helps to avoid false positives (see Experiment 6.3.3 for empirical analysis). If the bill gets rejected, then the proposing senator suppose that there is a local problem and starts a fault detection or recalibration service. Once a bill is approved by one chamber, it is sent to other chamber heads who may accept or reject it. In order for the bill to become a _state law_, all chamber heads must agree to identical version of the bill. When the bill is submitted to the _president_, the sink node, he may choose to sign the bill, thereby making it _law_. The president informs all chamber heads whether the bill became a law or not. If the chamber head does not receive a response from the president within a specific period of time, then it register the bill it generated as rejected.  
Figure 4 shows a Petri net that models the behaviour of the VCA in a chamber that consists of two sensing nodes (senators). In this model the first senator, Node 1, detects a change in the environmental conditions. The place with a single token is a guarding condition that allows the senator to generate only one bill at any time. When a senator detects a change, it enters into a monitoring phase after which it decides to keep the existing local domain model or to generate a bill to update that model. When a senator collects the required number of votes (in this scenario \(\upsilon=2\)), it broadcasts the new model which is then implemented by all nodes in the chamber. Finally, the token is deposited into the start place after the completion of the model update activity.  
This Petri net model was simulated using the S/T Petri-Net simulation system [30]. The simulation of the VCA Petri net with non-deterministic selection of activities allows checking the algorithm against deadlocks caused by controllers, introduced to enforce the given specifications, especially in the closed-loop net branches. It was found that the VCA Petri net is live and deadlock-free.