Delayed column generation example with swipl?

Hi,

I am trying to run the Delayed column generation example as provided by Markus Triska,
‘camels.pl’ may have been tested with Scryer Prolog 0.9.0 but when running swipl 8.5.7-41, I can’t even compile camel.pl.(The old source code I have mentions that it was tested against swipl 7.3.11)
It seems that several new librarys should be loaded
:- use_module(library(clpz)).
:- use_module(library(format)).
:- use_module(library(dcgs)).
:- use_module(library(between)).

What else has changed?
Is ‘Scryer’ a new Prolog? Is it possible to add the missing library’s to swipl (if so, how)?

Thanks,
Ben

Yes.
It is on GitHub with active discussions.

It is not so much adding the libraries to SWI-Prolog as it is converting the example to SWI-Prolog. While I have not seen the code you note, by looking at the name of the libraries I would not be surprised if many of the needed predicates are already loaded and available with SWI-Prolog when started. Granted some tweaking may need to be done to the predicates (probably can be via wrappers or maybe a dialect) and adding the missing functionality if needed.

The one thing that might cause the entire thing to fail is something in library(clpz) which can not be easily updated/ported. SWI-Prolog has library(clpfd) but as it notes

Please see CLP(Z) for more information.

which has source code.

At this point you have an idea of what I would be doing to get the example code working with SWI-Prolog.


My best guess to the source code for camels.pl


EDIT

In checking the Scryer clpz.pl code found this

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   Optimisation uses destructive assignment to save the computed
   extremum over backtracking. Failure is used to get rid of copies of
   attributed variables that are created in intermediate steps. At
   least that's the intention - it currently doesn't work in SWI:

   %?- X in 0..3, call_residue_vars(labeling([min(X)], [X]), Vs).
   %@ X = 0,
   %@ Vs = [_G6174, _G6177],
   %@ _G6174 in 0..3

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

I would not take that to mean it can not run on SWI-Prolog as the note is about an optimization. I would dig deeper, maybe an earlier version before the optimisation. :slightly_frowning_face:

library(clpz) is Markus’ follow up of library(clpfd). That resulted from a dispute about adding the SICStus attributed variable interface to SWI-Prolog next to the hProlog dynamic attributed variable interface it has now. That interface is pretty complicated and although @logicmoo and I tried to get it implemented we eventually reverted the changes due to stability and performance issues while I’ve still not seen a convincing argument why that interface is needed. So, alas, clpz will probably never run on SWI-Prolog.

The other libraries all seem to be built-in functionality, so you can simply remove the import. If the thing really needs clpz you are out of luck :frowning:

1 Like

Hi,

The Delayed column generation example comes with camels.pl, a knapsack problem.

I included v15.pl (defines weights, values and demands) and library(clfd).
Library clpz, format, dcgs and between were deleted.
The resulting code

:- include(v15).
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
:- use_module(library(clpfd)).
:- use_module(library(simplex)).
:- use_module(library(lists)).

compiles. And after consulting v15, the code executes without problems.

1 Like

Could you provide either a link or the source for v15.pl?

This is the link to the article. Delayed column generation example.
You can find links to camels.pl,v15.pl and many other usefull links for linear programming.

1 Like