Engineering Algorithm Development

Engineering algorithm development turns a stated engineering requirement into a procedure whose results you can justify. You decide what information enters, how calculations proceed, what counts as an acceptable result, and when the procedure stops. The central task is making those decisions precise enough that someone else can follow the procedure and check its behavior before implementation.

Specify what success means

A specification states the permitted inputs, required outputs, and conditions connecting them. Include units, valid ranges, assumptions, and the meaning of equality at a boundary. “Fill the tank sufficiently” is ambiguous; “return the first sampling time at which volume is at least the target without exceeding capacity” is testable.


Consider a hypothetical tank model with initial volume 0.40 m30.40\ \text{m}^3, constant net inflow 0.006 m3/s0.006\ \text{m}^3/\text{s}, and updates every 10 s10\ \text{s}. The target is 0.50 m30.50\ \text{m}^3 and capacity is 0.60 m30.60\ \text{m}^3. State whether you want the first qualifying sampling time or an estimated crossing time between samples. These are different outputs.


Specify unsuccessful outcomes too. Invalid inputs, an unsafe proposed update, and exhaustion of an update allowance convey different information. None should silently become a successful result.



Build a bounded procedure

Choose the information that must persist between steps. This information is the state. For a repeated calculation, a general update is


sk+1=F(sk,d),tk=kΔt.s_{k+1}=F(s_k,d),\qquad t_k=k\Delta t.


Here sks_k is the state after kk updates, dd contains fixed input data, and Δt\Delta t is the time represented by one update. Specify the initial state s0s_0 and initialize the counter to zero.


For the tank, the supplied model gives


Vk+1=Vk+qΔt.V_{k+1}=V_k+q\Delta t.


Each update adds (0.006)(10)=0.060 m3(0.006)(10)=0.060\ \text{m}^3. The first two updated volumes are therefore 0.46 m30.46\ \text{m}^3 and 0.52 m30.52\ \text{m}^3. The first qualifying sampling time is 20 s20\ \text{s}.


Check whether the initial state already meets the target. Before accepting a proposed update, check any safety constraint. If the proposed volume exceeds capacity, the sampled procedure cannot accept that update, even if it also passes the target. This rule concerns the specified sampled procedure; it does not establish that filling is physically impossible.


Give repeated work a finite bound, such as a maximum number of updates. A loop invariant is a statement that remains true whenever a repeated step begins. For this tank procedure, the stored volume is within capacity, and the counter equals the number of accepted updates. These statements help you check initialization and each update.


Four connected stages show specification, procedure design, testing, and revision.


Verify and refine

Trace a small case manually, recording the state, counter, and decision at each step. Then select tests that challenge the requirements rather than merely produce familiar numbers.


Test case

Behavior to verify

Initial state satisfies the target

Success with zero updates

An update reaches the target exactly

Success when the boundary is inclusive

Success occurs on the final allowed update

Success takes precedence over an exhausted allowance

Proposed update exceeds a safety bound

Unsafe state is not accepted

Allowance ends before success

An explicit limit outcome is returned



Review why the procedure works as well as testing examples. If you return the first feasible candidate, justify why the inspection order makes it the required candidate. After a revision, repeat boundary tests: changing one comparison can alter equality cases elsewhere. Improve efficiency only while preserving the specified results and failure behavior.

What to remember

  • Define valid inputs, units, success, and unsuccessful outcomes.
  • Initialize the state and counter consistently.
  • Make update order, boundary comparisons, and stopping rules explicit.
  • Combine manual traces, boundary tests, and reasoning about correctness.

Example: Developing a cooling completion procedure

A test rig estimates when a component is ready for handling. Its supplied sampled cooling model is


Tk+1=22+0.50(Tk−22),T_{k+1}=22+0.50(T_k-22),


where temperatures are expressed in degrees Celsius and each update represents 2.0 min2.0\ \text{min}. Initially, T0=86 ∘CT_0=86\ ^\circ\text{C}. The component is ready when T≤30 ∘CT\leq30\ ^\circ\text{C}. The procedure may perform at most four updates and must return the first qualifying sampling time, or LIMIT with the final temperature and elapsed time if the target remains unmet. Do not interpolate between samples.


Two consecutive temperature samples are separated by one cooling model update and two minutes.


Develop the procedure

a) Specify the state, checking order, and finite stopping rule.


Store the current temperature TT and the number of completed updates kk. Initialize T=86 ∘CT=86\ ^\circ\text{C} and k=0k=0. The elapsed time is always


t=k(2.0 min).t=k(2.0\ \text{min}).


Repeat the following decisions in order:

  1. If T≤30 ∘CT\leq30\ ^\circ\text{C}, return SUCCESS with TT and tt.
  2. Otherwise, if k=4k=4, return LIMIT with TT and tt.
  3. Otherwise, calculate the new temperature from the supplied model, store it, increase kk by one, and repeat.

Checking the target first allows success at initialization and on the fourth update. The counter increases once per update and cannot exceed four, so the maximum simulated time is


tmax⁡=4(2.0 min)=8.0 min.t_{\max}=4(2.0\ \text{min})=8.0\ \text{min}.


At each check, TT represents exactly kk completed updates. Checking the target at every sampling time in increasing order ensures that the first reported success is the earliest qualifying sample.

Trace the calculation

b) Apply the procedure and report its output.


The initial temperature exceeds 30 ∘C30\ ^\circ\text{C}, so the zero-update check does not return success. Calculate and check each successive state:


T1=22+0.50(86−22)=54 ∘C,T2=22+0.50(54−22)=38 ∘C,T3=22+0.50(38−22)=30 ∘C.\begin{aligned} T_1&=22+0.50(86-22)=54\ ^\circ\text{C},\\ T_2&=22+0.50(54-22)=38\ ^\circ\text{C},\\ T_3&=22+0.50(38-22)=30\ ^\circ\text{C}. \end{aligned}


The checks give the following results:

  • After zero updates, t=0.0 mint=0.0\ \text{min} and T=86 ∘CT=86\ ^\circ\text{C}; the target is unmet.
  • After ________ update, t=2.0 mint=2.0\ \text{min} and T=54 ∘CT=54\ ^\circ\text{C}; the target is unmet.
  • After ________ updates, t=4.0 mint=4.0\ \text{min} and T=38 ∘CT=38\ ^\circ\text{C}; the target is unmet.
  • After three updates, t=6.0 mint=6.0\ \text{min} and T=30 ∘CT=30\ ^\circ\text{C}; the target is met.

Equality satisfies the target. The procedure therefore returns SUCCESS at


t=3(2.0 min)=6.0 min,T=30 ∘C.t=3(2.0\ \text{min})=6.0\ \text{min},\qquad T=30\ ^\circ\text{C}.


It performs no fourth update because the required output is the first qualifying sampling time.

Test the boundaries

c) Keep the same model and four-update allowance. Predict the output if the target is changed to 26 ∘C26\ ^\circ\text{C}, then to 25 ∘C25\ ^\circ\text{C}. Also check an initial temperature of 29 ∘C29\ ^\circ\text{C} with the original 30 ∘C30\ ^\circ\text{C} target.


With the original initial temperature, the fourth updated temperature is


T4=22+0.50(30−22)=26 ∘C.T_4=22+0.50(30-22)=26\ ^\circ\text{C}.


For a 26 ∘C26\ ^\circ\text{C} target, the earlier samples all exceed the target, while the fourth equals it. The procedure returns SUCCESS with T=26 ∘CT=26\ ^\circ\text{C} at 4(2.0)=8.0 min4(2.0)=8.0\ \text{min}. Checking the allowance before the target would incorrectly reject this valid final-update success.


For a 25 ∘C25\ ^\circ\text{C} target, the fourth temperature remains above the target:


26 ∘C>25 ∘C.26\ ^\circ\text{C}>25\ ^\circ\text{C}.


The allowance is exhausted, so the output is LIMIT with final temperature 26 ∘C26\ ^\circ\text{C} and elapsed time 8.0 min8.0\ \text{min}. This outcome describes the permitted run; it does not claim that further cooling could never meet the target.


With initial temperature 29 ∘C29\ ^\circ\text{C} and target 30 ∘C30\ ^\circ\text{C}, the initial check succeeds because 29≤3029\leq30. The result is SUCCESS at 0.0 min0.0\ \text{min} with temperature 29 ∘C29\ ^\circ\text{C} and zero updates.

A bracket selection procedure may accept a design only when its mass is at most 2.50 kg2.50\ \text{kg} and its predicted applied stress is at most 120 MPa120\ \text{MPa}. Equality is permitted at both limits. Which acceptance rule correctly expresses these requirements?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A pump monitor receives one pressure reading at a time. Readings from 20 to 80 kPa, inclusive, are acceptable. The alarm should be on whenever the latest readings include at least three consecutive out-of-range readings.


Complete this algorithm using exact integers. The counter begins at zero and records the number of consecutive out-of-range readings ending at the latest reading.

  • If the new reading is acceptable, assign to the counter.
  • Otherwise, increase the counter by .
  • After updating the counter, turn the alarm on if the counter is at least three; otherwise, turn it off.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A ventilation controller can choose fan speeds of 600600, 900900, 12001200, or 1500 rpm1500\ \text{rpm}. A supplied model evaluates the airflow at each speed. The required output is the smallest available speed whose airflow is at least 0.080 m3/s0.080\ \text{m}^3/\text{s}, or NONE if no speed qualifies. Which procedure guarantees this output for any set of supplied model results?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

Extra Practice