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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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?
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
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
You are using a set and sets do not have multiplple emenets and therefore it is not possible. Sorry!
/Kris
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
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
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?
If all weights are 1 then you can skip multiplication by w[i].
/Kris
i am totally confused is there any github example to take a look or any sample of the basic code.
One possible example is at https://github.com/hakank/hakank/blob/master/minizinc/graph_partition.mzn
/Kris