J'implémente un algorithme de Local search avec time limit. J'aimerai fixer le time limit correctement. A terme, mon algorithme devra tourner 10 minutes sur un téléphone mobile, mais pour l'instant je le teste sur une unité centrale. De quelles informations ai-je besoin pour fixer ce time limit ? Quel time limit devrai-je fixer ? Cherche quelles sont les pratiques courantes et recommandées dans l'industrie et dans la recherche académique.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
🔍 What Information Do You Need to Set a Time Limit?
Before picking a wall-clock timeout, you need to understand how your algorithm progresses per unit of time. The most useful metrics are:
Metric
Why It Matters
Iterations / Evaluations per second (on your desktop CPU)
Tells you how much "work" the algorithm does in a given time. This is the primary bridge between time and solution quality.
Cost per iteration (neighbor generation + evaluation)
If this varies wildly (e.g., large graph, expensive heuristic), time alone is a poor proxy for progress.
Problem size / instance characteristics (number of variables, constraints, density)
Larger instances = fewer iterations per second, different quality curves.
Quality vs. time curve (empirical)
Does the algorithm converge fast then plateau? Diminishing returns? You need to know if 1 min gives 90% of max quality or if it keeps climbing.
Stochastic vs. deterministic
Randomized restarts or tabu lists change how time maps to diverse solutions found.
Mobile hardware profile (CPU model, clock speed, thermal limits, GC overhead if managed language)
Mobile CPUs are typically 2–5× slower single-core, and managed runtimes add GC pauses.
Practical minimum: Benchmark your algorithm on a representative instance and record iterations_per_second (or solutions_per_second). That number is your conversion factor.
🧮 How to Determine a Starting Time Limit
Warm-up benchmark
Run your local search on 3–5 representative instances for 60 seconds. Record:
Total iterations completed
Best objective value found
Standard deviation over runs (if stochastic)
Plot the quality curve
If you have time, run multiple 10s / 30s / 60s slices and plot best_value vs. log(time). This reveals:
Linear/logarithmic improvement
Plateau point (after which more time gives negligible gain)
Variance across runs
Choose a time limit based on your goal
If you want a "good enough" solution quickly: Pick a time just before the curve plateaus (e.g., where Δvalue < 1% per 10s).
If you need the best possible within a budget: Pick the full budget, but enable early stopping if no improvement for N iterations (see adaptive strategy below).
If you’re comparing algorithms: Use a fixed time (e.g., 30s, 2min) or a fixed evaluation budget (e.g., 1M neighbor evaluations) to make results comparable regardless of hardware speed.
Map to mobile
After the desktop benchmark, run the same instance on the target phone (or an emulator/benchmark suite). Measure iterations_per_second there.
If desktop: 500 it/s, phone: 120 it/s → phone is ~4× slower.
To get "10 minutes on phone" ≈ 600s → equivalent to ~300s on desktop (if you just scale time linearly).
Better: Fix an evaluation budget (e.g., "stop after 500k evaluations") rather than a wall-clock time, then measure what wall-clock time that budget takes on each device.
🏭 Industry Best Practices
Practice
Description
SLA / User-experience driven
Time limits are set by the maximum latency a user or system will accept (e.g., "route re-optimization must complete in ≤ 200ms"). The algorithm is given that hard cap.
Adaptive timeouts
Stop when either: (a) wall-clock time > limit, OR (b) no improvement for k iterations (e.g., 100–500 consecutive non-improving steps). This prevents wasting time on plateauing searches.
Budget-based scheduling
Instead of time ≤ T, use evaluations ≤ E. This makes the algorithm portable across CPUs/GPUs/mobile without re-tuning the timeout.
Warm-start + time budget
In production, you often start from a heuristic solution and only run local search for the remaining time. The timeout is often deadline - now - heuristic_time.
Battery / thermal awareness (mobile)
Some frameworks dynamically reduce the time limit or switch to a lighter heuristic when battery < 20% or device temperature is high.
Common industry pattern: timeout = min(fixed_budget, no_improvement_patience). The fixed budget is often derived from performance testing on the target device class, not guessed.
🎓 Academic Best Practices
Practice
Description
Fixed time limits per instance class
E.g., "30 seconds for instances ≤ 50 nodes, 2 minutes for ≤ 500, 10 minutes for ≥ 500". This normalizes comparisons across papers.
Proven optimality gap
Stop when the best-known upper bound / lower bound gap falls below a threshold (e.g., < 1% or < 0.1%). Time is just a safety cap.
Statistical repetition
Run 25–30 times with different seeds, report average/median quality at fixed time intervals (e.g., every 10s). Time limits are often "until convergence or 5 min, whichever first".
Strict wall-clock limits (e.g., 3600s = 1 hour) with per-instance time budgets. Runtimes exceeding the limit are scored as "timed out" with best solution found so far.
Time vs. quality trade-off analysis
Many papers plot "average best value vs. running time" across multiple instances to show the algorithm’s curve, rather than picking a single timeout.
Academic norm: report results at multiple time slices (e.g., every 30s up to 5min) or use a proven gap as the primary stopping criterion, with time as a hard cap.
📦 Recommended Workflow for Your Case
Benchmark on desktop
Find iters_per_sec on a few instances.
Plot best_value vs. iterations (not just time) to see if you’re hitting diminishing returns.
Set an evaluation budget (recommended)
e.g., "Run until 500k neighbor evaluations or 2 min wall-clock, whichever comes first."
This budget becomes your portable "time limit" – you’ll measure its actual wall-clock on both desktop and phone.
Test on phone
Run the same budget. If it takes 8 minutes on phone, you’re close to your 10-min goal.
If it takes 1 minute, increase the evaluation budget by ~12×.
If it takes 15 minutes, decrease it or add an early-stopping patience rule.
Add adaptive early stopping (optional but very useful)
python
def local_search(time_limit_sec, no_improve_patience=150):
start = time.time()
best = initial_solution()
no_improve = 0
while time.time() - start < time_limit_sec:
candidate = neighbor(best)
if evaluate(candidate) < evaluate(best):
best = candidate
no_improve = 0
else:
no_improve += 1
if no_improve >= no_improve_patience:
break # plateau detected
return best
On desktop: tune no_improve_patience by watching the quality curve.
On mobile: the same patience value will naturally correspond to a different wall-clock time, but the quality guarantee stays consistent.
Finalize the timeout
If you must use a pure wall-clock limit:
Desktop: run 2–5 min benchmarks, pick the time where quality plateaus.
Mobile: multiply the desktop time by the measured speed ratio (desktop_it/s ÷ phone_it/s).
If you can use an evaluation budget: set it once, and it will “just work” across devices with predictable quality.
🧩 Summary
You need: iterations/sec (or evaluations/sec) on a representative instance, plus a quality-vs-time/iterations curve.
Start with: a fixed evaluation budget or a time limit just before the quality plateau (typically 30 sec – 2 min on desktop for many combinatorial local searches).
Map to mobile: benchmark the same budget on phone, then scale the budget or apply a speed-ratio factor to hit your 10‑minute target.
Industry: often uses SLA-driven hard caps + early-stopping on stagnation; budgets (evaluations) are preferred over wall-clock for portability.
Academia: fixed per-instance time limits, proven gap thresholds, or statistical reporting at multiple time slices.
Practical tip: Don't try to "guess" the 10-minute mobile limit from desktop alone. Measure iterations per second on both, fix an evaluation budget that gives good quality on desktop, then verify its wall-clock on phone. Adjust the budget until the phone runtime sits near 10 minutes. This gives you a portable, reproducible, and quality-aware time limit.