Keywords

1 Introduction

The letter assignment problem (LAP) is an optimization problem from UI design devoted to find optimal keyboards configurations. The goal is to arrange a set of letters according to ergonomic criterion in order to maximize typing speed, while reducing typing errors and tiredness. The problem is relevant as many repetitive stress injuries are caused by the inappropriate use of keyboards. The LAP is based on the Fitts law, which can be seen as an estimation of typing performance involving distance of keys and their width. In the optimization sphere, it is well-known that linear objective functions with linear constraints can definitely be solved with exact methods such as the simplex one. However, the LAP is an instance of the quadratic assignment problem (QAP) which is NP-Hard whose mathematical formulation involves a quadratic objective function. As a consequence, today there is no polynomial-time algorithm able to guarantee the global optimum. Then, to tackle this problem, we propose the use of metaheuristics, which are multi-purpose problem solvers devoted to particularly tackle large instances of complex optimization problems. They are commonly able to provide near-optimal solutions in a limited amount of time when the use of exact methods is too expensive. In particular, we employ particle swarm optimization (PSO), which is one of the pioneers metaheuristics that has been largely used to solve different problems from multiple application domains. Interesting results are provided where PSO is able to rapidly find optimal designs for different keyboard configurations.

2 The Letter Assignment Problem

The letter assignment problem (LAP) derives from the well-known quadratic assignment problem (QAP) which belongs to the NP-hard class of problems, no existing then evidence of a polynomial-time algorithm able to guarantee the global optimum. To this end, the use of metaheuristics appear as a suitable candidate for conveniently tackling this problem. The LAP is the defined as follows: given n letters and n keyslots, the goal is to minimize an average cost \(c_{kl}\) of pressing the letter l after the letter k. The average cost is weighted by a bigram probability denoted as \(p_{kl}\), as depicted in Eq. 1.

$$\begin{aligned} min \sum _{k}\sum _{l}p_{kl} \dot{c}_{kl} \end{aligned}$$
(1)

The \(p_{kl}\) probabilities are computed by a bigram distribution of representative corpus of text as explained in [1], while the cost is calculated by Eq. 2

$$\begin{aligned} c_{kl} = \sum _{i=1}^n \sum _{j=1}^n t_{ij} x_{ki} x_{lj} \end{aligned}$$
(2)

where \(x_{lj}=1\) if letter l is assigned to keyslot j and \(x_{lj}=0\) otherwise. \(t_{ij}\) is the movement time (MT) from key i to key j, normally computed by Fitts’ law [5], as depicted in Eq. 3.

$$\begin{aligned} MT = a+b\log _2(\frac{D_{kl}}{W_{l}} +1) \end{aligned}$$
(3)

where \(D_{kl}\) is the distance between letters k and l and \(W_l\) represents the width of the keyslot holding l, a and b are constants that depend on the choice of input device. This function provides an estimation of the capable performance of a experience user. The LAP also involves the following constraints.

$$\begin{aligned} \sum _{l=1}^n x_{lj=1} \qquad \qquad \qquad \forall j \in \{1,\ldots ,n\} \end{aligned}$$
(4)
$$\begin{aligned} \sum _{j=1} x_{lj} \qquad \qquad \qquad \forall l \in \{1,\ldots ,n\} \end{aligned}$$
(5)
$$\begin{aligned} x_{lj} \in \{0,1\} \qquad \qquad \qquad \forall l,j \in \{1,\ldots ,n\} \end{aligned}$$
(6)

Constraint 4 is responsible for that each slot contains only one letter. Equation 5 ensures that each letter is assigned to only one slot and finally Eq. 6 guarantees the binary solutions. The technique employed to solve this problem is presented in the next section.

3 Particle Swarm Optimization

Particle swarm optimization (PSO) is one the pioneer and more tested metaheuristics [3]. It belongs to the class of population-based metaheuristics, where the population is composed of a set of agents called particles that explore promising regions of the search space in order to find optimal solutions. The classic PSO algorithm is depicted in Fig. 1

Fig. 1.
figure 1

PSO algorithm

$$\begin{aligned} V_p^d = V_p^d + c_1*rand*(pbest_p^d-present_p^d) + c_2*rand*(gbest^d-present_p^d) \end{aligned}$$
(7)
$$\begin{aligned} present_p^d =present_p^d + V_p^d \end{aligned}$$
(8)

where \(V_p^d\) is the velocity of the dimension d of the particle p, \(present_p^d\) is the current dimension d of the particle p, \(pbest_p^d\) is the dimension d of the best position that p has had, \(gbest^d\) is the dimension d of the best global position of the swarm, rand is an evenly distributed random number between 0 and 1, c1 and c2 are learning factors.

3.1 Discretization

Given that LAP is a binary problem we must adapt the PSO algorithm to fit the model properly. To this end, we employ a method based on a transfer and a discretization function as detailed in [4] in which we take the probability \(p_{mutj}\) of mutating the jth column of the solution in the particle p to the actual speed. In this particular case we use the S-shape transfer function, as shown below.

$$\begin{aligned} pmut_n^j = \frac{1}{1+ e^{2v^{j}_{n}}} \end{aligned}$$
(9)

Next, we generate the new binary value, based on the \(pmut_n^j\), from the discretization function as shown in Eq. 10.

$$\begin{aligned} n_j^{'} = \left\{ \begin{array}{ll} best_j\ if\ \alpha \le pmut_n^j\\ n_j\ otherwise \end{array}\right. \end{aligned}$$
(10)

where \(\alpha \) is an evenly distributed random number between 0 and 1.

4 Results and Conclusions

The PSO algorithm was tested with the 26 Letter Trapezoid Layout for touchscreens and the Zhai-Hunter-Smith’s variant of the Fitts-Bigram \((a=0.0, b=0.084, c=0.127)\), proposed in [2]. This keyboard has a search space of \(4*10^{26}\) and we assumed that the space bar is fixed at the bottom. The algorithm was able to get a fitness of 297.57437 in 5 h. Considering that the QWERTY layout has a score of 356.546251 based on the LAP metric and the known optimum found in previous research is 278.381124 [2], this is a promising result.

In this paper, we have presented ongoing work about PSO algorithms for solving the LAP. The problem is interesting as many repetitive stress injuries are caused by the inappropriate use of keyboards. As future work we expect to solve more instances of the LAP, and improve the performance of the proposed PSO. Analogous UI problems could also be solved with different metaheuristics.