Download presentation

Presentation is loading. Please wait.

Published byAbraham Meggison Modified over 2 years ago

1
Hybridisation Solver Cooperation in ECLiPSe

2
2 Introduction Motivation Sending Constraints to Different Solvers Probing Column Generation Motivation Sending Constraints to Different Solvers Probing Column Generation

3
3 Why Use Multiple Solvers? Real problems comprise different subproblems Different solvers/algorithms suit different subproblems Global reasoning can be achieved in different ways Linear solvers reason globally on linear constraints Domain solvers support application-specific global constraints Solvers complement each other Optimisation versus feasibility New and adapted forms of cooperation (e.g. Linear relaxation as a heuristic) Growing experience IC-Parc, CMU, Bologna, Bouygues, ILOG…see CPAIOR

4
4 How to Use Multiple Solvers Problem Decomposition Send subproblem constraints to subproblem solver e.g. Continuous/discrete circuits; Process scheduling Redundant Solving Send a constraint to more than one solver e.g. Hoist scheduling; Progressive Party Problem

5
5 Hybridising ic and eplex Local propagation e.g. interval propagation more general constraints handle integers directly Favourable example: Variable Bounds: [X 1,…,X 100 ] :: 1..100 Previous Constraints: X 1 < X 2, …, X 98 < X 99 Resulting Bounds: X 1 :: 1..2, …, X 99 :: 99..100 New Constraint: X 1 >= 3 Result (1 step): failure! Local propagation e.g. interval propagation more general constraints handle integers directly Favourable example: Variable Bounds: [X 1,…,X 100 ] :: 1..100 Previous Constraints: X 1 < X 2, …, X 98 < X 99 Resulting Bounds: X 1 :: 1..2, …, X 99 :: 99..100 New Constraint: X 1 >= 3 Result (1 step): failure! Global algorithmic solving e.g. Simplex, Gauss restricted class of constraints finds optimum without search Favourable example: Variable Bounds: [X 1,X 2 ] :: 1..100 New Constraints: X 1 > X 2, X 2 > X 1 Result (1 step): failure! Global algorithmic solving e.g. Simplex, Gauss restricted class of constraints finds optimum without search Favourable example: Variable Bounds: [X 1,X 2 ] :: 1..100 New Constraints: X 1 > X 2, X 2 > X 1 Result (1 step): failure!

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

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

8
8 Introduction Motivation Sending Constraints to Different Solvers Probing Column Generation Motivation Sending Constraints to Different Solvers Probing Column Generation

9
9 Constraint Setup - Multiple Solvers Solver 2 e.g.simplex Conceptual Model arbitrary constraints Conceptual Model arbitrary constraints Mapping & Filtering e.g eliminating disjunctions ignore nonlinear constraints Solver Model 2 e.g. linear Solver Model 2 e.g. linear Solver 1 e.g. intervals Solver Model 1 e.g. nonlinear Solver Model 1 e.g. nonlinear Mapping & Filtering e.g. break up into components

10
10 Example: Scheduling Three tasks and a time point task1,task2,task3, time1 Exactly one of task1 and task2 overlap time1 Disjunctive (non-linear) – send to ic Both task1 and task2 precede task3 Linear – send to eplex time1 task1 task2 task3

11
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

12
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).

13
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).

14
14 Communication IC - Eplex eplex_solver_setup(Objective, Cost, % impose cost bound in generic way [sync_bounds(yes)], % import all bounds before solving [ic:(min of ic), % trigger on ic bound changes ic:(max of ic)] ) trigger solver import var bounds export cost bound ICEplex

15
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}

16
16 Control Flow with Multiple Solvers Search/Choice Solver phase with communication Solver 1 Solver 2 Search/Choice

17
17 Eplex instance as compound constraint X 1 X 2... X m = =< >= =Cost c1c1 c2 cncn Obj solver setup External Solver 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)

18
18 A Hybrid Algorithm Set up constraints Make choices in ECLiPSe code programmer specified variable/value choices Apply interval propagation, e.g. lib(ic) Narrowed Bounds Empty intervals Instantiated integers Solve the continuous relaxation with Simplex Global Consistency (of continuous relaxation) Lower bound on cost “Suggested values” (optimising continuous relaxation) Set up constraints Make choices in ECLiPSe code programmer specified variable/value choices Apply interval propagation, e.g. lib(ic) Narrowed Bounds Empty intervals Instantiated integers Solve the continuous relaxation with Simplex Global Consistency (of continuous relaxation) Lower bound on cost “Suggested values” (optimising continuous relaxation)

19
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).

20
20 Hybrid Optimisation ic constraints eplex 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).

21
21 Common Arithmetic Solver Interface $::/2 $=/2, =:=/2 $>=/2, >=/2 $=/2, >/2 $=/2, #>/2 #=
{
"@context": "http://schema.org",
"@type": "ImageObject",
"contentUrl": "http://images.slideplayer.com/12/3408107/slides/slide_21.jpg",
"name": "21 Common Arithmetic Solver Interface $::/2 $=/2, =:=/2 $>=/2, >=/2 $=/2, >/2 $=/2, #>/2 #==/2, >=/2 $=/2, >/2 $=/2, #>/2 #=

22
22 Introduction Motivation Sending Constraints to Different Solvers Reduced Costs Motivation Sending Constraints to Different Solvers Reduced Costs

23
23 Weak Cooperation ?- overlap(S, 3, T, B1), B1 = 1. S1 = S1{1.0.. 4.0} B1 = 1 There 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

24
24 Transform Logical Reification into BigM Bool =:= (Time>=Start and Time

25
25 Tighter Integration As soon as non-linear constraints become linear, send them to eplex pos_overlap(Start,Dur,Time,B) :- Max1 is maxdiff(Start,Time), Max2 is maxdiff(Time,Start+Dur), eplex:(Time+(1-B)*Max1 >= Start), eplex:(Time < Start+Dur+(1-B)*Max2). As soon as B=1, the eplex constraint enforces overlap.

26
26 Tighter Cooperation eplex_cons([S1,S2,S3]) :- before(S1,3,S3), before(S2,5,S3). eplex_cons(T,[S1,S2,S3],Bools) :- Bools=[B1,B2,N1B1,N2B1,N1B2,N2B2], before(S1,3,S3), before(S2,5,S3), pos_overlap(S1,3,T,B1), neg_overlap(S1,3,T,N1B1,N2B1), eplex:(N1B1+N2B1 =:= 1-B1), pos_overlap(S2,5,T,B2), neg_overlap(S2,5,T,N1B2,N2B2), eplex:(N1B2+N2B2 =:= 1-B2), eplex:(B1+B2=:=1).

27
27 Impact on handling of disjunctions Goal ?- [S1,S2]::0..4, [B1,B2]::0..1, B1+B2=:=1, neg_overlap(S1,5,S2,B1,B2). MIP handling: solve continuous relaxation: S1=0, S2=0, B1=0.8, B2=0.2 then branch on B: B1=1 ; B2=0 Interval propagation: reasoning on bounds gives: S1::1..4,S2::0..3,B1=1, B2=0 no search! Goal ?- [S1,S2]::0..4, [B1,B2]::0..1, B1+B2=:=1, neg_overlap(S1,5,S2,B1,B2). MIP handling: solve continuous relaxation: S1=0, S2=0, B1=0.8, B2=0.2 then branch on B: B1=1 ; B2=0 Interval propagation: reasoning on bounds gives: S1::1..4,S2::0..3,B1=1, B2=0 no search!

28
28 Non-hybrid Optimisation :- lib(eplex). hybrid(Time,Starts,End) :- eplex_cons(Time,Starts,Bools), eplex:(Starts::1..20), eplex:(Bools::0..1), eplex:integers(Starts), eplex:integers(Bools), eplex_solver_setup(min(S3)), eplex_solve(End). All integer/linear constraints sent to eplex

29
29 Hybrid Optimisation :- lib(eplex), lib(ic), lib(branch_and_bound). hybrid(Time,Starts,End) :- Starts=[S1,S2,S3], ic:(Starts::1..20), eplex_cons(Time,Starts,Bools), Bools=[B1,B2|_], one_overlap(Time,S1,S2,B1,B2), List = [B1,B2|Starts], hybrid_opt(labeling(List),min(S3),End). Don’t send integrality constraints to eplex if search is to be done by branch and bound.

30
30 Using LP solution to improve labeling Try rounded LP-solution first better_indomain(X) :- eplex_var_get(X, solution, LpSol), Guess is fix(round(LpSol)), ( ic:(X #= Guess) ; ic:(X #\= Guess), indomain(X) ). Split at LP-solution split_domain(X) :- eplex_var_get(X, solution, LpSol), Split is fix(floor(LpSol)), ( ic:(X #= Split) ). And many better ways (repair...) Try rounded LP-solution first better_indomain(X) :- eplex_var_get(X, solution, LpSol), Guess is fix(round(LpSol)), ( ic:(X #= Guess) ; ic:(X #\= Guess), indomain(X) ). Split at LP-solution split_domain(X) :- eplex_var_get(X, solution, LpSol), Split is fix(floor(LpSol)), ( ic:(X #= Split) ). And many better ways (repair...)

31
31 Summary: Eplex in a hybrid setting CLP modelling and search / LP solving 1. Do modelling and transformations in ECLiPSe 2. Load relaxed model into external solver 3. Solve relaxed problem externally and get cost and solutions back 4. Do one search step (choice) in ECLiPSe Simplex ECLiPSe CPLEX / XPRESS-MP update bounds cost X 1 X 2... X m = =< >= =Cost c1c1 c2 cncn Obj relaxed solutions Search constraints

32
32 Multiple eplex instances eplex instance A eplex instance B solver state A solver state B Each instance is a constraint Can share variables with other instances. Each solver state independent Variables: share range, but have separate eplex ‘state’ for each instance

33
33 Introduction Motivation Sending Constraints to Different Solvers Reduced Costs Motivation Sending Constraints to Different Solvers Reduced Costs

34
34 Reduced Cost Best solution so far Relaxed Optimum Reduced Cost Infeasible Region Values ruled out by reduced cost Cost Value of variable 3 4 5 6 7 8 9

35
35 Reduced Cost Pruning rc_prune(Var,min,Curr,Prev) :- eplex_var_get(Var,reduced_cost,RC), ( RC=:=0.0 -> true ; eplex_var_get(Var,solution,Val), ic:( (Var-Val)*RC + Curr =< Prev) ).

36
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

37
37 T2 T3 T4 T5 The Bridge Scheduling Problem T1 M1 M2 M3 M4 M5 M6 B1 S1 B2 S2 B3 S3 B4 S4 B5 S5 B6 S6 P1 P2 A1 A2 A3 A4 A5 A6

38
38 Temporal constraints on the Schedule Precedence before(Start1,Duration1,Start2) Maximal delay before(Start2,-Delay,Start1) Minimize Perturbation Precedence before(Start1,Duration1,Start2) Maximal delay before(Start2,-Delay,Start1) Minimize Perturbation before(Start1,Duration1,Start2) :- Start1 + Duration1 #=< Start2

39
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=

40
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

41
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.

42
42 Exercise: Job Shop 1 Job1: 44 44 1 11 Job2:

43
43 Weak Cooperation ?- overlap(S, 3, T, B1), B1 = 1. S1 = S1{1.0.. 4.0} B1 = 1 There 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

44
44 Exercise overlap(Start,Duration,Time,Bool) :- ic:(Bool =:= (Time>=Start and Time

45
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).

46
46 Problem Constraints setup([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), ).

47
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 ).

48
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

49
49 Objectives Devise Hybrid techniques Encapsulate Mystifying techniques Apply To practical problems in IP and transport

50
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

51
51 Hybrids between CP and MP CP hybrids Flat structure MP solver as global CP constraint Exclude infeasible values from variable domains MP hybrids Hierarchical structure MP solver for master problem CP solver for subproblems Pass information inferred from optimal solutions

52
52 Encapsulation User identifies subproblems Separate 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

53
53 Applications Minimal Perturbation Scheduling Application to airline scheduling Patrol Assignment Application to emergency services Backup Route Generation Application to current internet technology Primary and Secondary Path Assignment Application to next generation internet technology

54
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”)

55
55 Example: The Multiple Vehicle Routing Problem Subproblem V Create a “good” tour for vehicle V Master Problem Select an optimal set of tours that cover the required locations

56
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

57
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

58
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 contain implicit_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)

59
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)

60
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)))

61
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)

62
62 See Also CPAIOR School proceedings Milano Tutorial Le Pape / Wallace Tutorial CP Proceedings Column Generation Benders Decomposition

Similar presentations

OK

FATCOP: A Mixed Integer Program Solver Michael FerrisQun Chen University of Wisconsin-Madison Jeffrey Linderoth Argonne National Laboratories.

FATCOP: A Mixed Integer Program Solver Michael FerrisQun Chen University of Wisconsin-Madison Jeffrey Linderoth Argonne National Laboratories.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Free ppt on uses of plants Ppt on display advertising Ppt on rational numbers for class 7 free download Ppt on autonomous car news Ppt on world war 2 Ppt on environment in hindi language Ppt on chapter management of natural resources Ppt on rbi reforms definition Ppt on 600 mw generator Ppt on review writing groups