Top Banner
1 24 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel
33

124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

Dec 14, 2015

Download

Documents

Arnold Marson
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

1 24

Modeling Patterns for LocalSolver

T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel

Page 2: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

2 24

Who we are

Large industrial group with businesses in construction, telecom, media

Operation Research subsidiary of the Bouygues group

Flagship productof Innovation 24

www.bouygues.com

www.innovation24.fr

www.localsolver.com

Page 3: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

3 24

LocalSolver in one slide

Select a set S of P cities among NMinimizing the sum of distances from each city to the closest city in S

function model() { x[1..N] <- bool(); constraint sum[i in 1..N] (x[i]) == P;

minDistance[i in 1..N] <- min[j in 1..N] (x[j] ? distance[i][j] : +inf); minimize sum[i in 1..N] (minDistance[i]); }

Results on the OR Library• 28 optimal solutions on the 40 instances

of the OR Lib• an average gap of 0.6%• with 1 minute per instance

Page 4: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

4 24

LocalSolver in one slide

function model() { x[1..N] <- bool(); constraint sum[i in 1..N] (x[i]) == P;

minDistance[i in 1..N] <- min[j in 1..N] (x[j] ? distance[i][j] : +inf); minimize sum[i in 1..N] (minDistance[i]); }

Select a set S of P cities among NMinimizing the sum of distances from each city to the closest city in S

Results on the OR Library• 28 optimal solutions on the 40 instances

of the OR Lib• an average gap of 0.6%• with 1 minute per instance

Page 5: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

5 24

LocalSolver in one slide

function model() { x[1..N] <- bool(); constraint sum[i in 1..N] (x[i]) == P;

minDistance[i in 1..N] <- min[j in 1..N] (x[j] ? distance[i][j] : +inf); minimize sum[i in 1..N] (minDistance[i]); }

Select a set S of P cities among NMinimizing the sum of distances from each city to the closest city in S

Results on the OR Library• 28 optimal solutions on the 40 instances

of the OR Lib• an average gap of 0.6%• with 1 minute per instance

An hybrid math programming solver

For large-scale mixed-variable non-convex optimization problems

Providing high-quality solutionsin short running timewithout any tuning

Page 6: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

6 24

Outline

LocalSolver Modeling Patterns for Local Search ? Six Modeling Patterns

Page 7: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

7 24

Modeling Patterns for LocalSolver

Why ?

Page 8: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

8 24

Modeling patterns ?

A classic topic in MIP or CP

Very little literature on modeling for Local Search… …because of the absence of model-and-run solver models and algorithms were designed together and not always clearly separated

Page 9: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

9 24

Modeling Pattern #1Choose the right set of decision variables

Page 10: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

10 24

Choose the right set of decision variables

function model() { x[1..N] <- bool(); constraint sum[i in 1..N] (x[i]) == P;

minDistance[i in 1..N] <- min[j in 1..N] (x[j] ? distance[i][j] : +inf); minimize sum[i in 1..N] (minDistance[i]); }

Select a set S of P cities among NMinimizing the sum of distances from each city to the closest city in S

Results on the OR Library• 28 optimal solutions on the 40 instances

of the OR Lib• an average gap of 0.6%• with 1 minute per instance

Page 11: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

11 24

Modeling Pattern #2Precompute what can be precomputed

Page 12: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

12 24

Precompute what can be precomputed

Document processing : dans un tableau une case de texte a plusieurs configurations hauteur x largeur possibles.

Comment choisir la configurations de chaque case de façon à minimiser la hauteur du tableau (sa largeur étant limitée) ?

29 x 8234x 61

45x 43

LocalSolver : mathematical programming by local search

LocalSolver : mathematical programming

by local search

LocalSolver :

mathematical

programming by local

search

Page 13: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

13 24

Precompute what can be precomputed

Première modélisation : 1 variable de décision par configuration (largeur, hauteur) possible pour chaque cellule

Formulation étendue :• On remarque qu’à partir de la largeur d’une colonne on peut déterminer la hauteur

minimum de chacune de ses cellules.• 1 variable de décision par largeur possible pour chaque colonne• Conséquence : en changeant une variable de décision, LocalSolver va changer la

hauteur et la largeur de toutes les cellules dans la colonne

-> R. Megel (Roadef 2013). Modélisations LocalSolver de type « génération de

colonnes » .

Page 14: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

14 24

Modeling Pattern #3Do not limit yourself to linear operators

Page 15: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

15 24

Do not limit yourself to linear operators

TRAVELING SALESMAN PROBLEM MIP approach: Xij=1 if city j is after city i in the tour

• Matching constraints and • Plus an exponential number of subtour elimination constraints• Minimize

Polynomial non-linear model: : Xik=1 if city i is in position k i in the tour

• Matching constraints and • the index of the kth city of the tour• Minimize

“at” operator

TSP Lib: average gap after 10mn = 2.6%

Page 16: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

16 24

Modeling Pattern #4Separate commands and effects

Page 17: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

17 24

Separate commands and effects Multi-skill workforce scheduling

Candidate modelSkillatk= 1 agent a works on skill k at timestep tConstraint SUMk (Skillatk) <= 1Constraint ORk (Skillatk) == (t [Starta, Enda[ )

Problem: any change of Starta will be rejected unless skills are updated for all impacted timesteps

Agent 1

Agent 2

Agent 3

Agent 4

8h 9h 10h 11h 12h 13h 14h 15h 16h 17h 18h 19h 20h

Page 18: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

18 24

Separate commands and effects Multi-skill workforce scheduling

Agent 1

Agent 2

Agent 3

Agent 4

Alternative modelSkillReadyatk= 1 agent a will works on skill k at timestep t if presentConstraint SUMk (SkillReadyatk) == 1Skillatk AND(SkillReadyatk , t [Starta, Enda[)

Now we have no constraint between skills and worked hours-> for any change of Starta skills are automatically updated

8h 9h 10h 11h 12h 13h 14h 15h 16h 17h 18h 19h 20h

Page 19: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

19 24

Separate commands and effects

Similar case: Unit Commitment Problems• A generator is active or not, but when active the production is in [Pmin, Pmax]

• Better modeled without any constraint

ProdReadygt float(Pmin,Pmax) Activegt bool()Prodgt Activegt ProdReadygt

Page 20: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

20 24

Modeling Pattern #5Invert constraints and objectives ?

Page 21: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

21 24

Invert constraints and objectives

Clément Pajean

Modèle LocalSolver d'ordonnancement d'une machine unique sous contraintes de Bin Packing

Vendredi 28

14h Bât B TD 35

Page 22: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

22 24

Modeling Pattern #6Use dominance properties

Page 23: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

23 24

Use dominance properties

Batch scheduling for N jobs having the same due date D.

Completion time of each job will be that of the batch selected for this job

Linear late or early cost (k k)

Date variable for each batch+ assignment of jobs to batches+ Precedence constraints

Basic Model

Batch 1 Batch 2Batch 3 Batch 4 Batch 5

D

Only one starting date variable + assignment of jobs to batches

No idle time

Batch 1 Batch 2 Batch 3Batch 4Batch 5

D

We can minimize a minimum

As if starting date was automatically adjusted after each move

No start date variable+ assignment of jobs to batches+ penalty[k] if due date at the end of batch kMinimize min[k in 1..5](penalty[k])

Optimal start will position due date at the end of a batch

Batch 1 Batch 2 Batch 3Batch 4Batch 5

Page 24: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

24 24

Summary

1. Choose the right set of decision variables

2. Precompute what can be precomputed

3. Do not limit yourself to linear operators

4. Separate commands and effects

5. Invert constraints and objectives ?

6. Use dominance properties

Page 25: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

25 24

Modeling Pattern #7Your turn!

Page 26: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

26 24

Why solving a TSP with LocalSolver ?

With function of A,B and T

Kinetic TSP

Page 27: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

27 24

Industrial « Bin-packing » Assignment of steel orders to «  slabs » whose capacity can take only 5 different values

Choose the right set of decision variables

Xij= 1 Order i is assigned to slab j

Model

Slabs

Yjk= 1 Slab j takes capacity k

Minimize total size of slabs

Page 28: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

28 24

Choose the right set of decision variables

Change

Ejection chain

Exchange

Slabs

Industrial « Bin-packing » Assignment of steel orders to «  slabs » whose capacity can take only 5 different values

Xij= 1 Order i is assigned to slab j

Model Yjk= 1 Slab j takes capacity k

In a good model:• when a value can be computed from others it is defined with operator

<- (it is an intermediate variable )• moving from a feasible solution to another feasible solution only

requires modifying a small number of decision variables.

Page 29: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

29 24

Choose the right set of decision variables

Change

Ejection chain

Exchange

Slabs

Industrial « Bin-packing » Assignment of steel orders to «  slabs » whose capacity can take only 5 different values

Xij= 1 Order i is assigned to slab j

Model Capak MinCapa[contentk]

“at” operator

Page 30: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

30 24

Modeling patterns for Mixed-Integer Programming

• MIP requires linearizing non linear structures of the problem

• The polyhedron should be kept as close as possible to the convex hull -> valid inequalities, cuts, and so on

• Symmetries should be avoided (or not…)

Page 31: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

31 24

Modeling patterns for constraint programming

Choice of variables (integer, set variables, continuous…) Choice of (global) constraints Redundant constraints Double point of view (with channeling constraints) And so on

Page 32: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

32 24

Modeling patterns for Local Search ?

Very little literature on this topic… …because of the absence of model-and-run solver models and algorithms were designed together and not always clearly separated

Page 33: 124 Modeling Patterns for LocalSolver T. Benoist, J. Darlay, B. Estellon, F. Gardi, R. Megel.

www.localsolver.com

1/18