Exercise set

Mathematical Modeling and Optimization Exercises

Solved modeling and optimization exercises for scaling, residuals, calibration, constraints, KKT checks, Pareto tradeoffs and validation gates.

These exercises practise mathematical modeling and optimization as engineering decision tools. The purpose is not only to solve equations. The purpose is to define variables clearly, scale quantities with different units, check feasibility, interpret multipliers and residuals, compare tradeoffs, and decide whether a model result is strong enough to support an engineering action.

Assume simplified screening models unless an exercise states otherwise. Real modeling work should also check units, boundary conditions, input data quality, solver settings, validation data, uncertainty, domain of applicability, and decision consequences.

How to Use These Exercises

For each exercise, identify:

  1. the model boundary and decision variable;
  2. the objective, constraint, residual or validation metric being used;
  3. the units and scaling of each quantity;
  4. the calculation result and its engineering meaning;
  5. the evidence needed before using the result for release, design or operation.

The common mistake is treating a mathematical optimum as an engineering answer. An optimum outside the validated model domain, too close to a constraint, or dominated by an arbitrary scaling choice is not a defensible decision.

Release Evidence Notes

Model-based recommendations should state the engineering decision, variables, objective, constraints, units, scaling, data source, solver configuration, validation metric and applicability domain. An optimum is release evidence only when the model assumptions, data quality and decision consequences are visible.

Optimization evidence should include feasibility, active constraints, constraint margins, sensitivity to weights or penalties, robustness to uncertain inputs, solver convergence and a check that the selected point is physically meaningful. A mathematically optimal point can still be rejected when it is brittle, unverifiable or outside the modeled operating envelope.

Engineering Boundary Notes

These exercises use simplified models and optimization screens. They do not replace domain physics, full numerical verification, uncertainty quantification, experimental validation, operations review or safety approval. Convexity, KKT checks and residual metrics are useful only when the mathematical formulation represents the real engineering decision.

Common Release Mistakes

  • optimizing a scaled objective without explaining the scaling choice;
  • accepting a feasible point with no validation against observed behavior;
  • ignoring active constraints, margin and sensitivity to uncertain inputs;
  • treating a local optimum as a global or operationally robust answer;
  • using penalty weights to hide a violated engineering requirement;
  • publishing a model recommendation without stating its domain of applicability.

Scenario Map

ScenarioExercisesPrimary checkEngineering decision
Model setup and validation1, 2, 3, 4, 15Scaling, residuals, calibration, bias and RMSEDecide whether the model is numerically and physically credible.
Solver and local optimization5, 6, 7, 8, 9, 10Gradient descent, Newton update, feasibility, corners and KKT checksIdentify the candidate solution and whether it satisfies constraints.
Tradeoffs, sensitivity and robustness11, 12, 13, 14, 16, 17Pareto selection, weighted objectives, local sensitivity, uncertainty and penalty behaviorDecide whether the optimum is robust enough to defend.
Release gate18Constraint margin, validation error and uncertaintyAccept, reject or hold a model-based recommendation.

Validation Package Checklist

  • engineering decision, variables and units are defined;
  • objective, constraints and scaling are justified;
  • data source, model assumptions and validity domain are documented;
  • solver settings, convergence and feasibility are checked;
  • active constraints, sensitivities and robustness are reviewed;
  • validation residuals or independent evidence support the model claim;
  • final decision states accept, reject, hold, collect data or reformulate.

Exercise 1: Scale Variables with Different Units

A design model uses plate thickness t and pump flow q. The reference values are t_{ref}=8\ \text{mm} and q_{ref}=120\ \text{L/min}. The candidate has t=10\ \text{mm} and q=96\ \text{L/min}. Use the scaled variables:

\displaystyle \tilde{t}=\frac{t-t_{ref}}{t_{ref}}

and:

\displaystyle \tilde{q}=\frac{q-q_{ref}}{q_{ref}}

Solution

For thickness:

\displaystyle \tilde{t}=\frac{10-8}{8}=0.25

For flow:

\displaystyle \tilde{q}=\frac{96-120}{120}=-0.20

The candidate is 25\% above the reference thickness and 20\% below the reference flow.

Engineering Comment

Scaling prevents the optimizer from treating millimeters and liters per minute as directly comparable numbers. The scaled values also make the design change readable: one variable increased and the other decreased relative to the baseline.

Plausibility Check

A 2\ \text{mm} increase from 8\ \text{mm} is one quarter of the reference. A 24\ \text{L/min} drop from 120\ \text{L/min} is one fifth of the reference, so the signs and magnitudes are plausible.

Exercise 2: Residual Norm Against a Model Gate

A calibration model has four normalized residuals:

\tilde{r}=[0.08,\ -0.04,\ 0.06,\ -0.02]

The validation gate requires:

\|\tilde{r}\|_2 \le 0.12

Check the gate.

Solution

Compute the residual norm:

\|\tilde{r}\|_2=\sqrt{0.08^2+(-0.04)^2+0.06^2+(-0.02)^2}
\|\tilde{r}\|_2=\sqrt{0.0064+0.0016+0.0036+0.0004}
\|\tilde{r}\|_2=\sqrt{0.012}=0.1095

Since:

0.1095 \le 0.12

the residual gate passes.

Engineering Comment

Passing a residual norm means the equations and data fit this metric. It does not prove the model is valid for extrapolation, rare operating points or different boundary conditions.

Plausibility Check

Each residual is below 0.10, so a combined norm slightly above 0.10 is credible for four terms.

Exercise 3: Linear Calibration of a Sensor Model

A simplified sensor model is:

y=ax

Two calibration points are (x_1,y_1)=(20,50) and (x_2,y_2)=(80,194). Estimate a by least squares through the origin:

\displaystyle a=\frac{\sum x_i y_i}{\sum x_i^2}

Then predict y at x=60.

Solution

Compute the numerator:

\displaystyle \sum x_i y_i=20 \times 50 + 80 \times 194=1000+15520=16520

Compute the denominator:

\displaystyle \sum x_i^2=20^2+80^2=400+6400=6800

Therefore:

\displaystyle a=\frac{16520}{6800}=2.429

Prediction at x=60:

\hat{y}=2.429 \times 60=145.7

Engineering Comment

The model assumes zero output at zero input and a constant slope. If the sensor has offset, saturation or temperature drift, this one-parameter model may fit the two points while still being physically incomplete.

Plausibility Check

The raw ratios are 50/20=2.5 and 194/80=2.425. The least-squares slope near 2.43 is therefore reasonable.

Exercise 4: Compare Model Error Metrics

A model predicts three validation values:

PointMeasuredPredicted
110096
2150156
3130127

Calculate the mean error and RMSE, where error is predicted minus measured.

Solution

Errors:

e=[-4,\ 6,\ -3]

Mean error:

\displaystyle \bar{e}=\frac{-4+6-3}{3}=-0.333

RMSE:

\displaystyle RMSE=\sqrt{\frac{(-4)^2+6^2+(-3)^2}{3}}
\displaystyle RMSE=\sqrt{\frac{16+36+9}{3}}=\sqrt{20.33}=4.51

Engineering Comment

The mean error is close to zero, but the RMSE shows typical error magnitude around 4.5 units. A near-zero bias does not mean individual predictions are accurate enough for release.

Plausibility Check

The errors are all single-digit values. An RMSE of about 4.5 is consistent with error magnitudes of 3, 4 and 6.

Exercise 5: One Gradient Descent Step

Minimize:

f(x)=(x-6)^2

starting from x_0=2 with step size \alpha=0.25. Use:

x_{k+1}=x_k-\alpha f'(x_k)

Solution

The derivative is:

f'(x)=2(x-6)

At x_0=2:

f'(2)=2(2-6)=-8

Update:

x_1=2-0.25(-8)=4

Engineering Comment

The step moves toward the optimum x=6 but does not reach it. Step size matters: too small is slow, too large can overshoot or diverge, especially in poorly scaled multi-variable problems.

Plausibility Check

The starting point is below 6, so the update should increase x. The computed value 4 moves in the correct direction.

Exercise 6: Newton Update for a Nonlinear Equation

Solve one Newton iteration for:

g(x)=x^2-10=0

from x_0=3. Use:

\displaystyle x_{k+1}=x_k-\frac{g(x_k)}{g'(x_k)}

Solution

At x_0=3:

g(3)=9-10=-1

and:

g'(x)=2x

so:

g'(3)=6

Newton update:

\displaystyle x_1=3-\frac{-1}{6}=3.1667

Engineering Comment

The update moves toward \sqrt{10}\approx 3.1623. Newton’s method can converge rapidly near a well-behaved root, but it can fail when derivatives are small, discontinuities are present, or the starting point is outside the valid model region.

Plausibility Check

Because 3^2=9 is below 10, the root should be slightly above 3. The update to 3.1667 is plausible.

Exercise 7: Feasibility of a Candidate Design

A candidate design has decision variables x=4 and y=7. It must satisfy:

x+y \le 12
2x+y \le 16
x \ge 0,\quad y \ge 0

Check feasibility.

Solution

First constraint:

x+y=4+7=11 \le 12

Second constraint:

2x+y=2(4)+7=15 \le 16

Nonnegativity:

4\ge 0,\quad 7\ge 0

The candidate is feasible.

Engineering Comment

Feasible does not mean optimal. It only means the design satisfies the stated constraints. The objective, uncertainty and validation limits still need to be checked.

Plausibility Check

Both constraint left-hand sides are one unit below their limits, so the design has a small but positive deterministic margin.

Exercise 8: Linear Programming by Corner Evaluation

Maximize:

z=5x+4y

subject to:

x+y \le 10
2x+y \le 14
x\ge 0,\quad y\ge 0

Evaluate the feasible corner points (0,0), (0,10), (7,0) and the intersection of the two active constraints.

Solution

Find the intersection:

x+y=10
2x+y=14

Subtract the first equation from the second:

x=4

Then:

y=6

Evaluate the objective:

Pointz=5x+4y
(0,0)0
(0,10)40
(7,0)35
(4,6)44

The best listed corner is:

(x,y)=(4,6)

with:

z=44

Engineering Comment

For a linear objective over a polygonal feasible region, an optimum occurs at a corner if a bounded optimum exists. The engineering review still needs to check whether the linear model and constraints are valid near the selected corner.

Plausibility Check

The optimum uses both resources fully:

4+6=10,\quad 2(4)+6=14

so it is plausible that this point is efficient.

Exercise 9: KKT Check for an Active Upper Bound

Minimize:

f(x)=(x-8)^2

subject to:

x \le 5

Use the constraint form g(x)=x-5 \le 0. Check whether x^\*=5 satisfies stationarity with a nonnegative multiplier:

f'(x^\*)+\lambda g'(x^\*)=0

Solution

Derivatives:

f'(x)=2(x-8)

and:

g'(x)=1

At x^\*=5:

f'(5)=2(5-8)=-6

Stationarity gives:

-6+\lambda=0

so:

\lambda=6

Because:

\lambda \ge 0

and the constraint is active, x^\*=5 satisfies the KKT sign check.

Engineering Comment

The unconstrained optimum would be x=8, but the constraint blocks it. The positive multiplier shows that the upper bound is valuable: relaxing it would improve the objective locally.

Plausibility Check

Since 5 is the largest feasible value and the objective wants x close to 8, the constrained optimum should sit at x=5.

Exercise 10: Lagrange Multiplier for a Balanced Allocation

Minimize:

f(x,y)=x^2+y^2

subject to:

x+y=10

Find the optimal allocation.

Solution

Use:

L=x^2+y^2+\lambda(x+y-10)

Stationarity:

\displaystyle \frac{\partial L}{\partial x}=2x+\lambda=0
\displaystyle \frac{\partial L}{\partial y}=2y+\lambda=0

Therefore:

2x=2y

so:

x=y

With x+y=10:

x=y=5

Engineering Comment

When two quadratic penalties have equal weights, the least-penalty allocation is balanced. If one variable had a different cost or risk weight, the optimum would shift toward the less expensive variable.

Plausibility Check

For a fixed sum, splitting evenly minimizes the sum of squares. Values like (0,10) give 100, while (5,5) gives 50.

Exercise 11: Pareto Dominance Check

Three feasible designs have mass and energy use:

DesignMassEnergy
A1280
B1095
C1378

Lower is better for both metrics. Identify whether any design is dominated.

Solution

Design A compared with B:

  • B has lower mass: 10<12.
  • A has lower energy: 80<95.

Neither dominates the other.

Design A compared with C:

  • A has lower mass: 12<13.
  • C has lower energy: 78<80.

Neither dominates the other.

Design B compared with C:

  • B has lower mass: 10<13.
  • C has lower energy: 78<95.

Neither dominates the other.

No design is dominated.

Engineering Comment

All three designs lie on the Pareto set for these two metrics. The decision needs a preference, constraint threshold or additional evidence such as reliability, manufacturability, cost or uncertainty.

Plausibility Check

Each design is best in at least one direction or trades one metric for the other, so no design is obviously inferior on both metrics.

Exercise 12: Weighted Objective with Normalized Terms

A candidate design has normalized cost penalty 0.30 and normalized risk penalty 0.12. The weighted objective is:

J=0.4J_{cost}+0.6J_{risk}

Calculate J. Compare it with another candidate with J=0.21.

Solution

Compute:

J=0.4(0.30)+0.6(0.12)
J=0.12+0.072=0.192

Since:

0.192<0.21

the candidate is better under this weighted objective.

Engineering Comment

The ranking depends on normalized terms and weights. A design review should check whether 0.4 and 0.6 represent explicit stakeholder priorities, safety requirements or arbitrary tuning.

Plausibility Check

The result lies between 0.12 and 0.30, closer to 0.12 because the risk term has higher weight.

Exercise 13: Local Sensitivity by Finite Difference

A model output changes from y=240 to y=252 when parameter p increases from 40 to 44. Estimate the local sensitivity:

\displaystyle S=\frac{\Delta y}{\Delta p}

Then estimate the output change for a +1.5 change in p.

Solution

Sensitivity:

\displaystyle S=\frac{252-240}{44-40}=\frac{12}{4}=3

Estimated output change:

\Delta y \approx 3 \times 1.5=4.5

Engineering Comment

Local sensitivity is useful near the tested point. It may not hold if the model is nonlinear, switches regimes, violates a constraint or moves outside the calibrated parameter range.

Plausibility Check

A 4 unit parameter change caused a 12 unit output change, so a 1.5 unit change causing about 4.5 units is consistent.

Exercise 14: Robust Constraint Margin

A design predicts peak stress:

\sigma=168\ \text{MPa}

The allowable stress is:

\sigma_{allow}=185\ \text{MPa}

Model uncertainty is estimated as \pm 9\ \text{MPa}. Check the guarded margin:

M=\sigma_{allow}-(\sigma+9)

Solution

Worst credible stress:

\sigma_{guarded}=168+9=177\ \text{MPa}

Guarded margin:

M=185-177=8\ \text{MPa}

The guarded constraint passes with 8\ \text{MPa} margin.

Engineering Comment

The nominal margin is 17\ \text{MPa}, but the uncertainty-aware margin is only 8\ \text{MPa}. If manufacturing variation, load uncertainty or model-form error is not included in the 9\ \text{MPa} allowance, the release claim is still weak.

Plausibility Check

Adding uncertainty should reduce margin. The margin drops from 17 to 8\ \text{MPa}, exactly by the 9\ \text{MPa} guard.

Exercise 15: Validation Bias and Acceptance Gate

A simulation is compared with five test values. The prediction errors in percent are:

e=[-3,\ -2,\ -4,\ -1,\ -5]

The acceptance gate requires absolute mean bias below 3\% and RMSE below 4\%. Check the gate.

Solution

Mean bias:

\displaystyle \bar{e}=\frac{-3-2-4-1-5}{5}=-3\%

Absolute mean bias:

|\bar{e}|=3\%

RMSE:

\displaystyle RMSE=\sqrt{\frac{9+4+16+1+25}{5}}
RMSE=\sqrt{11}=3.32\%

The RMSE passes. The bias is exactly 3\%. If the rule requires strictly below 3\%, the bias gate fails. If the rule permits less than or equal to 3\%, it passes.

Engineering Comment

The wording of acceptance gates matters. This model systematically underpredicts because all errors are negative. Even if the numerical gate passes, the bias direction may be unsafe for capacity, stress or thermal margins.

Plausibility Check

All errors are between 1\% and 5\%, so an RMSE near 3.3\% is reasonable. The mean is exactly the midpoint of these listed signed errors.

Exercise 16: Penalty Cost for Constraint Violation

A soft constraint allows outlet temperature up to 72^\circ\text{C}. A candidate predicts 75^\circ\text{C}. The penalty is:

P=50\max(0,T-72)^2

Calculate the penalty.

Solution

Constraint violation:

T-72=75-72=3

Penalty:

P=50(3)^2=450

Engineering Comment

A soft penalty is not the same as a safety constraint. If 72^\circ\text{C} protects equipment, people or compliance, the optimizer should not be allowed to trade it away for objective improvement.

Plausibility Check

The violation is positive, so the penalty must be positive. A quadratic penalty makes a 3 degree violation nine times the unit-violation penalty.

Exercise 17: Conditioning Effect of Variable Scaling

An optimization variable x_1 is measured in millimeters and varies around 2, while x_2 is measured in pascals and varies around 200{,}000. A simple solver uses step sizes proportional to raw variable magnitude. Estimate the ratio of raw magnitudes and explain the scaling risk.

Solution

Magnitude ratio:

\displaystyle \frac{200{,}000}{2}=100{,}000

The raw variables differ by a factor of 100{,}000.

Engineering Comment

Without scaling, the solver may take steps that are numerically appropriate for one variable and inappropriate for the other. This can make convergence slow, unstable or dominated by units rather than physics. Scaled variables should represent relative engineering changes, not raw unit magnitudes.

Plausibility Check

Pascals often produce large numerical values compared with millimeters. A five-order-of-magnitude difference is exactly the kind of situation where scaling matters.

Exercise 18: Model-Based Release Decision Gate

A model-based design recommendation has the following evidence:

CheckResultGate
Guarded stress margin+6\ \text{MPa}\ge +5\ \text{MPa}
Validation RMSE4.8\%\le 5.0\%
Mean bias-3.2\%$
Solver residual norm0.07\le 0.10
Input outside calibration rangeyesno

Decide whether the recommendation should be released.

Solution

Stress margin:

6\ \text{MPa} \ge 5\ \text{MPa}

passes.

Validation RMSE:

4.8\% \le 5.0\%

passes.

Bias:

|-3.2\%|=3.2\%>3.0\%

fails.

Solver residual:

0.07 \le 0.10

passes.

Calibration range:

\text{outside range} \ne \text{allowed}

fails.

The recommendation should not be released. It should be held for model review, additional validation data or a restricted operating envelope.

Engineering Comment

The pass results are not enough because two evidence gates fail. A model can be numerically well solved and still be unsafe to use when it is biased or extrapolated beyond calibration data.

Plausibility Check

The decision is conservative because the failed checks directly affect trust in the model, not just formatting or documentation. Holding the release is consistent with engineering validation practice.

REF

See also