hybridisation solver cooperation in eclipse. 2 introduction motivation sending constraints to...
TRANSCRIPT
Hybridisation
Solver Cooperation in ECLiPSe
2
Introduction
Motivation Sending Constraints to Different Solvers Probing Column Generation
Motivation Sending Constraints to Different Solvers Probing Column Generation
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
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
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!
6
Hybridising ic and eplex
ic?- ic:(X=\=Y)
eplex?- eplex:(X>=3)
Redundant?- [ic,eplex]:(X>=3), ic:(X=\=Y)
7
Techniques
Shared Variables Linear constraints to ic and eplex Reduced cost propagation Other methods (Milano tutorial)
8
Introduction
Motivation Sending Constraints to Different Solvers Probing Column Generation
Motivation Sending Constraints to Different Solvers Probing Column Generation
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
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
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) ).
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
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).
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
Control Flow with Multiple Solvers
Search/Choice
Solver phase withcommunication
Solver1
Solver2
Search/Choice
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)
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)
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
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).
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
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
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
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
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
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
Exercise: Job Shop
1Job1: 4 4
4 4
1
1 1Job2:
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
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
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
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),
).
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
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
Objectives
DeviseHybrid techniques
Encapsulate Mystifying techniques
Apply To practical problems in IP and transport
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
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
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
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
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
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
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
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
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)
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
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
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
See Also
CPAIOR School proceedings Milano Tutorial Le Pape / Wallace Tutorial CP Proceedings
Column Generation
Benders Decomposition