New to Picat - small snag

84 views
Skip to first unread message

Alex Gian

unread,
Mar 30, 2026, 8:01:36 PM (10 days ago) Mar 30
to Picat
Hello.  I have just started trying out Picat, so far I am very encouraged, I have a little exposure to other CP environments, nice to see all the different approaches.

I have come across the following problem:
I've tried to run the sample linear programming file 'diet.pi', as included in the distribution.
However, when I ran 'main', I got
    Picat> main
    *** error(existence_error(mip_solver),solve)
As if the mip solver was missing!
I tried changing the 'import' line. and solving it wit SAT and with CP, they both worked fine, it's just MIP that's not working.  Any ideas?

Even though I usually use Linux, I am running this on Win 11, 
Picat 3.9#7, (C) picat-lang.org, 2013-2026


Finally, my condolences re Håkan Kjellerstrand, it was through his articles that I landed on Picat, definitely one of the good guys.  Hope his shoes get filled.

Regards


Sergii Dymchenko

unread,
Mar 30, 2026, 9:05:11 PM (10 days ago) Mar 30
to Alex Gian, Picat
Hi,

For mip, Picat needs a linear programming solver installed. A reasonably fast open source one is cbc https://github.com/coin-or/cbc
After installing a solver the mip module should work.

-Sergii.

--
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/71dabe93-3960-4d0c-9dd9-fdd2923c03e3n%40googlegroups.com.

Alex Gian

unread,
Apr 1, 2026, 1:31:38 AM (8 days ago) Apr 1
to Picat
Thanks for that Sergii, but I an still a bit unclear on how to proceed.
I have now placed the cbc executable in the same path as the picat exe, but am not sure how I specify for the system to use it as its default mip solver.
The Picat guide says:
 cbc: Instruct Picat to use the Cbc MIP solver. Picat uses the following command to call the 
 Cbc solver :
 cbc TmpFile solve -solu SolFile
 where SolFile is a file for the solution, and TmpFile is a file that stores the CPLEX-format
 constraints. Picat throws existence_error if the command cbc is not available.

which makes no sense to me me.  Is there some line I must add to the program, or some command line option which I cannot see?
Am I supposed to specify TmpFle and SolFile myself, and if so, how?

All suggestions/hints/specific instructions appreciated...

Chufeng Jiang

unread,
Apr 1, 2026, 8:24:24 AM (8 days ago) Apr 1
to Alex Gian, Picat
Hi, What operating system are you using?

Alex Gian <alex...@gmail.com>于2026年4月1日 周三上午1:31写道:

David Silverman

unread,
Apr 1, 2026, 9:22:47 AM (8 days ago) Apr 1
to Picat
I recommend also my guide for picat newcomers. Here’s is a link for the MIP solver. 
  https://github.com/dsagman/picat/blob/main/readme.md#mip-mixed-integer-programming-integer-and-real

Alex Gian

unread,
Apr 1, 2026, 1:59:33 PM (8 days ago) Apr 1
to Picat
Thanks David,

I was already looking at your "Things I wish I'd known..." book, great stuff!  Good to see you around, you seem to ask the same sort of questions I would  ;)   )I was just looking at your q re "path" functions, I've been occupied with the same concept in puzzle solving.)

Now, on the subject of setting the default mip solver, I am still facing a bit of trouble.  Following your link, I saw that the correct form is  'solve([cbc], Vars)'.  Staying with the 'diet.pi' example I tried first:
solve([cbc], $[min(XSum],Xs),
which, of course did not work as there is no solve/3 defined. then I tried
solve([cbc], [$[min(XSum],Xs]),
which was accepted, but also failed, reporting:
*** error(existence_error(cbc), solve)
I have placed the cbc executable both on the same path as picat.exe and in the work directory, so I am unsure what to try next.
I wonder if its a Windows specific error, perhapps the name 'cbc.exe' instead of 'cbc' that's the problem.

Thanks for the help!




Alex Gian

unread,
Apr 1, 2026, 1:59:36 PM (8 days ago) Apr 1
to Picat
Normally I use Linux Ubuntu, but on this occasion I am using Windows 11.
I am now wondering if naming convention might be the problem (i.e. cbc.exe instead of plain cbc).  I'll try that next.
Did you have some other ideas why the OS could play a role in this?

Cheers!

Oisín Mac Fhearaí

unread,
Apr 1, 2026, 10:34:24 PM (8 days ago) Apr 1
to Picat
I have not tried running Picat in Windows, but perhaps the directory containing cbc.exe should be in the PATH environment variable.
Regarding the call to solve/2, I think it should look like this:

solve([cbc, $min(XSum)], Xs)

Oisín

Alex Gian

unread,
Apr 2, 2026, 6:57:07 AM (7 days ago) Apr 2
to Picat
Thanks for that Oisín, the directory is in the path in Windows, btw.

However I really, appreciate your hint re solve/2, my version wasn't sitting well with me, as it would imply two different semantics.  Anyway, I'll be back on Linux today and have a chance to try it out.

Regards.

Alex Gian

unread,
Apr 2, 2026, 2:12:00 PM (7 days ago) Apr 2
to Picat
Hm, the Windows one is working too, now, path must have finally caught up with it. :)

Anyway, I do realise that mixed integer programming is probably not going to be the first destination for someone venturing into Picat, but it would still be nice to update the docs so that they make clear the procedure for using external solvers.  At the moment it is not really clear for someone wandering in by chance...

Alex Gian

unread,
Apr 2, 2026, 2:12:05 PM (7 days ago) Apr 2
to Picat
Yes, that worked absolutely fine on Linux, thank you very much!

Not quite sure what the problem was on Windows, I may go back to it at some stage.  Maybe.


On Thursday, April 2, 2026 at 3:34:24 AM UTC+1 Oisín Mac Fhearaí wrote:

Doug Edmunds

unread,
Apr 2, 2026, 4:17:40 PM (7 days ago) Apr 2
to Picat
One way to get this working with Windows OS:

1. Create a new directory.  Name it, for instance, picat_mip_solvers.  
 Do not place it under the directory where you installed picat.
           For example: c:\other_programs\picat_mip_solvers
The reason for being outside of picat is so that you don't accidentally delete the directory the
next time you update picat.

2, Get the right cbc zip file from Github
Click where it indicates for latest release, find the area labeled ASSETS.  
I suggest you select this one for Windows 
       Cbc-releases.2.10.13-w64-msvc17-md.zip  

Note I ran a prompt in Gemini, and that's the file it recommended.  You may want to pick a different one from ASSETS
"which cbc release on github do I use for win11  https://github.com/coin-or/Cbc/releases/tag/releases%2F2.10.13  lists several?'

Extract the file cbc.exe from the bin subdirectory and place it in the new directory (picat_mip_solvers)  you created  

3. Open Windows Environmental Variables, and add the new directory to PATH in the top box. 
SAVE and close  Environmental Variables

4. Open a NEW terminal, and if necessary move to any directory other than the one you just created, so you
can test whether it is in the path.

5. Alt the command prompt type picat
Picat should open.  If not, add it to your path

6. At the command prompt type cbc
It should respond something similar to:

   Welcome to the CBC MILP Solver
   Version: 2.10.13
   Build Date: Mar 12 2026
   
   CoinSolver takes input from arguments ( - switches to stdin)
   Enter ? for list of commands or help  
   Coin:exit
   Total time (CPU seconds):       4.04   (Wallclock seconds):       4.04

Type exit or just close the terminal.

7.  Open a terminal where coin.pi was installed ( C:\ Picat\exs\mip for example

type picat coin

It should run the file.  if so, SUCCESS!

Note if at the prompt you don't need quotes around the file name and you don't need the .pi extension.

try out all the other .pi files in that directory

What's happening:  when the code has the line import mip,  mip.pi includes mip_aux which looks for specific file names (cbc for example), and loads
one of them.  If you have more than one solver in the directory (such as glpsol.exe) , you may have to fool picat so as to not
pick one higher up the list, by temporarily changing the name of the one higher (changing cbc.exe to something like cbcxxxx.exe)

Hope this helps

Alex Gian

unread,
Apr 3, 2026, 5:54:35 AM (6 days ago) Apr 3
to Picat
Ah, yes, thanks for that Doug.
Actually, I tested that method and it worked just fine on Linux too.

IOW, if 'cbc'  (or 'cbc.exe' for Windows) is discoverable anywhere on the system path, Picat will find it automagically, and then you can just solve as shown in the examples (diet.pl, in this case)
  solve($[min(XSum)],Xs),

The following variant, suggested by Roisin, and hinted at in David's notes, can be used if you have more than one solver executable on the path (e.g. cbc, glpk, gurobi... whatever), and you want to specify which to use without having to rename the others.
  solve([cbc, $min(XSum)], Xs),

This is what I think is not made clear in any documentation that I could find.  

Regards

Doug Edmunds

unread,
Apr 3, 2026, 11:39:11 AM (6 days ago) Apr 3
to Picat
There are 3 variants which will work

 solve([cbc, $min(XSum)], Xs),
or
 solve($[cbc, min(XSum)], Xs),
or
 solve($[cbc, $min(XSum)], Xs),

What will not work is 
 solve([cbc, min(XSum)], Xs),

% example code starts
import mip.

    % Optimization Goal: Maximize 2X + 3Y

    % if a different mip solver, replace cbc with it, i.e., glpk

main =>
    % Define variables with their domains
    X :: 1..100,
    Y :: 1..100,
   
    % Define constraints
    X + Y #<= 10,
   
    %  '$' converts max()from a function to a term for the solver to use
 
    % with a '$' before the first [] block, the code runs
    % solve($[cbc, max(2*X + 3*Y)], [X, Y]),
   
    % with the '$' inside the first block, the code runs
    solve([cbc, $max(2*X + 3*Y)], [X, Y]),

    % with two '$', before and inside the [], the code runs
    % solve($[cbc, $max(2*X + 3*Y)], [X, Y]),

    % without the '$', the code generates an error
    % solve([cbc, max(2*X + 3*Y)], [X, Y]),
   
    printf("Solution found!\n"),
    printf("X = %w, Y = %w\n", X, Y),
    printf("Objective Value = %w\n", 2*X + 3*Y).
 
    % code ends 
Reply all
Reply to author
Forward
0 new messages