|
@@ -0,0 +1,79 @@
|
|
1
|
+#! /usr/bin/env python3
|
|
2
|
+
|
|
3
|
+import math
|
|
4
|
+import numpy as np
|
|
5
|
+import pandas as pd
|
|
6
|
+
|
|
7
|
+class Populations:
|
|
8
|
+ """
|
|
9
|
+ This class is made of a pd.Series of the clients and the operation that
|
|
10
|
+ can be made on the population.
|
|
11
|
+ """
|
|
12
|
+ def __init__(self, carac):
|
|
13
|
+ """
|
|
14
|
+ Population constructor, initialises the client population with
|
|
15
|
+ the caracterictic given to it.
|
|
16
|
+ """
|
|
17
|
+ self.population = pd.Series()
|
|
18
|
+ self.nmbr = carac
|
|
19
|
+ self.add_client(self.nmbr)
|
|
20
|
+ """
|
|
21
|
+ We have to define more caracteristics. We will start with a
|
|
22
|
+ simple serie of inds and their number
|
|
23
|
+ """
|
|
24
|
+ return
|
|
25
|
+
|
|
26
|
+ def add_client(self, nb):#Need to add an arg "habits"
|
|
27
|
+ """
|
|
28
|
+ Add 'nb' clients to the population.
|
|
29
|
+ """
|
|
30
|
+ start = len(self.population)
|
|
31
|
+ end = start + nb
|
|
32
|
+ inds = []
|
|
33
|
+ for i in range(nb):
|
|
34
|
+ inds.append(Individu())
|
|
35
|
+ self.population = self.population.append(pd.Series(inds, index=range(start, end)))
|
|
36
|
+ self.nmbr += nb
|
|
37
|
+ return
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+class Individu: #tout OK
|
|
41
|
+ """
|
|
42
|
+ This class define the clients, it's caracteristics being :
|
|
43
|
+ - User habits :
|
|
44
|
+ - The habits with the Magna Wallet and the 3 tokens :
|
|
45
|
+ -self.magna_wallet_btc
|
|
46
|
+ -self.magna_wallet_eth
|
|
47
|
+ -self.magna_wallet_mgn
|
|
48
|
+ They containe statisctical law of the user habits.
|
|
49
|
+ The methods of this class operate on only one client.
|
|
50
|
+ """
|
|
51
|
+
|
|
52
|
+ def __init__(self):#OK
|
|
53
|
+ """
|
|
54
|
+ Constructeur d'une instance 'individu'.
|
|
55
|
+ Ce constructeur fait appel aux fonction especes et aleatoire
|
|
56
|
+ pour initialisé les variables d'un individu aux valeurs propres
|
|
57
|
+ à son espèce.
|
|
58
|
+ """
|
|
59
|
+ # Those 3 caracteristic are the users habits concerning the client
|
|
60
|
+ # use of Magna Wallet
|
|
61
|
+ self.magna_wallet_btc = (
|
|
62
|
+ np.random.normal(
|
|
63
|
+ loc=0.00001, scale=0.002),
|
|
64
|
+ abs(np.random.normal(
|
|
65
|
+ loc=0.002, scale=0.01))
|
|
66
|
+ )
|
|
67
|
+ self.magna_wallet_eth = (
|
|
68
|
+ np.random.normal(
|
|
69
|
+ loc=0.01, scale=0.9),
|
|
70
|
+ abs(np.random.normal(
|
|
71
|
+ loc=0.5, scale=5))
|
|
72
|
+ )
|
|
73
|
+ self.magna_wallet_mgn = (
|
|
74
|
+ np.random.normal(
|
|
75
|
+ loc=1, scale=10),
|
|
76
|
+ abs(np.random.normal(
|
|
77
|
+ loc=10, scale=50))
|
|
78
|
+ )
|
|
79
|
+ return
|