Tutorials › Optimal Design and Model-Informed Dosing › Comparing Computational Cost Across Designs

Simulation Studies of Designs · Tutorial 448 of 497

Comparing Computational Cost Across Designs

Learn to measure computational cost fairly across candidate designs, account for failed fits, and interpret runtime summaries alongside statistical performance.

Intermediate 11 min read

What You'll Learn

  • Define runtime and computational failure measures for each candidate design.
  • Distinguish total CPU time, elapsed wall-clock time, and time per attempted fit.
  • Calculate failure rates and computational cost per successful fit.
  • Choose runtime summaries that reveal skew and unusually slow fits.
  • Compare computational burden alongside statistical performance without conflating the two.
  • Recognize how timeouts, retries, and parallel execution can distort comparisons.

Why Computational Cost Belongs in a Design Comparison

A candidate sampling plan may perform well statistically but require substantially more computation to fit, or may fail more often under the analysis pipeline. Those costs matter when a simulation study compares plans: they affect how many replicates can be completed, how much computing capacity is needed, and whether the resulting performance summaries are based on many or few successful fits. A fair comparison therefore reports computational burden alongside, not in place of, statistical performance.

The comparison is meaningful only if the computational task is defined consistently. Candidate designs should be evaluated using the same fitting procedure, comparable hardware and software settings, and the same rules for recording run times and failures. If one design is fitted with different tolerances, different initial estimates, or a different timeout, the recorded cost may reflect those changes rather than the design itself.

Definition: For design \(d\), a fitting attempt is one execution of the specified analysis pipeline for one simulated replicate. Its runtime is the time measured for that attempt. A computational failure is an attempt that does not produce a usable fit under the prespecified success criteria, such as a non-converged fit or a timeout. A failure is an outcome to count, not a replicate to erase.

The success criteria need to be stated before comparing designs. For example, a usable fit might require successful convergence, finite estimates, and an estimated covariance matrix that meets specified checks. The criteria should be applied in the same way to every design. A failed fit may still consume substantial time, so runtime and failure status must be recorded together. If the analysis pipeline includes simulation, data processing, and fitting, decide whether the reported runtime covers fitting alone or the full pipeline, and use that definition consistently.

Measures of Computational Burden

Suppose \(R\) fitting attempts are planned for a design. Let \(T_r\) be the runtime of attempt \(r\), and let \(F_r=1\) if that attempt fails and \(F_r=0\) otherwise. The observed failure rate is the number of failed attempts divided by the number planned. The mean runtime per attempted fit includes both successful and failed attempts.

$$ \widehat{p}_{\mathrm{fail}}=\frac{\sum_{r=1}^{R}F_r}{R}, \qquad \overline{T}_{\mathrm{attempt}}=\frac{\sum_{r=1}^{R}T_r}{R}. $$

The total runtime across attempts describes the computational work recorded for that run. It is not the same as time per fit. Nor is it necessarily the elapsed time experienced by the analyst: when attempts run in parallel, the sum of their CPU times can exceed wall-clock time. CPU time measures processor work; wall-clock time measures elapsed duration. State which one is reported. For capacity planning on a shared computing system, both can be useful.

A useful complementary measure is the observed cost per successful fit: total recorded runtime divided by the number of successful fits. This incorporates time spent on failures. If there are no successful fits, this measure is undefined; report that result rather than assigning it an arbitrary value. A design's failure rate should still be shown separately, because a single cost-per-success number can conceal whether its burden comes from slow attempts or frequent failures.

Key takeaway: Report at least the planned attempt count, number of failures, failure rate, and a runtime summary. When failures occur, also consider total runtime per successful fit. Keep statistical performance measures separate and interpret them beside these computational measures.

Worked Comparisons

Worked Example: Cost per Successful Fit

Suppose two hypothetical designs are each evaluated with 100 fitting attempts. Design A uses 260 CPU minutes in total and has 10 failed fits. Design B uses 330 CPU minutes and has 2 failed fits. Assume every attempted fit has a recorded runtime, including failed fits, and the success criteria are identical.

For A, the observed failure rate is \(10/100=0.10\), or 10%. There are \(100-10=90\) successful fits, so total CPU time per successful fit is \(260/90=2.889\) CPU minutes.

For B, the observed failure rate is \(2/100=0.02\), or 2%. There are \(100-2=98\) successful fits, so total CPU time per successful fit is \(330/98=3.367\) CPU minutes.

A's mean CPU time per attempted fit is \(260/100=2.60\) minutes, compared with \(330/100=3.30\) minutes for B. A is less costly per successful fit in these observed runs, while B has a lower failure rate. Neither conclusion establishes which design is statistically preferable: the statistical performance measures must also be examined. The calculation does show why reporting only successful-fit runtime would understate A's computational burden.

Worked Example: Why a Mean Alone Can Mislead

Consider two hypothetical sets of eight successful fits, with times in minutes. Design X takes \(1, 1, 1, 1, 1, 1, 1,\) and \(13\) minutes. Design Y takes \(2.2\) minutes for each fit. Assume the times cover the same pipeline on comparable hardware, and neither set includes a failure.

For X, total time is \(7(1)+13=20\) minutes, so its mean is \(20/8=2.50\) minutes. Its median is 1 minute because the fourth and fifth ordered observations are both 1. For Y, the mean and median are both 2.20 minutes.

By the mean, Y is faster on average. By the median, X is faster for a typical attempt, but its 13-minute fit indicates a long-runtime case that may matter for scheduling. These summaries answer different questions. A runtime report should not select whichever summary makes a design look best: report a measure of centre and, when runtimes vary substantially, a measure that exposes the spread or upper tail. With only eight attempts, the maximum is informative as a description of these runs, not a dependable estimate of the worst runtime the design could produce.

Accounting for Repeated Attempts

If a failed fit is rerun until it succeeds, the computational burden depends on both runtime and success probability. Consider repeated, independent attempts under the same conditions, each with a constant success probability \(s\), where \(s>0\). Let \(N\) be the number of attempts up to and including the first success. The probability that at least \(k\) attempts are needed is the probability that the first \(k-1\) attempts all fail:

$$ P(N\geq k)=(1-s)^{k-1}. $$

For a positive integer-valued random variable, its expectation is the sum of its tail probabilities. Therefore,

$$ E[N]=\sum_{k=1}^{\infty}P(N\geq k) =\sum_{k=1}^{\infty}(1-s)^{k-1} =\frac{1}{s}. $$

If attempt runtimes are identically distributed with mean \(E[T]\), and each new attempt is independent of previous attempts, the expected total time through the first success is \(E[T]/s\). To see this, attempt \(k\) is run only if the first \(k-1\) attempts failed; that event is independent of the runtime of attempt \(k\). Thus expected total time is \(\sum_{k=1}^{\infty}(1-s)^{k-1}E[T]=E[T]/s\). This calculation assumes the same success probability and runtime distribution for each attempt. It is a planning approximation, not a reason to discard observed failures or to assume that retries are free.

Worked Example: Expected Time to Obtain a Successful Fit

Suppose a hypothetical fitting procedure has an estimated success probability of \(0.96\) per attempt and a mean runtime of 4.0 CPU minutes per attempt, counting both failures and successes. Assume repeated attempts are independent and have the same success probability and runtime distribution.

The expected number of attempts to obtain one success is \(1/0.96=1.0417\). The expected total CPU time is \(4.0/0.96=4.167\) minutes per successful fit. Equivalently, for 100 desired successful fits, this approximation gives \(100(4.167)=416.7\) CPU minutes.

This is an expectation, not a guarantee that 100 successes will take exactly 416.7 minutes. It also relies on the stated repeatability assumptions. If failures are caused by a persistent data or model problem, attempts may not be independent or have a stable success probability. In that setting, diagnose the cause rather than treating repeated reruns as an adequate cost model.

Putting Computational and Statistical Performance Together

Computational measures complement the statistical estimands established for a simulation question; they do not replace them. For example, a design may have an attractive interval width among successful fits but a substantial failure rate. Reporting interval performance only for successful fits describes that subset, while the failure rate describes how often the analysis did not produce the required result. Present both so readers can judge the scope of the statistical summaries.

Worked Example: Applying a Computational Budget

Suppose two hypothetical designs are assessed using 1,000 planned attempts. Design C has a failure rate of 2%, a mean runtime of 3.0 CPU minutes per attempt, and interval coverage of 94% among successful fits. Design D has a failure rate of 1%, a mean runtime of 5.5 CPU minutes per attempt, and coverage of 95% among successful fits. Assume the runtimes include failed attempts and the coverage calculations use the same prespecified definition for both designs.

For C, the expected success proportion based on the observed failure rate is \(1-0.02=0.98\). Its estimated computational cost per successful fit is \(3.0/0.98=3.061\) CPU minutes. For D, the corresponding calculation is \(5.5/(1-0.01)=5.556\) CPU minutes. To obtain 1,000 successful fits, the approximate CPU requirements are \(1{,}000(3.061)=3{,}061\) minutes, or \(51.0\) hours, for C and \(1{,}000(5.556)=5{,}556\) minutes, or \(92.6\) hours, for D.

D has one percentage point higher observed coverage and a lower observed failure rate, but its estimated cost per successful fit is higher. Whether that difference is acceptable depends on the statistical objectives and available computing budget. The calculation does not turn the two designs into a single ranking; it makes the cost of each option explicit for the design decision.

Diagnostics, Comparisons, and Limitations

Before interpreting a cost comparison, check for conditions that can make it misleading. Confirm that runtime units and timing boundaries match; record whether attempts were run serially or in parallel; and verify that failures and timeouts have not disappeared from the runtime data. A timeout is a failed attempt under the stated criteria. Its recorded duration is the time consumed before termination, not necessarily the time the fit would have taken to finish. If timeouts are used, state the limit and report how many occurred.

Inspect the distribution of runtimes rather than relying on a mean alone. A few unusually long fits can dominate total CPU time, while a median can hide the resource burden of those fits. Compare the number of completed attempts with the planned count, and verify that success and failure classifications use the same checks across designs. If one design has no successful fits, do not compare its statistical performance as though it were simply missing at random; report the failure burden plainly.

The main alternatives answer different operational questions. Mean time per attempt is useful for estimating average work, including failed attempts. Median runtime describes a typical attempt and is less affected by a few long runs. Total CPU time describes aggregate processor demand for the run. Wall-clock time describes elapsed duration under the particular scheduling and parallelization arrangement. Cost per successful fit combines runtime and success proportion, but can obscure whether cost is driven by slow fits or failures. A concise comparison table can show several of these measures together.

MeasureQuestion it helps answerImportant qualification
Mean runtime per attemptHow much time does an attempted fit use on average?Include failed attempts and state the timing boundary.
Median runtimeHow long does a typical attempt take?Does not describe the full runtime burden.
Total CPU timeHow much processor work did the run consume?Can exceed elapsed wall-clock time under parallel execution.
Failure rateHow often did an attempt fail the prespecified criteria?Report the numerator and planned attempt count.
Time per successful fitHow much recorded runtime was spent per usable fit?Undefined if there were no successful fits; report failures separately.

A common mistake is to calculate average runtime only among successful fits and conclude that the design is computationally efficient. That excludes the time consumed by failed attempts and may make a design with frequent costly failures appear artificially fast. The correction is to report runtime across all attempts, the failure rate, and, where useful, total runtime per successful fit. Another mistake is to compare elapsed times from runs with different numbers of parallel workers as though they measured the same resource use. Report CPU time and wall-clock time with their execution conditions rather than treating them as interchangeable.

No single computational measure is universally sufficient. Runtime depends on hardware, software, workload, tolerances, and implementation; failure rates can be uncertain when the number of attempts is modest. These measures describe the tested simulation and computing setup, not an invariant property of a sampling design. Their value is in making resource demands and analysis reliability visible under clearly stated conditions.

Check Your Understanding

Work through these questions, then check the solutions below.

  1. A design has 120 attempts, of which 12 fail, and total runtime of 360 CPU minutes. Find the failure rate, mean runtime per attempt, and observed CPU time per successful fit.
  2. Why can a median runtime be smaller than the mean, and what does that imply about reporting runtime?
  3. Under independent repeated attempts with success probability \(0.80\) and mean runtime 5 minutes per attempt, calculate the expected number of attempts and expected time to one success.
  4. Explain why CPU time and wall-clock time can differ in a parallel simulation.

Solutions. (1) The failure rate is \(12/120=0.10\), or 10%. Mean runtime is \(360/120=3.00\) CPU minutes per attempt. There are \(120-12=108\) successes, so observed time per successful fit is \(360/108=3.333\) CPU minutes. (2) A small number of long runtimes can pull the mean above the median. Report a measure of centre and enough information about spread or long runs to avoid hiding that tail. (3) The expected number of attempts is \(1/0.80=1.25\); expected time is \(5/0.80=6.25\) minutes, under the stated repeatability assumptions. (4) CPU time sums processor work across workers, whereas wall-clock time measures elapsed duration; parallel workers can accumulate CPU time simultaneously, making the total CPU time greater than elapsed time.

Clinical Biostats