Changeset 4432 for trunk/examples

Show
Ignore:
Timestamp:
08/18/08 17:07:31 (5 months ago)
Author:
pmoura
Message:

Added three more examples for using B-Prolog constraint support within Logtalk objects. Minor documentation improvements to the other constraint examples.

Location:
trunk/examples/constraints
Files:
3 added
9 modified

Legend:

Unmodified
Added
Removed
  • trunk/examples/constraints/bp/loader.lgt

    r4415 r4432  
    11 
    22:- initialization(( 
    3     logtalk_load([puzzle]))). 
     3    logtalk_load([clique, magic, puzzle, steiner]))). 
  • trunk/examples/constraints/bp/NOTES.txt

    r4415 r4432  
    1212To load this example and for sample queries, please see the SCRIPT.txt file. 
    1313 
    14 This folder contains a simple example illustrating how to use B-Prolog  
    15 constraint support with Logtalk. 
     14This folder contains a set of simple examples illustrating how to use B-Prolog 
     15constraint support with Logtalk. These examples are adapted with permission  
     16from the original author, Neng-Fa Zhou. 
     17 
     18The B-Prolog ::/2 finite-domain built-in predicate clashes with the Logtalk  
     19::/2 message sending operator. The solution is to use instead the alternative 
     20in/2 predicate. 
     21 
     22The built-in predicate_property/2 predicate fails to report some of the  
     23constraint predicates as built-in predicates. The solution is to encapsulate 
     24calls to these predicates using the {}/1 Logtalk control construct. 
  • trunk/examples/constraints/bp/SCRIPT.txt

    r4415 r4432  
    1616 
    1717 
     18| ?- clique::go. 
     19clique(17) 
     20clique(16) 
     21clique(15) 
     22clique(14) 
     23clique(13) 
     24clique(12) 
     25clique(11) 
     26clique(10) 
     27clique(9) 
     28clique(8) 
     29clique(7) 
     30clique(6) 
     31clique(5) 
     32{13,14,15,16,17} 
     33cputime=447 
     34yes 
     35 
     36 
     37| ?- magic::go. 
     38[[2,6,38,41,42,43,3],[29,4,30,39,28,5,40],[22,32,24,33,31,17,16],[34,36,21,1,11,35,37],[19,25,44,15,47,13,12],[23,45,8,26,7,48,18],[46,27,10,20,9,14,49]] 
     39execution time is 357milliseconds 
     40yes 
     41 
     42 
    1843| ?- puzzle::solve(V). 
    1944V = [9,5,6,7,1,0,8,2] ? 
    2045yes 
     46 
     47 
     48| ?- steiner::go. 
     49[{1,2,3},{1,4,5},{1,6,7},{1,8,9},{2,4,6},{2,5,8},{2,7,9},{3,4,9},{3,5,7},{3,6,8},{4,7,8},{5,6,9}] 
     50cputime=80 
     51yes 
  • trunk/examples/constraints/swipl/hexagon.lgt

    r4415 r4432  
     1 
     2% code adapted to Logtalk by Paulo Moura from one of the CLP(FD) examples 
     3% written by Markus Triska (August 2008) 
     4 
     5 
    16% Written 2006 by Markus Triska triska@gmx.at 
    27% Public domain code. 
     
    914    Q   R   S 
    1015*/ 
     16 
    1117 
    1218:- object(hexagon). 
  • trunk/examples/constraints/swipl/NOTES.txt

    r4428 r4432  
    1313 
    1414This folder contains a set of simple examples illustrating how to use Markus  
    15 Triska's CLP(FD) library distributed with SWI-Prolog with Logtalk. 
     15Triska's CLP(FD) library distributed with SWI-Prolog with Logtalk. These  
     16examples are adapted with permission from the original author, Markus Triska. 
     17 
     18The CLP(FD) library is loaded from the "loader.lgt" auxiliary loader file. 
     19This library must always be loaded prior to compilation of the individual  
     20example files. 
  • trunk/examples/constraints/swipl/puzzle.lgt

    r4415 r4432  
    11 
    2 % code adapted from one of the examples distributed with the CLP(FD) library 
     2% code adapted to Logtalk by Paulo Moura from one of the CLP(FD) examples 
     3% written by Markus Triska (August 2008) 
     4 
    35 
    46:- object(puzzle). 
  • trunk/examples/constraints/swipl/queens.lgt

    r4421 r4432  
     1 
     2% code adapted to Logtalk by Paulo Moura from one of the CLP(FD) examples 
     3% written by Markus Triska (August 2008) 
     4 
     5 
    16/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    27   N Queens animation demo. 
  • trunk/examples/constraints/swipl/sudoku.lgt

    r4421 r4432  
     1 
     2% code adapted to Logtalk by Paulo Moura from one of the CLP(FD) examples 
     3% written by Markus Triska (August 2008) 
     4 
     5 
    16/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    27   Sudoku CLP(FD) animation. 
  • trunk/examples/constraints/yap/NOTES.txt

    r4428 r4432  
    1313 
    1414This folder contains a set of simple examples illustrating how to use Markus  
    15 Triska's CLP(FD) library distributed with YAP with Logtalk. 
     15Triska's CLP(FD) library distributed with YAP with Logtalk. These examples  
     16are adapted with permission from the original author, Markus Triska. 
     17 
     18The CLP(FD) library is loaded from the "loader.lgt" auxiliary loader file. 
     19This library must always be loaded prior to compilation of the individual  
     20example files.