Optimisation problems in engineering design
An optimisation problem has design variables, an objective to minimise or maximise, and constraints that a design must satisfy. For a beam, the variables may be the width and height of the cross-section, the objective its mass, and the constraints limits on stress and deflection. Many engineering objectives are black boxes: They are evaluated by a simulation, have no usable gradient, are noisy, or mix continuous and integer variables. Landscapes with many local optima defeat gradient methods that start from a single point.
Population-based metaheuristics address these difficulties by sampling many designs at once and moving the population towards better regions. They make few assumptions about the problem, which is their strength and their limit: The no free lunch theorems show that, averaged over all possible problems, no search algorithm outperforms any other [1]. An algorithm performs well only when its search behaviour matches the structure of the problem, so engineering knowledge about variables, scales and constraints remains decisive.
Check your understanding. Why are gradient-based methods often unsuitable for the design objectives targeted by evolutionary algorithms?
Formulas: An optimisation problem
An optimisation problem collects the design variables in a vector and asks for the design that minimises an objective subject to constraints written as and to bounds on every variable:
A design that satisfies all constraints is feasible. A maximisation problem becomes a minimisation problem by changing the sign of the objective. Writing a limit as a ratio minus one, such as , makes all constraints dimensionless, so that means that half of the allowance is still unused. The no free lunch theorem states the limit of every general-purpose search method [1]. If is the sequence of objective values that an algorithm observes, then for any two algorithms and , summed over all possible objective functions ,
Every algorithm sees the same distribution of results on average, so an advantage on one class of problems is paid for on another.
Worked example: Evaluating one beam design
The cantilever of the notebook has length m and carries a tip load kN. Its rectangular steel section has width and height , with density kg/m³ and Young's modulus GPa. The mass is , the bending stress is , and the tip deflection is [2]. The limits are 160 MPa for the stress, mm for the deflection and for the slenderness. The design m and m gives:
Step 1. Mass.
Step 2. Stress.
Step 3. Deflection.
Step 4. Constraint values.
All three values are at most zero, so the design is feasible. The slenderness constraint is active, , while 62.5 percent of the stress allowance and half of the deflection allowance remain unused, which suggests that a lighter feasible design exists.
Genetic algorithms
Holland described adaptation in natural and artificial systems as the evolution of a population under selection and recombination [3], and Goldberg popularised genetic algorithms as practical search and optimisation tools [4]. A genetic algorithm encodes a design as a chromosome, which may be a bit string, a vector of real numbers or a permutation. A fitness function scores each chromosome. Selection chooses parents with a preference for fitter individuals: In tournament selection, a few individuals are drawn at random and the best of them becomes a parent. Crossover combines two parents into offspring, for example by exchanging parts of their chromosomes or by blending their real values. Mutation makes small random changes that keep diversity in the population. Elitism copies the best individuals unchanged into the next generation, so that the best design found is never lost.
The balance between exploration and exploitation governs performance. Strong selection pressure and small mutations converge quickly but risk premature convergence to a local optimum; weak pressure and large mutations explore widely but converge slowly. Population size, tournament size, crossover and mutation rates are therefore design parameters of the algorithm itself, and their effect must be judged over several independent runs, because a single run of a stochastic algorithm proves little [5].
Animation: A genetic algorithm on a multimodal landscape
Each dot is a candidate design on a landscape with many local minima. Press play and watch selection concentrate the population while mutation keeps exploring. Increase the mutation strength to see exploration win over exploitation.
Check your understanding. What is the role of elitism in a genetic algorithm?
Formulas: Selection, crossover and mutation
A genetic algorithm keeps a population of designs. For minimisation, a smaller objective value means a fitter individual. Tournament selection draws individuals at random, with replacement, and returns the best of them. If the population is ranked from (best) to (worst), the individual of rank wins when all drawn individuals have rank or worse but not all are worse than :
Fitness-proportional or roulette-wheel selection instead picks individual with probability for positive fitness values , for example in a minimisation problem [4]. For real-valued chromosomes, blend crossover places a child on the line between the parents and , with a random weight between 0 and 1, and Gaussian mutation adds a normally distributed random number with mean 0 and standard deviation 1, scaled by a fraction of the variable range :
For bit-string chromosomes of length , a string with the integer value is decoded to the interval from to as
One-point crossover swaps the tails of two parents after a random cut point, and bit-flip mutation flips every bit independently with probability . A string then stays unchanged with probability , and the expected number of flipped bits is [3, 4]. Elitism copies the best individual unchanged into the next generation [5].
Worked example: One generation of a real-coded genetic algorithm
The objective on the interval from 0 to 7 has its minimum at . The population holds individuals, the tournament size is , and the mutation scale is , so that .
Step 1. Evaluation.
The ranking is (rank 1), 4.5 (rank 2), 0.5 (rank 3) and 6 (rank 4), and the mean objective is .
Step 2. Selection pressure. With and , so that :
The four probabilities add up to one, and the best individual is seven times as likely to become a parent as the worst.
Step 3. Elitism. The best individual, , enters the next generation unchanged. Three children fill the remaining places. The individuals are numbered in the order 0.5, 2, 4.5 and 6.
Child 1. The first tournament draws individuals 1 and 3, with and , so parent wins. The second draws 2 and 4, with and , so parent wins. With the random weight , crossover and mutation with the normal number give
Child 2. The first tournament draws individuals 3 and 4, with and , so parent wins. The second draws 1 and 2, with and , so parent wins. With the random weight , crossover and mutation with the normal number give
Child 3. The first tournament draws individuals 2 and 3, with and , so parent wins. The second draws 1 and 4, with and , so parent wins. With the random weight , crossover and mutation with the normal number give
Step 4. The new generation. The population is now 2, 2.89, 3.58, 1.565, with objective values 2, 1.0121, 1.3364, 3.059225. The mean objective fell from 5.625 to
and the best value from 2 to 1.0121. One generation proves little, because every number above came from a random draw; the effect of the operators shows only over many generations and several independent runs [5]. Part A of the interactive lab creates such generations one at a time, with every tournament, crossover and mutation.
Worked example: Bit strings, one-point crossover and bit-flip mutation
The same interval from 0 to 7 is encoded with bits, so .
Step 1. Decoding the parents. The parent 01100 has and decodes to . The parent 10011 has and decodes to .
Step 2. One-point crossover after the second bit. The children take the first two bits of one parent and the last three of the other: 01011 with and , and 10100 with and .
Step 3. Bit-flip mutation. With , a child stays unchanged with probability , and on average bit flips. If the last bit of 01011 flips, the child becomes 01010 with and . Neighbouring integers decode to points apart, which is the resolution of the encoding.
Differential evolution and other real-valued methods
Differential evolution, proposed by Storn and Price, is a simple and effective method for continuous variables [6]. For each member of the population it builds a mutant vector by adding a scaled difference of two random members to a third, v = a + F (b - c), mixes the mutant with the current member by crossover with rate CR, and keeps the trial vector only if it is at least as good. Because the differences between population members shrink as the population converges, the step size adapts automatically to the scale of the landscape. SciPy provides a mature implementation with bounds and constraints [7].
Evolution strategies adapt a distribution of mutations instead. The covariance matrix adaptation evolution strategy, CMA-ES, learns the shape of promising regions and is among the most reliable methods for difficult continuous problems of moderate dimension [8]. Simulated annealing, met in Week 2, is a single-solution relative of these methods [9].
Formulas: Differential evolution and CMA-ES
Differential evolution keeps a population of real vectors with components each. For every target vector it draws three other members with distinct indices , and and forms the mutant vector with the scale factor , usually between 0.4 and 1 [6]:
Binomial crossover builds the trial vector component by component. A random number between 0 and 1 is drawn for every component , and one component is chosen at random to come from the mutant in any case:
On average components come from the mutant. Selection keeps the better of the two vectors:
The covariance matrix adaptation evolution strategy samples candidates around a mean with a step size and a covariance matrix , with drawn from the normal distribution . The best candidates, ranked , move the mean with positive weights that add up to one, and in simplified form they also update the covariance matrix with a learning rate [8]:
The product of a column vector with its transpose is a matrix that stretches along the direction of successful steps, which is how the method learns the shape of promising regions. The full algorithm adds an evolution path and a control of the step size .
Worked example: One trial vector of differential evolution
The objective is , with its minimum 0 at the origin. The population holds four vectors, , , and , and the control parameters are and .
Step 1. Target and partners. The target is with . The random indices are , and .
Step 2. Mutant vector.
Step 3. Crossover. The index takes the first component from the mutant. For the second component , so it also comes from the mutant: .
Step 4. Selection. , so replaces . Had been 0.95, the second component would have stayed 2, giving with , still an improvement.
With , on average components come from the mutant. The step is proportional to the spread of the population, so the steps shrink automatically as the population contracts around the optimum [6]. Part B of the interactive lab processes one target vector after another and shows this self-adapting step size.
Constraints
Engineering designs must be feasible. A penalty function adds to the objective a term that grows with the amount of constraint violation, which turns a constrained problem into an unconstrained one; the difficulty is choosing the weight of the penalty. Deb's feasibility rules avoid weights altogether: A feasible design always beats an infeasible one, two feasible designs are compared by objective, and two infeasible designs are compared by their total violation [10]. Repair operators that move an infeasible design back into the feasible region are useful when the constraint structure is known, and variable bounds are usually enforced directly.
For the cantilever beam of the notebook, a tip load P acts on a rectangular section of width b and height h. The maximum bending stress is 6 P L / (b h squared) and the tip deflection is 4 P L cubed / (E b h cubed) [2]. Minimising mass subject to limits on stress, deflection and the ratio h / b produces an optimum on the boundary of the feasible region, where the deflection limit and the ratio limit are both active. This optimum can be derived by hand, which makes the problem a good benchmark for the algorithms.
Check your understanding. Under Deb's feasibility rules, how are two infeasible designs compared?
Formulas: Penalties and feasibility rules
The total violation of a design adds up the parts of the constraints that are not satisfied:
A static penalty adds the violation to the objective with a weight , so that an unconstrained algorithm can be used:
Squared violations, , are a common variant. Deb's feasibility rules compare two designs and without any weight [10]: If and , the feasible is better. If , the smaller objective is better. If both are infeasible, the smaller violation is better.
For the cantilever with , the moment of inertia of the section, , enters the deflection through , so the deflection limit becomes a condition on alone:
The arrow reads "implies". For a given mass , that is a given area , the deflection falls as grows, so the lightest design pushes to the slenderness limit and to the deflection limit [2].
Worked example: Penalty weight against feasibility rules
Three designs of the beam:
| Design | , (m) | Mass (kg) | Stress (MPa) | Deflection (mm) | , , | |
|---|---|---|---|---|---|---|
| A | 0.05, 0.2 | 157 | 60 | 4 | , , | 0 |
| B | 0.04, 0.16 | 100.48 | 117.19 | 9.7656 | , , | 0.2207 |
| C | 0.03, 0.15 | 70.65 | 177.78 | 15.8025 | , , | 1.3364 |
Step 1. The violations. Design A is the feasible design of the first example, . With N m and N m³ as in the first example, design B gives
Only the deflection limit is violated. For design C:
The masses are kg and kg.
Step 2. A weak penalty. With : and . The infeasible design B wins, so the algorithm would return a beam that deflects too much.
Step 3. A strong penalty. With : , now worse than A with 157. The result depends on the weight, which must be chosen for each problem.
Step 4. Feasibility rules. A beats B and C because it is feasible. Between the two infeasible designs, B beats C because . No weight was needed.
Worked example: The lightest beam by hand
Step 1. The width.
Step 2. Height and mass. m, and
Step 3. The stress check.
which is below 160 MPa, so the stress constraint is inactive, as assumed. The optimum, 111.017 kg, lies on the boundary where the deflection and slenderness constraints are active, and Part C of the interactive lab uses it as the known optimum when the algorithms are compared. Part D of the interactive lab evaluates penalties and feasibility rules for any design.
Multiple objectives and Pareto optimality
Real designs trade off several objectives: mass against stiffness, cost against reliability, efficiency against noise. A design dominates another if it is no worse in every objective and better in at least one. The designs that no other design dominates form the Pareto set, and their objective values form the Pareto front. The engineer, not the algorithm, chooses a design from the front by weighing the objectives. NSGA-II finds approximations of the front in one run by ranking the population into non-dominated fronts and preserving spread with a crowding distance [11]. Simpler methods repeat single-objective optimisation, for example minimising mass for a sequence of deflection limits, which is how the notebook builds its front.

Formulas: Dominance, fronts and crowding
With objectives to be minimised, a design dominates a design , written , when it is no worse in every objective and better in at least one:
The double arrow reads "exactly when". The non-dominated designs of a set form its first front; removing them and repeating the test gives the second front, and so on. NSGA-II ranks its population by these fronts and, within a front, prefers designs in sparsely populated regions. The crowding distance of a design adds, over all objectives, the gap between its two neighbours along that objective, divided by the range of the objective in the front [11]:
Here and are the neighbours of when the front is sorted by objective , and the two extreme designs receive an infinite distance so that they are always kept. The -constraint method of the notebook minimises one objective while it limits the other, subject to , and repeats this for a sequence of limits (epsilon). For the beam, the analysis of the lightest design gives every point of the front in closed form while the stress limit is inactive:
because and .
Worked example: Fronts and crowding distances of six beam designs
Step 1. Points of the front. For a deflection limit of 12 mm:
The same formula gives 157 kg for 4 mm, 128.2 kg for 6 mm and 111 kg for 8 mm. The 4 mm point is design A of the previous example, which explains its active slenderness constraint.
Step 2. Dominance. The six designs are P1 = (157 kg, 4 mm), P2 = (130 kg, 8 mm), P3 = (111 kg, 8 mm), P4 = (90.6 kg, 12 mm), P5 = (95 kg, 15 mm), P6 = (128.2 kg, 6 mm). Every pair is compared in both objectives. P3 dominates P2, because and . P6 also dominates P2, because and . P4 dominates P5, because and . No other pair has a dominance relation: For example, P1 is heavier but stiffer than P6. The first front is therefore P1, P3, P4 and P6, and the second front holds P2 and P5.
Step 3. Crowding distances in the first front. Sorted by mass, the front reads P4, P3, P6, P1. The mass range is kg and the deflection range mm. P4 and P1 are extreme and receive infinite distances. For the two inner designs:
If NSGA-II had to drop one design of this front, it would drop P6, whose neighbours are closer together, and keep the spread of the front.
Step 4. Where the closed form ends. The stress reaches 160 MPa when , that is at a deflection of about 14.8 mm. For larger limits the stress constraint becomes active and the front no longer follows . Part E of the interactive lab ranks any set of designs and computes their crowding distances, and Part F samples beam designs and draws the Pareto front of mass and deflection.
Evolution at work
Evolutionary computation has produced designs that engineers would hardly have proposed by hand. An X-band antenna evolved at NASA for the Space Technology 5 mission met demanding requirements and flew in space in 2006 [12]. Structural shapes, truss topologies, electrical machines, chemical process conditions and production schedules are routinely optimised with genetic algorithms, differential evolution and their relatives [5]. Week 6 continues with swarm intelligence, which replaces biological evolution by the collective behaviour of birds, ants and bees.
Check your understanding. Design A has mass 100 kg and deflection 6 mm. Design B has mass 110 kg and deflection 6 mm. Which statement holds?
Python step 5: Random numbers, arrays and genetic operators
The Python step of this week is part of the Colab notebook, where every explanation stands next to a cell that runs it and the step closes with a quick check and exercises with immediate feedback. The printable lecture notes contain the same step together with the outputs of its code. The Colab button below opens the notebook at the step. Run the setup cell just above the step first, since the exercises use its check function.
Review cards
Select a card to turn it over.
Continue the week
The week continues with the simulation and the self-assessment of the interactive lab and with the Python step and the hands-on work of the Colab notebook. The week overview lists the discipline challenges, the weekly task and the research assignment.
Interactive lab Colab notebook Self-assessment Week overview and tasks
References
[1] Wolpert, D. H., & Macready, W. G. (1997). No free lunch theorems for optimization. IEEE Transactions on Evolutionary Computation, 1(1), 67-82. https://doi.org/10.1109/4235.585893
[2] Gere, J. M., & Goodno, B. J. (2013). Mechanics of Materials (8th ed.). Cengage Learning.
[3] Holland, J. H. (1992). Adaptation in Natural and Artificial Systems (2nd ed.). MIT Press. First edition 1975, University of Michigan Press.
[4] Goldberg, D. E. (1989). Genetic Algorithms in Search, Optimization, and Machine Learning. Addison-Wesley.
[5] Eiben, A. E., & Smith, J. E. (2015). Introduction to Evolutionary Computing (2nd ed.). Springer. https://doi.org/10.1007/978-3-662-44874-8
[6] Storn, R., & Price, K. (1997). Differential evolution: A simple and efficient heuristic for global optimization over continuous spaces. Journal of Global Optimization, 11(4), 341-359. https://doi.org/10.1023/A:1008202821328
[7] Virtanen, P., Gommers, R., Oliphant, T. E., et al. (2020). SciPy 1.0: Fundamental algorithms for scientific computing in Python. Nature Methods, 17(3), 261-272. https://doi.org/10.1038/s41592-019-0686-2
[8] Hansen, N., & Ostermeier, A. (2001). Completely derandomized self-adaptation in evolution strategies. Evolutionary Computation, 9(2), 159-195. https://doi.org/10.1162/106365601750190398
[9] Kirkpatrick, S., Gelatt, C. D., & Vecchi, M. P. (1983). Optimization by simulated annealing. Science, 220(4598), 671-680. https://doi.org/10.1126/science.220.4598.671
[10] Deb, K. (2000). An efficient constraint handling method for genetic algorithms. Computer Methods in Applied Mechanics and Engineering, 186(2-4), 311-338. https://doi.org/10.1016/S0045-7825(99)00389-8
[11] Deb, K., Pratap, A., Agarwal, S., & Meyarivan, T. (2002). A fast and elitist multiobjective genetic algorithm: NSGA-II. IEEE Transactions on Evolutionary Computation, 6(2), 182-197. https://doi.org/10.1109/4235.996017
[12] Hornby, G. S., Lohn, J. D., & Linden, D. S. (2011). Computer-automated evolution of an X-band antenna for NASA's Space Technology 5 mission. Evolutionary Computation, 19(1), 1-23. https://doi.org/10.1162/EVCO_a_00005