Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions web-frontend/src/app/optimize-and-export/page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,14 @@ describe('OptimizeAndExportPage error handling', () => {
});

render(<OptimizeAndExportPage />);
const solverSelect = screen.getByRole('combobox', { name: /solver/i });
const solverOptions = Array.from((solverSelect as HTMLSelectElement).options);
expect(solverSelect).toHaveValue('ortools/cp-sat');
expect(solverOptions.map(option => option.text)).toContain('OR-Tools / CP-SAT (CPU)');
expect(solverOptions.map(option => option.text)).toContain('PuLP / cuOpt (GPU)');
expect(solverOptions.map(option => option.value)).not.toContain('pulp/cbc');

await user.selectOptions(solverSelect, 'pulp/cuopt');
await user.click(screen.getByRole('button', { name: /optimize and download/i }));

await expect(screen.findByText('Schedule optimized and downloaded successfully!')).resolves.toBeInTheDocument();
Expand All @@ -632,6 +640,11 @@ describe('OptimizeAndExportPage error handling', () => {
expect(screen.getByText('OPTIMAL')).toBeInTheDocument();

expect(fetch).toHaveBeenCalledWith('http://localhost:8000/optimize', expect.objectContaining({ method: 'POST' }));
const optimizePostCall = (fetch as unknown as ReturnType<typeof vi.fn>).mock.calls.find(
([url, options]) => url === 'http://localhost:8000/optimize' && options?.method === 'POST'
);
expect(optimizePostCall?.[1].body).toBeInstanceOf(FormData);
expect((optimizePostCall?.[1].body as FormData).get('solver')).toBe('pulp/cuopt');
expect(fetch).toHaveBeenCalledWith(
'http://localhost:8000/optimize/opt_test',
expect.objectContaining({ method: 'GET' })
Expand Down
17 changes: 17 additions & 0 deletions web-frontend/src/app/optimize-and-export/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ export default function OptimizeAndExportPage() {
const [apiEndpoint, setApiEndpoint] = useState(INITIAL_BACKEND_API_URL);
const [prettifyArg, setPrettifyArg] = useState(true);
const [anonymizeScheduleData, setAnonymizeScheduleData] = useState(true);
const [solverArg, setSolverArg] = useState('ortools/cp-sat');
const [timeoutArg, setTimeoutArg] = useState<number | string>(300);
const [timeoutError, setTimeoutError] = useState<string | null>(null);
const [isLoading, setIsLoading] = useState(false);
Expand Down Expand Up @@ -655,6 +656,7 @@ export default function OptimizeAndExportPage() {
}

formData.append('timeout', String(timeoutArg));
formData.append('solver', solverArg);

const createResponse = await fetch(`${normalizeEndpoint(apiEndpoint)}/optimize`, {
method: 'POST',
Expand Down Expand Up @@ -881,6 +883,21 @@ export default function OptimizeAndExportPage() {
</span>
</label>

<div>
<label htmlFor="solver-select" className="block text-sm font-medium text-gray-700 mb-2">
Solver
</label>
<select
id="solver-select"
value={solverArg}
onChange={(e) => setSolverArg(e.target.value)}
className="block w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 shadow-sm transition-colors focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200"
>
<option value="ortools/cp-sat">OR-Tools / CP-SAT (CPU)</option>
<option value="pulp/cuopt">PuLP / cuOpt (GPU)</option>
</select>
</div>

<div>
<label className="block text-sm font-medium text-gray-700 mb-2">
Solver Timeout
Expand Down
Loading