hybridisation solver cooperation in eclipse. 2 introduction motivation sending constraints to...

46
Hybridisation Solver Cooperation in ECLiPSe

Upload: abraham-meggison

Post on 14-Dec-2015

226 views

Category:

Documents


7 download

TRANSCRIPT

Page 1: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

Hybridisation

Solver Cooperation in ECLiPSe

Page 2: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

2

Introduction

Motivation Sending Constraints to Different Solvers Probing Column Generation

Motivation Sending Constraints to Different Solvers Probing Column Generation

Page 3: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

3

Why Use Multiple Solvers?

Real problems comprise different subproblemsDifferent solvers/algorithms suit different subproblems

Global reasoning can be achieved in different waysLinear solvers reason globally on linear constraintsDomain solvers support application-specific global constraints

Solvers complement each otherOptimisation versus feasibilityNew and adapted forms of cooperation

(e.g. Linear relaxation as a heuristic)

Growing experienceIC-Parc, CMU, Bologna, Bouygues, ILOG…see CPAIOR

Page 4: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

4

How to Use Multiple Solvers

Problem DecompositionSend subproblem constraints to subproblem solver

e.g. Continuous/discrete circuits; Process scheduling

Redundant SolvingSend a constraint to more than one solver

e.g. Hoist scheduling; Progressive Party Problem

Page 5: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

5

Hybridising ic and eplex

Local propagatione.g. interval propagationmore general constraintshandle integers directlyFavourable example:

Variable Bounds:

[X1,…,X100] :: 1..100

Previous Constraints:

X1 < X2 , … , X98 < X99

Resulting Bounds:

X1 :: 1..2, …, X99 :: 99..100

New Constraint:

X1 >= 3

Result (1 step): failure!

Local propagatione.g. interval propagationmore general constraintshandle integers directlyFavourable example:

Variable Bounds:

[X1,…,X100] :: 1..100

Previous Constraints:

X1 < X2 , … , X98 < X99

Resulting Bounds:

X1 :: 1..2, …, X99 :: 99..100

New Constraint:

X1 >= 3

Result (1 step): failure!

Global algorithmic solvinge.g. Simplex, Gaussrestricted class of constraintsfinds optimum without searchFavourable example:

Variable Bounds:[X1,X2] :: 1..100

New Constraints:X1 > X2, X2 > X1

Result (1 step): failure!

Global algorithmic solvinge.g. Simplex, Gaussrestricted class of constraintsfinds optimum without searchFavourable example:

Variable Bounds:[X1,X2] :: 1..100

New Constraints:X1 > X2, X2 > X1

Result (1 step): failure!

Page 6: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

6

Hybridising ic and eplex

ic?- ic:(X=\=Y)

eplex?- eplex:(X>=3)

Redundant?- [ic,eplex]:(X>=3), ic:(X=\=Y)

Page 7: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

7

Techniques

Shared Variables Linear constraints to ic and eplex Reduced cost propagation Other methods (Milano tutorial)

Page 8: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

8

Introduction

Motivation Sending Constraints to Different Solvers Probing Column Generation

Motivation Sending Constraints to Different Solvers Probing Column Generation

Page 9: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

9

Constraint Setup - Multiple Solvers

Solver 2e.g.simplex

Conceptual Modelarbitrary constraints

Conceptual Modelarbitrary constraints

Mapping & Filteringe.g eliminating disjunctionsignore nonlinear constraints

Solver Model 2e.g. linear

Solver Model 2e.g. linear

Solver 1e.g.

intervals

Solver Model 1e.g. nonlinear

Solver Model 1e.g. nonlinear

Mapping & Filteringe.g. break up into components

Page 10: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

10

Example: Scheduling

Three tasks and a time pointtask1,task2,task3, time1

Exactly one of task1 and task2 overlap time1Disjunctive (non-linear) – send to ic

Both task1 and task2 precede task3Linear – send to eplex

time1

task1

task2task3

Page 11: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

11

Encoding Overlap in IC with Booleans

Each task has start time and duration.A task with Start and Duration overlaps Time if

overlap(Start,Duration,Time,Bool) :- ic:(Bool =:= (Time>=Start and Time<Start+Duration)).

Exactly one task overlaps Time:

one_overlap(Time,S1,S2) :-ic:( overlap(S1,3,Time) #\= overlap(S2,5,Time) ).

Page 12: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

12

Encoding Precedence with eplex

A task with Start1 and Duration1 precedes a task with Start2 if:

before(Start1,Duration1,Start2) :-eplex:(Start1+Duration1 =< Start2).

Assuming task1 has duration 3 and task2 duration 5:

eplex_cons(Start1,Start2,Start3) :-before(Start1,3,Start3),before(Start2,5,Start3).

Page 13: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

13

Using IC for intervals in eplex

bounds are `passive’ in eplex: solving only update cost bound ic’s domain may have holes, but eplex sees only the lower and upper

bounds. change in ic bounds transferred to eplex via:

explicit posting of bounds: [ic,eplex]:(X>=3) import all ic bounds when eplex is triggered selected transfer of ic bounds suspend(ic_to_eplex_bounds(X,S), 7,[X->ic:min,X->ic:max], S),

:- demon ic_to_eplex_bounds/3.ic_to_eplex_bounds(V, S) :- var(V), ic: get_bounds(V, Min, Max), eplex: (V:: Min..Max).ic_to_eplex_bounds(V, S) :- nonvar(V), kill_suspension(S).

Page 14: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

15

A Simple Hybrid Algorithm

:- lib(ic), lib(eplex).hybrid(Time,[S1,S2,S3],S3) :-

[S1,S2,S3]::1..10,one_overlap(Time,S1,S2),eplex_cons(S1,S2,S3),eplex:eplex_solver_setup(min(S3),S3,[sync_bounds(yes)],

[ic:(min of ic), ic:(max of ic)]),labeling([S1,S2,S3]).

Note• Variable bounds are seen by both solvers• eplex solver runs whenever bounds change

?- hybrid(3, S, E).S = [1, 4, 9]

E = E{8.999999 .. 1.0Inf}

Page 15: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

16

Control Flow with Multiple Solvers

Search/Choice

Solver phase withcommunication

Solver1

Solver2

Search/Choice

Page 16: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

17

Eplex instance as compound constraint

X1 X2 ... Xm

=

=<

>=

= Cost

c1

c2

cn

Obj

solver

setup

ExternalSolver

When solver is triggered:

• solver’s variable bounds get updated

• new constraints get added

• solver is run

• cost bound (or failure) is exported

• solution values are exported and ECLiPSe variables annotated (optional)

Page 17: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

18

A Hybrid Algorithm

Set up constraints

Make choices in ECLiPSe codeprogrammer specified variable/value choices

Apply interval propagation, e.g. lib(ic)Narrowed BoundsEmpty intervalsInstantiated integers

Solve the continuous relaxation with SimplexGlobal Consistency (of continuous relaxation)Lower bound on cost“Suggested values” (optimising continuous relaxation)

Set up constraints

Make choices in ECLiPSe codeprogrammer specified variable/value choices

Apply interval propagation, e.g. lib(ic)Narrowed BoundsEmpty intervalsInstantiated integers

Solve the continuous relaxation with SimplexGlobal Consistency (of continuous relaxation)Lower bound on cost“Suggested values” (optimising continuous relaxation)

Page 18: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

19

Optimisation

eplex optimises linear relaxation at each waking Opt bound tightened by eplex B&B minimize only labels discrete variables

:- lib(branch_and_bound).hybrid_opt(Search,ObjFun,Opt) :-

eplex_solver_setup(ObjFun,Opt,[sync_bounds(yes)], [ic:(min of ic), ic:(max of ic)]),minimize(Search,Opt).

Page 19: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

20

Hybrid Optimisation

ic constraintseplex constraints

no eplex:integers/1 constraints!

labeling(Vars) :-

( foreach(X, Vars) do

indomain(X)

).

% choice, ic-propagation (automatic)

% simplex solving if necessary (automatic)

% cost bound applied (automatic)

:- lib(ic), lib(eplex).hybrid(Time,[S1,S2,S3],End) :-

ic:([S1,S2,S3]::1..20),one_overlap(Time,S1,S2,B1,B2),eplex_cons(S1,S2,S3),List = [B1,B2,S1,S2,S3],hybrid_opt(labeling(List),min(S3),End).

Page 20: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

36

Introduction

Motivation Sending Constraints to Different Solvers Linearising Logical Constraints Probing Column Generation

Motivation Sending Constraints to Different Solvers Linearising Logical Constraints Probing Column Generation

Page 21: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

37

T2 T3 T4 T5

The Bridge Scheduling Problem

T1

M1 M2 M3 M4 M5 M6

B1S1

B2S2

B3S3

B4S4

B5S5

B6S6

P1 P2

A1

A2A3 A4 A5

A6

Page 22: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

38

Temporal constraints on the Schedule

Precedencebefore(Start1,Duration1,Start2)

Maximal delaybefore(Start2,-Delay,Start1)

Minimize Perturbation

Precedencebefore(Start1,Duration1,Start2)

Maximal delaybefore(Start2,-Delay,Start1)

Minimize Perturbation

before(Start1,Duration1,Start2) :- Start1 + Duration1 #=< Start2

Page 23: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

39

Resource Constraints

Start End

Machine

Tasks

T1

T2

T3

T4

T5

Start of T1

overlap(S1,S2,D2,B12) :- B12 tent_is (S1>=S2 and S1=<S2+D2).

Resource usage at start of T1:

1 + B12 + B13 + B14 + B15

Resource Limit

Page 24: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

40

Probing

Send temporal constraints to eplex Set tentative values to eplex solution Propagate tentative values Identify bottleneck (maximum overlap) Add precedence constraint on two bottleneck tasks

Page 25: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

41

eplex Setting Tentative Values

eplex_to_tent(Expr,Opt) :- Trig=[new_constraint,post(set_ans_to_tent)], eplex_solver_setup(Expr,Opt,[],0,Trig).

set_ans_to_tent :- eplex_get(vars,Vars), eplex_get(typed_solution,Solution), Vars tent_get Solution.

Page 26: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

42

Exercise: Job Shop

1Job1: 4 4

4 4

1

1 1Job2:

Page 27: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

43

Weak Cooperation

?- overlap(S, 3, T, B1), B1 = 1.S1 = S1{1.0 .. 4.0}B1 = 1There are 2 delayed goals:ic:(T>=S)ic:(S+3>T)

Once the boolean variable has been labelled to 1, the constraints are linear, but they are not posted to eplex

Page 28: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

44

Exercise

overlap(Start,Duration,Time,Bool) :-

ic:(Bool =:=

(Time>=Start and Time<Start+Duration)).

Extend ‘overlap’ so that when the boolean

variable is instantiated, the right inequality

is sent to eplex

Page 29: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

45

Exercise

solve(List,Opt) :-

List=[S1,S2,S3,S4,S5,S6,S7,S8],

eplex:integers(List),

setup(List,End),

eplex_to_tent(min(End),Opt),

minimize((repair,eplex_get(cost,Opt)),Opt).

:- lib(repair).

:- lib(eplex).

:- lib(branch_and_bound).

Page 30: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

46

Problem Constraintssetup([S1,S2,S3,S4,S5,S6,S7,S8],End) :-

init([S1,S2,S3,S4,S5,S6,S7,S8,End]),

follows(S2,S1,1),

follows(S3,S2,4),

follows(S4,S3,4),

follows(End,S4,1),

follows(S6,S5,4),

follows(S7,S6,1),

follows(S8,S7,1),

follows(End,S8,4),

cons_nolap(S1,1,S5,4),

cons_nolap(S2,4,S6,1),

cons_nolap(S3,4,S7,1),

cons_nolap(S4,1,S8,4).

init(List) :-

(foreach(X,List)

do

X tent_set 0,

eplex: (X>=0),

).

Page 31: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

47

Solution

cons_nolap(S1,D1,S2,D2) :-

nolap(S1,D1,S2,D2) r_conflict cs-eplex_nolap(S1,D1,S2,D2).

nolap(S1,D1,S2,D2) :-

S2 >= S1+D1 ; S1 >= S2+D2.

eplex_nolap(S1,D1,S2,_) :- eplex: (S2 >= S1+D1).

eplex_nolap(S1,_,S2,D2) :- eplex: (S1 >= S2+D2).

follows(Time,S,D) :- eplex: (Time >= S+D).

repair :-

conflict_constraints(cs,List),

(member(Goal,List) ->

call(Goal), repair

;

true

).

Page 32: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

48

Introduction

Motivation Sending Constraints to Different Solvers Linearising Logical Constraints Probing Column Generation

Motivation Sending Constraints to Different Solvers Linearising Logical Constraints Probing Column Generation

Page 33: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

49

Objectives

DeviseHybrid techniques

Encapsulate Mystifying techniques

Apply To practical problems in IP and transport

Page 34: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

50

Decomposing Hybrid Problems

Full problem

CP and MP constraints

?

3

2

4

5

1

Solve CP

subproblems

1

3

4

2

Solve MP

master problem

Page 35: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

51

Hybrids between CP and MP

CP hybridsFlat structure

MP solver as global CP constraint

Exclude infeasible values from variable domains

MP hybridsHierarchical structure

MP solver for master problem

CP solver for subproblems

Pass information inferred from optimal solutions

Page 36: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

52

Encapsulation

User identifies subproblemsSeparate solvers associated with master and subproblems

Communication of solution information between solvers handled automatically

Iteration and stopping criteria handled automatically

Available as an ECLiPSe Library

Page 37: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

53

Applications

Minimal Perturbation SchedulingApplication to airline scheduling

Patrol AssignmentApplication to emergency services

Backup Route GenerationApplication to current internet technology

Primary and Secondary Path AssignmentApplication to next generation internet technology

Page 38: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

54

Column Generation (1)

We can instead decompose a problem into a Master Problem and Subproblems

The Subproblems find solutions to subsets of the constraints

The Master Problem finds an optimum combination of those solutions (termed “columns”)

Page 39: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

55

Example: The Multiple Vehicle Routing Problem

SubproblemV

Create a “good” tour for vehicle V

Master ProblemSelect an optimal set of tours that cover the required

locations

Page 40: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

56

Column Generation for MVRP

Subproblem can be solved by any appropriate technique e.g. we use ic for MVRP subproblems

The subproblem solver is independent of column generation - only a cost vector is needed for the interface

Subproblem can be solved by any appropriate technique e.g. we use ic for MVRP subproblems

The subproblem solver is independent of column generation - only a cost vector is needed for the interface

Page 41: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

57

Column Generation - Details

Choice of initial column set impacts performance Column management can become an issue For integer problems we must perform column

generation within each node of a branch-and-bound tree

Branching alters the subproblems

Page 42: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

58

The colgen Library (1)

colgen_instance(+Name) Post constraints to instances:

Name:Expr =:= B

Name:Expr >= B

Name:Expr =< B

Expr linear expressions as for eplex but may also containimplicit_sum(-Var)

This term will be instantiated during problem solution to the sum of the master problem variables in the optimal solution

Name:minimize(SubProblem, Obj)

Page 43: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

59

The colgen Library (2)

Subproblems constraints posted separately by user User writes subproblem solution predicate

SolveSubProblem(+SPStruct, -Args, …)

SPStruct is a special structure:

sp_prob with [ master_pool, cost, coeff_vars, cutoff, module ],

Initial column set can be specified Name:cg_subproblem_solution(+SPSol)

SPSol is a special structure:

sp_sol(cost, coeff_vars, aux)

Page 44: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

60

Example: The Multiple Vehicle Routing Problem

colgen_instance(mvrp)

For each job J:mvrp:(implicit_sum(J))=:=1)

For each vehicle P:mvrp:(implicit_sum(P))=:=1)

mvrp:minimize(sp(Patrol, Jobs,Cost), implicit_sum(Cost)))

Page 45: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

61

The colgen Library: Summary

ECLiPSe library for decomposition and solution of partially linear problems

Arbitrary subproblem constraints and solution method

Best-first search Arbitrary branching schemes defined by user (or

there will be)

Page 46: Hybridisation Solver Cooperation in ECLiPSe. 2 Introduction  Motivation  Sending Constraints to Different Solvers  Probing  Column Generation  Motivation

62

See Also

CPAIOR School proceedings Milano Tutorial Le Pape / Wallace Tutorial CP Proceedings

Column Generation

Benders Decomposition