combinatorial generation problemsperezguillau.me/document/combi_tutorial_2018.pdf · •...
TRANSCRIPT
CombinatorialGenerationProblems
GuillaumePerez
Motivations
• Combinatorialproblemsareeverywhere
2
Pickupanddeliveries
DamsplacementinamazonKnapsackproblems
Musicandtextgeneration
CombinatorialOptimizationProblems
• Findinganoptimal objectfromafinitesetofobjects• Example:Findingtheshortestpathinagraph
• Decisionvariablesarediscrete• Differentfromcontinuousoptimization
3
Easywithcontinuous variables Hard withdiscretevariables
max
Pi2S xivi
subject to:
Pi2S xiwi W
Knapsackproblems
xixi
Theend?
ThankYou
• Questions?
4
OnSolvingCombinatorialProblems
5
ProblemModeling
Optimization
SolutionModel
OnSolvingCombinatorialProblems
6
ProblemModeling
Optimization
SolutionModel
OnSolvingCombinatorialProblems
7
ProblemModeling
Overapproximation
Optimization
SolutionModel
OnSolvingCombinatorialProblems
8
ProblemModeling
Overapproximation
Underapproximation
Optimization
Solution
ModelingisanArt,butoptimizingisascience
Model
SequenceGeneration
• Generateasequence
• Butwithconstraints• #orange<3• #apple>1• Finishbystrawberry
9
Productlinescheduling
x1 x2 x3 x4 x5 x6 x7
7 5 3 5 3 7 7
Generationunderconstraints
• WhatifIwanttogenerateatextwithrhymes?
• Textandmusicusingsomeone’s“style”?
• Musicwithoutplagiarism?
• Poetrywithagivennumberofsyllables?
10
FindarhymewithcombinatorialThatdoesn’tsound artificial
Letitgo,letitgoCan'thold itbackanymore
Inthemonthofthe longdeclineofrosesI,beholdingthesummerdeadbeforeme,Setmyfacetotheseaandjourneyedsilent,
Algernon CharlesSwinburne
Examplewithimage
Generationunderconstraints
• WhatifIwanttogenerateatextwithrhymes?
• Textandmusicusingsomeone’s“style”?
• Musicwithoutplagiarism?
• Poetrywithagivennumberofsyllables?
11
FindarhymewithcombinatorialThatdoesn’tsound artificial
Letitgo,letitgoCan'thold itbackanymore
Inthemonthofthe longdeclineofrosesI,beholdingthesummerdeadbeforeme,Setmyfacetotheseaandjourneyedsilent,
Algernon CharlesSwinburne
Examplewithimage
SequencewithRhymes
• Example,rhymesbetweeneachtwolines
• Howtoexpress that?• 1variablepersyllable?• 1variableperword?
12
IbePuertoRicandayparadefloatin’ThatBenzMarinaDelReycoastin’SheinschooltobearealestateagentLastmonth Ihelpedherwiththecarpayment
Famous– KanyeWest
x1 x2 x3 x4 x5x6 x7 x8 x9 x10
Constraint:x5 andx10 mustrhyme.
https://youtu.be/1wYXSxCvN68?t=73
SequencewithRhymes
• Givenacorpus
• Generatesentencesthatrhyme
• WhatvaluesfortheXi withi ≠{5,10}?
• WhatvaluesfortheXi withi ={5,10}?
13
x1 x2 x3 x4 x5x6 x7 x8 x9 x10
Constraint:x5 andx10 mustrhyme.
Section2inexercises
Generationunderconstraints
• WhatifIwanttogenerateatextwithrhymes?
• Textandmusicusingsomeone’s“style”?
• Musicwithoutplagiarism?
• Poetrywithagivennumberofsyllables?
14
FindarhymewithcombinatorialThatdoesn’tsound artificial
Letitgo,letitgoCan'thold itbackanymore
Inthemonthofthe longdeclineofrosesI,beholdingthesummerdeadbeforeme,Setmyfacetotheseaandjourneyedsilent,
Algernon CharlesSwinburne
Examplewithimage
SequencewithStyle
• What’ssomeonestyle?• It’sownwayofdoing orpresentingthings.
• Howtoextract it?
• Howtouseittogenerate newcontents?
15
Blindweare,ifcreationofthisclonearmywecouldnotsee.
Yoda
extract Style
generate
SequencewithStyle
• Example• Extract thewordstransitionprocess
• Generate• Great lords build
16
• Toycorpus:Great lords listenbuteverybourgeois listenwhilegreat bourgeoisbuildwheneverylordsbuild
redcatsfollowbutyellowdogssleepwhilereddogsfollowwhenyellowcatssleep
Section3inexercises
ThisisastateJ
SequencewithStyleandRhymes
• Complexity?• NP-complete (reductionfrom3-SAT)toprovethatitexistsasolution• #P-complete(reductionfromcounting3-SAT)forexactsampling
17
Theend?
ThankYou
• Questions?
18
ModelingWithConstraints
• Manyframeworksexist• Satsolvers• MIPsolvers• ConstraintProgramming(CP)solvers
• Modeling• Variableswithdomain
• Constraints
19
x1 x2 x3 x4 x5x6 x7 x8 x9 x10
Constraint:x5 andx10 mustrhyme.
BlackboxSolvers
SequencewithStyleandRhymes
• Ourfirstmodel• 10Variables
• 5bysentence• Domain:allpossiblewordsfromcorpus
• Transitionconstraint• Betweenconsecutivevariables
• Rhymeconstraint• Betweenthetwolastwords
20
X1
X2
X3
X4
X5
X6
X7
X8
X9
X10
Variables
Transitio
n
Transitio
n
Transitio
n
Transitio
n
Transitio
n
Transitio
n
Transitio
nTransitio
n
Transitio
n
Rhym
e
Transitionconstraint?
• Standalone• Justpickonewordinthepossiblenext
• Constraint• Booleanformula:• Table:
21
• Toycorpus:Great lords listenbuteverybourgeois listenwhilegreat bourgeoisbuildwheneverylordsbuild
redcatsfollowbutyellowdogssleepwhilereddogsfollowwhenyellowcatssleep
Xi
Xi+1Transitio
n =great
=lords∨ =bourgeois
Xi Xi+1
great lordsgreat bourgeois
Xi Xi+1
great lordsgreat bourgeois… …
Xi=great∧ Xi+1=lords∨Xi=great∧ Xi+1=bourgeois
Section5inexercises
Generationunderconstraints
• WhatifIwanttogenerateatextwithrhymes?
• Textandmusicusingsomeone’s“style”?
• Musicwithoutplagiarism?
• Poetrywithagivennumberofsyllables?
22
FindarhymewithcombinatorialThatdoesn’tsound artificial
Letitgo,letitgoCan'thold itbackanymore
Inthemonthofthe longdeclineofrosesI,beholdingthesummerdeadbeforeme,Setmyfacetotheseaandjourneyedsilent,
Algernon CharlesSwinburne
Examplewithimage
SequenceWithoutplagiarism
• Problem:• MaxOrder (Papadopoulosetal.,AAAI2014)• Avoiding plagiarisminMarkovsequencegeneration
• Exampleofgoal:• Basedonacorpus
• Generate sequences
• All thesubsequences ofsize2belongtothecorpus• “Greatlordssleep”Fail(unknowntransition)
• None ofthesubsequences ofsize3belongstothecorpus• “Greatlords listen“Fail(plagiarism)
• “Redcatssleep”Success
23
• Toycorpus:Greatlordslistenbuteverybourgeois listenwhilegreatbourgeoisbuildwheneverylordsbuild
redcatsfollowbutyellowdogssleepwhilereddogsfollowwhenyellowcatssleep
SequencewithStyleandRhymes
• Ourfirstmodel• 10Variables
• 5bysentence• Domain:allpossiblewordsfromcorpus
• Transitionconstraint• Betweenconsecutive2variables
• Rhymeconstraint• Betweenthetwolastwords
• PlagiarismConstraint• Betweenconsecutive3variables
24
X1
X2
X3
X4
X5
X6
X7
X8
X9
X10
Variables
Transitio
n
Transitio
n
Transitio
n
Transitio
n
Transitio
n
Transitio
n
Transitio
nTransitio
n
Transitio
n
Rhym
e
Forbidden
Forbidden
Forbidden
Forbidden
Forbidden
Forbidden
Forbidden
Forbidden
Section6inexercises
Inconsistency
• Example
• Solution:• Usemodelingtools
25
X1
X2
X3
X4
Constraint
1
Constraint
2
X1 X2 X3 X4
a b a bb a b a
X1 X2 X3 X4
a a a ab b b b
Constraint 1
Constraint 2Nosolution!
Combinatorialproblemsolving
• Needforefficientmodelingtools• Hardtoexpress
• Let’susethesolutions
• Efficientdatastructure:1. Efficientlyrepresentsdiscreteproblemsolutions
1. Compression
2. Efficientlycombinable2. Combination
3. Integratedintosolversviafastandincrementalalgorithms.3. Integration
26
root
a
0
b
1
c
0 2 1
d
02
tt
1 2 0
• BDDgeneralization
• EachLayerrepresentsavariable• Eacharc islabeledbyavalue
• Eachpath fromroot nodetott noderepresentsavalidassignment
• Exponentialcompressionpower• Exponentialnumberortuples
Multi-valuedDecisionDiagram(MDD)
X1
X2
X3
27
root
a
0
b
1
c
0 2 1
d
02
tt
1 2 0
Multi-valuedDecisionDiagram(MDD)
28
X1 X2 X30 0 10 0 20 2 10 2 21 1 11 1 21 0 01 2 0
24valuesVS 10arcs+6nodes
1090 tuplesVS14,000nodes100variables600,000arcs
root
a
0
b
1
c
0 2 1
d
02
tt
1 2 0
Reduction• Operationwhichmerges equivalent nodes
• Twonodesareequivalentiftheyhavethesameoutgoingarcs
• Foragivenvariableordering• Canonical
root
a
0
b
1
c
0 1
d
2
e
0 1
tt
0 1 1 0 1
29
Reduction• Operationwhichmerges equivalent nodes
• Twonodesareequivalentiftheyhavethesameoutgoingarcs
• Foragivenvariableordering• Canonical
• Compressionismadebyreduction• Sub-graphsharing
root
a
0
b
1
ce
0 1
d
2 01
tt
011
30
Combination
root1
a
0
b
1
ce
0 1
d
2 01
tt1
011
root2
k
0 2
l
0 2
tt2
1 2
31
∩ =
root
0
0 2
tt
1
Allsetoperations
GoalMDDTransition∩¬Plagiarism
32
• Toycorpus:Greatlordslistenbuteverybourgeois listenwhilegreatbourgeoisbuildwheneverylordsbuild
redcatsfollowbutyellowdogssleepwhilereddogsfollowwhenyellowcatssleep
Redcatssleep
r
great every red yellow
lords bourgeois bourgeois lords
tt
build listen
cats dogs cats dogs
sleep follow
MaxOrderMDDmodel
Corpus
M
MarkovMDDm (Size3)
33
MarkovMDD
34
• Toycorpus:Greatlordslistenbuteverybourgeois listenwhilegreatbourgeoisbuildwheneverylordsbuild
redcatsfollowbutyellowdogssleepwhilereddogsfollowwhenyellowcatssleep
Redcatssleepr
great every red yellow
lords bourgeois
tt
build listen
cats dogs
sleep follow
MaxOrderMDDmodel
Corpus
M
P
MarkovMDDm (Size3)
ProhibitedsequencesMDD3 (Size3)
35
ProhibitedMDD
36
• Toycorpus:Greatlordslisten buteverybourgeois listenwhilegreatbourgeoisbuildwheneverylordsbuild
redcatsfollowbutyellowdogssleepwhilereddogsfollowwhenyellowcatsleep
r
great every red yellow
lords bourgeois bourgeois lords
tt
listen build
cats dogs cats dogs
follow sleep
MaxOrderMDDmodel
Corpus V
Allthesolutions (size3)
MDDv (valid)
M
P
MarkovMDDm (Size3)
ProhibitedsequencesMDD3 (Size3)
DeletionM– P
Remark:P⊆M
37
Removing
38
r
great every red yellow
lords bourgeois bourgeois lords
tt
build listen
cats dogs cats dogs
sleep follow
r
great every red yellow
lords bourgeois
tt
build listen
cats dogs
sleep follow
r
great every red yellow
lords bourgeois bourgeois lords
tt
listen build
cats dogs cats dogs
follow sleep
=-MarkovMDD ProhibitedMDD
Allsolutions
MaxOrderMDDmodel
V
X1
X2
X3
X4
X5
X6
X7
X8
X9
X10
X11
IntersectionMDDGlobalValid
VariablesConstraints
39
V
V
V
V
V
V
V
V
MaxOrder Results
• MDDcontainsallthesolutions• NolongerneedasolverJ• Canbeembeddedwithotherconstraints
• Benchmark“Proust– Àlarecherchedutempsperdu”• 11,000differentwords(domain)• MaxPlagiarism:4• Generatesequencesoflength20• 2creations&1deletion&16intersections
• MDDSize• 1Mnodes, 190Marcs• 2.2*1035 tuples
• Results• First:~400seconds, equivalent totheadhocalgorithm• Orderingeffect:143s
40
Compressionratio:1027
MDDGlobalValid
Generationunderconstraints
• WhatifIwanttogenerateatextwithrhymes?
• Textandmusicusingsomeone’s“style”?
• Musicwithoutplagiarism?
• Poetrywithagivennumberofsyllables?
41
FindarhymewithcombinatorialThatdoesn’tsound artificial
Letitgo,letitgoCan'thold itbackanymore
Inthemonthofthe longdeclineofrosesI,beholdingthesummerdeadbeforeme,Setmyfacetotheseaandjourneyedsilent,
Algernon CharlesSwinburne
Examplewithimage
Sequencewithagivennumberofsyllables
• Syllabicpoeticmeter• 12syllables
• Frenchpoetsfrom17th to19th century
• Automaticgenerationfromacorpus• Example• Grands seigneurs, toutbourgeoisveut batir comme unBœuf
• Greatlords,everybourgeoiswantstobuildlikeaBeef• Grands – sei – gneurs - tout– bour – geois – veut – bâ- tir – comme – un– Bœuf• 1 2 3 4 5 6 78910 11 12
42
Sampling Model
Corpus
M
MarkovMDDm (Sizen)
43
MarkovMDD
44
• Toycorpus:Greatlordslistenbuteverybourgeois listenwhilegreatbourgeoisbuildwheneverylordsbuild
redcatsfollowbutyellowdogssleepwhilereddogsfollowwhenyellowcatsleep
Redcatssleepr
great every red yellow
lords bourgeois
tt
build listen
cats dogs
sleep follow
Sampling Model
Corpus
M
MarkovMDDm (Sizen)
M ∑
Arclabelreplacedbytheirnumberofsyllables
45
ValueTransformation
46
Transformationr
great every red yellow
lords bourgeois
tt
build listen
cats dogs
sleep follow
r
1 3 1 2
1 2
tt
1 2
1 1
1 2
Sampling Model
Corpus
M
MarkovMDDm (Sizen)
∑
∑(1,k)=12Sumofnvariableshavingthevalues1tokasdomain
M ∑
Arclabelreplacedbytheirnumberofsyllables
47
SumMDD
• ∑(1,3)=5• Allthepathsarecomposedofvalueswhosesumis5.
r
1
1
2
2
3
3
2
1
3
2
4
3 1 2 1
tt
3 2 1
48
Sampling Model
Corpus
M
MarkovMDDm (Sizen)
∑
∑(1,k)=12Sumofnvariableshavingthevalues1tokasdomain
M ∑
Arclabelreplacedbytheirnumberofsyllables
AIntersection
Allthesolutions
49
Intersection
50
r
1
1
2
2
3
3
2
1
3
2
4
3 1 2 1
tt
3 2 1
r
1 3 1 2
1 2
tt
1 2
1 1
1 2
∩ =r
1
1
3
3
2
2
3
2
4
1
tt
2 1
3
11
2
Conversion
r
1
1
3
3
2
2
3
2
4
1
tt
2 1
3
11
2
• Solutions:• Sequencesofsize2fromthecorpus• Sumofsyllablesequal5• (Usually12)
51
r
1
great
3
every
2
yellow
3
bourgeois
4
lords
tt
listen build
3
cats dogs
follow
Transformation
• NowSample!• BigMDDs
• Millionsofnodes• Hugeamountofsolution• 1090 in our problems
Conclusion
• Learntomodelandsolvesomeproblems
• Usingstandalonemethods
• Usingbasicsofmodelingandsolvers
• Usingsomeadvancemodelingtools
• Providedgoodmodelforsomehardproblems
52
ThankYou
• Questions?• ForrealJ
53
CombinatorialGenerationProblems
GuillaumePerez