CP-SAT, breaking symmetries in graph coloring using lowest index color ordering

237 views
Skip to first unread message

fbahr

unread,
Jul 21, 2022, 11:48:37 AM7/21/22
to or-tools-discuss
Hello there...

I'd like to implement a symmetry breaking rule for the graph coloring problem which -- for a given graph G=(V,E) w/ V = {0,...,n} --basically requires that a color i (encoded by an integer 0 <= i <= m) can only be assigned to a vertex with index j if there's at least one other vertex with index k < j that is colored using color i+1.

Can this be achieved without introducing a "bunch" of binary variables `color[v,c]` encoding whether a vertex v is assigned color c. (Right now, I'm using integer variables w/ domain [0,...,m] to encode the coloring of a vertex. Hence, ideally, I'd be looking for something like:
"addImplication(x[v] == i, exists(x[w] == i+1 for w \in {0,v-1})").

Thanks in advance for your input,
FB


Laurent Perron

unread,
Jul 21, 2022, 12:23:53 PM7/21/22
to or-tools-discuss
Remove the integer variable, and use the Boolean ones
 They will be created anyway, in addition to the integer variables. 

--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/or-tools-discuss/f25b5632-fb86-4b65-bc1b-7b98434a8240n%40googlegroups.com.

fbahr

unread,
Jul 21, 2022, 12:36:56 PM7/21/22
to or-tools-discuss
I was afraid you'd say sth. like this ;-)

Well, it's a "bunch" of variables then...

Thanks for the advice!


On Thursday, July 21, 2022 at 6:23:53 PM UTC+2 Laurent Perron wrote:
Remove the integer variable, and use the Boolean ones
 They will be created anyway, in addition to the integer variables. 

Le jeu. 21 juil. 2022, 08:48, fbahr <floria...@gmail.com> a écrit :
Hello there...

I'd like to implement a symmetry breaking rule for the graph coloring problem which -- for a given graph G=(V,E) w/ V = {0,...,n} -- basically requires that a color i (encoded by an integer 0 <= i <= m) can only be assigned to a vertex with index j if there's at least one other vertex with index k < j that is colored using color i+1.

Can this be achieved without introducing a "bunch" of binary variables `color[v,c]` encoding whether a vertex v is assigned color c. (Right now, I'm using integer variables w/ domain [0,...,m] to encode the coloring of a vertex. Hence, ideally, I'd be looking for something like:
"addImplication(x[v] == i, exists(x[w] == i+1 for w \in {0,v-1})").

Thanks in advance for your input,
FB


Laurent Perron

unread,
Jul 21, 2022, 1:00:35 PM7/21/22
to or-tools-discuss
Presolve will create them anyway. 

fbahr

unread,
Jul 22, 2022, 2:35:45 PM7/22/22
to or-tools-discuss
Sorry, for "nagging" you again... but:

Now, given both `x[v] = i` (`x` being a dict of IntVars, `v` a vertex index, and `i` the value assigned to `x[v]`) and `color[v,i]` (`color` being a dict of dicts of BoolVars, `color[v][i]` determining whether vertex `v` is assigned color `i`), the most basic way to relate those two "sets" of variables in a purely MIP setting clearly is to require
1) sum_i { color[v][i] } = 1 \forall v (or, in CP-SAT-speak: addExactlyOne)
2) x[v] = sum_i { i * color[v][i] } \forall v.

Is there a more elegant and/or efficient "CP-way" to achieve this (for instance -- not exactly sure what I'm talking about here -- maybe exploiting addElement)?

With kind regards,
FB

Laurent Perron

unread,
Jul 22, 2022, 4:00:51 PM7/22/22
to or-tools-discuss
why do you need X, replace it with a list of Booleans
Laurent Perron | Operations Research | lpe...@google.com | (33) 1 42 68 53 00



Reply all
Reply to author
Forward
0 new messages