import { useId, useState } from "react"; import { Dices, Info, RotateCcw } from "lucide-react"; import { AllSettings, Dialog, Dropdown, IconButton, InputField, ParamControls, type ParamValue } from "@elvis/ui"; import { ALGORITHMS, algorithmById } from "./algorithms"; import type { RunEditor } from "./useOptimisation"; const helpClass = "text-sm text-ink-muted"; interface OptimiserControlsProps { editor: RunEditor; twoVariables: boolean; onResetStart: () => void; onRandomStart: () => void; // Extra help under the start point, e.g. that the plot can be clicked hint?: string; } // An optimiser's algorithm, settings and start point; used for the main run // (Configure) and for setting up a comparison (Compare) export default function OptimiserControls({ editor, twoVariables, onResetStart, onRandomStart, hint }: OptimiserControlsProps) { const active = algorithmById(editor.algorithm); const [infoOpen, setInfoOpen] = useState(false); const id = useId(); const hasSettings = active.params.length > 0; const changed = Object.keys(editor.params).length > 0; function setOne(name: string, value: ParamValue) { editor.changeParams({ ...editor.params, [name]: value }); } function resetOne(name: string) { editor.changeParams(Object.fromEntries(Object.entries(editor.params).filter(([key]) => key !== name))); } return ( <> {/* The algorithm, with its settings' details and a reset beside it */}
The initial point must be numbers.
} {hint &&{hint}
}