Menu

The Graph Partitioning Problem

Help
Pangiotis
2017-11-06
2017-11-09
  • Pangiotis

    Pangiotis - 2017-11-06

    i am trying to simulate the The Graph Partitioning Problem but i am bit confused. i defined a collection of integers using "Set Constraints" but my problem is that Set with BoundSetDomain is defined with glb(d) = {1}, set containing element 1, and lub(d) = {1..3}, set containing elements 1, 2 and 3. For example, i want to have exaclty a set of {1,3} and not {1..3}, with 1, 2 and 3. What can i do here can you help me?

     
  • kris

    kris - 2017-11-07

    You can do it by constracring IntervalDomain to values you want. For example

    SetVar v = new SetVar(store, "v", new BoundSetDomain(
    new IntervalDomain(1, 2),
    new IntervalDomain(1, 10)));

    will create v::{{1..2}..{1..10}}[card={2..10}]

    If you want glb = {1,3} you need to create IntervalDomain constaining 1 and then add 3. For example

    d = new IntervalDomain(1, 1);
    d.unionAdapt(3,3);

    This should give you d :: {{1,3}..{1..3}}[card=2..3}]

    You may also use addElement method from IntervalDomain.

    I hope it helps,
    /Kris

     
  • Pangiotis

    Pangiotis - 2017-11-08

    yes but what about if i want to add multiple edges for my graph partion problem except from {1.3}. For example i want to have to simulate edges of the graph d :: {{1,3}..{2,4}..{3,2} etc }.what i do in this occasion? i was trying to do
    d.unionAdapt(1,3);
    d.unionAdapt(2,4);
    but it not works for the second element

     
  • kris

    kris - 2017-11-08

    You are using a set and sets do not have multiplple emenets and therefore it is not possible. Sorry!

    /Kris

     
  • Pangiotis

    Pangiotis - 2017-11-08

    what do i need to use to solve the graph partition problem instead of sets then? i will appreciate a lot if you might give me some directions

     
  • kris

    kris - 2017-11-08

    I would do the following. I define variable p[i] for each node i and then define the partitioning cost, for example, as number of edges that go between partitions. This can be definef as

    cost = sum (i in 1..n, j in i+1..n) ( (x[i] != x[j]) * w[i]);

    where w[i] defines the "weight" of the edge or numbe rof edges going between two nodes. Then we can minimize the cost of partitioning.

    /Kris

     
  • Pangiotis

    Pangiotis - 2017-11-08

    thanks for this approach, but my problem has equal weights(1 for all) of each edge. Consider this approach to briefly understand it here . What do you suggest for this approach?

     
  • kris

    kris - 2017-11-08

    If all weights are 1 then you can skip multiplication by w[i].
    /Kris

     
  • Pangiotis

    Pangiotis - 2017-11-09

    i am totally confused is there any github example to take a look or any sample of the basic code.

     

Log in to post a comment.