GraphPartitioningwithAMPL Graph Partitioning with AMPL Antonio Mucherino Laboratoried’Informatique,ÉcolePolytechnique CourseonOperationsResearch (ISC610A) SemesterI- 2008/09 TD5-December4th 2008 GraphPartitioningwithAMPL Graphpartitioning Introduction Recalling some definitions: Clustering Wealreadyknowwhataclusteringproblemis. LetX beasetofsampleswhosepartitionisunknown. Letussupposethatthereisnopreviousknowledgeaboutthe data(notrainingsetisavailable). Definition Clusteringisaimedatfindingapartition{C ,C ,...,C }ofthesetof 1 2 K data,suchthat K X = C, ∀i,j|1≤i <j ≤K C ∩C =∅. i i j i[=1 Eachclusterrepresentsasubsetoffeaturesofthesamplesthat itcontains. GraphPartitioningwithAMPL Graphpartitioning Introduction Recalling some definitions: Graph Wealreadyknowwhatagraphis. Definition AgraphisanorderedpairG =(V,E)comprisingasetV ofvertices ornodestogetherwithasetE ofedgesorlinks,whichare2-element subsetsofV. Undirectedgraph: agraphinwhichedgeshavenoorientation. DirectedgraphorDigraph: agraphG =(V,A),whereAisa setoforderedpairsofvertices,evencalledarcsordirected edges. Weightedgraph: agraphinwhichnumbers(weights)are assignedtoeachedge. Itcanbedirectedandundirected. Itis denotedbyG =(V,E,w)orG =(V,A,w),wherew represents theweights. GraphPartitioningwithAMPL Graphpartitioning Introduction Recalling some definitions: Graph partitioning Definition Graphpartitioning istheclusteringproblemoffindingasuitable partitionofasetofdatarepresentedthroughagraphG. EachclusterisasubgraphofthegraphG,i.e. asubsetofits vertices. Intuitively,thebestpartitionistheonethatseparatessparsely connecteddensesubgraphsfromeachother. sparselyconnected: thenumberofedgesbetweenvertices belongingtodifferentclustersisminimal. dense: thenumberofedgesbetweenverticesbelongingtothe sameclusterismaximum. GraphPartitioningwithAMPL Graphpartitioning Mathematicalformulation Formulating an optimization problem Howcanwesolveagraphpartitioningproblem? Weneedtofindapartitioninclustersofaweightedundirected graphG=(V,E,c),where V isthesetofverticesofG, E isthesetofedgesofG, c isthesetofweightseventuallyassignedtotheedges. Thisproblemcanbeformulatedasaglobaloptimization problem. Wewantthenumberofedgesbetweenverticesbelonging to differentclusterstobeminimal. Therefore,weneedtosolveaminimizationproblem,subjecttoa certainnumberofcontraints. WewillsolvethisproblembyCPLEX/AMPL. GraphPartitioningwithAMPL Graphpartitioning Mathematicalformulation Parameters and Variables Parameters V,setofverticesofG E,setofedgesofG c,setofweightsofG K,numberofdesiredclustersinthepartition Variables x ,binary,indicatesifthevertexu iscontainedinto uk theclusterk ≤K: 1 ifu ∈kthcluster x = uk (cid:26) 0 otherwise GraphPartitioningwithAMPL Graphpartitioning Mathematicalformulation Objective function Whatdoweneedtominimize? Wewantthetotalweightsoftheedgesbetweendifferent clusterstobeasminimumaspossible: Thinkitout: youshouldbeabletogiveananswerwithin1 minute! GraphPartitioningwithAMPL Graphpartitioning Mathematicalformulation Objective function Whatdoweneedtominimize? Wewantthetotalweightsoftheedgesbetweendifferent clusterstobeasminimumaspossible: 1 min c x x 2 uv uk vl k6=Xl≤K(uX,v)∈E Thinkitout: youshouldbeabletogiveananswerwithin1 minute! GraphPartitioningwithAMPL Graphpartitioning Mathematicalformulation Constraints ConstraintI Eachvertexmustbeassignedtoonlyonecluster: ∀u ∈V x =1 uk kX≤K ConstraintII Thetrivialsolution(allthevertecesintoonecluster)mustbe excluded: ∀k ∈K x ≥1 uk uX∈V GraphPartitioningwithAMPL Graphpartitioning Mathematicalformulation Constraints ConstraintIII (ingeneral,optional) Eachclustercannotexceedacertaincardinality: ∀k ≤K x ≤C uk uX∈V ConstraintIV (ingeneral,optional) Verticeshavingdifferentcolorcannotbeclusteredtogether: ∀u 6=v ∈V, k 6=l ≤K, x x ≤γ uk vl uv where 1 ifuandvhavethesamecolor γ = uv (cid:26) 0 otherwise
Description: