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:
- the model boundary and decision variable;
- the objective, constraint, residual or validation metric being used;
- the units and scaling of each quantity;
- the calculation result and its engineering meaning;
- 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
| Scenario | Exercises | Primary check | Engineering decision |
|---|---|---|---|
| Model setup and validation | 1, 2, 3, 4, 15 | Scaling, residuals, calibration, bias and RMSE | Decide whether the model is numerically and physically credible. |
| Solver and local optimization | 5, 6, 7, 8, 9, 10 | Gradient descent, Newton update, feasibility, corners and KKT checks | Identify the candidate solution and whether it satisfies constraints. |
| Tradeoffs, sensitivity and robustness | 11, 12, 13, 14, 16, 17 | Pareto selection, weighted objectives, local sensitivity, uncertainty and penalty behavior | Decide whether the optimum is robust enough to defend. |
| Release gate | 18 | Constraint margin, validation error and uncertainty | Accept, 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:
and:
Solution
For thickness:
For flow:
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:
The validation gate requires:
Check the gate.
Solution
Compute the residual norm:
Since:
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:
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:
Then predict y at x=60.
Solution
Compute the numerator:
Compute the denominator:
Therefore:
Prediction at x=60:
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:
| Point | Measured | Predicted |
|---|---|---|
| 1 | 100 | 96 |
| 2 | 150 | 156 |
| 3 | 130 | 127 |
Calculate the mean error and RMSE, where error is predicted minus measured.
Solution
Errors:
Mean error:
RMSE:
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:
starting from x_0=2 with step size \alpha=0.25. Use:
Solution
The derivative is:
At x_0=2:
Update:
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:
from x_0=3. Use:
Solution
At x_0=3:
and:
so:
Newton update:
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:
Check feasibility.
Solution
First constraint:
Second constraint:
Nonnegativity:
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:
subject to:
Evaluate the feasible corner points (0,0), (0,10), (7,0) and the intersection of the two active constraints.
Solution
Find the intersection:
Subtract the first equation from the second:
Then:
Evaluate the objective:
| Point | z=5x+4y |
|---|---|
| (0,0) | 0 |
| (0,10) | 40 |
| (7,0) | 35 |
| (4,6) | 44 |
The best listed corner is:
with:
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:
so it is plausible that this point is efficient.
Exercise 9: KKT Check for an Active Upper Bound
Minimize:
subject to:
Use the constraint form g(x)=x-5 \le 0. Check whether x^\*=5 satisfies stationarity with a nonnegative multiplier:
Solution
Derivatives:
and:
At x^\*=5:
Stationarity gives:
so:
Because:
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:
subject to:
Find the optimal allocation.
Solution
Use:
Stationarity:
Therefore:
so:
With x+y=10:
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:
| Design | Mass | Energy |
|---|---|---|
| A | 12 | 80 |
| B | 10 | 95 |
| C | 13 | 78 |
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:
Calculate J. Compare it with another candidate with J=0.21.
Solution
Compute:
Since:
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:
Then estimate the output change for a +1.5 change in p.
Solution
Sensitivity:
Estimated output change:
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:
The allowable stress is:
Model uncertainty is estimated as \pm 9\ \text{MPa}. Check the guarded margin:
Solution
Worst credible stress:
Guarded margin:
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:
The acceptance gate requires absolute mean bias below 3\% and RMSE below 4\%. Check the gate.
Solution
Mean bias:
Absolute mean bias:
RMSE:
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:
Calculate the penalty.
Solution
Constraint violation:
Penalty:
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:
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:
| Check | Result | Gate |
|---|---|---|
| Guarded stress margin | +6\ \text{MPa} | \ge +5\ \text{MPa} |
| Validation RMSE | 4.8\% | \le 5.0\% |
| Mean bias | -3.2\% | $ |
| Solver residual norm | 0.07 | \le 0.10 |
| Input outside calibration range | yes | no |
Decide whether the recommendation should be released.
Solution
Stress margin:
passes.
Validation RMSE:
passes.
Bias:
fails.
Solver residual:
passes.
Calibration range:
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.