number partitioning

65
number partitioning

Upload: jordan-hamilton

Post on 03-Jan-2016

33 views

Category:

Documents


0 download

DESCRIPTION

number partitioning. Like subset sum. Given a bag of numbers, can you partition this into 2 bags such that the sum of the integers in each bag is equal?. Recently featured in the Crystal Maze! (Thanks Zoe!). Try it!. 4 5 3 2 1 8 7 3 5 9. Try that!. Try that?. Try that?. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: number partitioning

number partitioning

Page 2: number partitioning

Like subset sum

Page 3: number partitioning
Page 4: number partitioning

Given a bag of numbers, can you partition thisinto 2 bags such that the sum of the integers in each bag is equal?

Recently featured in the Crystal Maze!(Thanks Zoe!)

Page 5: number partitioning

Try it!

Page 6: number partitioning

Try that!

4 5 3 2 1 8 7 3 5 9

Page 7: number partitioning

Try that?

Page 8: number partitioning

Try that?

Page 9: number partitioning

Can you think of a 1st test tocarry out to determine if there is no partition?

Page 10: number partitioning

Given a bag of numbers, can you partition thisinto 2 bags such that the sum of the integers in each bag is equal?

Garey & Johnson “Computers and Intractability”

[SP12] PARTITIONINSTANCE: Finite set A and a size s(a) Z+ for each a AQUESTION: Is there a subset A’ A such that aA’ s(a) aA-A’ s(a)

Page 11: number partitioning
Page 12: number partitioning

How complex?

Page 13: number partitioning

Who cares?

Imagine you have 2 machines on the shop floorYou have n activities, of varying durationsPlace the activities on the machines to minimise makespan

Page 14: number partitioning

Why just 2-partition?Why not m-way partitioning?Is there an optimisation problem?

Page 15: number partitioning

A number of constraint encodings

Page 16: number partitioning

}1,0{

},0{

},0{

berobject/num i of weight is th

i

ii

ii

i

D

wR

wL

w

1st stab

1

0

1

0

01

00

n

ii

n

ii

iiii

iiii

RL

wRLD

RwLD

variables

constraints

Questions:- What are the “decision variables”- Can we be more efficient

- generate more propagation- Bound or enumerated variables- Is there a better model?- What if it is insoluble?

Page 17: number partitioning
Page 18: number partitioning
Page 19: number partitioning
Page 20: number partitioning

iiii

iiii

wRLD

RwLD

01

00

Page 21: number partitioning

1

0

1

0

n

ii

n

ii RL

Page 22: number partitioning
Page 23: number partitioning
Page 24: number partitioning

How can I make an IntegerVariable with a domainthat is a set of values, rather than a range?

Laura?

If I had L[i] {0,w[i]} and R[i] {0,w[i]}could I throw away D[i] and have R[i] ≠ L[i]?

Page 25: number partitioning
Page 26: number partitioning
Page 27: number partitioning
Page 28: number partitioning

Look! No D!

Page 29: number partitioning

Questions, questions, questions

Decision variables … does it matter?Heuristics?

Value ordering … does it matterBound versus enumerated variables … anyone?

Size of state space?

Propagation: what will it do? Will it

have an effect?

How will search progress?How big is the model?

Symmetries

Page 30: number partitioning

Symmetry

If we are using a static variable ordering heuristic andIf we are using the 0/1 decision variables D[i]Does it make any difference if we have D[0] = 0 or D[0] = 1

That is, can we half the search space?

Page 31: number partitioning

1st stab

Why use CP for numPart?

Can we think of any “side constraints”?

Actually, an important question: justify use of CP

Page 32: number partitioning

A 2nd stab

We want to minimise the difference between the sum of the numbers on the left and the sum of the numbers

on the right

Right!?

Page 33: number partitioning

An optimisation problem

Minimise the difference between left and right

A 2nd stab

Page 34: number partitioning

Minimize imbalance

Page 35: number partitioning

How do we optimise in CP?

A sequence of decision problems

Branch and bound

Page 36: number partitioning
Page 37: number partitioning

Demo of Optimize

Page 38: number partitioning

Why is Optimize so slow?

Page 39: number partitioning

When can this propagate?

Page 40: number partitioning

Can we limit the search effort?

Page 41: number partitioning
Page 42: number partitioning

3d stab

Page 43: number partitioning

3d stab

Optimize is a wee bit “clunky”

Can we do better?

Put ½ the numbers on one side

Page 44: number partitioning
Page 45: number partitioning
Page 46: number partitioning

}1,0{

berobject/num i of weight is th

ii

D

w

1st stab

X

XDw

mX

wm

n

iii

n

ii

maximise

.

}..0{2

1

0

1

0

variables

constraints

Page 47: number partitioning

Maximize the sum ofWeights on the rightAs close to tot/2

X

XDw

mX

wm

n

iii

n

ii

maximise

.

}..0{2

1

0

1

0

Page 48: number partitioning

Demo of OptimizeV2

Page 49: number partitioning

Why was version 2 faster?

Page 50: number partitioning

Could we Optimize without the decision variable D?

I suppose so … could explore this

Replace scalar with sum

Page 51: number partitioning

So?

Page 52: number partitioning

1. Three stabs!2. A fair bit to consider3. Has this all been easy?4. Is there a better way to do numPart?

Page 53: number partitioning
Page 54: number partitioning
Page 55: number partitioning
Page 56: number partitioning

… and now for something completely different!!!

Page 57: number partitioning

Assume for sake of argument, we have 3 digit numbers

Will it be easier to partition a bag of 100 numbers or a bag of 10 numbers?

Will we always be able to partition a bag of numbers?

Page 58: number partitioning

Decision Problem

Page 59: number partitioning

Random Data

Page 60: number partitioning

Random Data

Page 61: number partitioning

Answer these questions

1. As we increase n does the problem get easier?2. As we increase n do more or less instances have partitions?3. As we increase d do problems get easier or harder?

Page 62: number partitioning

Experiment

Page 63: number partitioning

Experiment

Page 64: number partitioning

Experiment

Page 65: number partitioning

Experiment 1: d = 3, vary n from 9 to 26 in single steps, sample size 10

Experiment 2: d = 3, vary n from 100 to 500 in steps of 100, sample size 10

Experiment 3: d = 6, vary n from 15 to 26 in single steps, sample size 10

Experiment 4: d = 6, vary n from 100 to 500 in steps of 100, sample size 10

Experiment 5: d = 7, n = 100, sample size 10

Experiment

Observe % solubility and search effort