Title: Hybrid Algorithms, Local Search and ECLiPSe
1Hybrid Algorithms, Local Search and ECLiPSe
2Overview
- Motivations
- From Problem to Solution
- Solvers
- Global Constructive Search Hybrids
- Hybrids with Separate Search Routines
- Mappings between Models
- Hybrid Search
3Combinatorial Optimisation
- Theory
- Why arent deterministic computers as efficient
as nondeterministic ones? - Practice
- Science and Engineering
- Configuration and design
- Resource and Task Optimisation
- Industry and government organisations
4Applications of CP in Melbourne
- Internet Routing and Balancing
- Telstra
- Supply Chain
- Patrick Corp
- Berri Ltd
- Linfox
- Coles Myers
- Transportation
- Translogix
- IBM
- CTI
- NAB
- Construction Scheduling
- Synctec
- Bovis Lend Lease
- Health Systems
- Southern Health
5Four Case Studies
- Logistics with Depots
- Wincanton Transport
- Patrol Despatcher
- RAC
- Flight Schedule Retimer
- BA
- Network resilience
- Cisco Systems
6Logistics with Depots
7Logistics with Depots Summary
- Objectives
- Generate feasible schedule
- Minimise driver/vehicle/travel costs
- Constraints
- Collection and delivery time windows
- Vehicle capacity data
- Travel time data
- Vehicle load/unload time data
- Driver shift data
- Business Benefits
- Strategy which customers to take
- Profitability how much to charge
8Patrol Despatcher
The RACs Birmingham Despatch Centre
9Patrol Despatcher Summary
- Operational Objectives
- Meet real-time requirements
- Decisions match business goals
- Handle larger regions
- Consistency, completeness
- Business Benefits (planned)
- Cost savings
- Quick, fair decisions
- Better despatching at borders
- Flexible business process
- Strategic Objectives
- Despatch a years worth of jobs
- Simulate the companys operation
- Meet constraints/business criteria
- Business Benefits
- Negotiation with patrols
- Test benefits of onsite protocol
- Test different resource levels
- Test different objectives (cost/QoS)
10Flight Schedule Retimer
11Flight Schedule Retimer Summary
- Objectives
- Retime scheduled flights
- Observing constraints
- Minimising changes to existing schedule
- Business Benefits
- Aircraft utilisation gains
- Slot profile change
- Punctuality improvement
12Network Resilience Summary
- Objectives
- For each route passing through a network
component, find an alternative that avoids the
component - Separate shared link risk groups
- Ensure there is sufficient bandwidth in
alternative routes - Business Benefits
- Computes minimal network redundancy
- Maintains quality of service
- Exploits MPLS technology
13Approaches Research Communities
- Operations Research
- Integer/linear programming
- Metaheuristics
- Generate and improve
- Constraint Programming
- Constraint programming
14Combinatorial Optimisation CommunityBig
Questions
- What problem features best map to what
approaches? - Schedule optimisation problem
- 10,000 variables Time points
- 50,000 constraints
- 1 disjunction
- Can each approach be informed by the others?
- Why do metaheuristics improve faster than branch
and bound? - How do we get from a problem definition to a
problem solution?
15Overview
- Motivations
- From Problem to Solution
- Solvers
- Global Constructive Search Hybrids
- Hybrids with Separate Search Routines
- Mappings between Models
- Hybrid Search
16Problem Definition gt Problem Solution
PhD
Solver Platform
17Mapping Conceptual to Design Model
Conceptual Model Add Constraint
Behaviour Add Search Design Model
18Logical Transformations
- Conceptual Model
- Decompose
- Transform
- Tighten
- Link
- Conceptual Model
19Logical Transformations
- Conceptual Model
- Decompose
- Transform
- Tighten
- Link
- Conceptual Model
20Final Conceptual Model to Design Model
- Conceptual Model
- Logic
- Solver Choices
- Add constraint behaviour
- Search Choices
- Add search
- Design Model
- Program
21Add Constraint Behaviour
- Post constraints to chosen solvers
- Choose information to export from one solver to
another - Choose information to export from solvers to
search engine
22 Constraint Programming Nature and Scope
Model
Algorithm
Finite Domain Library
Repair Library
Interval Reasoning Library
Linear Programming Library
CPLEX
Xpress-MP
23Add Search
- Choose one global or multiple separate searches
- Choose type of search
- Choose information to import from and export to
solvers
24Research Challenge
Example Workforce Scheduling
Scheduling
Routing
What search? What information? What control?
Subproblem
Subproblem
25Overview
- Motivations
- From Problem to Solution
- Solvers
- Global Constructive Search Hybrids
- Hybrids with Separate Search Routines
- Mappings between Models
- Hybrid Search
26Constraint Behaviour Solvers
- Finite Domain
- Linear
- Interval
- Integer/linear (MIP)
- Set
- SAT
- One-way constraints
27Communication Between Solvers
Information Events
Import constraints wake(Change,Prior)
Export assignments return / failure
variables
interrupt(Prior)
post(Change)
constraints heuristics
28Finite Domain Solver Information
- Import
- Variables and domains
- Constraints primitive,reified,global,
- Export
- Instantiation
- Domain bounds
- Domain sizes
- Active constraints on a variable
- Entailed constraints (disequalities,
inequalities, reified) - Disentailed constraints
29Constraint Behaviour Solvers
- Finite Domain
- Linear
- Interval
- Integer/linear (MIP)
- Set
- SAT
- One-way constraints
30Linear Solver Information
- Import
- Linear constraints (2X 3Y 6Z lt 24.3)
- Optimisation expression (min(2X Y))
- Export
- Optimum value
- An optimal solution
- Reduced costs, shadow prices
31Linear Constraints
Optimal solution
Feasible Region
32Shadow Prices
X-Y lt 2
X-Y lt 1
Feasible Region
Shadow Price
33Reduced Costs
34Reduced Costs
Variable X
Feasible Region
35Reduced Costs
Feasible Region
Reduced Cost
36ECLiPSe Linear Solver Interface eplex
- lib(eplex)
- An interface between ECLiPSe and an external
LP/MIP solver - XPRESS-MP, a product by Dash Associates
- CPLEX, a product by ILOG SA
- Motivation to have this link
- Use state-of-the-art linear programming tools
- Use ECLiPSe for modelling
- Build hybrid solvers
- Implementation
- Tight coupling, using subroutine libraries
37Mathematical Programming
- minimize
- 10 A1 7 A2 11 A3
- 8 B1 5 B2 10 B3
- 5 C1 5 C2 8 C3
- 9 D1 3 D2 7 D3
- subject to
- A1 A2 A3 200
- B1 B2 B3 400
- C1 C2 C3 300
- D1 D2 D3 100
- A1 B1 C1 D1 ? 500
- A2 B2 C2 D2 ? 300
- A3 B3 C3 D3 ? 400
Plant capacity
Client demand
Transportation cost
A
200
10
1
? 500
8
9
5
B
400
7
5
2
? 300
5
3
C
300
10
11
3
8
? 400
7
D
100
- Modelled as a matrix
- Each row is one constraint
- Each column is one variable
38Example problem as a matrix
A1 A2 A3 B1 B2 B3 C1 C2 C3 D1 D2 D3
1 1 1 0 0 0 0 0 0 0 0 0 200
0 0 0 1 1 1 0 0 0 0 0 0 400
0 0 0 0 0 0 1 1 1 0 0 0 300
0 0 0 0 0 0 0 0 0 1 1 1 100
1 0 0 1 0 0 1 0 0 1 0 0 ? 500
0 1 0 0 1 0 0 1 0 0 1 0 ? 300
0 0 1 0 0 1 0 0 1 0 0 1 ? 400
10 7 11 8 5 10 5 5 8 9 3 7
39Modelling MP problems in Eplex
- Eplex can model multiple MP problems
simultaneously - Each MP problem represented by an eplex instance
MP Problem
eplex instance
variables bounds
X1 X2 ... Xm
solution values
c1
lt
c2
constraints
gt
cn
Cost
Obj
cost
40Transportation Problem in ECLiPSe
- - lib(eplex).
- main1(Cost, Vars) -
- Vars A1, A2, A3, B1, B2, B3, C1, C2, C3, D1,
D2, D3, - Vars 0.0..1.0Inf,
- eplex (A1 A2 A3 200),
- eplex (B1 B2 B3 400),
- eplex (C1 C2 C3 300),
- eplex (D1 D2 D3 100),
- eplex (A1 B1 C1 D1 lt 500),
- eplex (A2 B2 C2 D2 lt 300),
- eplex (A3 B3 C3 D3 lt 400),
- eplex optimize(min(
- 10A1 7A2 11A3
- 8B1 5B2 10B3
- 5C1 5C2 8C3
41Linear constraints
- Non-strict linear equalities and inequalities
- eplex(XY)
- eplex(XgtY)
- eplex(XltY)
- No strict inequalities or disequalities allowed
- X and Y are linear expressions
- X
- 123 3.4
- Expr - Expr
- E1 E2 E1 - E2 Coeff E2
- sum( ListOfExpr )
42Triggering the solver repeatedly
- eplex_solver_setup(Objective, -Cost,
Options, Priority, TriggerModes) - Objective
- min(Expr) or max(Expr)
- -Cost
- variable - it does not get instantiated, but only
bounded by the solution cost. - TriggerModes
- inst - if a variable was instantiated
- bounds - if a variable bound was changed
- deviating_bounds - if a variable bound was
changed such that its LP-solution was excluded by
more than a tolerance. - new_constraint - when a new constraint appears
- trigger(Atom) - explicit triggering
43Retrieving results from eplex instance
- eplex_get(Handle, What, -Value)
- Solver results
- typed_solution
- reduced_cost
- slack
- dual_solution
- Statistics
- simplex_iterations
- node_count
- statistics
- Original setup input
- vars, ints, constraints, objective
44Constraint Behaviour Solvers
- Finite Domain
- Linear
- Interval
- Integer/linear (MIP)
- Set
- SAT
- One-way constraints
45Interval Solver Information for integer and
continuous variables
- Import
- Variables and domains
- Integrality (or not)
- Constraints primitive,reified,global,
- Export
- Instantiation
- Domain bounds
- Domain sizes
- Active constraints on a variable
- Entailed constraints (disequalities,
inequalities, reified) - Disentailed constraints
- Interfaces Linear Relaxation and FD Solver
46Integer/linear (MIP) Solver Information
Exponential Cost Solver
- Import
- Linear constraints
- Optimisation expression
- Integrality constraints
- Export
- Optimum value
- An optimal solution
- Reduced costs, shadow prices
- Linear Constraints (cutting planes)
- Fixed variables
- Search node heuristics
- Branching heuristics
47Set Solver InformationFinite Sets of Values
- Import
- Set variables and domains
- Set cardinality variables and domains
- Constraints primitive,reified,global,
- Export
- FD information on cardinality variables
- Values excluded from set
- Values included in set
- Entailed/disentailed set constraints
48SAT Solver Information Exponential Cost Solver
- Import
- Clauses
- Export
- Feasible solutions
- If solver can be suspended, can export
- Clauses (nogoods)
- Variable choice heuristics
49Constraint Behaviour Solvers
- Finite Domain
- Linear
- Interval
- Integer/linear (MIP)
- Set
- SAT
- One-way constraints
50One-way solver information
- Import
- One-way constraints (functions)
- Heuristic information
- Variable (tentative) assignments
- Export
- Inconsistency
- Heuristic information
- Variable (tentative) assignments
51One-way Solver Examples
- X Y 3
- Y 2 gt X 5
- Y 4 gt X 7
- Incremental Computation
- S sumX,Y,Z
- Y 4 gt S S_old
- Application
- Var select(mindomain,X,Y,Z)
- Y \ 4 gt ???
- Method
- Invariant (specialised implementation of
incremental one-way solver)
4 Y_old
52One-way Solver in ECLiPSe - repair
- Purpose
- To maintain non-logical tentative information
- Library Invocation
- lib(repair)
- Method
- Attach hidden information to each variable
- Associate events and actions with this info.
53Tentative Assignments to Avoid Failing
Logical Assignment
Tentative Assignment
Define Decision Variables Constrain Decision
Variables Search for a Solution
X1..10 X4
X tent_set 8 X tent_set 4
Xgt5
Fail Record Conflict
54Problem Modelling and Solving
FD
Repair
VarsDomain
Vars tent_set Vals
Initialise Decision Variables Constrain Decision
Variables Search for a Solution
ic ltConsgt
ltConsgt r_conflict Store
ic labeling(Vars)
repair(Store)
55Tentative Invariants
X,Y tent_set 1,2
Initialise Decision Variables Constrain Decision
Variables During Search
Either Y X1
r_conflict a
Or Y tent_is X1
X tent_set 3
Record Conflict
Y4
56Overview
- Motivations
- From Problem to Solution
- Solvers
- Global Constructive Search Hybrids
- Mappings between Models
- Hybrid Search
57Global Constructive Search Hybrid Forms
Add constraint and wake solvers
Root Node
Node1
Node2
Some of these leaf nodes are our solutions
58Cooperating Solvers Intersecting Subproblems
C1
Y
X
Z
C2
Subproblem2
Subproblem1
59Cooperating Solvers Copied Variables
Y
C1
X2
X1
Z
C2
Solver2
Solver1
Keep X1 and X2 in step Communicate
events Communicate information
60Cooperating Solvers Copied Variables
Y
C1
X2
C2
X2 gt 10.5
X2 gt 11
X2 gt 11
X1
Z
X1 gt 10.5
X1 gt 10.5
integer(X2)
Linear Solver
Interval Solver
Info on X
X gt 10.5
X1 gt 11
61FD and Linear Solver Cooperation (within a
Global Constructive Search)
- Motivation
- Linking through Channeling Constraints
- Forms of Cooperation
62Motivation for FD Linear Comunication
63Motivation for FD Linear CommunicationPerformanc
e
- Linear
- e.g. Simplex, Gauss
- restricted class of constraints
- finds optimum without search
- Favourable example
- Variable Bounds
- X1,X2 1..100
- New Constraints
- X1 gt X2, X2 gt X1
- Result (1 step) failure!
- FD
- e.g. interval propagation
- more general constraints
- handle integers directly
- Favourable example
- Variable Bounds
- X1,,X100 1..100
- Previous Constraints
- X1 lt X2 , , X98 lt X99
- Resulting Bounds
- X1 1..2, , X99 99..100
- New Constraint
- X1 gt 3
- Result (1 step) failure!
64FD and Linear Constraint Solving Performance
- Add N variables and trivial constraints
- N 100, 200, 500, 1000, 2000, 5000, 10,000,
20,000, 50,000 - The Constraints
- for each variable XJ do XJ1..N, XJ
gt XJ-1. - The Solvers
- FD
- CLPQ
- CPLEX (run once, after posting ALL constraints)
- CPLEX (incremental)
65Performance Figures (FD) - X i1gtXi
Log. Time per Constraint
66The Less Trivial Case - N Propagation Steps per
Constraint
- Add N variables and constraints
- N 100, 200, 500, 1000, 2000, 5000, 10,000,
20,000, 50,000 - The Constraints
- for each variable XJ do XJ1..N, XJ-1
gt XJ-1. - The Solvers
- FD
- CPLEX (run once, after posting ALL constraints)
- CPLEX (incremental)
67Performance Figures (FD) - X i1gtXi
Log. Time per Constraint
68Motivation for FD Linear Comunication
69One-machine Scheduling
Task 1 Start-time 0..15, Duration 5 Task 2
Start-time 0..15, Duration 15,
Either Task1 must precede Task2
0
5
25
10
15
20
Or Task2 must precede Task1
0
5
10
15
20
Constraint no_overlap(S1,5,S2,15).
70 Representing Disjunction with
Auxiliary Boolean Variables
no_overlap(S1,D1,S2,D2) - S1 gt
S2D2. no_overlap(S1,D1,S2,D2) - S2 gt S1D1.
Choose a large number M Introduce variables
B1,B2 0..1 Replace disjuction with
conjunction
no_overlap(S1,D1,S2,D2,B1,B2) - S1M-B1M gt
S2D2, S2M-B2M gt S1D1, B1B2gt1.
Example S1,S2 0..4, no_overlap(S1,3,S2,5,B1
,B2), B11 gt fail!
71Communicating Linear and FD Solvers
Optimisation Integer Feasibility
X,Y0..10 Ygt 2X XY gt 5 Cost min(X2Y)
FD
Linear
S1,S20..4, B1,B20..1 S1 10 - B110 gt S2
3 S2 10 - B210 gt S1 5 B1 B2 gt 1
Cost min(S1)
B20, B11 S1 3..4, S2 0..1
Cost 0..30
Cost gt 0
Cost gt 25/3
72Hoist Scheduling
Each product must be dipped in a sequence of
tanks.
73Disjunctive Constraint in Hoist Scheduling
Period P 1 Hoist
action b
0
T1
T2
1
2
3
4
action a
P
PT1
PT2
1
2
3
4
Disjunctive Constraint on actions a and b T2
gt PT1timefull12 timeempty23 or PT1 gt
T2timefull34 timeempty41
74Disjunctive Constraint in Hoist Scheduling
Period P 2 Hoists
action b hoist H2
0
T1
T2
1
2
3
4
action a hoist H1
P
PT1
PT2
1
2
3
4
Disjunctive Constraint on actions a and b T2
gt PT1timefull12 timeempty23 or PT1 gt
T2timefull34 timeempty41 or H1 lt H2
75Hoist Performance
76Hoist Robustness -Algorithm
100 Randomly Generated 2-hoist 2-track Problems
Optimal Solutions Found 100
Minimum Time 167 secs
Maximum Time 1146 secs
Average Time 314 secs
77Hoist Robustnes - Model
- Benchmark Hoist Scheduling Problem
- Tank Capacities
- Two hoists on one track
- Multiple hoists on multiple tracks
FD/Linear Hybrid Previous approaches
Same basic model for each problem class Completely different models
78FD and Linear Solver Cooperation (within a
Global Constructive Search)
- Motivation
- Linking through Channeling Constraints
- Forms of Cooperation
79Different Models in FD and Linear
Distances Table Data
X1 X2 X3 X4 X5 X6
X2
X1 X2 X3 X4 X5 X6
X1
0 5 2 4 1 7
5 0 4 7 2 5
2 4 0 4 6 1
4 7 4 0 3 5
1 2 6 3 0 2
7 5 1 5 2 0
X5
X4
X3
X6
TSP Problem Find shortest route
80ECLiPSe Syntax
- Iteration
- foreach(El,a,b,c,d) do write(El),write( ).
- for(K,1,4) do write(K), write( ).
- for(K,1,4),foreach(El,List) do ElK
- Consta, (foreach(El,List), for(_,1,4),
param(Const) do ElConst) - Consta, (foreach(El,List), for(_,1,4) do
ElConst) - for(K,1,4),for(J,1,4) do write(K-J),write( ).
- multifor(K,J,1,1,3,3) do write(K-J),write(
)
a b c d
1 2 3 4
List 1,2,3,4
List a,a,a,a
List _,_,_,_
1-1 2-2 3-3 4-4
1-1 1-2 1-3 2-1 2-2 2-3 3-1 3-2 3-3
81ECLiPSe Syntax
- Arrays
- Struct f(a,b,c,d), X is Struct2.
- Xb
- Matrix m(f(11,12),f(21,22),f(31,32)), X is
Matrix3,2 - X32
- Matrix m(f(11,12),f(21,22),f(31,32)), X is
Matrix1..3,2 - X12,22,32
- dim(M,2,2), A is M1,2
- M ((_,A),(_,_))
- dim(M,2,3),
- ( multifor(K,J,1,1,2,3), param(M) do X is
MK,J, XK-J) - M ((1-1, 1-2, 1-3), (2-1, 2-2, 2-3))
-
82TSP Problem ECLiPSe FD Design Model
- length(Vars,6), ic(Vars 1..6),
icalldifferent(Vars), - length(Dists,6), ic(Dists 1..10),
- ( for(J,1,6),
- foreach(SJ,Vars),
- foreach(DJ,Dists),
- param(Data)
- do
- ListJ is DataJ,1..6),
icelement(SJ,ListJ,DJ) ), - ic (Cost sum(Dists))
For example icelement(S3,2,4,0,4,6,1,D3)
83TSP Problem ECLiPSe Linear Design Model
dim(Bools,6,6), Bools0..1, ( for(J,1,6),
param(Bools) do eplex
(Bools0..1), eplex
(sum(BoolsJ,1..6) 1),
eplex (sum(Bools1..6,J) 1) ), (
multifor(I,J,1,1,6,6),
foreach(C,Costs), param(Bools,Data) do
C BoolsI,JDataI,J
), eplex(Cost sum(Costs)).
84Mapping FD Variables to Booleans
ic,eplex (Var 1..N), length(Bools,N),
eplex (Bools0..1), eplex (sum(Bools)
1), (foreach(B,Bools), for(Val,1,N),
for(E,Exprs) do E BVal), eplex (Var
sum(Exprs)).
Channeling constraint in linear solver
85Cooperating Solvers Copied Variables
Channeling constraint in linear solver
Bk
C1
Var
C2
Bk1
Var
Z
Vark
Vark
Linear Solver
FD Solver
Info on Var
86Cooperating Solvers Copied Variables
Channeling constraint in linear solver
Bk
C1
Var
C2
Bk1
Var
Vark
Vark
Z
Linear Solver
FD Solver
Info on Var
87Mapping FD Variables to Booleans
ic (Var 1..N), length(Bools,N),
ic,eplex (Bools0..1), eplex(sum(Bools)
1), ( foreach(B,Bools), for(Val,1,N), param(Var)
do ic (Var, Val, B) ).
Channeling constraint in FD solver
88FD and Linear Solver Cooperation (within a
Global Constructive Search)
- Motivation
- Linking through Channeling Constraints
- Forms of Cooperation
89Information Communicated from FD to Linear Solvers
- Variable Bounds
- Variable instantiation
- Variable remains in linear solver, with identical
bounds - Linear Constraints
- Delay
- MLLP
90Communicating FD to LP Delay
- XB gt Y
- As soon as B is instantiated to 1, send XgtY to
linear solver - As soon as B is instantiated to 0, send 0gtY to
linear solver - As soon as X is instantiated, send XB gtY to
linear solver - ECLiPSe Syntax
- suspend(eplex (XBgtY), 3, X,B -gt inst)
91Communicating FD to LP MLLP Hookers Mixed
Logical Linear Programming
- FD(X1,,Xn) gt LP(Y1,,Ym)
- If search or propagation entails FD constraint,
- then LP constraint is posted to linear solver
- ECLiPSe Syntax
- mllp_1(X) ? Xgt5 eplex (Y gt X)
92Information Communicated from Linear to FD Solvers
- Directly
- Cost Bounds
- Indirectly
- Reduced costs gt Var ?Val
- often by fixing Bval0
93Reduced Cost Pruning
94Branch-and-bound (incremental)
Cost
Solu- tions
(Proof of optimality)
Lower bound (relaxed solution)
Iterations
95Communicating Linear and FD Solvers
Optimisation
X,Y0..10 Ygt 2X XY gt 5 Cost min(X2Y)
FD
Linear
Cost 0..30
Cost gt 25/3
96Branch-and-bound (incremental)
Cost
Solu- tions
Optimal solution
(Proof of optimality)
No solution
Lower bound (relaxed solution)
Iterations
4
97Global Constructive Search FD and Linear Solvers
Add constraint and wake FD and linear solvers
Root Node
Node1
Node2
Some of these leaf nodes are our solutions
Reasoning at each node Repeat Reduce FD
domains Tighten linear relaxed cost bound Until
fixpoint
98Linear and FD Constraints as Fixpoint Operators
99Information Communicated from FD and Linear to
Search Engine
- FD
- Domain size
- Number of active constraints
- Linear
- Relaxed solution
- Reduced costs gt regret
100Combining Linear and FD Horses for Courses
Problem Progressive Party Cabinet Assignment Set Partitioning
CP gt 5 mins 9.27 secs 64.68 secs
LP gt 5 mins gt 5 mins 0.18 secs
CP LP 91.5 secs 13.2 secs 0.71 secs
101Overview
- Motivations
- From Problem to Solution
- Solvers
- Global Constructive Search Hybrids
- Hybrids with Separate Search Routines
- Mappings between Models
- Hybrid Search
102Hybridisation Forms with Separate Subproblem
Search Routines
Subproblem A
Subproblem B
Search Solver 1
Search Solver 2
103Hybridisation using Nogoods
BSubmodel
ASubmodel
Nogood
Solution
Solver
Solver
Solution to subproblem A is infeasible for
subproblem B gt Add constraint to subproblem A
precluding similar solutions
104Solver Requirements
- Extract Minimal Cause of Conflict
- General
- Application-specific
- Export Constraints
- Treatable by solver A
- Exclude current violation
- Leave choice points if necessary
- Disjunction of alternatives should not preclude
any feasible solutions
105Different Models in FD and Linear
Distances Table Data
X1 X2 X3 X4 X5 X6
X2
0 5 2 4 1 7
5 0 4 7 2 5
2 4 0 4 6 1
4 7 4 0 3 5
1 2 6 3 0 2
7 5 1 5 2 0
X1 X2 X3 X4 X5 X6
X1
X5
X4
Flow out of subset gt 1
X3
X6
TSP Problem Find shortest route
106Hybrisation of FD and One-way solver using nogoods
Subproblem A Temporal Constraints
Subproblem B Resource Constraints
Nogood
Solution
Interval Solver
One-way Solver
107ECLiPSe Repair library
- Tentative Values
- Vars tent_set Vals
- Vars tent_get Vals
- Conflict Sets
- conflict_constraints(Cset,CCs)
- conflict_vars(CVars,CCs)
- Constraint Annotations
- Constraint r_conflict Cset
- Var tent_is Expression
108Example Bridge Scheduling
- Schedule tasks to build a bridge
- Schedule consists of different tasks that share
several resources - (eg. excavator, pile-driver)
- Some tasks depend on others
- Temporal Constraints
- e.g time for concrete to set
- Disjunctive resource constraints
- pile-driver can only be used in one task at a
time
109The Bridge Scheduling Problem
T2
T1
T3
T4
T5
M1
M6
M5
M4
M3
M2
B6 S6
B1 S1
A1
A6
B4 S4
B5 S5
B2 S2
B3 S3
A5
A3
A4
A2
P1
P2
110Bridge Scheduling Problem
No. Name Description
Duration Resource 1 PA
Beginning of project
0 - 2 A1
Excavation (abutment 1) 4
excavator 3 A2 Excavation
(pillar 1) 2
excavator 8 P1 Foundation
Piles 1 20
pile-driver 9 P2 Foundation
Piles 2 13
pile-driver 10 U1 Erection of
temporary housing 10
- 11 S1 Formwork (abutment 1)
8 carpentry 17
B1 Concrete Foundation (abut. 1)
1 concrete-mixer 23 AB1
Concrete Setting Time (abut 1) 1
- 29 M1 Masonry work
(abutment 1) 16
bricklaying 35 L Delivery of
preformed Bearers 2
crane 36 T1 Positioning (preformed
bearer 1) 12 crane 42
V1 Filling 1
15 caterpillar 46
PE End of Project
0 -
111Temporal constraints on the Schedule
- Precedence
- before(Start1,Duration1,Start2)
- Maximal delay
- before(Start2,-Delay,Start1)
before(Start1,Duration1,Start2) - ic
(Start1 Duration1 lt Start2).
112Resource Constraints
Machine
End
Start
D1
D2
D3
D4
D5
Tasks
noclash(S1,D1,S2,D2) - ic (S1gtS2D2). noclash(S
1,D1,S2,D2) - ic (S2gtS1D1).
113Non-repair Search Labeling
before(S1,D,S2), noclash(S0,D0,S1,D1),
mylabeling(Starts) - ( foreach(S,Starts) do
mindomain(S,S) ).
114Repair Search Probe Backtracking
before(S1,D,S2) noclash(S0,D0,S1,D1) r_conflict
cs
- Tentative Values are earliest possible start
times - They satisfy temporal constraints
- They may violate resource constraints
tent_set_to_min(Vars) - ( foreach(Var,Vars),
foreach(Min,Mins) do mindomain(Var,Min) ),
Vars tent_set Mins.
115A disjunctive constraint is in conflict
- Probe can cause violation (overlap)
repair_label - conflict_vars(cs,CVs), tent_set_
to_min(CVs), conflict_constraints(cs,CCs), (
CCs -gt true CCs Constraint_, c
all(Constraint), Fix the constraint
create choice point tighten var bounds
repair_label ).
116Repair Search Top level
- Fix to tentative values after all conflicts
resolved
minimize( ( repair_label, Starts tent_get
Starts ), End_date ).
117Adding Multiples of Linear Constraints
A3 6X 9Y lt 21 B2 6X 12Y lt 24
(A) 2X 3Y lt 7 (B) 3X 6Y lt 12
A3B2 12X 21Y lt 45
Optimisation expression 12X 21Y
Optimum value 45
Dual values for
constraint A3
for constraint B2
118Adding Multiples of Linear Constraints
A3 6X 9Y lt 24 B2 6X 12Y lt 20
(A) 2X 3Y lt 8 (B) 3X 6Y lt 10
A3B2 12X 21Y lt 44
Optimisation expression 12X 21Y
Optimum value 44
Dual values for
constraint A3
for constraint B2
119Hybridisation Using Benders Decomposition
BSubmodel
ASubmodel
BendersCut
Solution
Solver computing duals
Solver
Solution to subproblem A is infeasible for
subproblem B gt Add Benders cut to subproblem A
precluding similar solutions
120Hybridisation using Column Generation
A AllocateTasks
B Assign a resource
CostBound
ResourceAssignment
Solver
Solver computing duals
Solution to subproblem B is used to build
solutions to A gt Add cost bound focussing B on
useful assignments
121Requirement
- Access to Dual Values
- Encapsulation of Hybridisation Technique
- Automatic generation of Benders Cut/Column
- Automatic imposition of cut/cost bound
- Automatic detection of stopping condition
- Handling of Numerical Instability
- Automatic avoidance of looping
- User hooks to control tailing off behaviour
122Plug-and-play with Column Generation
1-Dimensional Cutting Stock Example
Stock Boards of length 17 Required 25
boards of length 3 20 boards of
length 5 15 boards of length
9 Minimise Wastage
123Plug-and-play with Column Generation
- - lib(ic), lib(colgen).
- solve(Cost) -
- Vars Threes,Fives,Nines, Vars 0..10,
- 3Threes5Fives9Nines Used, Used lt
17, - Waste 17-Used,
- colgen (sum(Threes) gt 25),
- colgen (sum(Fives) gt 20),
- colgen (sum(Nines) gt 15),
- minimize(my_solve(C,Vars), sum(Waste), Cost).
124Plug-and-play with Column Generation
my_solve(C,Vars) - labeling(Vars),
colgen sol(C,Vars).
- my_solve routine written by problem solver
- Master problem dual automatically created by
library - Dual cost constraint automatically added to
subproblem
125Overview
- Motivations
- From Problem to Solution
- Solvers
- Global Constructive Search Hybrids
- Hybrids with Separate Search Routines
- Mappings between Models
- Hybrid Search
126Logical Transformations
- Conceptual Model
- Decompose
- Transform
- Tighten
- Link
- Conceptual Model
127Problem Decomposition
- Send variables to different solvers
- Send constraints to different solvers
- Send to multiple solvers
- Variables
- Constraints
128Linking Constraints to Solvers in ECLiPSe
- - lib(ic).
- solve(Digits) -
- Digits S,E,N,D,M,O,R,Y,
- integers(Digits),
- ic (Digits 0..9),
- ic alldifferent(Digits),
- ic (S gt 1), ic (M gt 1),
- ic (1000S 100E 10N D
- 1000M 100O 10R E
- 10000M 1000O 100N 10E Y),
- labeling(Digits).
129Requirement Generic Solver Interface
- - lib(eplex).
- solve(Digits) -
- Digits S,E,N,D,M,O,R,Y,
- eplex integers(Digits),
- eplex (Digits 0..9),
- alldifferent(0,9,Digits),
- eplex (S gt 1), eplex (M gt 1),
- eplex (1000S 100E 10N D
- 1000M 100O 10R E
- 10000M 1000O 100N 10E Y),
- optimize(min(sum(Digits),_Min).
130Mapping SENDMOREMONEY to both ic and eplex
- - lib(ic), lib(eplex).
- solve(Digits) -
- Digits S,E,N,D,M,O,R,Y,
- icintegers(Digits),
- ic,eplex (Digits 0..9),
- ic alldifferent(Digits),
- ic,eplex (S gt 1), ic,eplex M gt 1,
- ic,eplex (1000S 100E 10N D
- 1000M 100O 10R E
- 10000M 1000O 100N 10E
Y), - eplex_solver_setup(min(sum(Digits)),_Min,
,0,inst), - labeling(Digits).
131Logical Transformations
- Conceptual Model
- Decompose
- Transform
- Tighten
- Link
- Conceptual Model
132Transform
- Global constraints
- e.g. turn a set of disjunctions into an atmost
- Dual forms
- e.g. Constraints -gt variables, variables -gt
constraints - Manageable constraints
- e.g. eliminate disjunctions
- Separable subproblems
- e.g. multiple resource scheduling problem -gt
schedule each resource separately
133A CLP(R) Model
solve(W,X,Y,Z) - imp(X,W), imp(Y,W),
two(X,Y,Z). imp(X,Y) - XltY. two(X,Y,Z) -
and(X,Y). two(X,Y,Z) - and(Y,Z). two(X,Y,Z) -
and(Z,X). and(X,Y) - Xgt1, Ygt1. ?-
solve(W,X,Y,Z), W0.
134Removing Disjunction from a CLP Model
solve(W,X,Y,Z, B) - imp(X,W, B), imp(Y,W, B),
two(X,Y,Z, B). imp(X,Y, B) - XltY
2-2B. two(X,Y,Z, B) - B1,B2,B3
0..1, and(X,Y, B1), and(Y,Z, B2), and(Z,X,
B3), B1B2B3 gt B. and(X,Y, B) - X 2-2B gt
1, Y 2-2B gt 1. ?- solve(W,X,Y,Z, 1), W0.
solve(W,X,Y,Z) - imp(X,W), imp(Y,W),
two(X,Y,Z). imp(X,Y) - XltY. two(X,Y,Z) -
and(X,Y). two(X,Y,Z) - and(Y,Z). two(X,Y,Z) -
and(Z,X). and(X,Y) - Xgt1, Ygt1. ?-
solve(W,X,Y,Z), W0.
135Removing Disjunction from a CLP(R) Model
- Add boolean to all predicates
- solve(W,X,Y,Z, B) - imp(X,W, B),
imp(Y,W, B), two(X,Y,Z, B). - Call the goal with extra boolean1
- ?- solve(W,X,Y,Z,1).
- Add M(1-B) to inequations
- imp(X,Y, B) - XltY 2-2B.
- Replace disjunction with boolean inequations
- two(X,Y,Z, B) -
- B1,B2,B3 0..1,
- and(X,Y, B1), and(Y,Z, B2), and(Z,X,
B3), - B1B2B3 gt B.
136Logical Transformations
- Conceptual Model
- Decompose
- Transform
- Tighten
- Link
- Conceptual Model
137Tighten
- By programmer
- Experience
- Maths
- Automatically
- Propagation
- Intelligent methods
138Redundant Constraints
- Cover a mutilated chess board with dominoes
dominoes(List) - length(List,31),
foreach(D,List) do domino(D), guess(List).
domino(X-Y) - X,Y 2..63,
(Y X8) or guess(List) -
for(N,2,63), param(List) do
member(X-Y,List), (XN Y N).
Y X1
139Redundant Constraints
- Cover a mutilated chess board with dominoes
dominoes(List) - length(List,31),
foreach(D,List) do domino(D), guess(List).
bw(List,B,W), B30, W32, bw(,0,0).
bw(X-YT,B,W) - bw(T,BR,WR), B BR1, W
WR1.
140Logical Transformations
- Conceptual Model
- Decompose
- Transform
- Tighten
- Link
- Conceptual Model
141Link
- Channeling constraints
- Communicating intermediate solutions
142Summary
Conceptual Model Add Constraint
Behaviour Add Search Design Model
143Overview
- Motivations
- From Problem to Solution
- Solvers
- Global Constructive Search Hybrids
- Hybrids with Separate Search Routines
- Mappings between Models
- Hybrid Search
144Hybrid Search
- Incomplete Constructive Search
- Local Search
- Hybrid Schemes
- Current Framework
145Incomplete Constructive Search - Labelling
- Select a variable
- Allocate credit to each value in the variables
domain - Choose a value
Credit Based Search
Incoming Credit Allocated credit
16 8 4 2 1
1 0
146Incomplete Constructive Search - Labelling
- Select a variable
- Allocate credit to each value in the variables
domain - Choose a value
Best N
Incoming Credit Allocated credit
3 3 3 3 0
0 0
147Incomplete Constructive Search - Labelling
- Select a variable
- Allocate credit to each value in the variables
domain - Choose a value, and take its credit
Limited Discrepancy Search
Incoming Credit Allocated credit
2 2 1 0 0
0 0
148Incomplete Constructive Search- Other
- Step search
- Xa v X ? a
- 2-variable constraints
- S1 S2D2 v S2 S1D1
- Range splitting
- X gt 4 v X 4
149Based on Value Choice Heuristics
- Problem-specific
- N-queens middle-out
- Relaxed solution
- Linear relaxation
- Tree relaxation
- Relaxed local search (Kamarainen)
- Previous solution
- Limited Discrepancy Search
- Only count a discrepancy when two heuristics agree
150Local Search
- Min conflicts
- change a variable in conflict
- (improves expected time to solve 2-SAT)
- Guided Local Search
- Escape from local opt. by penalising solution
features - ? Can we change viewpoint so features are
represented by new-variable assignments ? - ? Are feature variables also decision variables ?
151Hybrid Schemes
- MIP and Row Generation
- Repair variables in conflict
- Iterated search methods
- Local search hybrids
- Core/dependent variables
- Large Neighbourhoods
152MIP Bridge Scheduling
before(S1,D,S2), noclash(S0,D0,S1,D1), optimiz
e(End,Cost).
noclash(S1,D1,S2,D2) - eplexB1,B20..1,
eplexintegers(B1,B2),
eplex(S1M-B1MgtS2D2), eplex(S2M-B2MgtS1
D1), eplex(B1B2 gt 1)
Solve linear relaxation Find 0e lt Bool lt
1-e Branch on Bool lt 0 or Bool gt 1 effectively
branch on S2gtS1D1 or S1 gt S2D2
153Hybrid Bridge Scheduling
- Probe can cause violation (overlap)
repair_label - conflict_vars(CVs), tent_set_to_
min(CVs), conflict_constraints(cs,CCs), ( CCs
-gt true CCs Constraint_, call(
Constraint), Fix the constraint
create choice point affect probe
repair_label ).
154A repair heuristic
- Pick a constraint according to a heuristic
noclash(S0,D0,S1,D1) r_conflict cs -
tasks(Task0,Task1) select_constraint(TaskPairs,Se
lectedPair) - (
foreach(TaskPair,TaskPairs),
foreach(Key-TaskPair,KeyedCCs) do
TaskPair tasks( task with durationD0
, task with durationD1), Key is
min(D0,D1) ), sort(1,gt,KeyedCCs,_
- SelectedPair_).
155Results MIP vs Hybrid LP Nodes
156Exploring search spaces
partial assignments
- Tree search
- constructive (partial/total assignments)
- systematic
- complete or incomplete
- Local search
- move-based (only total assignments)
- random or systematic
- incomplete
157A Tentative Assignment
Remaining Variables
Conflict Region of Violated Constraints
Changed Variables
158Tree Search Employing Tentative Assignments
a
b
c
c
159 Search with Tentative Assignments
Initialise Decision Variables Constrain Decision
Variables Search for a Solution
Vars tent_set Vals
ltConsgt r_conflict a
search(a) - ( find_conflict( a, Var) -gt
search(a)
true ).
160Local Search - algorithm template
- local_search
- set starting state
- while global_condition
- while local_condition
- select a move
- if acceptable
- do the move
- if new optimum
- remember it
- endwhile
- set restart state
- endwhile
161Local Search instances
- Algorithm parameters
- starting (and restarting) state
- global and local condition
- possible moves and how to select one
- when is a move accepted
- Different parameters yield different algorithms
- random walk
- hill climbing
- simulated annealing
- tabu search
- ... and many variants
162Hill climbing
- hill_climb(MaxTries, MaxIter, VarArr, Profit,
Opt) - - init_tent_values(VarArr, 0),
starting solution - (
- for(I,1,MaxTries),
global condition - fromto(0, Opt1, Opt4, Opt),
- param(MaxIter,Profit,VarArr)
- do
- (
- for(J,1,MaxIter),
local condition - fromto(Opt1, Opt2, Opt3,
Opt4), - param(I,VarArr,Profit)
- do
- Profit tent_get PrevProfit,
- (
- flip_random(VarArr),
try a move - Profit tent_get
CurrentProfit, - CurrentProfit gt
PrevProfit, is it uphill? - conflict_constraints(cap
,) is it a solution? - -gt
163Techniques used here
- Move operation and acceptance test
- They are within the condition part of the
if-then-else construct, so - If the acceptance test fails (no solution or
objective not improved) the move is automatically
undone by backtracking! - Detecting solutions
- Constraint satisfaction is checked by checking
whether the conflict constraint set is empty - Monitoring cost/profit
- Retrieve tentative value of Profit-variable
before and after the move to check whether it is
uphill - Since the move changes the tentative values of
some variable(s), tent_is/2 will automatically
update the Profit variable!
164Auxiliaries used
- Starting state
- init_tent_values(VarArr, N) -
- ( foreacharg(X,VarArr),param(N) do X tent_set N
). - Move operator (the most stupid one...)
- flip_random(VarArr) -
- functor(VarArr, _, N),
- X is VarArrrandom mod N 1,
- X tent_get Old,
- New is xor(Old,1),
- X tent_set New.
165Interleaved Search Methods
- Interleaved Construction and repair
- 1) Construct a partial solution till no
consistent extension - 2) Make this partial solution tentative
- 3) Choose a value for the next variable
- 4) Repair the tentative solution
- Instances
- Greedy construction local search repair
- Weak commitment repair by constructive search
- Iterated search retain completeness by
distinguishing instantiated and repairable
variables
166From Local to Global
- Local search on small set of driving variables
- Constructive search to complete solution and cost
- Move by unfixing part of solution
- Create move by constructive search
- Pesant best neighbour
- Large neighbourhood search
- Linear optimisation (Le Pape)
167Current Framework
partial assignments
Move between (consistent) partial solutions Move
upwards by unfixing a variable Move downwards
by fixing a variable
Limitations of diagram Should go to ancestor
node Should rearrange tree after move
168Current Framework
- Unfix
- Which variable?
- What dependency information should be kept?
- Fix
- Which variable?
- What propagation?
- Move by unfixing and fixing
- Can this successfully encompass complex moves,
e.g.2-swaps? - Is there a viewpoint that makes this equivalent
to unfixfix?
169Summary
- Separate Model from Solution
- No
- Separate Constraint Behaviour from Search
- No
- Bring together MP, CP and SSP
- No
- Consequence
- Theres lots to be done ?