number partitioning

Post on 03-Jan-2016

25 views 0 download

Tags:

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 of number partitioning

number partitioning

Like subset sum

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!)

Try it!

Try that!

4 5 3 2 1 8 7 3 5 9

Try that?

Try that?

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

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)

How complex?

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

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

A number of constraint encodings

}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?

iiii

iiii

wRLD

RwLD

01

00

1

0

1

0

n

ii

n

ii RL

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]?

Look! No D!

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

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?

1st stab

Why use CP for numPart?

Can we think of any “side constraints”?

Actually, an important question: justify use of CP

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!?

An optimisation problem

Minimise the difference between left and right

A 2nd stab

Minimize imbalance

How do we optimise in CP?

A sequence of decision problems

Branch and bound

Demo of Optimize

Why is Optimize so slow?

When can this propagate?

Can we limit the search effort?

3d stab

3d stab

Optimize is a wee bit “clunky”

Can we do better?

Put ½ the numbers on one side

}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

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

Demo of OptimizeV2

Why was version 2 faster?

Could we Optimize without the decision variable D?

I suppose so … could explore this

Replace scalar with sum

So?

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

… and now for something completely different!!!

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?

Decision Problem

Random Data

Random Data

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?

Experiment

Experiment

Experiment

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