Newer
Older
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/**
* Parameter panel - input fields for simulation configuration.
*/
import { useSimulationStore } from '../../store/simulationStore';
export default function ParameterPanel() {
const {
config,
updateConfig,
addServer,
removeServer,
updateServer,
isRunning,
} = useSimulationStore();
if (!config) {
return (
<div className="text-sm text-gray-500 text-center py-4">
Aucune configuration chargée
</div>
);
}
const handleArrivalRateChange = (e: React.ChangeEvent<HTMLInputElement>) => {
updateConfig({ arrival_rate: parseFloat(e.target.value) || 0 });
};
const handleCoordinatorServiceRateChange = (e: React.ChangeEvent<HTMLInputElement>) => {
updateConfig({ coordinator_service_rate: parseFloat(e.target.value) || 0 });
};
const handleExitProbabilityChange = (e: React.ChangeEvent<HTMLInputElement>) => {
updateConfig({ coordinator_exit_probability: parseFloat(e.target.value) || 0 });
};
const handleServerServiceRateChange = (serverId: string, value: string) => {
updateServer(serverId, { service_rate: parseFloat(value) || 0 });
};
const handleServerRoutingProbChange = (serverId: string, value: string) => {
updateServer(serverId, { routing_probability: parseFloat(value) || 0 });
};
// Calculate total routing probability
const totalRoutingProb =
config.coordinator_exit_probability +
config.servers.reduce((sum, s) => sum + s.routing_probability, 0);
const isProbabilityValid = Math.abs(totalRoutingProb - 1.0) < 0.001;
return (
<div className="space-y-4">
<div className="border-t border-gray-200 pt-4">
<h3 className="text-sm font-medium text-gray-700 mb-3">
Paramètres du réseau
</h3>
{/* External arrival rate */}
<div className="mb-4">
<label className="block text-xs font-medium text-gray-600 mb-1">
Taux d'arrivée externe (λ)
</label>
<input
type="number"
step="0.001"
min="0"
value={config.arrival_rate}
onChange={handleArrivalRateChange}
disabled={isRunning}
className="block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 text-sm disabled:bg-gray-100"
/>
<p className="text-xs text-gray-500 mt-1">
Requêtes par unité de temps
</p>
</div>
{/* Coordinator parameters */}
<div className="mb-4">
<h4 className="text-xs font-semibold text-gray-700 mb-2 uppercase">
Coordinateur
</h4>
<div className="space-y-3">
<div>
<label className="block text-xs font-medium text-gray-600 mb-1">
Taux de service (μc)
</label>
<input
type="number"
step="0.01"
min="0"
value={config.coordinator_service_rate}
onChange={handleCoordinatorServiceRateChange}
disabled={isRunning}
className="block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 text-sm disabled:bg-gray-100"
/>
</div>
<div>
<label className="block text-xs font-medium text-gray-600 mb-1">
Probabilité de sortie (p)
</label>
<input
type="number"
step="0.01"
min="0"
max="1"
value={config.coordinator_exit_probability}
onChange={handleExitProbabilityChange}
disabled={isRunning}
className="block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 text-sm disabled:bg-gray-100"
/>
</div>
</div>
</div>
{/* Servers */}
<div className="mb-4">
<div className="flex items-center justify-between mb-2">
<h4 className="text-xs font-semibold text-gray-700 uppercase">
Serveurs
</h4>
<button
onClick={addServer}
disabled={isRunning}
className="text-xs text-blue-600 hover:text-blue-700 disabled:text-gray-400 font-medium"
>
+ Ajouter serveur
</button>
</div>
<div className="space-y-3">
{config.servers.map((server, index) => (
<div
key={server.id}
className="border border-gray-200 rounded-md p-3 bg-gray-50"
>
<div className="flex items-center justify-between mb-2">
<span className="text-xs font-medium text-gray-700">
Serveur {index + 1}
</span>
{config.servers.length > 1 && (
<button
onClick={() => removeServer(server.id)}
disabled={isRunning}
className="text-xs text-red-600 hover:text-red-700 disabled:text-gray-400"
>
Supprimer
</button>
)}
</div>
<div className="space-y-2">
<div>
<label className="block text-xs text-gray-600 mb-1">
Taux de service (μ{index + 1})
</label>
<input
type="number"
step="0.001"
min="0"
value={server.service_rate}
onChange={(e) =>
handleServerServiceRateChange(server.id, e.target.value)
}
disabled={isRunning}
className="block w-full px-2 py-1 border border-gray-300 rounded text-sm disabled:bg-gray-100"
/>
</div>
<div>
<label className="block text-xs text-gray-600 mb-1">
Probabilité de routage (q{index + 1})
</label>
<input
type="number"
step="0.01"
min="0"
max="1"
value={server.routing_probability}
onChange={(e) =>
handleServerRoutingProbChange(server.id, e.target.value)
}
disabled={isRunning}
className="block w-full px-2 py-1 border border-gray-300 rounded text-sm disabled:bg-gray-100"
/>
</div>
</div>
</div>
))}
</div>
</div>
{/* Probability validation */}
<div
className={`p-3 rounded-md text-xs ${
isProbabilityValid
? 'bg-green-50 border border-green-200 text-green-800'
: 'bg-red-50 border border-red-200 text-red-800'
}`}
>
<div className="flex items-center justify-between">
<span className="font-medium">
Conservation des probabilités
</span>
<span className="font-mono">
{isProbabilityValid ? '✓' : '✗'}
</span>
</div>
<div className="mt-1 font-mono">
p + Σq = {totalRoutingProb.toFixed(3)}
{isProbabilityValid ? ' = 1.0' : ' ≠ 1.0'}
</div>
</div>
</div>
</div>
);
}