Lecture 8: Constraint Handling in Evolutionary Algorithms

Motivation

Spring Design

Aims:\texttt{Aims:} to minimise the weight of a tension/ compression spring. All design variables are continuous.

Constraints:\texttt{Constraints:}

  1. Minimum deflection
  2. Shear stress
  3. Surge frequency
  4. Diameters

Let the wire diameter d=x1d=x_1, the mean coil diameter D=x2D=x_2 and the number of active coils N=x3N=x_3. The following are the constraints on these variables:

0.05x12,    0.25x21.3,    2x3150.05 \leq x_1 \leq 2, \;\; 0.25 \leq x_2 \leq 1.3 , \;\; 2 \leq x_3 \leq 15

We can write this as a function to minimise:

f(X)=(x3+2)x2x12f(X) = (x_3 +2)\cdot x_2 \cdot x_1^2

which is subject to the following:

g1(X)=1x23x371785x140g_1(X) = 1 - \frac{x_2^3x_3}{71785x_1^4} \leq 0

g2(X)=4x22x1x212566(x2x13x14)+15108x1210g_2(X) = \frac{4x_2^2 - x_1x_2}{12566(x_2x_1^3 - x_1^4)} + \frac{1}{5108x_1^2} - 1 \leq 0

g3(X)=1140.45x1x22x30g_3(X) = 1- \frac{140.45x_1}{x_2^2x_3} \leq 0

g4(X)=x2+x11.510g_4(X) = \frac{x_2 + x_1}{1.5} -1 \leq 0

Engineering Optimisation

Also known as Design Optimisation, this is the process to find the combination of design variables that optimises the design objective and satisfies the constraints.

A design variable is under the control of the designer and could have an impact on the solution of the optimisation problem. They can be:

Design objectives represent the desires of the designers such as to maximise profit or minimise cost

Constraints are desires the designers cannot optimise infinitely due to:

A design constraint is usually rigid or hard as they often need to be strictly adhered to.

Engineering optimisation problems fall under constrained optimisation problems

Constrained Optimisation Problems

In general a constrained optimisation problem can be represented as:

minx{f(x)}\min_{\vec{x}} \{f(\vec{x})\}

subject to:

gi(x)0,i{1,,m}g_i(\vec{x}) \leq 0, \forall i \in \{1,\ldots,m\}
hj(x)=0,j{1,,p}h_j(\vec{x}) = 0, \forall j \in \{1,\ldots,p\}

where xx is the nn dimensional vector x=(x1,x2,,xn)\vec{x} = (x_1,x_2,\ldots, x_n), f(x)f(\vec{x}) is the objective function, gi(x)g_i(\vec{x}) is the inequality constraint and hj(x)h_j(\vec{x}) is the equality constraint

We denote the search space as S\mathcal{S} and the feasible space as FS\mathcal{F} \in \mathcal{S}. The global optimum of F\mathcal{F} might not be the same as that of S\mathcal{S}

Types of Constraints

There are two main types of constraints we will look at:

  1. Linear Constraints: relatively easy to deal with
  2. Non-linear Constraints: can be much harder to deal with.

Constraint Handling in Evolutionary Algorithms

Penalty Function Approach

There are 3 sub approaches under the penalty function method:

Static Penalties

The penalty function is pre-defined and fixed during evolution

The general form of static penalty function is:

f(x)=f(x)+i=1mri(Gi(x))2f'(\vec{x}) = f(\vec{x}) + \sum_{i=1}^{m}r_i(G_i(\vec{x}))^2

where rir_i are fixed, predefined values

Equality constraints can be converted into inequality contraints:

hj(x)hj(x)ϵ0h_j(\vec{x}) \rightarrow h_j(\vec{x}) - \epsilon \leq 0{}

Where ϵ>0\epsilon > 0 but is small

This approach is simple to implement but requires rich domain specific knowledge to accurately set rir_i

rii(1,,m+p)r_i \forall i \in (1,\ldots, m+p) can be divided into a number of different levels. When to use each level is determined by a set of heuristics, such as the more important the constraint, the larger the value of rir_i

Dynamic Penalty Functions

Dynamic Penalty Functions take the general form:

f(x)=f(x)+r(t)i=1mGi2(x)+c(t)j=1pHj2(x)f'(\vec{x}) = f(\vec{x}) + r(t) \cdot \sum_{i=1}^{m}G_i^2(\vec{x}) + c(t) \cdot \sum_{j=1}^{p}H_j^2(\vec{x})

Where r(t)r(t) and c(t)c(t) are two penalty coefficients

The general principal of DPFs is that larger the generation number tt, the larger the penalty coefficients r(t)r(t) and c(t)c(t)

Common Dynamic Penalty Functions

Common Dynamic Penalty Functions include:

Application

Given a static penalty function Φ(x)=f(x)+rG(x)\Phi(\vec{x}) = f(\vec{x}) + rG(\vec{x}) where G(x)=i=1mGi(x)G(\vec{x}) = \sum_{i=1}^{m}G_i(\vec{x}) and Gi(x)=max{0,gi(x)}G_i(\vec{x}) = \max\{0,g_i(\vec{x})\}

How does rr affect our training?

For a minimisation problem using Φ(x)\Phi(\vec{x}) for two individuals x1\vec{x_1} and x2\vec{x_2}, their fitness values are not determined by Φ(x)    \Phi(\vec{x}) \implies changing fitness values

Fitness proportional selection: As we now have changing fitness values we, by extension, have changing selection probabilities.

Ranking Selection: Φ(x1)<Φ(x2)    f(x1)+rG(x1)f(x2)+rG(x2)\Phi(\vec{x_1}) < \Phi(\vec{x_2}) \implies f(\vec{x_1}) + rG(\vec{x_1}) \leq f(\vec{x_2}) + rG(\vec{x_2})

From this we can see that different rr values lead to different ranking of individuals in the population.

The use of different penalty functions lead to different objective functions and therefore different explorations of the search space, finding different optima.

Essentially, penalty function transform fitness and change the ranking system leading to different candidates being selected.
Inappropriate penalty function lead to infeasible results, setting rr is difficult

Part 2

Stochastic Ranking

Proposed by Prof. Xin Yao a lecturer at the University of Birmingham in 2000

This is a rank-based selection scheme that handles constraints
It does not use penalty functions and is self adaptive

Ranking Selection

Sort a population of size MM from best to worst, according to their fitness values:

x(M1),x(M2),,x(0)x_{(M-1)}',x_{(M-2)}',\ldots, x_{(0)}'

From this set we select the top γ\gamma-ranked individuals xγx_{\gamma}' with probability p(γ)p(\gamma) where p(γ)p(\gamma) is a ranking function such as:

Penalty functions essentially perform a transformation of the objective, fitness function. A rank change     \implies a selection change.

Here we instead change the rank directly in the Evolutionary Algorithm.

We can view ranking as the same as sorting. We can modify the sorting algorithm in the EA to consider constraint violation.

Stochastic Ranking is essentially a modified form of bubble sort with some additional rules to handle constraints

Stochastic Ranking Algorithm

for j:=1 to M:  
  for i := 2 to M:
    u := U(0;1) # randomly uniformly distributed random number
    if G(x'[i-1]) = G(x'[i]) == 0 or u <= P_f :
      # Swap values so that better (smaller) are before the larer ones
      if f(x'[i-1]) < f('[i]):
        swap(I[i], I[i-1])
        swap(f(x'[i]),f(x'[i-1]))
        swap(G(x'[i]),G(x'[i-1]))
    else:
      if G(x'[i-1]) < G(x'[i]):
        swap(I[i], I[i-1])
        swap(f(x'[i]),f(x'[i-1]))
        swap(G(x'[i]),G(x'[i-1]))

Where:

PfP_f

Why do we introduce PfP_f given that is allows for infeasible solutions, in the cases where their fitness values are higher than feasible ones, with some probability?

Where Pf>0.5P_f > 0.5: Most comparisons are based solely on f(x),f(x), \therefore infeasible solutions are likely to occur.

Where Pf<0.5P_f < 0.5 : Most comparisons are based on G(x),$G(x), \$\therefore infeasible solutions are lss likely to occur, however, the resulting solutions may be poor

Recommended values of PfP_f fall between 0.45 and 0.5

If penalty functions perform fitness transformation, converting rank change to selection change. Stochastic ranking changes ranks by changing the sorting algorithm. Why do we not change selection directly in the EA?

Feasibility Rule

This method is simple and parameter free, however, it can lead to premature convergence.

The Repair Approach to Constraint Handling

Instead of modifying an EA or fitness function, infeasible individuals can be repaired into feasible ones

Let IsI_s be an infeasible individual and IrI_r be a feasible one.

Repairing Infeasible Individuals

For this process we maintain two populations:

  1. A population of evolving individuals, feasible or infeasible.
  2. A population of feasible reference individuals, subject to change but not evolution.

Algorithm

I_r = select a reference individual
do until individual z_i is feasible{
  z_i = a_i * I_s + (1-a_i)* I_r, where 0<a_i < 1
  calculate the fitness value of z_i : f(z_i)
  if f(z_i) <= f(I_r) then replace I_s with z_i
  else{
    u = U(0;1) // uniformly distributed random number
    if u <= Pr then replace I_s with z_i
  }
}

Notice we replace IrI_r with ziz_i with some probability PrPr even though ziz_i is worse than IrI_r

Implementation Issues

Conclusion

Adding a penalty term to the objective function is equivalent to changing the fitness function, which, in turn, is equivalent to changing the selection probabilities. It is easier and more effective to change the selection probabilities directly and explicitly using Stochastic ranking and Feasibility rules.
We have also seen that there are alternative constraint handling techniques such as repairing methods.