Assigning Mona Lisa pixels

5 downloads 0 Views 301KB Size Report
There are specialized algorithms for the assignment problem that perform better ... R. Jonker and T. Volgenant, A shortest augmenting path algorithm for dense ...
AN ASSIGNMENT PROBLEM BASED ON THE MONA LISA ERWIN KALVELAGEN

Abstract. The assignment problem is a well known elementary model. Using an example from [3] we apply this model on a digital rendering of the Mona Lisa.

1. The Assignment Problem The assignment problem deals with assigning n workers to n jobs. Each worker must be assigned to exactly one job. The objective is to minimize total cost. The following optimization model defines this problem type: ASSIGNMENT

minimize x

subject to

X i,j X i X

ci,j xi,j xi,j = 1 ∀j xi,j = 1 ∀i

j

xi,j ∈ {0, 1} ∀i, j The assignment problem is in fact a special case of the transportation model. Assignment problems also often occur as a relaxation of more complicated models such as the traveling salesman problem (TSP). •GGG ggg• GG ggggg GG gggggggg gggGgGgGG •ggg o• GG ooo GG GG ooooo oGoG ooo GGG • • o o GG oo o G o GG o GG ooo •oo • Figure 1. Graph representation of an assignment This problem is also sometimes described as the (bipartite) matching problem. Although the assignment problem is easy to solve as an LP, simple variants and extensions are often very difficult. An example of such a hard problem is the quadratic assignment problem. Date: November 12, 2002. 1

2

ERWIN KALVELAGEN

The assignment problem can be solved as an LP instead of a MIP as it automatically assumes integer values in the optimal solution. This is the result of a property called totally unimodular. Assignment problems are often very degenerate. Some LP solvers will be affected by this: they will perform a (sometimes large) number of iterations without improving the objective function. An example is shown below, where BDMLP tries to solve the model assignlisa.gms: Iter 20780 20800 20817 20820 20840 20860 20867

Sinf/Objective 3.12130000E+04 3.12130000E+04 3.12130000E+04 3.12130000E+04 3.12130000E+04 3.12130000E+04 3.12130000E+04

Status nopt nopt nopt nopt nopt nopt nopt

Num 9434 8078 8279 8256 9578 8824 8288

Freq

49

50

There are specialized algorithms for the assignment problem that perform better than general LP solvers. An example of such a specialized code is described in [2]. A recent discussion about modern implementations can be found in [1]. In many cases authors will use the term assignment problem for more general and more complicated problems. 2. Mona Lisa An interesting experiment was performed in [3] where the assignment model was used to find interesting spots in the Mona Lisa, the famous painting by Leonardo da Vinci (1452 – 1519). This oil on wood painting is also known as La Gioconda and is on display in the Musee du Louvre in Paris. It should probably be dated in the period between 1503 and 1505. Knuth works on a gray scale digitized version of the painting. A plot is reproduced in figure 3. Each xi,j represents a pixel. The objective function is formed by interpreting ci,j ∈ [0, 255] as the brightness level of each pixel (zero is black, 255 is white). The objective function is maximized: max

X

ci,j xi,j

i,j

X (1)

xi,j ≤ 1 ∀i

j

X

xi,j = 1 ∀j

i

xi,j ∈ {0, 1} We need to use inequalities here as the picture is non-square (there are 360 rows and 250 columns). 2.0.1. Model assignlisa.gms.

1

$ontext Assignment problem for lisa(360,250,255,0,360,0,250,0,22950000) Erwin Kalvelagen, March 2002

1http://www.gams.com/~erwin/monalisa/assignlisa.gms ~erwin/monalisa/lisa.inc

and

http://www.gams.com/

AN ASSIGNMENT PROBLEM BASED ON THE MONA LISA

3

Reference: Donald E. Knuth, "The Stanford GraphBase: A Platform for Combinatorial Computing", ACM Press, 1993.

$offtext

set i ’rows’ /0*359/; set j ’columns’ /0*249/; table c(i,j) $include ’lisa.inc’ ; equations objective ’maximize highlighted parts’ column(j) ’column sum’ row(i) ’row sum’ ; variables z x(i,j) ;

’objective variable’ ’pixels’

binary variable x; objective.. row(i).. column(j)..

z =e= sum((i,j),c(i,j)*x(i,j)); sum(j, x(i,j)) =l= 1; sum(i, x(i,j)) =e= 1;

model m /all/; solve m using rmip maximizing z;

The data file is too large to reproduce here. It contains the gray scale values (ranging from 0 through 255) for each pixel of the 360 × 250 image. The resulting model has 360 + 250 + 1 = 611 equations and 360 × 250 + 1 = 90001 variables. The result is illustrated in figure 32. References 1. Rainer E. Burkard and Eranda C ¸ ela, Linear assignment problems and extensions, Tech. Report 127, Karl-Fransenz Universit¨ at Graz and Technische Universit¨ at Graz, June 1998. 2. R. Jonker and T. Volgenant, A shortest augmenting path algorithm for dense and sparse linear assignment problems, Computing 38 (1987), 325–340. 3. Donald E. Knuth, The stanford graphbase: A platform for combinatorial computing, ACM Press, 1993. GAMS Development Corp., Washington DC E-mail address: [email protected]

2http://www.gams.com/~erwin/monalisa/monalisa.png

4

ERWIN KALVELAGEN

Figure 2. Mona Lisa

AN ASSIGNMENT PROBLEM BASED ON THE MONA LISA

Figure 3. Interesting pixels are highlighted

5