From 1215648b1ba3c592bd9d97b871349673d1702e44 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 13 Dec 2021 20:40:18 +0100 Subject: Faster optimal solver. This is a pretty big one, but unfortunately performance only improved by about 5%. I implemented one of the main ideas of nxopt, that is switching to the inverse scramble on the fly if it gives a lower branching factor. On the one hand it makes sense that it does not have such a huge impact, since it only rarely happens that we do have a lower branching factor on inverse, but on the other hand I am quite sad that the improvement is barely noticeable :-( Maybe the problem is that I have introduced a lot of new overhead and I can improve that in the future. Or maybe I am just overlooking something stupid. --- src/alg.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/alg.c') diff --git a/src/alg.c b/src/alg.c index 4e96925..1158eba 100644 --- a/src/alg.c +++ b/src/alg.c @@ -373,3 +373,35 @@ realloc_alg(Alg *alg, int n) alg->allocated = n; } +void +swapmove(Move *m1, Move *m2) +{ + Move aux; + + aux = *m1; + *m1 = *m2; + *m2 = aux; +} + +void +unniss(Alg *alg) +{ + int i; + Alg *aux; + + aux = new_alg(""); + + for (i = 0; i < alg->len; i++) + if (!alg->inv[i]) + append_move(aux, alg->move[i], false); + + for (i = alg->len-1; i >= 0; i--) + if (alg->inv[i]) + append_move(aux, inverse_move(alg->move[i]), false); + + for (i = 0; i < alg->len; i++) { + alg->move[i] = aux->move[i]; + alg->inv[i] = false; + } + free(aux); +} -- cgit v1.3