56
Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution with Wagner-Whitin costs Allocating grid resources

Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Embed Size (px)

Citation preview

Page 1: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Constraint Programming Researchat York

1. Modelling2. Symmetry Breaking3. SAT4. Applications

• Allocating orders to steel slabs in a steel mill• Distribution with Wagner-Whitin costs• Allocating grid resources

Page 2: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

What is Constraint Programming?

• Solve a combinatorial (optimisation) problem by– Mapping it to the finite-domain constraint satisfaction problem

(modelling)• Characterise problem by a set of constraints that a solution must satisfy

• For optimisation, include an objective function

– Solving the constraint satisfaction problem

• Useful for solving a wide range of important, complex problems including scheduling, allocation, layout and configuration problems.

Page 3: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Research on Modelling

Page 4: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Modelling Bottleneck

• Modelling a problem as a constraint program requires moderate/great expertise.

• Hence constraint technology is used almost exclusively by large enterprises on problems with large payoff.

Page 5: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Reducing the Modelling Bottleneck

• Systematise the knowledge of the expert.– 2 to 3 years: We have been building models more and

more systematically

• Embed this knowledge in a “compiler” that can reformulate a high-level problem specification into a set of constraints that can be executed efficiently using existing toolkits.– CONJURE

Page 6: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

CONJURE

Automated Model Generation

• Given an abstract formal problem specification, in ESSENCE

• Generates a set of correct models– Should include good models generated by experts

– These models are in ESSENCE', a subset of ESSENCE

that is similar to what is provided by existing constraint toolkits

Page 7: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

ESSENCE

– Must be at a level of abstraction above that at which modelling decisions are made

Page 8: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Distinguishing Features of ESSENCE

• Many types of non-atomic decision variablesSets, multisets, partitions, tuples, functions,

relations…

• Decision variables of arbitrarily-nested typesSet of 1..nSet of set of 1..n

Multiset of set of set of 1..n

• Quantification over decision variablesForall x in S … where S is a decision var of type set

• Type of unnamed elements

Page 9: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Generating Good Models Involves

1. Representing complex decision variables.

2. Identifying and breaking symmetries.

3. Exploiting channelling.

4. Performing transformations.

CONJURE is specificied by a set of compositional refinement rules and can perform 1 -- 3.

Page 10: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Expected Benefits of this Research

• Rigorous account of model generation– Make study of modelling more systematic– Reveal gaps in understanding– Guide study of model selection by identifying decision

points and available alternatives– Useful for teaching, presenting, cataloguing

• Formal account of model generation– Generator: CONJURE

– Proof checker– Major step towards automated entire modelling process

Page 11: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Research on Symmetry Breaking

Page 12: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Symmetry in Constraint Models

• Symmetry in a model results in symmetry in the search space of partial assignments to variables.

• Example: Find 3 natural numbers that sum to 9– X +Y + Z = 9– {X2, Y8}, {X8, Y2} are symmetric

• Enormous speed-ups can be obtained if symmetric parts of the search space can be avoided.

Page 13: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Symmetry-Breaking Constraints

• Add constraints to the model to rule out some, but not all, symmetrical assignments– To X + Y + Z = 9

add the constraint X Y Z

Page 14: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Row and Column Symmetry

• Many models use matrices of decision variables.

• These often have row and/or column symmetry

Row symmetry: swap any two rows and a solution stays a solution

Column symmetry: swap any two cols and a solution stays a solution

• We have identified and analysed several symmetry-breaking constraints and have implemented efficient propagation algorithms for them.

Page 15: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Allocating a Divisible Resource:An Application to Grid Computing

Alan M. Frisch Artificial Intelligence Group

Dept. Computer Science

University of York

In collaboration with:

Mark Bartlett (York), Youssef Hamadi (MSR),

Ian Miguel (St. Andrews), Chris Unsworth (Glasgow)

Page 16: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Introduction

• Effective use of grid computing will require efficient methods to solve a variety of combinatorial problems, such as:• Resource allocation,• Configuration, and• Scheduling.

• This talk considers the allocation of a divisible resource (e.g. bandwidth) via advanced reservations.

Page 17: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Introduction

• Given bids for quantities of the resource, each offering a price:• Accept a subset of the bids that can be fulfilled and

maximises revenue.

• This talk presents methods for solving realistic instances of this problem in batch mode.

• Concludes with discussion of a dynamic setting.

Page 18: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

• Given:– A finite set of times totally ordered by – Along with each time t, capacity(t), a positive integer– A finite set of bids– Along with each bid b

• price(b), bw(b), two positive integers

• duration(b), a non-empty interval of times

• Find: a set accept bids

• Such that: t times bw(b) capacity(t)

Temporal Knapsack Problem (TKP)

b accept|t duration(b)

• Maximising: price(b)b accept

Page 19: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Sample Instance of TKP

Bid3: 5 units, £20

t2 t3 t4 t5t1

Uniform Capacity: 10

Bid2: 6 units, £10Bid1: 6 units, £11

t2 t3 t4 t5t1

Bid2: 6 units, £10Bid1: 6 units, £11

Solution: Objective Fn = £21

Page 20: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

TKP Generalises Knapsack• Every instance of Knapsack is an instance of TKP in which |times| = 1.• Hence TKP is NP-hard. (Easy to see that TKP is NP-easy)

Page 21: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Multi-dimensional Knapsack (MDK) generalises TKP

• Multi-dimensional knapsack– each item has n-dimensional vector as its size – knapsack has n-dimensional vector as its capacity– sum of sizes of items in knapsack cannot exceed capacity of knapsack

• Every instance of TKP is an instance of MDK in which every item has size of form (0 … 0 bw … bw 0 … 0)

Page 22: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

TKP Reduces toInteger Linear Programming

Bid3: 5 units, £20

t2 t3 t4 t5t1

Uniform Capacity: 10

Bid2: 6 units, £10Bid1: 6 units, £11

Maximise: Xb price(b)b bids

Subject to:

b Xb in {0,1}

6X2 6X2+ 5X3

5X3 6X1 + 5X3

6X1

Page 23: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Solving the TKP

• Decomposition algorithm

• Greedy Algorithm

• Integer Linear Programming

Page 24: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Decomposition Algorithm

Page 25: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Decomposition Algorithm

• Makes use of four operations:• Forced rejection of bids.• Remove times (can lead to forced acceptance).• Split into independent sub-problems.• Branch on accept/reject a bid.

• These operations are composed into a branch and bound search for optimal solutions.

Page 26: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Forced Reject

• If at any time during the interval required by a bid, available bandwidth is less than that requested, bid rejected.

10 units required.Bid:

AvailableCapacity:

105

t1 t2 t3 t4 t5 t6 t7 t8 t9

Page 27: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Remove Times

Bid3: 5 units

t5 t6 t6 t7 t8 t9 t10 t11 t12t1 t2 t3 t4

Capacity: 10

Demand:

Bid2: 6 unitsBid1: 6 units

t5 t8

56

6• Problem reduced to important decision points.

Page 28: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Remove Times Forced Accept

Bid3: 5 units

t5 t6 t6 t7 t8 t9 t10 t11 t12t1 t2 t3 t4

Capacity: 10

Demand:

Bid2: 6 unitsBid1: 4 units

t4 t5

56 • Bid1 Accepted.

Page 29: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Split

• Can solve independently, combine solutions.

Bid3: 5 units

t5 t6 t6 t7 t8 t9 t10 t11 t12t1 t2 t3 t4

Bid2: 6 unitsBid1: 6 units

t5t1 t2 t3 t4

Bid2: 6 units

Bid3: 5 units

t6 t6 t7 t8 t9 t10 t11 t12

Bid1: 6 unitsAND

Page 30: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Branch

t5 t8

56

6

t5 t8

66

Capacity 10Demand 11

t5 t8

66

Reject Bid3Accept Bid3 OR

Demand 6Capacity 5

Capacity 10Demand 6

Page 31: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Interaction: Example

• Bid 1: Forced reject.

Bid2: 5 units

t5 t6 t6 t7 t8 t9t1 t2 t3 t4

Bid1: 6 units

Capacity:Demand:

Page 32: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Interaction: Example

• Times removed. So bid 2 accepted.

Bid2: 5 units

t5 t6 t6 t7 t8 t9t1 t2 t3 t4

Capacity:

Demand:

Page 33: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Reduce• Instance of TKP reduced if:

• Contains no forced rejects.• Demand(t) > capacity(t) for all times t.• Reduce operation:

• Forall b bids TestForcedReject(b).

• Forall t times TestRemoveTime(t).

TestForcedReject(b:bid) if exists t duration(b) s.t. bw(b) > capacity(t) then Reject(b)

TestRemoveTime(t:time) if demand(t) capacity(t) then RemoveTime(t)

Page 34: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Decomposition Algorithm: Initialisation(P)

• Reduce(P)

• Split P into set of problems S.

• Foreach s S, Solve(s).

Page 35: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Decomposition Algorithm: Solve(P)

• If no bids, return.

• Select a bid b from bids.

• Branch on:1. Reject(b) then Reduce(P).

Split(P) into set of problems S.

Foreach s S, Solve(s).

2. Accept(b) then Reduce(P).

Split(P) into set of problems S.

Foreach s S, Solve(s).

Page 36: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Smarter Problem Reduction

• ReduceAfterReject(P, b).• Forall t duration(b), TestRemoveTime(t).

• ReduceAfterAccept(P, b).• Forall b’ bids s.t duration(b) overlaps duration(b’).

• TestForcedReject(b’).

• Let R be set of bids rejected in previous step.• Forall b’ R, Forall t b’ TestRemoveTime(t).

Page 37: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Selecting Bid to Branch on

• Of many availabile strategies, we have tried– Highest Price Order (in experiments)– Highest bandwidth x length

• encourages decomposition

• Slightly slower than previous (limited experiments)

– Next: Select to force decompositions

Page 38: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

AND/OR Search Space

• Decomposition requires AND/OR search.

• To optimise, must also perform branch and bound.

Decomposition: AND node.Accept/Reject branch:OR nodes

etc etc

Page 39: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Search Strategy• Currently use AO*

– Only uses upper bounds (simplistic method)– Optimal in that it expands fewest possible nodes for any given upper-bound method– Uses too much memory

• Next: Get good upper bounds through linear relaxation and cuts• Next we will consider other Branch & Bound search algorithms (upper and lower bounds)

– First: depth first– Then: algorithms that exploit bounded memory

Page 40: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Greedy Algorithm

Page 41: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Greedy Algorithm: Properties

• Guaranteed to terminate with a solution quickly.• Low polynomial time.

• Not guaranteed to find optimal solution.

Page 42: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Greedy Algorithm: Stage 1Forall t times While (capacity(t) < demand(t)) let b be a minimal rate bid in {b’|t duration(b’)} Reject(b)

Rate(b) = price(b)/(bw(b) |duration(b)|)

Page 43: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Greedy Algorithm: Stage 2

Let R be set of bids rejected in Stage 1Foreach b R selected in descending order of rate if forall t duration(b): capacity(t)-demand(t) > bw(t) then put b back into bids.Accept all bids.

Page 44: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Performance

Page 45: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Generating Random Instances

• Given parameters: max-rate, number of bids

• Allocate resources for a period of one month. Granularity of 15 minutes, gives 2,880 times.

• Start time of each bid: uniform random [1, 2880]

• Duration of each bid: uniform random [1, 100]

• Bandwidth of each bid: uniform random [1, 50]

• Rate of each bid: uniform random [1, max-rate]

• Price and end time of each bid derived from above.

Page 46: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Solution Quality of Greedy

Page 47: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Time to Solution

Page 48: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Integer Programming

• Not thoroughly tested, in particular not on hardest instances.

• On test instances tried it is very fast.

Page 49: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Ongoing and Future Work

Page 50: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Ongoing Work on Batch Problem

• Improve decomposition algorithm as described• Get more realistic test data.• Generation of more varied random instances, including

some very hard instnaces• More realistic model of Grid allocation.

• Suggestions solicited!

Page 51: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Dynamic Operating Environment

• Assume time-points separated by 30-min intervals.

• Initially:• Have a set of bids as usual.• Assume start time of each bid > t• Produce a solution within 30 mins.

t

Page 52: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Dynamic Operating Environment

• At time t+1, may receive new bids.• New problem depends on operating conditions.• Commit Deadline:

• Bids have a deadline by which must commit to accept/reject.• Can reconsider any bid prior to commit deadline.• Problem at t+1:

• New bids• Bids at t that haven’t reached their deadline.

• NB Can vary price with deadline.

t+1

Page 53: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Dynamic Operating Environment

• At time t+1, may receive new bids.

• New problem depends on operating conditions.

• Throw-out Penalty:• Might throw out an accepted bid by taking a penalty.• Problem at t+1:

• New bids

• Bids at t that haven’t begun to execute.

t+1

Page 54: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

TKP in ESSENCEGiven: times: set of Int capacity: times -> Nat Bids: enumerated price, bw: Bids -> Nat duration: Interval of times????Find: accept: set of Bids

Such that: t times bw(b) capacity(t)

Maximising: price(b)

b bids|t duration(b)

b accept

Page 55: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Solutions Anytime

• When time limited, want guarantee that a solution can always be returned (even if sub-optimal).

• Given extra time, solution quality should improve.

1st Decomposition node.

Solve each of these sub-problems once.Gives a first (probably sub-optimal) solution.Go back and solve each sub-problem to optimality.

Page 56: Constraint Programming Research at York 1. Modelling 2. Symmetry Breaking 3. SAT 4. Applications Allocating orders to steel slabs in a steel mill Distribution

Heuristics

• At an OR node:• Select a bid. Which?• Must try both accept and reject. Which first?

Decomposition: AND node.Accept/Reject branch:OR nodes