diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-12-13 20:40:18 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-12-13 20:40:18 +0100 |
| commit | 1215648b1ba3c592bd9d97b871349673d1702e44 (patch) | |
| tree | 7dc73a013c76b0cb0976e98d5e07902a0045363f /src/alg.c | |
| parent | 296f35b7ed4ea3177c520f28176f44d6ad47d76d (diff) | |
| download | nissy-1215648b1ba3c592bd9d97b871349673d1702e44.tar.gz nissy-1215648b1ba3c592bd9d97b871349673d1702e44.zip | |
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.
Diffstat (limited to 'src/alg.c')
| -rw-r--r-- | src/alg.c | 32 |
1 files changed, 32 insertions, 0 deletions
| @@ -373,3 +373,35 @@ realloc_alg(Alg *alg, int n) | |||
| 373 | alg->allocated = n; | 373 | alg->allocated = n; |
| 374 | } | 374 | } |
| 375 | 375 | ||
| 376 | void | ||
| 377 | swapmove(Move *m1, Move *m2) | ||
| 378 | { | ||
| 379 | Move aux; | ||
| 380 | |||
| 381 | aux = *m1; | ||
| 382 | *m1 = *m2; | ||
| 383 | *m2 = aux; | ||
| 384 | } | ||
| 385 | |||
| 386 | void | ||
| 387 | unniss(Alg *alg) | ||
| 388 | { | ||
| 389 | int i; | ||
| 390 | Alg *aux; | ||
| 391 | |||
| 392 | aux = new_alg(""); | ||
| 393 | |||
| 394 | for (i = 0; i < alg->len; i++) | ||
| 395 | if (!alg->inv[i]) | ||
| 396 | append_move(aux, alg->move[i], false); | ||
| 397 | |||
| 398 | for (i = alg->len-1; i >= 0; i--) | ||
| 399 | if (alg->inv[i]) | ||
| 400 | append_move(aux, inverse_move(alg->move[i]), false); | ||
| 401 | |||
| 402 | for (i = 0; i < alg->len; i++) { | ||
| 403 | alg->move[i] = aux->move[i]; | ||
| 404 | alg->inv[i] = false; | ||
| 405 | } | ||
| 406 | free(aux); | ||
| 407 | } | ||
