• Aucun résultat trouvé

Energy complexity in population model protocols

N/A
N/A
Protected

Academic year: 2022

Partager "Energy complexity in population model protocols"

Copied!
135
0
0

Texte intégral

(1)

Thesis

Reference

Energy complexity in population model protocols

NOTO, Eugenio

Abstract

Aujourd'hui, l'énergie a une fonction cruciale dans les appareils électroniques. En effet, à une époque pratiquement tout le monde possède des machines munies d'un processeur, comme un smartphone, une tablette, un ordinateur ou même une machine à laver, un appareil économe en énergie signifie économiser de l'argent et une bonne chose pour l'environnement. Un autre avantage est la durée d'utilisation, en effet nous possédons de plus en plus d'appareils a batterie et utiliser moins d'énergie signifie une durée d'utilisation plus longue. Dans des domaines plus spécialisés, comme les réseaux de senseurs, l'énergie signifie durée de vie du réseau. En fait, il est de l'intérêt de tout le monde de bien gérer la consommation d'énergie. Dans cette thèse, l'approche va être de montrer que l'on peut économiser de l'énergie non seulement en créant du matériel performant mais aussi en programmant. Cette thèse va commencer en définissants des métriques pour mesurer la consommation d'énergie, ensuite en choisissant des composantes atomiques pour la création de systèmes complexes sur lesquels on [...]

NOTO, Eugenio. Energy complexity in population model protocols. Thèse de doctorat : Univ. Genève, 2018, no. Sc. 5243

URN : urn:nbn:ch:unige-1076580

DOI : 10.13097/archive-ouverte/unige:107658

Available at:

http://archive-ouverte.unige.ch/unige:107658

Disclaimer: layout of this document may differ from the published version.

(2)

UNIVERSITÉ DE GENÈVE FACULTÉ DES SCIENCES Département d’Informatique Professeur José Rolim

Energy Complexity in Population Model Protocols

THÈSE

présentée à la Faculté des Sciences de l’Université de Genève pour obtenir le grade de Docteur ès sciences, mention informatique

par

Eugenio NOTO de

Rome, Italie Thèse N

o

5243

GENÈVE RéProMail Université de Genève

2018

(3)
(4)

Contents

1 Energy 1

1.1 Definitions . . . 1

1.2 Components . . . 4

2 Introduction to population model protocol 12 2.1 Definition of the model . . . 12

2.2 Properties . . . 12

2.3 Computation . . . 13

2.4 Considerations . . . 14

2.5 Physical construction . . . 16

2.6 Flock of birds example . . . 17

3 Complexity 23 3.1 Space complexity . . . 23

3.2 Time complexity . . . 24

3.2.1 Markov chain approach . . . 25

3.2.2 Differential equations method . . . 29

3.2.3 Step-by-step method . . . 32

3.2.4 Combining the methods . . . 36

3.3 Energy complexity from conventional complexity . . . 38

4 Algorithm analysis 40 4.1 Flock of birds . . . 41

(5)

4.1.1 Log(n) architecture . . . 45

4.2 Flock of birds algorithm 2 . . . 52

4.2.1 One state, one flip-flop architecture . . . 56

4.2.2 Log(n) architecture . . . 61

4.3 Addition modulo 2 . . . 66

4.3.1 One state, one flip-flop architecture . . . 70

4.3.2 Log(n) architecture . . . 75

4.4 Addition modulo 4 . . . 80

4.4.1 One state, one flip-flop architecture . . . 84

4.4.2 Log(n) architecture . . . 91

5 Conclusion 100 5.1 Energy in Population model protocols . . . 100

5.2 Clues for energy complexity in other electrical devices . . . 104

Appendices 108 A Markovian method program 109 A.1 Problem . . . 109

A.2 Markov creation . . . 112

A.3 Parameters . . . 118

A.4 Fast average computation . . . 120

B Step by step method program 122

(6)

Abstract

Today, energy has a crucial function in electronic devices. Indeed, at a time where a person has electric machines with a processor inside like computers, phones, dishwashers and so on, a device that saves energy means an economy of money and a good thing for the environment. Another thing making the economy of energy important today is the mutiplication of electronic devices working with a battery.

For all those devices such as smartphones, tablets, bluetooth loudspeakers etc. that more and more people carry with them, an energy efficient device means a longer duration of utilisation. In most specialised computer science domains, such as sensor networks, the energy is particularly crucial since it means the lifetime of the network.

The list of examples of the importance of energy efficient devices is far from being exhaustive. Basically, everybody from the developper to the user has interest in having devices that manage well the energy consumption, and up to now, the research has been done mostly on the hardware but there is another approach. What if the energy consumption could be optimized not only thanks to a better conception of the device but also with the help of the software that is used?

In this thesis this approach will be treated and developed. In the beginning several definitions of energy measurement will be given that will be used to compute the energy consumption in the systems. With that, the atomic parts of a logical system that can be used to construct whatever electronical device and that can be used with the energy measures defined will be set, explaining why those choices are made.

Several basic structures needed in real time systems are also built in order to see how they consume energy and to have a first idea of how a system will use his energy.

(7)

Then, since it is impossible to analyse all the possible devices at once, one type is chosen: the Population model protocol. The model will be defined, its properties will be checked and its possibilities of computations will be explored. With all that, the choice of this particular model instead of others will be justified due to its very good properties which are very positive for this kind of work. Then, thanks to the components defined, it will be explained how to complete a physical Population model protocol in which the energy consumption can be computed.

In the next part, the complexity of the Population model protocol will be studied in general. Due to the patterns used to build the systems, a method will be defined to compute the space complexity. Then, several mathematical tools will be defined and theorems will be proved in order to compute the time complexity and finally a formula to compute the energy consumption will be given. This part is very important for the proof that the energy consumption is a complexity value, so the link between energy time and space must be shown.

After that, several algorithms will be implemented in a dedicated architecture in order to get an energy consumption value that is the closest possible to the value of the algorithms and not to the physical architecture. Those algorithms will be compared and studied from all sides of the complexity.

In the end, the observations on the algorithms will be explained, with the conclu- sion that energy is a complexity value, the link between energy time and space will be provided for the case of Population model protocols and criteria to choose the best algorithm in therm of energy consumption will be given. Finally, the results obtained will be injected in other simple device architecture to get a clue if the results obtained for the Population model protocols are also usable for other systems.

(8)

Chapter 1 Energy

1.1 Definitions

To compute the energy complexity, different definitions will be used. The first is the definition of the model given by Kei Uchizawa, Takao Nishizeki and Eiji Takimoto in [1]. They use threshold gates that work as follows: Each gate is a tuple(i, a, o, w, t) where i ∈ N is the number of inputs, a ∈ {0,1} is the activation value where 0 corresponds to not active and1to active,o∈Nis the number of outputs. Finally we havew∈Roand a thresholdt. The idea is to use those threshold gates interconnected with themself to build systems. In those cases, there will be some input for the system which will be connected to the inputs of several threshold gates, the outputs of those gates will be connected to other gates and so on until the final layer of gates will provide an output which corresponds to the output of the system. For each gate, the valuea is computed like this: a = 1 if P

i≥ t and 0 in the other case the value of each output isoi =a·wi. To compute the energy of a system, we will take the sum of all the active gates: energy=P

a. This definition of energy consumption is based on the fact that a system where all the internal components are active consumes more energy that another composed by the same amount of components, but in which some of them are inactive.

(9)

If we want to transpose this definition in an electrical scheme in order to stay close to those assumptions, we will stay at the level of logical gates. For the energy we will make the sum of all the logical gates that have a value of one and we will use three types of gates: the "and gate" which has a value of one if all its inputs are one and zero in the oter cases, the "or gate" which has a value of one if at least one of its inputs has a value of one and zero if all the imputs are set to zero and finally the

"not gate" which has only one input and has a value of one if its input is zero and zero otherwise. This modification makes sense because a system where all the logical gates have a value of one uses more electricity than a model where all the gates have a value of zero.

In a static system this would be perfect, but in a dynamic system where there is an evolution depending on time, this definition of energy consumption might not be enough. For making this visible, a lower level should be considered. The logical gates that will be introduced in the next paragraph are built most of the time with the C-MOS technology which uses itself the combination of the P-MOS and the N-MOS transistors [2] [3]. Those transistors have two inputs, the source and the gate and one output, the drain. The mechanic of the N-MOS is that when a sufficient tension is provided to the gate, an electric field is generated that gives the composing material the same properties as a conductor and the source will be connected to the drain.

The P-MOS transistor works in an opposite way, the material is a semiconductor, but if a sufficient tension is given, it loses the conductor capacities and the source is not anymore connected to the drain. To activate those transistors, extra energy is required and we have to take this into account. A first way is just to count one every time a logical gate changes its value. If a functionτ that takes as an input the output of a logical gate at a time t and gives as a result the new output at a time t+ 1 is considered, here is the energy consumption e of this logical gate during the

(10)

interval]t, t+ 1]:

e=

τ(0) = 0⇒e= 0 τ(0) = 1⇒e= 1 τ(1) = 0⇒e= 1 τ(1) = 1⇒e= 0

Of course this way of counting totally neglects the method mentionned at first.

A way to take into account the two ideas at the same time is just to sum them up, which gives us, using the sameτ function:

e=

τ(0) = 0⇒e= 0 τ(0) = 1⇒e= 2 τ(1) = 0⇒e= 1 τ(1) = 1⇒e= 1

because in the first case there is no value change and the final value is 0, in the second there is a state change and the final value is 1, and in the two last cases there is either a state change or a final value of 1, but never both at the same time.

In this thesis, those three metrics make sense. The first that will be called "ones"

is the most accurate approximation of energy consumption. As a matter of fact in static systems the "ones" method is very good and the two others have no sense since they produce respectively an energy of 0 or the same as the "ones" method. In the case that is considered here, in other words in dynamic systems and in Population model protocol, the "ones" method remains very accurate since the longer an element remains in the same state, the more the method is accurate. Here, considering the case of Population model protocols, the size of a problem will be given by the number of agents, and at each time, a scheduler will select at random two agents and make them interact. That time will be the only moment when agents will change their state, now if n agents are part of a problem, the probability that one precise agent will be selected is n1 + n−1n · n−11 = n2. According to the geometric distribution, on the average every agent will change its state every n2 draws and stay on the same

(11)

state the rest of the time. Then, for a bign, there will be a lot of agents staying in the same state a lot of time, giving to the "ones" method a high level of accurancy.

At the same time, this method is not perfect for a complexity computation, because it is a floor approximation and therefore does not bound the function. For more informations about Population model Protocols, I invite to read the next chapter.

The second method, called "changes", only takes care of the changing state of the logical gates. This obviously does not include all the time in which the logical gates will have the same output, but since that is frequency dependant and in this thesis we do not want to be matherial dependant, no frequency value will be considered and in those conditions, this method is measuring exactly what is done.

The "combined" method, which is the sum of the two others, will do what the each one of the other methods cannot do alone: beeing an upper bound of the energy. Indeed, it takes into account the static consumption of the logical gates and the changing states, but giving to the changes the same weight as to the static is definitely adding more than the real consumption and therefore a good complexity value is computed.

1.2 Components

In this part there will be built up the systems in which the energy consumption will be measured. To do so the bricks that will be used for all the systems will be described. As already anticipated, only a logical layer is needed with the energy computation methods described, deeper electronical layers will not be considered anymore. To make the things simple, only the three most basic logical gates will be used. The reason is that despite the fact that we count the same amount of energy for each logical gate, in reality there are differences between them. The more complex logical gates are used, the more the difference between the most consuming and the least consuming will be big [3] and the less our computations will be correct. In view of the above mentionned, the decision has been taken to use only the most basic and

(12)

the choice of the three has been made because this is the minimun needed to build whichever system [4] [5]. Here are they:

• and:

• or:

• not:

A problem that has to be considered is the number of inputs for each logical gate.

In the theory a logical gate with two inputs and another one with ten inputs will consume the same amount of energy, but in practice, when the gate is physically built, it is done with more material and consumes more [3]. To make the future sys- tems comparable we will use only logical gates with two inputs. In order to simplify the schemes, we will draw logical gates with more than two inputs, for instance n, as a single logical gate with the required number of inputs, but for the calculations, we will consider them as a subsystem composted byn−1logical gates. It is always possible to do that connecting logical gates with two inputs between them as shown in the examples for the "and gate" below:

1 2 3 4

1 2 34

1 2 3 4

It is easy to show that the truth table of the three schemes are the same and for the or gate, the same patterns will work. obviously, the "not gate" has only one

(13)

input and this is not going to change.

Those three logical gates are enough to build every single system needed in this thesis, but in order to have simpler and understandable graphics, another item will be used: the flip-flop [2] [5] [2] [6]. The flip-flop is a basic memory element and in or- der to have a dynamic system, a memory element is required because when a system is a function over time, remembering the current state of the system is necessary to compute the next step. It will be drawn as follows:

• flip-flop: Q Q¯ D L

The flip-flop has a binary value as every other component considered, which can be checked through the outputQ. If the flip-flop at a time t has an input D and an output Q, at a time t+ 1 it will have a new input D1 and an output Q0 = D. A flip-flop can be built in two steps, we will start with this first scheme [7] [5]:

and 1

and 2 D

LD

HereLD is the controller, if it is set to 1, "and 2" is 0 and "and 1" is will hava a value ofD, therefore the "or gate" has also a value ofD thanks to the input coming from "and 1". On the contrary, if LD is set to 0, "and 1" has an input of 0 and so its output will also be 0, "and 2" will get its value from the previous output of the

(14)

system (same as the "or gate") and forward it to to the or gate ant therefore to the output of the system. The idea is to connect a clock to LD and the input of the memory element toD. The problem is that between two ticks of the clock, the value of the memory element will be the input and if it changes, the whole system will sustain changes because what is built is asynchronous. To correct that problem, a second identical system will be added after the previous one but with the LDinput inverted [7] [5]:

and 1

and 2

or 1

and 3

and 4

or 2 D

LD

From now on, LD will get its value from a clock which will alternate from a value of 0 to a value of 1, then 0 and so on. When the clock is set to 0, "and 2" and "and 3" are set to 1 and the two other "and gates" have a value of 0, which implies that

"or 1" has its previous value which is also sent to "and 3" and "or 2" and is therefore the value of the system. If the clock has a value of 1, it is "and 1" and "and 4" that are set to 1, so "or 1" has a value of D and "or 2" its previous value. In this case the value of the clock does not matter, the output of the system is stable, which means that it is synchronous and this system will be the flip-flop. The synchronous part is very important, because if the memory elements of the future systems will be asynchronious, each time that an input will change, several logical gates will activate and some energy will be consumed. Now if we have multiple entries that are coming, and they do not arrive at the same time, each time that one of them will come,

(15)

the system will waste energy in computing partial and incorrect solutions. Plus, the energy will becomes uncomputable, since it is not possible to see forward and know which value is coming in which order. In another way, with a synchronous system, the inputs will arrive, and when the clock is set to 1, the whole system will go to the next step.

To complete this section, the energy consumption of the flip-flop will be computed with the three methods described, and with this, all the tools needed to compute energy in complex systems will be set. To compute those values, two variables will be considered: first the input dataDand second the output of the flip-flopQ. The value will be computed for a complete clock cycle, considering that the clock is already set to 0, we start to compute when the value changes to 1 and compute a second time when it turns to 0 again, since all the systems that will be considered in the future will be synchronous, the input valueDcannot change when the clock is set to 1 and will change after it is set to 0 again. The first thing remarked is that when the clock is on 0, "and 2", "or 1", "and 3" and "or 2" will have the same value and when the clock is on 1, "and 1" and "or 1" will have the same value as well as "and 4" and

"or 2". In addition, the two "not" gates will be set to 1 once in each clock cycle and change value twice, which consumes 2 energy units for the method counting the ones, 4 for the changing values method and 6 for the combined one. With those informations, here are the tables and graphs with the energy consumption:

D Q e

0 0 2

0 1 4

1 0 8

1 1 10

Figure 1.1: Ones

(16)

Those results are explained as follows: in the first row, all the logical gates are set to 0 all along the clock cycle exept the 2 "not gates" in the second rowQ is set to 1 and when the clock is set to 0, "and 2", "or 1", "and 3" and "or 2" have the same values, since "or 2" isQ, all those gates start in the state 1. When the clock changes to 1, the whole left side of the system is set to 0, but "and 4" and "or 2" have the value 1 and consume 2 energy units, there will be added the 2 of the "not gate". In the third case, the system starts again with all the gates set to 0, and when the clock changes to 1, "and 1" and "or 1" change their values to one, because of that, when the clock returns to 0, "and 2", "or 1", "and 3" and "or 2" are all set to 1. If the usual 2 coming from the "not gates" are added, we reach the value of 8. Finally in the last case, the flip-flop starts in the same state as in the second case and when the clock changes to 0, we have 4 gates set to 1 and after the clock returns to 0, another 4, so due to the "not gates", a value of 10 is reached.

D Q e

0 0 4

0 1 10

1 0 10

1 1 12

Figure 1.2: changes

With the same set up as in the previous method, the system will be analysed again.

As said, in the first case the system will stay with only 0 all along the clock cycle, then the value of the energy consumption depends only by the two "not" gates. In the second case, at the first clock change, 4 gates are changing state: "and 2", "or 1", "and 3" and "and 4" are switching state, the first 3 from 1 to 0 and the last from 0 to 1 and at the second clock change, "and 4" and "or 2" are changing both from 1 to 0. In this counting energy method, we do not care about how the gates are changing, but only that they are changing, adding to those 6 changes the 4 coming

(17)

from the "not gates", we reach a value of 10. The same value is computed for the third case, but this time when the clock changes to 1, we have "and 1" and "or 1"

that change from 0 to 1 and when the clock completes its cycle, "and 2", "and 3"

and "or 2" that change from 0 to 1 and "and 1" that changes from 1 to 0. In the end there is the last case, with "and 1" and "and 4" starting at 0 that will change to 1 when the clock moves to 1 and to 0 when the clock comes back to 0 and "and 2" and "and 3" that start at 1, change to 0 and return at 1.

D Q e

0 0 6

0 1 14

1 0 18

1 1 22

Figure 1.3: combined

This one is obtained just adding the previous two methods.

Now there will be given a small analysis of the described procedures. First of all, the three methods are sorted in consuming order as the "ones" method estimates the consumption as smaller than the "changes" which estimates itself a smaller con- sumption than the "combined". Now, if each situation is considered equiprobable, a consumption of the average consumption for a method minus the standard deviation is considered low, a consumption of the average plus the standard deviation is con- sidered high and the rest average, so here will be shown what happened. The "ones"

method has an average consumption of 6 with a standard deviation of 3.16. Two cases are under the average and two are above, one is low energy consuming, two are average and one is very consuming. With the same assumption, the "changes"

method has an average of 9 and a standard deviation of 3, which implies only one value below the average and three above, with one low consumption, three average

(18)

and no high. In the combined method, we have exactly the same results than in the "ones" method. Here we see that the second method is different from the other two because the system is more balanced with a small consuming state and three medium but more than average consuming states. The other two are more similar, but special attention should be given to the differences because the "ones" method has its values distributed on a line while the "combined" has a very economic state and the most expensive state is just above the average. This reasoning will be useful when considering more complex systems.

(19)

Chapter 2

Introduction to population model protocol

2.1 Definition of the model

A Population model protocol is a special kind of sensor network. In this network, the sensors called agents will interact in a random way with other agents and with their local knowledge they will give an answer to a global problem [8] [9] [10]. More formally, a Population model protocolAconsteists of a finite set of statesQ, a finite set of input symbols X ⊆ Q, a finite set of output symbols Y, an output function O : Q → Y, and a joint transition function δ : QxQ → QxQ. A Population model protocol is executed by a finite population of agentsA with states in Q.

2.2 Properties

Once done with the definition of Population model protocols, several properties should be defined. The first one is the uniformity. When a Population model protocol is defined, the transition functionδhas to be defined in a way that the protocol works and leads to the correct answer whatever the number of agents [8] [10].

(20)

The second one is the anonymity. Here it is said that every agent is totally anony- mous and cannot be recognised by any method or by anybody, particularly by other agents or the scheduler [8] [10].

The third property is fairness [8] [10] and it is the most complex property. To explain it, the definition of configuration is needed. A configuration C : V → Q describes the state of each agent of the population at a precise moment. It is usually represented by a set containing the statesQ of each agentV, because a set does not have an order and therefore respects the anonymity of the population. From that are defined some notations [8] [10]:

• C −→e C0, from the configuration C we reach in one step the configuration C0 via an encountere∈E

• C−→C0, from the configuration C we reach in one step the configurationC0 if it exists an encountere ∈E such that C −→e C0

• C−→ C0,C0 is reachable fromC (It exists a sequenceC, C1, C2, ..., Cn, C0 such that Ci−→Ci+1)

A finite or infinite sequence is called execution. Finally, the formal definition of fairness is that given two configurations C, C0 such that C−→C0, if C occurs an infinite number of times in an execution, the same holds to C0.wle

2.3 Computation

it is important to define the computation for a Population model protocol, because the protocol is not able to stop itself and give a solution. A computation is an infinite fair execution. To receive the solution we will talk about stability. At one point, the scheduler or the initiator of the protocol, will stop it, take an agent and check its answer. This will be the answer provided by the protocol to the submitted problem.

(21)

To consider the solution correct, we need two things: first that the configuration is stable and second that all the agents agree with an unique answer. For the first point, a configuration is stable if and only if for each e ∈ E, C −→e C. Of course, since the encounters between agents are randomly made, we have no guarantee of the time that it will take to reach a stable configuration, but because of the fairness, we know that if a stable configuration exists, it will be reached sooner or later [8]

[10]. This thesis will give some tools that will allow to know when to stop a protocol on a stable configuration with only a small error probability but without waiting too much. The point of agreement of an answer is up to the person that sets up the protocol to manage that in each stable configuration, all the agents have the same output after applying the output function over their state.

2.4 Considerations

The question here can be why to use Population model protocols and not standard electronic devices as smartphones, tablets or computers. The first reason is the simplicity. With the components described in the energy complexity section, it is not that hard to build a Population model protocol, which means a hundred percent knowledge about the system. It is true that for each problem, a different system is built, but each agent has the same architecture and it is easy to analyse. In addition the system is fully scalable, by adding agents. Contrariwise, building a smartphone or a laptop architecture will be much more complex [11] and even if only one architecture were enough for all the problems, it is harder and not fully scalable because a certain amount of memory cannot be exeded. In addition it will complexify the computations. A third solution could be to use an existing device, but in that case, it would have been very hard to analise precisely the components, plus how those components interacts and without this knowledge it is impossible to compute a theoretical energy consumption.

There is also another reason to use Population model protocol rather than other electronic devices: the precision of the computation. In the case of Population model

(22)

protocols, each architecture is dedicated to a problem, the only obstacle is to decide for each problem, which is the best architecture. Is it better to balance the logical gates in order to have the most similar energy consumption no matter in which state our agents are or is it better to have very expensive states used rarely and very cheap ones used more often? Electronic devices with a multitask processor will bring a different set of problems [11]. For instance the memory of the system: those systems will have a fixed amount of memory that will interact with the system. In the case that not all the memory is used in a problem, the unused part, even doing nothing and with a value of 0, will still consume energy as shown when we defined the memory elements and this is noise in our computation. This case will add more complex computations in order to remove the noise because this energy is used by the architecture and not the problem. A similar problem, but more difficult to deal with, can be found in the processor. Taking for instance the ALU of a processor, there is a control architecture and a slave architecture. The control architecture will enable and disable several parts of the slave architecture in order to execute the operation needed in that specific moment, which means that in the control architecture, if several operations are not needed, the memory elements representing those operations will make noise because of using energy all of the time for no reason. In addition, the same happens in the slave architecture where a part of the system will never be used and will consume energy. This noise is very difficult to remove, because an ALU with less operation will not only not use the amount of energy for the unused parts, but also have more simple and less consuming connections in the remaining part.

The last obvious problem is that when a processor is built, an architecture has to be designed and this architecture can be balanced between the different operations or unbalanced. In both cases, even in the balanced, several operations will consume more than the others and since the architecture will be the same for all the problems (in the other case a processor is built for each problem and we have a very complex architecture to design for each problem as mentionned above) the problems that use the least consuming operations will consume less, not because of the problem, but because of the architecture design and this is not what is wanted to be developed in this thesis.

(23)

This leads to the choice of the model between the different Population model pro- tocols. The model described in this section is the standard deterministic Population model protocol [10]. It has a limited calculability power, since it can solve the prob- lems in the first-order logic of the Presburger arithmetic [10], which means natural numbers or booleans in a finite set as input and output, and as operators: addition, comparisons and every boolean operation. Because the goal is not to compute com- plex data, but just to compare the consumption behavior of different algorithms, we do not need more complex systems. Also, another characteristic of this protocol is that it is not robust to errors, so in this thesis no errors will be taken into account during transmissions or internal electric failures. To take care of all these issues, more powerful Population model protocols exists, but they will not be used in this thesis because they are more complicated to analyse and their use won’t benefit in terms of energy complexity. As explained, the standard model has the best properties to exploit and here it is not needed to solve more complex problems or avoid errors that can occur in real life systems.

2.5 Physical construction

Instead, an architecture will be provided for each problem, making the computa- tion of the used energy doable. Of course the architecture will not be free. In order to create comparable problems, several patterns will be given in order to build the systems thanks only to the number of states and the function δ. To construct a Population model protocol, all the agents will be built individually. Each agent will need enough memory to remind its state and this can be done easily in two ways.

First it can have a flip-flop for each of the k states [2] [7], which implies k outputs in order to communicate its state to another agent and the second way is to have log2(k) flip-flops in order to code the state in binary [2] [7]. For δ, only the basic logical gates will be used, the function will take as input all the connections from the flip-flops of the agent, plus the same number as external input that are the state of the agent who is communicating with. All those inputs go to an "and gate" and if there are several inputs that lead to the same state, the different "and gates" that

(24)

represent those states will be connected to an "or gate". With those statements, it is easy to notice that the first method will require more flip-flops, but easier connec- tions for δ because if we are in a state, only the flip-flop representing this state will be set on 1 and all the others will be on 0. The second method will use less flip-flops, but will have more connections, because to identify a state, the connections with all the flip-flops will be needed.

2.6 Flock of birds example

Here will be put in practice the theory seen up to now. A theoretical example of how to create a Population model protocol will be set and it will be shown how to create the logical circuit in the sensors. The problem will not yet be analysed in terms of energy complexity, because the tools to do so have not yet been presented.

We will only consider a correct Population model protocol and its logical circuits, nothing more.

We will start explaining the problem: there is a flock of birds and the protocol should tell if this flock is contaminated and will answer that it is if the majority of the birds are sick. To do so, each bird will receive an agent, the agent will mesure the temperature of its host and decide if the bird is sick or not. Then, communicating with the other agents during a flight of the flock, all the agents will decide if the flock is sick or not and give the answer via the output function [9] [12] [10].

Formally, each agent will have four states Q1, Q2, Q3 and Q4, the input function I equals Q1 if the temperature is higher than a certain treeshold and Q2 otherwise.

The output function O will say that the flock is sick if the agent is in the state Q1

or Q3 and say that the flock is healthy if one of the two other states is read. Now

(25)

the transition function will be described:

δ=

Q1, Q2 ⇒Q3, Q4

Q1, Q4 ⇒Q1, Q3

Q2, Q3 ⇒Q2, Q4 Q3, Q4 ⇒Q3, Q3

All the other combinations are traeted as the identity function. (Qx, Qy ⇒Qx, Qy).

Now the properties should be checked. The anonymity is naturally respected, because nowhere in the protocol an agent can be identified or a specific agent is required. Concerning the uniformity, it is also respected, because nowhere a certain amount of agents is needed and it will be shown later that the protocol works with every number of agents. The fairness is respected too, if we consider no failure in the system, which means that no agent will communicate a wrong state and also that no agent will leave the protocol, each agent has a positive probability to communicate with every other agent and this probability is given by a function depending of the position of birds in the flock. Because of that, since we are an infinite time in the same configuration every possible draw can occur and will an infinite number of times which is the definition of the fairness. There are stable configurations too, if a configuration contains only Q1 and Q3 or contains only Q2 and Q4, whatever is the draw, only the identity function can be applied and the configuration remains the same forever. The answer is consistent, because Q1 and Q3 are mapped by O to the same answer and Q2 and Q4 are mapped by O to the same answer too and there is no other stable configuration, which obviously implies that if a stable configuration is reached, the system has an answer to the problem. Finally it must be checked that the Population model protocol converges to a stable configuration after a certain amount of time. Due toI, it is known that the starting configuration is composed only by agents in the statesQ1 and Q2. Assume first that there is more Q1 than Q2 in the starting configuration, after a certain time, due to the fairness property the first draw will be used |Q2| times and since with these rules there is no way that the agents state becomes Q2 from another state, after that happened,

(26)

there will be onlyQ1, Q3 and Q4. Again, due to the fairness property, there will be enough draw (Q1, Q4) and (Q3, Q4) to reach at one point the stable configuration containing onlyQ1 andQ3. The same reasoning could be applied if there is the same number ofQ1 andQ2 in the initial configuration except that in the second part there will be only Q3 and Q4 and sooner or later there will be enough (Q3, Q4) draws.

It is a bit more complicated with more Q2 than Q1. The first part is the same, thanks to the fairness there will be |Q1| times the draw(Q1, Q2) that will bring the configuration to contain only Q2, Q3 and Q4. Here unlike the before mentionned, we can have the draw (Q2, Q3) that will reduce the number of Q3 in the protocol and the draw (Q3, Q4) that contrariwise will increase them. Let us take the less favorable configuration, oneQ2 and all the other agents are onQ3. First of all, given this transition function, there is no possibility to reduce the number of Q2 which make it impossible to reach a stable configuration containing only Q3. Here, if the draw(Q3, Q3) happened, the configuration will remain the same and if we have the sequence (Q2, Q3) → (Q3, Q4) we will stay in the same configuration too. Now by the fairness property, we know that if the considered configuration will appear an infinite number of times and(Q2, Q3)is drawable and leads to a configuration where there is aQ2 a Q4 and the rest are Q3, this will happen an infinite number of times, but this reasoning could be applied again on this new configuration and will give two Q4 and recursively will lead to a configuration composed only by Q2 and Q4 that is stable. Then our Population model protocol converges to a solution.

Now the agents will be built with logical gates formally. In this example only the ones built with one flip-flop for each state will be considered, the other ones will be studied in the algorithm analysis chapter of this thesis. Since we have four possible states, each agent will have 4 flip-flops, so there will be four entries that correspond to the four states of the agent it is communicating with and four outputs that correspond to its state. Then there will be a system of "and gates", "or gates"

and "not gates" that will implement the transition function. In the example, In1, In2, In3, In4 will be the inputs coming from the four flip-flops from another agent and if neededOut1,Out2, Out3,Out4 the states of the flip-flops of the current agent.

(27)

Before starting the schema, the boolean equations will be given using "·" as "and",

"+" as "or" and " " as "not".

Out1 =Out1·In2 Out2 =Out2·In1

Out3 =Out1·In2+Out4·In1+Out4·In3+Out3·In1 Out4 =Out2·In1+Out3·In2+Out4·In2+Out4·In4

Of course this is not the only solution. For instance another one is with the in and out inverted in the right part of the equations. There are also other possibilities to create the equations, here is given a possibility with the smallest amount of logical gates. To achieve this result, logic and Karnaugh tables are used [7]. As described earlier, using one flip-flop per state of the agents allows to have less logical gates to create the system, because when a flip-flop has its output value set to one, it is known that all the others are set to zero. Now there is the logical figure:

Q Q¯ D L

Q Q¯ D L

Q Q¯ D L

Q Q¯ D L In1

In2

In3

In4

(28)

To conclude this example, the energy consumption of an interaction between two agents will be computed. The two agents will be considered in all possible states one at a time and the energy when they change to a new state will be computed.

The chosen architecture implies that there is only one flip-flop with a value of one and the three others have an output equal to zero. When the agent is in state 1, the flip-flop on the top of the figure is on 1, for state 2, its the second flip-flop and so on for the two other possibilities. The full operation consists in this: the two agents will connect, which means that the output of one becomes the input of the other and vice versa, at that moment the energy up to the flip-flop input will be computed since the inputs combined with the outputs will activate several logical gates, then the clock tick will occur and at this moment the states of the flip-flops will be updated and counted as energy consumption and finally the two agents will instantaneously disconnect without giving the time to compute a second time the circuit preceding the flip-flops. Here are the results of the interactions:

Qa1 Qa2 Qa1+ Qa2+ eones echanges ecombined

1 1 1 1 36 50 86

1 2 3 4 38 66 104

1 3 1 3 38 52 90

1 4 1 3 38 59 97

2 2 2 2 36 50 86

2 3 2 4 39 59 98

2 4 2 4 38 52 90

3 3 3 3 40 54 94

3 4 3 3 40 60 100

4 4 4 4 40 54 94

In the table the Qa1 and Qa2 represents respectively the states of the first and second agent, the + represents the states after the interaction and finally the e represent the mesure of energy consumption, in addition the combination of states is considered only once, because if we reverse the values of two agents the energy consumption will be the same. For the echanges and ecombined values, the real values depend of the previous interaction and were counted here as in the worst case to

(29)

obtain a superior bound as required in a complexity value, in any case, there is only a difference of 2 or 3 between the best and the worst case. Below there is the graph with the values of the three energy units:

Figure 2.1: Energy in one interaction of flock of birds

Here it is impossible to provide a more detailed statistical analysis because the probabilities of encounters depend from the number of agents and from the config- uration and those informations vary from one instance of the problem to another.

Intuitively at the beginning of the problem there is a greater probability to find agents with a value coming from the input alphabet and in the end from states that map to one of the values of the output alphabet.

(30)

Chapter 3 Complexity

When the energy consumed by a Population model protocol is analysed, the num- ber of clock ticks, in this case the number of interactions, as well as the number of equipment used are closely related to the energy consumption. For those reasons, a space and a time complexity that match the traditional definitions should be defined.

3.1 Space complexity

The definition of space complexity is the amount of memory needed to solve a problem [13]. In the case of Population model protocols, the agents have each a state that is needed to advance to the solution of the problem. Then, the space complexity will be the number of flip-flops that an agent has multiplied by the number of agents of the system. This is a good option, because by taking individually agent by agent with less flip-flops, less states can be memorized and the algorithm will not work, contrariwise, more memory won’t bring anything to the algorithm. The sum of the flip-flops of all agents is needed, because it matches the traditional definition where the space complexity is a function of the size of the problem and without this restriction the space complexity will be a constant depending only on the problem and not on its size. In this definition of the complexity the logical doors that does not compose the flip-flops are not taken into account, because their presence in the

(31)

system is not linked to the memory but to the algorithm needed to solve the problem.

In a Turing machine this would be the transition function and this has nothing to do with the memory. As a reminder a Population model protocol can be built in several ways and in this thesis we consider two. The first one uses one flip-flop per state and is used in the flock of birds example and gives us the following space complexity:

n· |Q|

Wherenis the number of agents and|Q|the number of states per agent. The second formula for the second way to build the required Population model protocol is:

n·log2(|Q|)

3.2 Time complexity

The time complexity will be as easy as the space complexity to define, but a lot more complicated to compute. Indeed, the time complexity is the number of operations needed to solve a problem [13], in this case it will be simply the number of draws needed to reach a stable configuration and intuitively this definition is perfectly matching. The problem is that the definition of a Population model protocol does not give an end, the protocol never knows when it reaches the stable configuration, it is just built for running and the definition tells that after an infinite number of interactions the stable configuration will be achieved. This is due mostly to the fact that the interactions are drawn at random and there is no certitude about how many interactions will drive us to a wrong or immobile path. Due to that, several approximations will be given in order to have an idea of how many interactions are needed on average to achieve a solution and of course all of them will have their benefits and their negative points.

(32)

3.2.1 Markov chain approach

A first intuitive way to attack this problem is using the Markov chain [14] but first several elements should be defined or redefined. Indeed, in the Markov chain, a graph with probability on the edges is taken and the Markov chain will tell which nodes of the graph are achieved and with which probability. Then, the first move will be to create the graph. The nodes of the graph will be the different configurations of the corresponding Population model protocol, which will be redefined in order to have a unique and more simple representation. Usually a configuration is a set containing the states’ list of each agent. Respecting the anonymity property, we can change that into a vector v ∈Nq:

v =

 v1 v2

... vq

whereq=|Q|is the number of possible states of the Population protocol model and vi the number of agents in the state i. Note that the population n =

q

X

i=1

vi. Since this vector is the unique representation of the configuration, it is now sure that each configuration will have a unique node in the graph. Now only the edges need to be added. For each node of the graph, the probabilitypof each input for the transition functionδwill be computed, then the functionδwith the configuration corresponding to the current node as an input will be applied and a new configuration corresponding to a node will be received as an output. An edge will be created between the node corresponding to the input to the node corresponding to the output of delta and its probability will be p.Fwith Finally the operation will be repeated on each node of the graph. To enter more in detail withp, the probability of drawing 2 agents in the same state i is C

2 vi

Cn2 if vi ≥2 or0 [14] else and the probability of drawing two agents in two different states i and j is vCiv2j

k

if vi ≥ 1 and vj ≥ 1 or 0 in the other cases [14]. We are sure that this algorithm ends and the graph is finite because there is a maximum of (n+q−1)! different possible configurations for a Population model

(33)

protocol [14] and each node of the graph represents a different configuration. In addition, we know the stable configuration which is represented by a node with only one arc pointing itself and with a probability of1. Finally, with a small modification of the algorithm which allows us to count the number of steps needed to generate a node, we can also know which is the minimum number of interactions to reach a stable configuration. Now that a graph is generated, it will be transformed into a Markov chain in order to know how many interactions are needed to reach a stable configuration which means that we have our solution. According to the fact that the agents are picked at random, the number of interactions can be huge, but with the fairness property we are sure that this configuration will be reached. Our purpose will be to calculate the average number of interactions needed to have a reference value.

As already said, to analyse the graph, we will use the Markov chain. The Markov matrixM [14] is aγ×γ Matrix whereγ ≤(n+q−1)is the number of configurations and each line i represents the state Qi and each column j represents the state Qj. Plus Mij is the probability p(i, j) to go from the state Qi to the state Qj and is equal to the weight of the arc leading from the state Qi to the state Qj of the graph. By definition we can take the line vector x0 =

1 0 0 · · · 0

wich is the probability vector of position after time0if the starting configuration is the first row of the Markov chain. To obtain the value after a time t we use iteratively the formula

x(t−1)M =xt

which is the same as:

x0Mt=xt

If we name A the set containing thej such as p(j, j) = 1 (the stable configurations) we have

∀t ∈N, f(t) = X

i∈A

xt(i)

(34)

the repartition function of staying in a stable configuration after a time t. The problem is that this law will not follow a linear distribution and we cannot calculate the value because we should iterate until the infinity. To solve this problem we will use another method called fast average computation.

Looking more carefully to M we remark that forS beeing the set of states, ∀i∈S

∃j ∈ S, i → j and p(j, j) = 1, which means that M is an absorbing matrix. The property∃j ∈Ssuch asp(j, j) = 1is true because by definition in a population model protocol, the answer is reached only in a stable configuration which is described this way and∀i∈S, i→j is given by the fairness condition of the model. Once we have an absorbing matrix, we can switch the lines to have a canonical form which is a matrix where the absorbing states are at the end of the matrix [14], we have then:

M = Q R 0 Id

!

Now, if we want the matrix of the probability after a time t, as said we have : Mt= Qt (Id+Q+Q2+· · ·+Qn−1)R

0 Id

!

to prove that we can use by induction:

Mt=M Mt−1 = Q R 0 Id

! Qt−1 (Id+Q+Q2+· · ·+Qn−2)R

0 Id

!

= Qt (Id+Q+Q2+· · ·+Qn−1)R

0 Id

!

Looking better at this matrix, it is easy to remark that lim

t→∞Qt = 0 [14]. It is obvious because Mijt is the probability of staying in the state j starting from i and moving during a time t. Since there are absorbing states reachable from every non absorbing state, their probability can only increase until reaching 1 and then the

(35)

probability of staying in a non absorbing state after a long time is0. This result is already proved in [14] and will be useful later.

Another important result is the fundamental matrix of the Markov chain [14]. This matrix calledN, is given by:

N = (Id−Q)−1

Theorem: N =Id+Q+Q2+· · ·

Proof: first we will show that Id −Q is invertible and we proceed as follows:

suppose that a vectorv exists such as (Id−Q)v = 0 then Qtv =Qt−1Qv =Qt−1v

Which means that for eacht ≥1, Qtv =v and so:

v = lim

t→∞Qtv = 0

With this result, we see that0is not an eigenvalue of (Id−Q)and then the matrix is invertible. Now we have to prove that N =Id+Q+Q2+· · ·. For that we use:

(Id−Q) Id+Q+Q2+· · ·+Qt

=Id−Qt+1 Id+Q+Q2+· · ·+Qt

=N Id−Qt+1

t→∞lim

t

X

i=0

Qt =N

As mentioned before, the probability of going from a statej to a stateiin exactly tsteps is given byMijt. Then we can deduce that the mean number of times we pass trough a state in an infinite amount of time starting by a stateiis given by

X

t=0

Mijt.

(36)

If we takei, j 6∈A we have

X

t=0

Mijt =

X

t=0

Qtij =Nij

We can then deduce that the mean time before reaching an absorbing state is the sum of the mean time spent in every non absorbing state which is:

X

j6∈A

Nij

The good point here is that once the graph is known, the method works fast and gives us the real average, not an approximation. The problem comes from the graph, indeed, as explained, the graph can contain(n+q−1)!states which is too long to be computed for really big problems. In addition, even for regular sized problems, there are a lot of different possible starting configurations and for finding which one is interesting to analyse (for instance the most consuming to have a complexity value) or to try several sizes in order to interpolate a complexity function, multiple instances need to be built and again too much time is required to obtain results. The trick is to use other methods to approximate a solution and when it becomes known, use the Markov chain method to have more precise results. Another very interesting point of this method is that it can be adapted to compute very good estimations of the energy consumption by a Population model protocol. The first intuitive way is if the energy consumption computed on one interaction gives results with a very small difference between all the different possibilities of encounter, the average number of interactions obtained by the fast average method can be multiplied by the average energy value and finally by the number of agents and this can be a good approximation.

3.2.2 Differential equations method

Here, to solve the problems raised by the previous method, an approximation for the time complexity will be given using differential equations. The question is: does this new technique have more precise values than the previous one? And if it is the

(37)

case, is this method faster? If the answer to those two question is yes, this method is strictly better than the previous one, but otherwise (and this is the case here) since we already have very good values but hard to compute can we have a less good approximation, but that can be compute quickly? From the theory, we can assume that the solution will be less good than the previous method, but still very close and perfectly in scale with the correct solution and if solving the equation is not too hard, since it takes very few steps, the speed can be an achieved goal too.

The idea is the following: for a problem with n agents and q states, we already consider the configurations as a q dimensional vector v. Let now use a Rq space where the configuration v is represented by the point with the coordinates of v in this space [15]. The transition function of the population model protocol has one input and an output which are both a vector of dimensionk where

k

X

i=0

vi = 2. If the

inputinij is the result of a drawing of a sensor in the stateiand another in the state j from a configuration vt and outi,j the vector that represents the two states after the transition function applies on an encounter with two agents in the statesiandj, we can say thatvt+1 =vt−inij +outij whereoutij is the output. Instead of making a draw, since we are now in a real space, we will now move in the space using the mean reached configuration which is the sum of all possible draws multiplied by the probability of that draw [14] [15].

∀i6=j, vt+1 =vt+

q

X

i=0

(outii−inii)·Cv2

t(i)

Cn2 +

q

X

i=0 q

X

j=0

(outij −inij)· vt(i)vt(j) Cn2

Trivially that leads to:

vt+1−vt=

q

X

i=0

(outii−inii)· Cv2

t(i)

Cn2 +

q

X

i=0 q

X

j=0

(outij −inij)·vt(i)vt(j) Cn2

Now, of course all the times belonging to integers are defined and have a precise value, but the model does not have values for real times which are required in a

(38)

differential equation system, then it will be decided that all the values in between of two integers will be the linear function that brings from vt to tt+1 where t and t+ 1 are integers. With that definition which does not contradict anything in our problem, we reach the following result [16] [17]:

vt+1−vt= lim

δt→0

vt+δt−vt δt =

q

X

i=0

(outii−inii)·Cv2

t(i)

Cn2 +

q

X

i=0 q

X

j=0

(outij−inij)·vt(i)vt(j) Cn2

And finally:

vt = Z

(

q

X

i=0

(outii−inii)·Cv2

t(i)

Cn2 +

q

X

i=0 q

X

j=0

(outij −inij)· vt(i)vt(j) Cn2 )dt

Getting aqdimensional space is instantaneous because it is not needed to generate all the points of the space, we can consider the points only when we need them. The vector moved in R takes nothing because the values already exist. To create the input/output vectors is a quick operation because mostly there are 2·q2 different possibilities for the transition function. Once the formula is treated with Maple for instance the generic solution to the equation system will have an answer very fast.

Up to here everythig seems good, but unfortunately it is not finished. Now that the generic solution is computed, an exact solution is wished, but to do that some parameters should be configurated in order to set the constant that arrives with the intergal for instance. It is not a problem to find enough values sincev0 corresponds to the starting configuration, thanks to the properties over the calculability [10] it is easy to create a centralised system that tells which is the stable configuration which implies that v is also known and finally we can manually compute several integer values. What happens is that most of the times, the general solution is very complicated (for instance the flock of birds example will have a 70 rows general solution) and injecting the values to identify the exact solution will need to solve very complex equations that will take more time than the Markov chain method and this will make this method unusable most of the time. The only way is to try this method and if it works to use it, contrariwise something else is needed. In case, a

Références

Documents relatifs

Our results have been generalized in [Ho], where the limits of n-point correlation functions of the energy density are obtained, via the introduction of multipoint

We introduce a family of DG methods for (1.1)–(1.3) based on the coupling of a DG approximation to the Vlasov equation (transport equation) with several mixed finite element methods

Integrating the power spectral densities of the magnetic and electric fields in the 10 to 500 Hz frequency range shows that the energy density of waves is higher inside the

The schemes are con- structed by combing a discontinuous Galerkin approximation to the Vlasov equation together with a mixed finite element method for the Poisson problem.. We

There exists a constant c > 0 such that, for any real number , there are infinitely many integers D for which there exists a tuple of algebraic numbers

For energy companies, issues related to the factory of the future are the decentralised production of energy mainly based on renewable energies, the monitoring and

Considering the context of performance and new media work made by Indigenous artist in the 1990s, this programme, Following that Moment, looks back at six experimental

Abstract – This paper focuses on sizing optimization of a multisource generator (here: thermal and photovoltaic) that harvest the energy in the human environment.. For