460 likes | 477 Views
Learn about using multiple solvers for optimal problem-solving, sending constraints, and hybrid techniques in an innovative solver setting. Understand the benefits of solver cooperation and different algorithms for diverse subproblems.
E N D
Hybridisation Solver Cooperation in ECLiPSe
Introduction • Motivation • Sending Constraints to Different Solvers • Probing • Column Generation
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
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
Local propagation e.g. interval propagation more general constraints handle integers directly Favourable 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 solving e.g. Simplex, Gauss restricted class of constraints finds optimum without search Favourable example: Variable Bounds: [X1,X2] :: 1..100 New Constraints: X1 > X2, X2 > X1 Result (1 step): failure! Hybridising ic and eplex
Hybridising ic and eplex • ic • ?- ic:(X=\=Y) • eplex • ?- eplex:(X>=3) • Redundant • ?- [ic,eplex]:(X>=3), ic:(X=\=Y)
Techniques • Shared Variables • Linear constraints to ic and eplex • Reduced cost propagation • Other methods (Milano tutorial)
Introduction • Motivation • Sending Constraints to Different Solvers • Probing • Column Generation
Constraint Setup - Multiple Solvers Conceptual Model arbitrary constraints Mapping & Filtering e.g. break up into components Mapping & Filtering e.g eliminating disjunctions ignore nonlinear constraints Solver Model 1 e.g. nonlinear Solver Model 2 e.g. linear Solver 2 e.g.simplex Solver 1 e.g. intervals
task1 task2 time1 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 task3
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) ).
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).
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).
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}
Control Flow with Multiple Solvers Search/Choice Solver phase with communication Solver 1 Solver 2 Search/Choice
Eplex instance as compound constraint setup 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) X1 X2 ... Xm c1 = External Solver c2 =< cn >= Obj = Cost
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)
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).
Hybrid Optimisation :- 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). 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)
Introduction • Motivation • Sending Constraints to Different Solvers • Linearising Logical Constraints • Probing • Column Generation
The Bridge Scheduling Problem T1 T2 T3 T5 T4 M6 M1 M5 M4 M3 M2 B6 S6 B1 S1 A1 A6 B4 S4 B5 S5 B2 S2 B3 S3 A5 A3 A4 A2 P1 P2
Temporal constraints on the Schedule • Precedence • before(Start1,Duration1,Start2) • Maximal delay • before(Start2,-Delay,Start1) • Minimize Perturbation • before(Start1,Duration1,Start2) :- Start1 + Duration1 #=< Start2
Machine End Start T1 T2 Tasks T3 Resource usage at start of T1: T4 T5 1 + B12 + B13 + B14 + B15 Resource Limit Start of T1 Resource Constraints overlap(S1,S2,D2,B12) :- B12 tent_is (S1>=S2 and S1=<S2+D2).
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
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.
Exercise: Job Shop 1 4 4 1 Job1: 4 1 1 4 Job2:
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
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
Exercise :- lib(repair). :- lib(eplex). :- lib(branch_and_bound). 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).
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), ).
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 ).
Introduction • Motivation • Sending Constraints to Different Solvers • Linearising Logical Constraints • Probing • Column Generation
Objectives • Devise • Hybrid techniques • Encapsulate • Mystifying techniques • Apply • To practical problems in IP and transport
5 3 3 4 2 ? 1 2 4 1 Full problem CP and MP constraints Solve CP subproblems Solve MP master problem Decomposing Hybrid Problems
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
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
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
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”)
Example: The Multiple Vehicle Routing Problem • SubproblemV • Create a “good” tour for vehicle V • Master Problem • Select an optimal set of tours that cover the required locations
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
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
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)
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)
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)))
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)
See Also • CPAIOR School proceedings • Milano Tutorial • Le Pape / Wallace Tutorial • CP Proceedings • Column Generation • Benders Decomposition