Mathematical Programming: Modelling and Applications Sonia Cafieri - - PowerPoint PPT Presentation

mathematical programming modelling and applications
SMART_READER_LITE
LIVE PREVIEW

Mathematical Programming: Modelling and Applications Sonia Cafieri - - PowerPoint PPT Presentation

Mathematical Programming: Modelling and Applications Sonia Cafieri LIX, cole Polytechnique cafieri@lix.polytechnique.fr October 2009 Ecole S. Cafieri (LIX) TD6 oct 2009 1 / 38 Outline Graphs - basic definitions 1 Densest subgraph


slide-1
SLIDE 1

Ecole

Mathematical Programming: Modelling and Applications

Sonia Cafieri LIX, École Polytechnique

cafieri@lix.polytechnique.fr

October 2009

  • S. Cafieri (LIX)

TD6

  • ct 2009

1 / 38

slide-2
SLIDE 2

Ecole

Outline

1

Graphs - basic definitions

2

Densest subgraph problem

3

Graph partitioning problem

4

Graph partitioning problem - 2 -

  • S. Cafieri (LIX)

TD6

  • ct 2009

2 / 38

slide-3
SLIDE 3

Ecole

Basic definitions

Definition

A Graph is an ordered pair G = (V, E) comprising a set V of vertices or nodes together with a set E of edges or links, which are 2-element subsets of V. Undirected graph: a graph in which edges have no orientation. Directed graph or Digraph: a graph G = (V, A), where A is a set of ordered pairs of vertices, even called arcs or directed edges. Weighted graph: a graph in which numbers (weights) are assigned to each edge. It can be directed and undirected. It is denoted by G = (V, E, w) or G = (V, A, w), where w represents the weights.

  • S. Cafieri (LIX)

TD6

  • ct 2009

3 / 38

slide-4
SLIDE 4

Ecole

Basic definitions

Let G = (V, A) be a directed graph. A function µ : A − → N, that associates an integer number to each arc of G, is called arc coloring of G. Since we can associate a color to each integer number, the function µ actually asso- ciates a color to each arc of G. Subgraphs of the graph G can be located by considering all its arcs having the same color: H = (U, B) : U ⊆ V, B ⊆ A, ∀e, f ∈ B µ(e) = µ(f).

  • S. Cafieri (LIX)

TD6

  • ct 2009

4 / 38

slide-5
SLIDE 5

Ecole

Densest subgraph problem

Given a digraph G = (V, A), an arc coloring µ of G, a color k, find the densest uniformly coloured subgraph H of G, i.e. the subgraph H = (U, B) of G in which the arcs have the same color k and such that |B| − |U| is maximun. Formulate a mathematical model and solve it by AMPL/CPLEX.

  • S. Cafieri (LIX)

TD6

  • ct 2009

5 / 38

slide-6
SLIDE 6

Ecole

Densest subgraph problem: data

15 vertices color k: 2 Edges: (1,15) (µ = 1), (2,15) (µ = 1), (2,3) (µ = 1), (2,4) (µ = 1), (3,5) (µ = 1), (4,5) (µ = 1), (5,6) (µ = 1), (5,11) (µ = 2), (5,12) (µ = 2), (5,13) (µ = 2), (5,14) (µ = 2), (6,9) (µ = 1), (7,8) (µ = 1), (7,11) (µ = 2), (7,12) (µ = 2), (7,13) (µ = 2), (7,14) (µ = 2), (7,15) (µ = 1), (8,10) (µ = 2), (8,14) (µ = 2), (11,12) (µ = 2), (11,13) (µ = 2), (12,13) (µ = 2)

  • S. Cafieri (LIX)

TD6

  • ct 2009

6 / 38

slide-7
SLIDE 7

Ecole

Mathematical formulation

Sets: V, set of vertices of G A, set of arcs of G Parameters: µ, arc coloring of graph G k, a prefixed arc color Variables: xv, binary, indicates if the vertex v is contained into the densest uniformly colored subgraph (U, B): ∀v ∈ V xv =

  • 1

if v ∈ U

  • therwise
  • S. Cafieri (LIX)

TD6

  • ct 2009

7 / 38

slide-8
SLIDE 8

Ecole

Mathematical model

Objective function: The densest subgraph has the maximum number of arcs and the minimum number of vertices: max  

(u,v)∈A

xuxv −

  • v∈V

xv   Constraint: There cannot be arcs in the subgraph having a color different from k: ∀(u, v) ∈ A xuxv ≤ min (max(0, µ(u, v) − k + 1), max(0, k − µ(u, v) + 1))

  • S. Cafieri (LIX)

TD6

  • ct 2009

8 / 38

slide-9
SLIDE 9

Ecole

Product of binary variables

Observation: we have a product of binary variables in the objective function. Because of the product of binary variables, this formulation is nonlinear: Mixed-Integer NonLinear problem. ⇓ Use a suitable reformulation for removing the product in the objective function.

  • S. Cafieri (LIX)

TD6

  • ct 2009

9 / 38

slide-10
SLIDE 10

Ecole

Mathematical model: product of binary variables

A new variable: yuv ∈ [0, 1], represents the product between xu and xv. Objective function updated: We substitute xuxv with yuv: max  

(u,v)∈A

yuv −

  • v∈V

xv  

  • S. Cafieri (LIX)

TD6

  • ct 2009

10 / 38

slide-11
SLIDE 11

Ecole

Mathematical model: product of binary variables

Constraint updated: We substitute xuxv with yuv: ∀(u, v) ∈ A yuv ≤ min (max(0, µ(u, v) − k + 1), max(0, k − µ(u, v) + 1)) New Linearization Constraints: ∀(u, v) ∈ A yuv ≤ xu ∀(u, v) ∈ A yuv ≤ xv ∀(u, v) ∈ A yuv ≥ xu + xv − 1

  • S. Cafieri (LIX)

TD6

  • ct 2009

11 / 38

slide-12
SLIDE 12

Ecole

Densest Subgraph problem: AMPL model

param n >= 1, integer; set V := 1..n; set E within {V,V}; # arc colours param kmax default 10; # max number of colours param k <= kmax, >= 0, integer, default 1; param mu{E} >=0, integer, <= kmax; # variables var x{V} binary; var y{(u,v) in E} >= 0, <= min(max(0, mu[u,v]-k+1), max(0,k-mu[u,v]+1)); # model maximize densesubgraph : sum{(u,v) in E} y[u,v] - sum{v in V} x[v]; # linearization constraints subject to lin1 {(u,v) in E} : y[u,v] <= x[u]; subject to lin2 {(u,v) in E} : y[u,v] <= x[v]; subject to lin3 {(u,v) in E} : y[u,v] >= x[u] + x[v] - 1;

  • S. Cafieri (LIX)

TD6

  • ct 2009

12 / 38

slide-13
SLIDE 13

Ecole

Densest Subgraph problem: AMPL data

param n := 15; # number of vertices param k := 2; # color param : E : mu := 1 15 1 2 15 1 2 3 1 2 4 1 3 5 1 4 5 1 5 6 1 5 11 2 5 12 2 5 13 2 5 14 2 6 9 1 7 8 1 7 11 2 7 12 2 7 13 2 7 14 2 7 15 1 8 10 1 8 14 2 11 12 2 11 13 2 12 13 2 ;

  • S. Cafieri (LIX)

TD6

  • ct 2009

13 / 38

slide-14
SLIDE 14

Ecole

Densest Subgraph problem: AMPL run

model densest_subgraph.mod; data densest_subgraph.dat;

  • ption solver cplex;

solve; display x;

  • S. Cafieri (LIX)

TD6

  • ct 2009

14 / 38

slide-15
SLIDE 15

Ecole

Densest Subgraph problem: Solution

ILOG AMPL 10.100, licensed to "ecolepolytechnique-palaiseau". AMPL Version 20060626 (Linux 2.6.9-5.ELsmp) ILOG CPLEX 10.100, licensed to "ecolepolytechnique-palaiseau", options: e m b q use=8 CPLEX 10.1.0: optimal integer solution; objective 5 12 MIP simplex iterations 0 branch-and-bound nodes x [*] := 1 2 3 4 5 1 6 7 1 8 9 10 11 1 12 1 13 1 14 1 15 ;

  • S. Cafieri (LIX)

TD6

  • ct 2009

15 / 38

slide-16
SLIDE 16

Ecole

Graph partitioning

Definition

Graph partitioning is the problem of finding a suitable partition of a set of data represented through a graph G. Graph partitioning is a clustering problem. Each cluster is a subgraph of the graph G. Intuitively, the best partition is the one that separates sparsely connected dense subgraphs from each other. sparsely connected: the number of edges between vertices belonging to different clusters is minimal. dense: the number of edges between vertices belonging to the same cluster is maximum.

  • S. Cafieri (LIX)

TD6

  • ct 2009

16 / 38

slide-17
SLIDE 17

Ecole

Graph partitioning: example

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77

  • S. Cafieri (LIX)

TD6

  • ct 2009

17 / 38

slide-18
SLIDE 18

Ecole

Graph partitioning problem

Given a weighted undirected graph G = (V, E, c), where V is the set of vertices of G, E is the set of edges of G, c is the set of weights eventually assigned to the edges, and an integer K ≤ |V|, find a partition of k ≤ K subsets (clusters) of V minimizing the total weights of edges between different clusters. Write the mathematical formulation and solve the problem using AMPL.

  • S. Cafieri (LIX)

TD6

  • ct 2009

18 / 38

slide-19
SLIDE 19

Ecole

Graph partitioning problem: data

16 vertices maximum number of clusters: 4 Edges: (1,15) (2,15) (2,3) (2,4) (3,5) (4,5) (5,6) (5,16) (6,9) (7,8) (7,16) (8,10) (8,16) (11,16) (12,16) (13,16) (14,16) Edge Weights: 1 for each edge

  • S. Cafieri (LIX)

TD6

  • ct 2009

19 / 38

slide-20
SLIDE 20

Ecole

Mathematical formulation

Sets: V, set of vertices of G E, set of edges of G Parameters: c, weights of G K, maximum number of clusters in the partition Variables: ∀u ∈ V, k ≤ K, xuk, binary, indicates if the vertex u is contained into the cluster k: xuk = 1 if u ∈ kth cluster

  • therwise
  • S. Cafieri (LIX)

TD6

  • ct 2009

20 / 38

slide-21
SLIDE 21

Ecole

Mathematical formulation

Objective function: what do we need to minimize? we want to minimize the total weights of the edges between different clusters: min

x

1 2

  • k=l≤K
  • (u,v)∈E

cuvxukxvl

  • S. Cafieri (LIX)

TD6

  • ct 2009

21 / 38

slide-22
SLIDE 22

Ecole

Mathematical formulation

Constraints:

  • each vertex must be assigned to only one cluster:

∀u ∈ V

  • k≤K

xuk = 1

  • the trivial solution (all the vertices into one cluster) must be excluded:

∀k ∈ K

  • u∈V

xuk ≥ 1

  • S. Cafieri (LIX)

TD6

  • ct 2009

22 / 38

slide-23
SLIDE 23

Ecole

Some observations

The objective function contains a product of binary terms. We introduce a new variable wukvl representing the product of the two binary variables. We substitute the products with the new variable wukvl everywhere, as for example in the objective function: min 1 2

  • k=l≤K
  • (u,v)∈E

cuvwukvl We add linearization constraints: ∀u ∈ V, v ∈ V, l ∈ K, k ∈ K : (u, v) ∈ E or (v, u) ∈ E wukvl ≤ xuk wukvl ≤ xvl wukvl ≥ xuk + xvl − 1

  • S. Cafieri (LIX)

TD6

  • ct 2009

23 / 38

slide-24
SLIDE 24

Ecole

Graph partitioning: AMPL model

param n >= 1, integer; # number of vertices set V := 1..n; set E within {V,V}; param c{E}; # edge weights param kmax; # max number of clusters set K := 1..kmax; var x{V,K} binary; # original problem variables var w{V,K,V,K} >= 0, <= 1; # linearization variables minimize intercluster : sum{k in K, l in K, (u,v) in E : k != l} c[u,v] * w[u,k,v,l]; # constraints subject to assignment {v in V} : sum{k in K} x[v,k] = 1; subject to existence {k in K} : sum{v in V} x[v,k] >= 1; # linearization constraints subject to lin1 {u in V, v in V, h in K, k in K : (u,v) in E or (v,u) in E} : w[u,h,v,k] <= x[u,h]; subject to lin2 {u in V, v in V, h in K, k in K : (u,v) in E or (v,u) in E} : w[u,h,v,k] <= x[v,k]; subject to lin3 {u in V, v in V, h in K, k in K : (u,v) in E or (v,u) in E} : w[u,h,v,k] >= x[u,h] + x[v,k] - 1;

  • S. Cafieri (LIX)

TD6

  • ct 2009

24 / 38

slide-25
SLIDE 25

Ecole

Graph partitioning: Solution

ILOG AMPL 11.010, licensed to "ecolepolytechnique-palaiseau". AMPL Version 20080219 (Linux 2.6.9-5.ELsmp) ILOG CPLEX 10.100, licensed to "ecolepolytechnique-palaiseau", options: e m b q use=1 CPLEX 10.1.0: optimal integer solution; objective 3 1850 MIP simplex iterations 149 branch-and-bound nodes x [*,*] : 1 2 3 4 := 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 ;

  • S. Cafieri (LIX)

TD6

  • ct 2009

25 / 38

slide-26
SLIDE 26

Ecole

Graph partitioning problem - 2 -

Given a weighted undirected graph G = (V, E, c), and an integer K ≤ |V|, find a partition of k ≤ K subsets (clusters) of V minimizing the total weights of edges between different clusters, such that: the clusters do not exceed a certain “balanced” cardinality C = ⌈ |V|

2 ⌉;

adjacent vertices with same colour must be clustered together. Write the mathematical formulation and solve the problem using AMPL.

  • S. Cafieri (LIX)

TD6

  • ct 2009

26 / 38

slide-27
SLIDE 27

Ecole

Mathematical formulation

Constraints to be added to the previous formulation:

  • each cluster cannot exceed a certain cardinality:

∀k ≤ K

  • u∈V

xuk ≤ C

  • vertices having different color cannot be clustered together:

∀u = v ∈ V, k = l ≤ K, xukxvl ≤ γuv where γuv is a new parameter defined as: ∀u, v ∈ V, u = v, γuv =

  • 1

if u and v havedifferentcolor

  • therwise
  • S. Cafieri (LIX)

TD6

  • ct 2009

27 / 38

slide-28
SLIDE 28

Ecole

Some observations

We need to impose a maximum cardinality C for the constraint: ∀k ≤ K

  • u∈V

xuk ≤ C One possible choice is: C = ⌈|V| 2 ⌉. Note that, in AMPL, we can write the constraint as:

subject to cardinality {k in K} : sum{v in V} x[v,k] <= ceil(card{V}/2);

  • S. Cafieri (LIX)

TD6

  • ct 2009

28 / 38

slide-29
SLIDE 29

Ecole

Some observations

We can allow the optimization process to determine the number of clusters actually

  • used. We can introduce the binary variable:

∀k ≤ K zk =

  • 1

if cluster k is not empty

  • therwise

We can change the second constraint to ∀k ≤ K

  • u∈V

xuk ≥ zk to ensure that a cluster that does not exist need not have any vertices assigned to it, and add the term

  • k≤K

zk to the objective function, thus ensuring that the maximum number of clusters should be empty.

  • S. Cafieri (LIX)

TD6

  • ct 2009

29 / 38

slide-30
SLIDE 30

Ecole

Graph partitioning: AMPL model (1/2)

param n >= 1, integer; # number of vertices set V := 1..n; set E within {V,V}; # edge weights param c{E}; # edge weights # vertex colours param lambda{V}; param gamma{u in V, v in V : u != v} := if (lambda[u] = lambda[v]) then 0 else 1; # max number of clusters param kmax; set K := 1..kmax; # original problem variables var x{V,K} binary; # linearization variables var w{V,K,V,K} >= 0, <= 1; # cluster existence variables var z{K} binary;

  • S. Cafieri (LIX)

TD6

  • ct 2009

30 / 38

slide-31
SLIDE 31

Ecole

Graph partitioning: AMPL mod (2/2)

minimize intercluster : sum{k in K, l in K, (u,v) in E : k != l} c[u,v] * w[u,k,v,l] + sum{k in K} z[k]; # constraints subject to assignment {v in V} : sum{k in K} x[v,k] = 1; subject to cardinality {k in K} : sum{v in V} x[v,k] <= ceil(card{V}/2); subject to existence {k in K} : sum{v in V} x[v,k] >= z[k]; subject to diffcolours {u in V, v in V, k in K, l in K : u != v and k != l} : w[u,k,v,l] <= gamma[u,v]; # linearization constraints subject to lin1 {u in V, v in V, h in K, k in K : (u,v) in E or (v,u) in E} : w[u,h,v,k] <= x[u,h]; subject to lin2 {u in V, v in V, h in K, k in K : (u,v) in E or (v,u) in E} : w[u,h,v,k] <= x[v,k]; subject to lin3 {u in V, v in V, h in K, k in K : (u,v) in E or (v,u) in E} : w[u,h,v,k] >= x[u,h] + x[v,k] - 1;

  • S. Cafieri (LIX)

TD6

  • ct 2009

31 / 38

slide-32
SLIDE 32

Ecole

Graph partitioning: AMPL dat

param n := 16; # number of vertices param kmax := 4; # max number of clusters param : E : c := 1 15 1 2 15 1 2 3 1 2 4 1 3 5 1 4 5 1 5 6 1 5 16 1 6 9 1 7 8 1 7 16 1 8 10 1 8 16 1 11 16 1 12 16 1 13 16 1 14 16 1 ;

  • S. Cafieri (LIX)

TD6

  • ct 2009

32 / 38

slide-33
SLIDE 33

Ecole

Graph partitioning: AMPL dat

param lambda := 1 1 2 2 3 3 4 3 5 2 6 2 7 2 8 2 9 1 10 1 11 4 12 4 13 4 14 4 15 1 16 4 ;

  • S. Cafieri (LIX)

TD6

  • ct 2009

33 / 38

slide-34
SLIDE 34

Ecole

Graph partitioning: AMPL run

model clustering.mod; data random.dat; # solver:

  • ption solver cplex;

# solving the problem solve; # printing the result display x;

  • S. Cafieri (LIX)

TD6

  • ct 2009

34 / 38

slide-35
SLIDE 35

Ecole

Graph partitioning: Solution

ILOG AMPL 11.010, licensed to "ecolepolytechnique-palaiseau". AMPL Version 20080219 (Linux 2.6.9-5.ELsmp) ILOG CPLEX 10.100, licensed to "ecolepolytechnique-palaiseau", options: e m b q use=1 CPLEX 10.1.0: optimal integer solution; objective 1 65 MIP simplex iterations 0 branch-and-bound nodes x [*,*] : 1 2 3 4 := 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 ;

  • S. Cafieri (LIX)

TD6

  • ct 2009

35 / 38

slide-36
SLIDE 36

Ecole

Graph partitioning: data

This is a random graph.

  • S. Cafieri (LIX)

TD6

  • ct 2009

36 / 38

slide-37
SLIDE 37

Ecole

Graph partitioning: AMPL dat

param n := 10; # number of vertices param kmax := 2 # max number of clusters param : E : c := 4 9 1 6 10 1 7 10 1 2 8 1 8 7 1 2 5 1 2 9 1 9 10 1 4 1 1 5 3 1 6 5 1 4 6 1 ; param lambda := 1 1 2 2 ...... 10 10 ;

  • S. Cafieri (LIX)

TD6

  • ct 2009

37 / 38

slide-38
SLIDE 38

Ecole

Graph partitioning: Solution

  • S. Cafieri (LIX)

TD6

  • ct 2009

38 / 38