/**
* Parameter panel with Material-UI - input fields for simulation configuration
*/
import {
Box,
TextField,
Typography,
Divider,
Button,
IconButton,
Paper,
Alert,
Stack,
} from '@mui/material';
import {
Add as AddIcon,
Delete as DeleteIcon,
CheckCircle as CheckCircleIcon,
Error as ErrorIcon,
} from '@mui/icons-material';
import { useSimulationStore } from '../../store/simulationStore';
export default function ParameterPanel() {
const {
config,
updateConfig,
addServer,
removeServer,
updateServer,
isRunning,
} = useSimulationStore();
if (!config) {
return (
Aucune configuration chargée
);
}
const handleArrivalRateChange = (e: React.ChangeEvent) => {
updateConfig({ arrival_rate: parseFloat(e.target.value) || 0 });
};
const handleCoordinatorServiceRateChange = (e: React.ChangeEvent) => {
updateConfig({ coordinator_service_rate: parseFloat(e.target.value) || 0 });
};
const handleExitProbabilityChange = (e: React.ChangeEvent) => {
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 (
Paramètres du réseau
{/* External arrival rate */}
{/* Coordinator parameters */}
Coordinateur
{/* Servers */}
Serveurs
}
onClick={addServer}
disabled={isRunning}
>
Ajouter
{config.servers.map((server, index) => (
Serveur {index + 1}
{config.servers.length > 1 && (
removeServer(server.id)}
disabled={isRunning}
color="error"
>
)}
handleServerServiceRateChange(server.id, e.target.value)}
disabled={isRunning}
fullWidth
size="small"
/>
handleServerRoutingProbChange(server.id, e.target.value)}
disabled={isRunning}
fullWidth
size="small"
/>
))}
{/* Probability validation */}
: }
>
Conservation des probabilités
p + Σq = {totalRoutingProb.toFixed(3)}
{isProbabilityValid ? ' = 1.0 ✓' : ' ≠ 1.0 ✗'}
);
}