number partitioning
-
Upload
jordan-hamilton -
Category
Documents
-
view
37 -
download
0
description
Transcript of number partitioning
![Page 1: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/1.jpg)
number partitioning
![Page 2: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/2.jpg)
Like subset sum
![Page 3: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/3.jpg)
![Page 4: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/4.jpg)
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](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/5.jpg)
Try it!
![Page 6: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/6.jpg)
Try that!
4 5 3 2 1 8 7 3 5 9
![Page 7: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/7.jpg)
Try that?
![Page 8: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/8.jpg)
Try that?
![Page 9: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/9.jpg)
Can you think of a 1st test tocarry out to determine if there is no partition?
![Page 10: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/10.jpg)
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](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/11.jpg)
![Page 12: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/12.jpg)
How complex?
![Page 13: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/13.jpg)
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](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/14.jpg)
Why just 2-partition?Why not m-way partitioning?Is there an optimisation problem?
![Page 15: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/15.jpg)
A number of constraint encodings
![Page 16: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/16.jpg)
}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](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/17.jpg)
![Page 18: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/18.jpg)
![Page 19: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/19.jpg)
![Page 20: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/20.jpg)
iiii
iiii
wRLD
RwLD
01
00
![Page 21: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/21.jpg)
1
0
1
0
n
ii
n
ii RL
![Page 22: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/22.jpg)
![Page 23: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/23.jpg)
![Page 24: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/24.jpg)
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](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/25.jpg)
![Page 26: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/26.jpg)
![Page 27: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/27.jpg)
![Page 28: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/28.jpg)
Look! No D!
![Page 29: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/29.jpg)
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](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/30.jpg)
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](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/31.jpg)
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](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/32.jpg)
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](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/33.jpg)
An optimisation problem
Minimise the difference between left and right
A 2nd stab
![Page 34: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/34.jpg)
Minimize imbalance
![Page 35: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/35.jpg)
How do we optimise in CP?
A sequence of decision problems
Branch and bound
![Page 36: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/36.jpg)
![Page 37: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/37.jpg)
Demo of Optimize
![Page 38: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/38.jpg)
Why is Optimize so slow?
![Page 39: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/39.jpg)
When can this propagate?
![Page 40: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/40.jpg)
Can we limit the search effort?
![Page 41: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/41.jpg)
![Page 42: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/42.jpg)
3d stab
![Page 43: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/43.jpg)
3d stab
Optimize is a wee bit “clunky”
Can we do better?
Put ½ the numbers on one side
![Page 44: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/44.jpg)
![Page 45: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/45.jpg)
![Page 46: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/46.jpg)
}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](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/47.jpg)
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](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/48.jpg)
Demo of OptimizeV2
![Page 49: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/49.jpg)
Why was version 2 faster?
![Page 50: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/50.jpg)
Could we Optimize without the decision variable D?
I suppose so … could explore this
Replace scalar with sum
![Page 51: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/51.jpg)
So?
![Page 52: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/52.jpg)
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](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/53.jpg)
![Page 54: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/54.jpg)
![Page 55: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/55.jpg)
![Page 56: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/56.jpg)
… and now for something completely different!!!
![Page 57: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/57.jpg)
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](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/58.jpg)
Decision Problem
![Page 59: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/59.jpg)
Random Data
![Page 60: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/60.jpg)
Random Data
![Page 61: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/61.jpg)
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](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/62.jpg)
Experiment
![Page 63: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/63.jpg)
Experiment
![Page 64: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/64.jpg)
Experiment
![Page 65: number partitioning](https://reader031.fdocuments.net/reader031/viewer/2022012916/56813742550346895d9ed613/html5/thumbnails/65.jpg)
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