-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpeople.py
129 lines (105 loc) · 4.64 KB
/
people.py
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Albert:vert Béatrice:rouge Claude:violet Denis:bleu Emilie:jaune
def create_all_satisfaction_function(people):
for citizen in people:
for economic_activity in people[citizen]:
satisfaction_coef = people[citizen][economic_activity]["coef"]
extreme_satisfaction = people[citizen][economic_activity]["max"]
people[citizen][economic_activity]["satisfaction_function"] = create_satisfaction_function(satisfaction_coef, extreme_satisfaction)
return people
def create_satisfaction_function(satisfaction_coef, extreme_satisfaction):
def satisfaction_function(x):
if(x<0):
return x * 100000
satisfaction = x*satisfaction_coef
if(extreme_satisfaction > 0):
if(satisfaction > extreme_satisfaction):
satisfaction = extreme_satisfaction
else:
if(satisfaction < extreme_satisfaction):
satisfaction = -abs(x*1000)
return satisfaction
return satisfaction_function
def create_5_people():
people = {}
people["Albert"] = {}
people["Béatrice"] = {}
people["Claude"] = {}
people["Denis"] = {}
people["Emilie"] = {}
for citizen in people.keys():
people[citizen]["Rbois"] = {"coef":0, "max":0}
people[citizen]["Cbois"] = {"coef":0, "max":0}
people[citizen]["Rtarte"] = {"coef":0, "max":0}
people[citizen]["Ctarte"] = {"coef":0, "max":0}
people["Albert"]["Rbois"]["coef"] = -1.6
people["Albert"]["Rbois"]["max"] = -5
people["Albert"]["Cbois"]["coef"] = 1.2
people["Albert"]["Cbois"]["max"] = 12
people["Albert"]["Rtarte"]["coef"] = -1
people["Albert"]["Rtarte"]["max"] = -3
people["Albert"]["Ctarte"]["coef"] = 0
people["Albert"]["Ctarte"]["max"] = 0
people["Béatrice"]["Rbois"]["coef"] = -2
people["Béatrice"]["Rbois"]["max"] = -4
people["Béatrice"]["Cbois"]["coef"] = 0.4
people["Béatrice"]["Cbois"]["max"] = 10
people["Béatrice"]["Rtarte"]["coef"] = -0.67
people["Béatrice"]["Rtarte"]["max"] = -2
people["Béatrice"]["Ctarte"]["coef"] = 0.5
people["Béatrice"]["Ctarte"]["max"] = 1
people["Claude"]["Rbois"]["coef"] = -5
people["Claude"]["Rbois"]["max"] = -5
people["Claude"]["Cbois"]["coef"] = 0.75
people["Claude"]["Cbois"]["max"] = 30
people["Claude"]["Rtarte"]["coef"] = -1.5
people["Claude"]["Rtarte"]["max"] = -3
people["Claude"]["Ctarte"]["coef"] = 1
people["Claude"]["Ctarte"]["max"] = 5
people["Denis"]["Rbois"]["coef"] = -1.5
people["Denis"]["Rbois"]["max"] = -6
people["Denis"]["Cbois"]["coef"] = 0.5
people["Denis"]["Cbois"]["max"] = 10
people["Denis"]["Rtarte"]["coef"] = -0.88
people["Denis"]["Rtarte"]["max"] = -3.5
people["Denis"]["Ctarte"]["coef"] = 1.5
people["Denis"]["Ctarte"]["max"] = 3
people["Emilie"]["Rbois"]["coef"] = -0.6
people["Emilie"]["Rbois"]["max"] = -3
people["Emilie"]["Cbois"]["coef"] = 0.75
people["Emilie"]["Cbois"]["max"] = 15
people["Emilie"]["Rtarte"]["coef"] = -0.4
people["Emilie"]["Rtarte"]["max"] = -2
people["Emilie"]["Ctarte"]["coef"] = 1
people["Emilie"]["Ctarte"]["max"] = 4
return create_all_satisfaction_function(people)
def create_2_people():
people = {}
people["Albert"] = {}
people["Béatrice"] = {}
people["Albert"]["Rpomme"] = {"coef": -1, "max": 10}
people["Albert"]["Cpomme"] = {"coef": 1, "max": 10}
people["Albert"]["Rpoire"] = {"coef": -2, "max": 10}
people["Albert"]["Cpoire"] = {"coef": 2, "max": 20}
people["Béatrice"]["Rpomme"] = {"coef": -2, "max": 10}
people["Béatrice"]["Cpomme"] = {"coef": 2, "max": 15}
people["Béatrice"]["Rpoire"] = {"coef": -1, "max": 10}
people["Béatrice"]["Cpoire"] = {"coef": 1, "max": 10}
return create_all_satisfaction_function(people)
def create_3_people():
people = {}
people["Albert"] = {}
people["Béatrice"] = {}
people["Claude"] = {}
people["Albert"]["Rpomme"] = {"coef": -1, "max": 10}
people["Albert"]["Cpomme"] = {"coef": 1, "max": 10}
people["Albert"]["Rpoire"] = {"coef": -2, "max": 10}
people["Albert"]["Cpoire"] = {"coef": 2, "max": 20}
people["Béatrice"]["Rpomme"] = {"coef": -2, "max": 10}
people["Béatrice"]["Cpomme"] = {"coef": 2, "max": 15}
people["Béatrice"]["Rpoire"] = {"coef": -1, "max": 10}
people["Béatrice"]["Cpoire"] = {"coef": 1, "max": 10}
people["Claude"]["Rpomme"] = {"coef": -2, "max": 10}
people["Claude"]["Cpomme"] = {"coef": 2, "max": 20}
people["Claude"]["Rpoire"] = {"coef": -2, "max": 10}
people["Claude"]["Cpoire"] = {"coef": 2, "max": 20}
return create_all_satisfaction_function(people)