mmin and mmax table modes

73 views
Skip to first unread message

Neng-Fa Zhou

unread,
Oct 28, 2025, 10:54:58 PMOct 28
to Picat
The newly released development version 3.9#3 introduces two new table modes, mmin and mmax, which instruct Picat to table all optimal answers. This long-awaited feature greatly enhances the expressiveness and efficiency of dynamic programming models.

Many dynamic programming problems can now be modeled more naturally and solved more efficiently using these modes. For example, the following new solution for the 2024 Advent of Code Day 16 problem:

https://github.com/nfzhou/aoc/blob/main/aoc_24_16_part2_mmin.pi

is much shorter than the original version that used the min mode and runs in less than half the time.

The best_plan_nondet predicate in the planner module of version 3.9#3 now employs the mmin mode in its implementation. It is generally much faster than the previous version, which relied on depth-bounded search. For instance, Oisín’s solution for the 2024 AoC Day 21 problem

https://github.com/DestyNova/advent_of_code_2024/blob/main/16/part2_best_plan_nondet_infeasible.pi

now runs over 1000× faster.

I plan to release a stable version before this year’s Advent of Code. Please let me know if you have any requests or feature suggestions.

Cheers,
NF

Neng-Fa Zhou

unread,
Oct 28, 2025, 11:07:08 PMOct 28
to Picat
Oisin's program for the Day 21 problem is here:


With this new implementation, his program using best_plan_nondet for the Day 16 problem is also much faster now.

Cheers,
NF

Chufeng Jiang

unread,
Oct 29, 2025, 4:31:10 PMOct 29
to Picat
Fantastic! Amazing!

Oisín Mac Fhearaí

unread,
Oct 29, 2025, 5:00:29 PMOct 29
to Neng-Fa Zhou, Picat
That's an amazing improvement! I don't think I fully understand when to use each tabling mode, but at least some trial and error should help build an intuition for which one works in which circumstance.
I'm excited to try the new version for this year's Advent of Code puzzles -- bear in mind this year there will only be 12 days of puzzles, and the global leaderboard won't be used, so it should all be a little calmer.

--
You received this message because you are subscribed to the Google Groups "Picat" group.
To unsubscribe from this group and stop receiving emails from it, send an email to picat-lang+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/picat-lang/c9845ef6-f516-4896-94ac-ad98c3ec0289n%40googlegroups.com.

jf

unread,
Oct 31, 2025, 4:36:40 PMOct 31
to Picat
I have some problem with planner (not the new version):
Picat 3.9#1, (C) picat-lang.org, 2013-2025

When trying to run the copy of the farmer/goat... from the book, I get this error message:

Undefined procedure: c_PICAT_TABLE_MAP_DEL_cc/2

(for best_plan, plan works).

Please check if the new version has this problem as well.
Thank you,
JF

-----


import planner.
main =>
   S0 = [s,s,s,s],
   best_plan(S0,Plan),
   writeln(Plan).

final([n,n,n,n]) => true.

action([F,F,G,C],S1,Action,ActionCost) ?=>
   Action = farmer_wolf,
   ActionCost = 1,
   opposite(F,F1),
   S1 = [F1,F1,G,C],
   not unsafe(S1).
   action([F,W,F,C],S1,Action,ActionCost) ?=>
   Action = farmer_goat,
   ActionCost = 1,
   opposite(F,F1),
   S1 = [F1,W,F1,C],
   not unsafe(S1).
action([F,W,G,F],S1,Action,ActionCost) ?=>
   Action = farmer_cabbage,
   ActionCost = 1,
   opposite(F,F1),
   S1 = [F1,W,G,F1],
   not unsafe(S1).
action([F,W,G,C],S1,Action,ActionCost) =>
   Action = farmer_alone,
   ActionCost = 1,
   opposite(F,F1),
   S1 = [F1,W,G,C],
   not unsafe(S1).

index (+,-) (-,+)
opposite(n,s).
opposite(s,n).

unsafe([F,W,G,_C]), W == G, F !== W => true.
unsafe([F,_W,G,C]), G == C, F !== G => true.






Dne středa 29. října 2025 v 22:00:29 UTC+1 uživatel Oisín Mac Fhearaí napsal:

Neng-Fa Zhou

unread,
Nov 25, 2025, 10:04:52 PMNov 25
to Picat
I don't see this issue in the development version 3.9#3. I don't recall any changes made after version 3.9#1 that affect this program. Could you check on your side if the issue is indeed in version 3.9#1 and if the issue is still in 3.9#3? I am about release a stable version, and thought that the issue should be addressed in the new release.

Thank you,
NF 

jf

unread,
Nov 26, 2025, 2:44:19 PMNov 26
to Picat
Dear Sir,

the problem persists in Picat 3.9#3, (C) picat-lang.org, 2013-2025

* However: *
I have compiled my own version with regexes from Hakan Kjellerstrand

It works without problem, but fails with plan.

I have downloaded pre-compiled - original - picat binary and it works OK as expected.

Therefore the problem seems to be either by some regex incompatibility or some problem
with my compilation of picat with regexes. [ubuntu 24.04].

Best regards
Jf



Dne středa 26. listopadu 2025 v 4:04:52 UTC+1 uživatel Neng-Fa Zhou napsal:

Hakan Kjellerstrand

unread,
Nov 26, 2025, 2:58:07 PMNov 26
to Picat
Hi, Jf.

I tested your program using 3.9#3 compiled with regex and it works without any problems. Note that I'm running on a Ubuntu 20.04 .

Did you try with the current 3.9#3 version: (from Oct 29)  https://picat-lang.org/download/picat393_src.tar.gz ?

Can you test with my version (compiled on Ubuntu 20.04) and see if that work? https://hakank.org/picat/picat_v3_9__3_3.zip

Best,

Hakan

Hakan Kjellerstrand

unread,
Nov 26, 2025, 3:42:23 PMNov 26
to Picat
Also, what happens if you compile 3.9#3 without including the regex stuff?

/Hakan

Peter Ludemann

unread,
Nov 26, 2025, 4:11:39 PMNov 26
to Picat
Which regex library does Picat use (and Ubunto 20 supplies)?
There have been some changes over time.
(I modified SWI-Prolog's regexp to use the latest pcre2 libraries ... contact me directly if you want more info).

- peter

Hakan Kjellerstrand

unread,
Nov 26, 2025, 4:23:27 PMNov 26
to Peter Ludemann, Picat
Hi Peter.

The regex module is not included in the official Picat distribution. I added an interface to (some functions in) PCRE2 which requires some changes in the Picat source code. I'm using -lpcre2-8 .
See https://github.com/hakank/picat_regex for more information.

Best,

Hakan



--

Peter Ludemann

unread,
Nov 26, 2025, 7:33:28 PMNov 26
to Hakan Kjellerstrand, Picat
Hi Halkan:

If you're using the 8-bit API, I presume you're also using the PCRE2_UTF flag? (That's what I'm using)

I have a Debian system (ChromeBook) and the libpcre2-dev package, dated 01 Jan 2023 (!) with documentation dated 17 Feb 2024 (!) ... presumably Ubuntu is using something a bit more modern. Anyway, I'm using release 10.42 and the latest release (October 2025) is 10.47. Release 10.43 and 10.45 have a "lot of changes" ... I don't know if any of these releases require code changes.

I also have an Ubuntu system but it needs to be upgraded before I can do anything with it, and that upgrade won't happen before end of year.
Reply all
Reply to author
Forward
0 new messages