Updated to Logtalk 2.9.1
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@211 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
||||
This folder contains several examples of Logtalk programs. Most of
|
||||
these examples need objects, protocols and categories that are
|
||||
these examples need objects, protocols, and categories that are
|
||||
defined in the Logtalk standard library or in other examples, so
|
||||
you should load them first (see the NOTES file inside each example
|
||||
folder).
|
||||
@@ -36,6 +36,9 @@ bricks
|
||||
classvars
|
||||
example of implementation of class variables (as found in Smalltalk)
|
||||
|
||||
errors
|
||||
example showing the Logtalk compiler warning and error reporting
|
||||
|
||||
inheritance
|
||||
examples of public, protected and private inheritance with both
|
||||
prototypes and classes/instances
|
||||
@@ -84,7 +87,7 @@ roots
|
||||
objects, protocols and categories needed by most of the other examples
|
||||
|
||||
searching
|
||||
state-space searching frame work
|
||||
state-space searching framework
|
||||
example adopted from Ivan Bratko's "Prolog Programming for Artificial
|
||||
Intelligence" book
|
||||
|
||||
@@ -93,7 +96,7 @@ sicstus
|
||||
|
||||
symdiff
|
||||
example of using parametric objects to implement symbolic expression
|
||||
differentiation and simplification.
|
||||
differentiation and simplification
|
||||
|
||||
viewpoints
|
||||
example on how to implement property and value sharing with prototypes
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -2,10 +2,11 @@
|
||||
:- initialization(
|
||||
logtalk_load([
|
||||
descriptors,
|
||||
expert,
|
||||
|
||||
order,
|
||||
|
||||
expert,
|
||||
|
||||
falconiforms, % orders
|
||||
passerformes,
|
||||
tubenose,
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
@@ -12,5 +12,5 @@ This folder contains examples of public, protected and private inheritance,
|
||||
for both prototypes and classes/instances. The category "predicates" defines
|
||||
a set of three predicates, one public, one protected and one private. This
|
||||
category is imported by the root objects: "parent" for the prototypes and
|
||||
"object" for the classes/instances. Each root object have a set of three
|
||||
"root" for the classes/instances. Each root object have a set of three
|
||||
descendants, each one using one of the inheritance types.
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
@@ -52,6 +52,36 @@ protected/0 - private
|
||||
yes
|
||||
|
||||
|
||||
% descendant1 extends public::prototype1
|
||||
|
||||
| ?- descendant1::interface.
|
||||
|
||||
interface/0 - public
|
||||
public/0 - public
|
||||
protected/0 - protected
|
||||
|
||||
yes
|
||||
|
||||
|
||||
% descendant2 extends public::prototype2
|
||||
|
||||
| ?- descendant2::interface.
|
||||
|
||||
interface/0 - public
|
||||
public/0 - protected
|
||||
protected/0 - protected
|
||||
|
||||
yes
|
||||
|
||||
|
||||
% descendant3 extends public::prototype3
|
||||
|
||||
| ?- descendant3::interface.
|
||||
|
||||
interface/0 - public
|
||||
|
||||
yes
|
||||
|
||||
|
||||
% object (root of the inheritance graph) interface
|
||||
|
||||
|
@@ -8,6 +8,9 @@
|
||||
prototype1,
|
||||
prototype2,
|
||||
prototype3,
|
||||
descendant1,
|
||||
descendant2,
|
||||
descendant3,
|
||||
|
||||
root,
|
||||
subclass1,
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,21 +1,21 @@
|
||||
|
||||
:- initialization(
|
||||
logtalk_load([
|
||||
aberdeen_air,
|
||||
aiai,
|
||||
plan1,
|
||||
airport,
|
||||
albert_hall,
|
||||
castle,
|
||||
aberdeen_air,
|
||||
city,
|
||||
edin,
|
||||
london,
|
||||
albert_hall,
|
||||
edinburgh,
|
||||
edin,
|
||||
aiai,
|
||||
castle,
|
||||
fly,
|
||||
glasgow,
|
||||
imperial,
|
||||
lhr,
|
||||
london,
|
||||
manchester,
|
||||
plan1,
|
||||
renfrew,
|
||||
ringway,
|
||||
victoria])).
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,10 @@
|
||||
|
||||
:- initialization(
|
||||
logtalk_load([
|
||||
quick1,
|
||||
|
||||
location2,
|
||||
|
||||
aberdeen,
|
||||
aberystwyth,
|
||||
birmingham,
|
||||
@@ -30,15 +34,12 @@
|
||||
salesman,
|
||||
|
||||
circular,
|
||||
incremental,
|
||||
presort,
|
||||
driving,
|
||||
geographic2,
|
||||
incremental,
|
||||
metric1,
|
||||
permute,
|
||||
presort,
|
||||
|
||||
location2,
|
||||
|
||||
descend,
|
||||
quick1,
|
||||
natural])).
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,15 +1,15 @@
|
||||
|
||||
:- initialization(
|
||||
logtalk_load([
|
||||
cylinders,
|
||||
distributor,
|
||||
electrical,
|
||||
engine,
|
||||
fault,
|
||||
mechanical,
|
||||
engine,
|
||||
cylinders,
|
||||
electrical,
|
||||
starting,
|
||||
sparking,
|
||||
plugs,
|
||||
distributor,
|
||||
fuel_system,
|
||||
lights,
|
||||
mechanical,
|
||||
plugs,
|
||||
sparking,
|
||||
starter_motor,
|
||||
starting])).
|
||||
starter_motor])).
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
:- initialization(
|
||||
logtalk_load([
|
||||
sort1,
|
||||
tracer])).
|
||||
tracer,
|
||||
sort1])).
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -2,9 +2,9 @@
|
||||
:- initialization(
|
||||
logtalk_load([
|
||||
space,
|
||||
space_time,
|
||||
time,
|
||||
space_time,
|
||||
|
||||
space3,
|
||||
space_time4,
|
||||
time1])).
|
||||
time1,
|
||||
space_time4])).
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,7 +1,7 @@
|
||||
|
||||
:- initialization(
|
||||
logtalk_load([
|
||||
circle2,
|
||||
ellipse3,
|
||||
circle2,
|
||||
line2,
|
||||
point2])).
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,9 +1,9 @@
|
||||
|
||||
:- initialization(
|
||||
logtalk_load([
|
||||
bounded_coordinate,
|
||||
bounded_history_point,
|
||||
bounded_point,
|
||||
history_point,
|
||||
point,
|
||||
point_history])).
|
||||
point_history,
|
||||
bounded_coordinate,
|
||||
bounded_point,
|
||||
bounded_history_point,
|
||||
history_point])).
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -2,8 +2,8 @@
|
||||
:- initialization(
|
||||
logtalk_load([
|
||||
concentric,
|
||||
polygon,
|
||||
hexagon,
|
||||
pentagon,
|
||||
polygon,
|
||||
square,
|
||||
triangle])).
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,12 +1,9 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
||||
|
||||
% :
|
||||
|
||||
|
||||
| ?-
|
||||
% the objects in this example are used by several of the other examples.
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -2,7 +2,7 @@
|
||||
:- initialization(
|
||||
logtalk_load([
|
||||
initialization,
|
||||
classp, class,
|
||||
objectp, object,
|
||||
abstract_classp, abstract_class,
|
||||
classp, class,
|
||||
nil])).
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
@@ -12,9 +12,10 @@ You will need to also load the objects in the roots example.
|
||||
|
||||
You will also need to load the following files in the library directory:
|
||||
dates.loader, types.loader, events.loader, metapredicates.loader, and
|
||||
hierarchies.loader.
|
||||
hierarchies.loader. Alternatively, you can just load the all.loader file.
|
||||
|
||||
Some of the code in this folder is adopted from the book "Prolog Programming
|
||||
for Artificial Intelligence" by Ivan Bratko.
|
||||
|
||||
The object "performance" only provides correct results for the first solution.
|
||||
For a description of the search problems, please see a classical AI book
|
||||
(such as the one above) or visit the url <http://www.plastelina.net/games>.
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
@@ -43,8 +43,8 @@ CC.<__>..........MMMC
|
||||
..........<__>.MMMCCC
|
||||
|
||||
Cost = 15,
|
||||
Path = [((3,3),esq,0,0),((2,2),dir,1,1),((3,2),esq,0,1),((3,0),dir,0,3),((3,1),esq,0,2),((1,1),dir,2,2),((2,2),esq,1,1),((0,2),dir,3,1),((0,3),esq,3,0),((0,1),dir,3,2),((0,2),esq,3,1),((0,0),dir,3,3)],
|
||||
Initial = ((3,3),esq,0,0)
|
||||
Path = [((3,3),left,0,0),((2,2),right,1,1),((3,2),left,0,1),((3,0),right,0,3),((3,1),left,0,2),((1,1),right,2,2),((2,2),left,1,1),((0,2),right,3,1),((0,3),left,3,0),((0,1),right,3,2),((0,2),left,3,1),((0,0),right,3,3)],
|
||||
Initial = ((3,3),left,0,0)
|
||||
yes
|
||||
|
||||
|
||||
@@ -65,16 +65,43 @@ C..........<__>.MMMCC
|
||||
CC.<__>..........MMMC
|
||||
..........<__>.MMMCCC
|
||||
solution length: 12
|
||||
number of state transitions: 27
|
||||
ratio solution length / state transitions: 0.4444444444444444
|
||||
minimum branching degree: 2
|
||||
average branching degree: 2.5555555555555554
|
||||
number of state transitions: 26
|
||||
ratio solution length / state transitions: 0.461538
|
||||
minimum branching degree: 1
|
||||
average branching degree: 2.30769
|
||||
maximum branching degree: 3
|
||||
time: 0.067999999999756255
|
||||
time: 0.02
|
||||
|
||||
Cost = 15,
|
||||
Path = [((3,3),esq,0,0),((2,2),dir,1,1),((3,2),esq,0,1),((3,0),dir,0,3),((3,1),esq,0,2),((1,1),dir,2,2),((2,2),esq,1,1),((0,2),dir,3,1),((0,3),esq,3,0),((0,1),dir,3,2),((0,2),esq,3,1),((0,0),dir,3,3)],
|
||||
Initial = ((3,3),esq,0,0) ?
|
||||
Path = [((3,3),left,0,0),((2,2),right,1,1),((3,2),left,0,1),((3,0),right,0,3),((3,1),left,0,2),((1,1),right,2,2),((2,2),left,1,1),((0,2),right,3,1),((0,3),left,3,0),((0,1),right,3,2),((0,2),left,3,1),((0,0),right,3,3)],
|
||||
Initial = ((3,3),left,0,0) ?
|
||||
|
||||
yes
|
||||
|
||||
|
||||
% bridge problem, solved using a hill climbing strategy
|
||||
|
||||
| ?- performance::init, bridge::initial_state(Initial), hill_climbing(30)::solve(bridge, Initial, Path, Cost), bridge::print_path(Path), performance::report.
|
||||
|
||||
_|____________|_ lamp 1 3 6 8 12
|
||||
1 3 lamp _|____________|_ 6 8 12
|
||||
3 _|____________|_ lamp 1 6 8 12
|
||||
1 3 6 lamp _|____________|_ 8 12
|
||||
3 6 _|____________|_ lamp 1 8 12
|
||||
3 6 8 12 lamp _|____________|_ 1
|
||||
6 8 12 _|____________|_ lamp 1 3
|
||||
1 3 6 8 12 lamp _|____________|_
|
||||
solution length: 8
|
||||
state transitions: 346
|
||||
ratio solution length / state transitions: 0.0231214
|
||||
minimum branching degree: 1
|
||||
average branching degree: 7.42453
|
||||
maximum branching degree: 15
|
||||
time: 0.28
|
||||
|
||||
Initial = [], right, [1, 3, 6, 8, 12]
|
||||
Path = [ ([], right, [1, 3, 6, 8, 12]), ([1, 3], left, [6, 8, 12]), ([3], right, [1, 6, 8, 12]), ([1, 3, 6], left, [8, 12]), ([3, 6], right, [1, 8|...]), ([3, 6|...], left, [1]), ([6|...], right, [...|...]), ([...|...], ..., ...)]
|
||||
Cost = 29
|
||||
|
||||
yes
|
||||
|
||||
@@ -104,11 +131,11 @@ yes
|
||||
|
||||
solution length: 6
|
||||
number of state transitions: 105
|
||||
ratio solution length / state transitions: 0.05714285714285714
|
||||
ratio solution length / state transitions: 0.0571429
|
||||
minimum branching degree: 2
|
||||
average branching degree: 3.6315789473684212
|
||||
average branching degree: 3.63158
|
||||
maximum branching degree: 4
|
||||
time: 0.20000000000027285
|
||||
time: 0.02
|
||||
|
||||
Path = [(0,0),(0,3),(3,0),(3,3),(4,2),(0,2)],
|
||||
Initial = (0,0) ?
|
||||
@@ -144,14 +171,14 @@ yes
|
||||
|
||||
solution length: 8
|
||||
number of state transitions: 12
|
||||
ratio solution length / state transitions: 0.6666666666666666
|
||||
ratio solution length / state transitions: 0.666667
|
||||
|
||||
|
||||
|
||||
minimum branching degree: 1
|
||||
average branching degree: 2.0
|
||||
average branching degree: 2
|
||||
maximum branching degree: 3
|
||||
time: 0.021999999999934516
|
||||
time: 0.00
|
||||
|
||||
Path = [(0,0),(4,0),(4,3),(0,3),(3,0),(3,3),(4,2),(0,2)],
|
||||
Initial = (0,0) ?
|
||||
@@ -190,9 +217,9 @@ solution length: 6
|
||||
number of state transitions: 15
|
||||
ratio solution length / state transitions: 0.4
|
||||
minimum branching degree: 2
|
||||
average branching degree: 3.1333333333333333
|
||||
average branching degree: 3.13333
|
||||
maximum branching degree: 4
|
||||
time: 0.050000000000181899
|
||||
time: 0.01
|
||||
|
||||
Cost = 5,
|
||||
Path = [[2/1,1/2,1/3,3/3,3/2,3/1,2/2,1/1,2/3],[2/2,1/2,1/3,3/3,3/2,3/1,2/1,1/1,2/3],[2/3,1/2,1/3,3/3,3/2,3/1,2/1,1/1,2/2],[1/3,1/2,2/3,3/3,3/2,3/1,2/1,1/1,2/2],[1/2,1/3,2/3,3/3,3/2,3/1,2/1,1/1,2/2],[2/2,1/3,2/3,3/3,3/2,3/1,2/1,1/1,1/2]],
|
||||
@@ -232,9 +259,9 @@ solution length: 6
|
||||
number of state transitions: 15
|
||||
ratio solution length / state transitions: 0.4
|
||||
minimum branching degree: 2
|
||||
average branching degree: 3.1333333333333333
|
||||
average branching degree: 3.13333
|
||||
maximum branching degree: 4
|
||||
time: 0.046000000000276486
|
||||
time: 0.02
|
||||
|
||||
Cost = 5,
|
||||
Path = [[2/1,1/2,1/3,3/3,3/2,3/1,2/2,1/1,2/3],[2/2,1/2,1/3,3/3,3/2,3/1,2/1,1/1,2/3],[2/3,1/2,1/3,3/3,3/2,3/1,2/1,1/1,2/2],[1/3,1/2,2/3,3/3,3/2,3/1,2/1,1/1,2/2],[1/2,1/3,2/3,3/3,3/2,3/1,2/1,1/1,2/2],[2/2,1/3,2/3,3/3,3/2,3/1,2/1,1/1,1/2]],
|
||||
|
@@ -31,8 +31,8 @@
|
||||
|
||||
expand(Path, l(State,F/G), Threshold, Tree, Solved, Solution, Space, Cost) :-
|
||||
F =< Threshold,
|
||||
(bagof(Next/Cost,
|
||||
(Space::next_state(State, Next, Cost), \+ list::member(Next, Path)),
|
||||
(bagof(Next/Cost2,
|
||||
(Space::next_state(State, Next, Cost2), \+ list::member(Next, Path)),
|
||||
Successors) ->
|
||||
succlist(G, Successors, Trees, Threshold, Space),
|
||||
bestf(Trees, F2, Threshold),
|
||||
|
@@ -11,9 +11,6 @@
|
||||
parnames is ['Bound']]).
|
||||
|
||||
|
||||
:- calls(state_space).
|
||||
|
||||
|
||||
:- uses(list).
|
||||
|
||||
|
||||
|
@@ -25,7 +25,6 @@
|
||||
Space::goal_state(State).
|
||||
|
||||
hill(Space, State, Threshold, Path, Solution, SoFar, Total) :-
|
||||
SoFar < Threshold,
|
||||
findall(
|
||||
(Estimate, Cost, Next),
|
||||
(Space::next_state(State, Next, Cost),
|
||||
@@ -34,9 +33,10 @@
|
||||
Estimate is Guess + Cost),
|
||||
States),
|
||||
list::sort(States, SortedStates),
|
||||
list::member((_, Cost, Next), SortedStates),
|
||||
SoFar2 is SoFar + Cost,
|
||||
hill(Space, Next, Threshold, [State| Path], Solution, SoFar2, Total).
|
||||
list::member((_, Cost2, Next2), SortedStates),
|
||||
SoFar2 is SoFar + Cost2,
|
||||
SoFar2 =< Threshold,
|
||||
hill(Space, Next2, Threshold, [State| Path], Solution, SoFar2, Total).
|
||||
|
||||
|
||||
:- end_object.
|
||||
|
@@ -66,7 +66,7 @@
|
||||
write('average branching degree: '), write(Average), nl,
|
||||
write('maximum branching degree: '), write(Maximum), nl,
|
||||
write('time: '), write(Time), nl,
|
||||
!.
|
||||
::retractall(transitions(_, _, _)). % clean up for next solution
|
||||
|
||||
|
||||
transitions(Number) :-
|
||||
@@ -87,9 +87,8 @@
|
||||
findall(State2, ::transitions(State1, State2, _), States2),
|
||||
list::length(States2, Length)),
|
||||
Lengths),
|
||||
list::sort(Lengths, SortedLengths),
|
||||
SortedLengths = [Minimum| _],
|
||||
list::reverse(SortedLengths, [Maximum| _]),
|
||||
list::min(Lengths, Minimum),
|
||||
list::max(Lengths, Maximum),
|
||||
numberlist::sum(Lengths, Sum),
|
||||
list::length(Lengths, Length),
|
||||
Average is Sum / Length.
|
||||
@@ -116,12 +115,14 @@
|
||||
before(_, solve(_, _, _), _) :-
|
||||
!,
|
||||
time::cpu_time(Time),
|
||||
::assertz(start_time(Time)).
|
||||
::retractall(start_time(_)),
|
||||
::asserta(start_time(Time)).
|
||||
|
||||
before(_, solve(_, _, _, _), _) :-
|
||||
!,
|
||||
time::cpu_time(Time),
|
||||
::assertz(start_time(Time)).
|
||||
::retractall(start_time(_)),
|
||||
::asserta(start_time(Time)).
|
||||
|
||||
|
||||
after(_, next_state(S1, S2), _) :-
|
||||
@@ -145,7 +146,8 @@
|
||||
after(_, solve(_, _, Solution), _) :-
|
||||
!,
|
||||
time::cpu_time(Time),
|
||||
::assertz(end_time(Time)),
|
||||
::retractall(end_time(_)),
|
||||
::asserta(end_time(Time)),
|
||||
list::length(Solution, Length),
|
||||
::retractall(solution_length(_)),
|
||||
::asserta(solution_length(Length)).
|
||||
@@ -153,11 +155,11 @@
|
||||
after(_, solve(_, _, Solution, _), _) :-
|
||||
!,
|
||||
time::cpu_time(Time),
|
||||
::assertz(end_time(Time)),
|
||||
::retractall(end_time(_)),
|
||||
::asserta(end_time(Time)),
|
||||
list::length(Solution, Length),
|
||||
::retractall(solution_length(_)),
|
||||
::asserta(solution_length(Length)).
|
||||
|
||||
|
||||
:- end_object.
|
||||
|
||||
|
@@ -1,17 +1,18 @@
|
||||
|
||||
:- initialization(
|
||||
logtalk_load([
|
||||
best_first1,
|
||||
state_space,
|
||||
water_jug,
|
||||
farmer,
|
||||
heuristic_state_space,
|
||||
bridge,
|
||||
eight_puzzle,
|
||||
miss_cann,
|
||||
search_strategy,
|
||||
blind_search1,
|
||||
breadth_first1,
|
||||
depth_first1,
|
||||
eight_puzzle,
|
||||
farmer,
|
||||
heuristic_search1,
|
||||
heuristic_state_space,
|
||||
best_first1,
|
||||
hill_climbing1,
|
||||
miss_cann,
|
||||
performance,
|
||||
search_strategy,
|
||||
state_space,
|
||||
water_jug])).
|
||||
performance])).
|
||||
|
@@ -31,7 +31,7 @@
|
||||
|
||||
next_state((X, Y), (Z, 3)) :-
|
||||
X > 0, Y < 3,
|
||||
Aux is X + Y, Aux >= 4,
|
||||
Aux is X + Y, Aux >= 3,
|
||||
Z is X - (3 - Y).
|
||||
|
||||
next_state((X, Y),(Z, 0)) :-
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
@@ -10,5 +10,5 @@ The examples in this folder are adopted from the SICStus Prolog manual.
|
||||
To load all objects in this example consult the sicstus.loader utility
|
||||
file (note that the *.loader files are Prolog files).
|
||||
|
||||
You will also need to load the follwing files in library directory:
|
||||
You will also need to load the following files in library directory:
|
||||
hierarchies.loader and types.loader.
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
@@ -9,7 +9,7 @@ Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
| ?- sort(rational)::sort([1/8, 2/7, 6/5, 2/9, 1/3], Sorted).
|
||||
|
||||
Sorted = [1/8, 2/9, 2/7, 1/3, 6/5]
|
||||
yes.
|
||||
yes
|
||||
|
||||
|
||||
| ?- sort(colours)::sort([orange, indigo, red, yellow, violet, blue, green], Sorted).
|
||||
@@ -27,19 +27,19 @@ yes
|
||||
| ?- red_circle(3)::color(Color).
|
||||
|
||||
Color = red
|
||||
yes.
|
||||
yes
|
||||
|
||||
|
||||
| ?- red_circle(3)::area(Area).
|
||||
|
||||
Area = 28.274334
|
||||
yes.
|
||||
yes
|
||||
|
||||
|
||||
| ?- red_circle(3)::ancestors(As).
|
||||
|
||||
As = [circle(3, red), ellipse(3, 3, red)]
|
||||
yes.
|
||||
yes
|
||||
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ Side = 2
|
||||
Width = 2
|
||||
Height = 2
|
||||
Area = 4
|
||||
yes.
|
||||
yes
|
||||
|
||||
|
||||
| ?- square(2)::current_predicate(Pred).
|
||||
|
@@ -1,13 +1,13 @@
|
||||
|
||||
:- initialization(
|
||||
logtalk_load([
|
||||
circle11,
|
||||
ellipse3,
|
||||
circle2,
|
||||
circle11,
|
||||
red_circle1,
|
||||
colours,
|
||||
math_constants,
|
||||
ellipse3,
|
||||
rational,
|
||||
rectangle2,
|
||||
red_circle1,
|
||||
sort1,
|
||||
square1])).
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
@@ -16,7 +16,7 @@ S = 0
|
||||
yes
|
||||
|
||||
|
||||
% diffrentiate and then simplify the expression 2x^3 + x^2 - 4x
|
||||
% differentiate and then simplify the expression 2x^3 + x^2 - 4x
|
||||
|
||||
| ?- (2*x**3 + x**2 - 4*x)::diff(D), D::simplify(S).
|
||||
|
||||
@@ -26,7 +26,7 @@ S = 2*(3*x**2)+2*x-4
|
||||
yes
|
||||
|
||||
|
||||
% diffrentiate and then simplify the expression ln(x^2 + 2x - 7) + 4x
|
||||
% differentiate and then simplify the expression ln(x^2 + 2x - 7) + 4x
|
||||
|
||||
| ?- (log(x**2 + 2*x - 7) + 4*x)::diff(D), D::simplify(S).
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
@@ -1,6 +1,6 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.8.4
|
||||
Release 2.9.1
|
||||
|
||||
Copyright (c) 1998-2001 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
Reference in New Issue
Block a user