.


:




:

































 

 

 

 





, Goals,
S. , ,
S, SO, , SO, .
, Goals0
SO , Goals S,
.
SO: GoalsO------ > S: Goals

GoalsO , .

1, SO , GoalsO
.

2. G Goals
:

G ;

G GoaisO, .

GoalsO Goals Goals ( ) . , , Goals G. . 17.3.


17.



.(A) Goals



 


 


deli AJ


add(A)


. 17.S. GoalsO. : GoalsO - < A) Goals -add (). , Gcsls -

, .

Goals StartState, .

StartState Goals , .

G Goals , G. Goals , NewGoals, NewGoals StartState.

, , . , [ a, ) clear (b) . : impossible(Goal, Goals)

, Goal Goals, .. Goal Goals , . :

impossible< on(X, X), \. % impossible< on! X, Y), Goals):-member{ clear! Y), Goals)


I % % i

member { on (X, YD, Goals), 1

member; on(Xl, Y), Goals], xl \== X.

impossible(clear! X>, Goals);-member (on [ _, X), Goals).

, , , 17.5. , . plan : cone* Preplan, [Action], Plan)



II. Prolog


, . 17.1.

17.5. , ,

% , % plan{ State, Goals, Plan) plant State, Goals, []):-

satisfied [ State, Goals). % Goals

% State


plant State, Goals, Plan):-conc(PrePlan, [Action], Plan),

select! State, Goals, Goal), achieves* Action, Goal), can Action, Condition),

preserves Action, Goals),

regress! Goals, Action, RegressedGoals),

plan! State, RegressedGoals, Preplan).


, i *

! Action

Goals % Goals % Action


 


satisfied! State, Goals):-delete all! Goals, State, []].


% Goals, % State


 


select! State, Goals, Goal):-membert Goal, Goals).

achieves! Action, Goal):-adds! Action, Goals], member(Goal, Goals).

preserves (Action, Goals):-

deletes(Action, Relations),

not (member(Goal, Relations), membert Goal, Goals)).


% Goal Goals %

; Action % Goals


regress) Goals, Action, RegressedGoals):- % Goals

% Action adds) Action, NewRelations), delete_all Goals, NewRelations, RestGoals), can) Action, Condition),

addnew! Condition, RestGoals, RegressedGoals). I

I ,

% addnew! NewGoals, OldGoals, AllGoals):

% OldGoals - NewGoalS OldGoals;

i NewGoals OldGoals


addnew([], l, l).

addnewt [Goal | _ ], Goals, _) impossible) Goal, Goals),!,

fail.

addnew) [x Lib L2, L3>:-

member) X, L2),!, addnew) Ll, , L3).


-


% Goal Goals l

i


 


addnew! [X I Ll]f L2, addnew! Ll, L2, L3)


[X


L3])


: -


 


17.



% delete_all(LI, L2, Diffj:

Diff - , L1 L2

delete_all([), _, []).

delete_all([X I LI], L2, Diff):-member[ X, L2),!, delete_all[ Ll, L2, Diff).

delete_allt [X [ Ll], L2, [X I Diff]):-

delete ~-'-~- ' 1, L2, Diff].

17.5. , , on (, ) , . 17.1. , : (move(, , 2), move(, 1, ))

[ on (, }], ( ) ?

, , : ( ) . , - , . , . , . , , , .

select (State, Goals, Goal), . , , . , , , " " on (.. , , ). , , , .

achieves (Action, Goal), , . ( -

398 II. Prolog


, .) , , , , ; , .

, , , , , , .

, . , .

(. 12), ; , .

1. s(Model, Node2, Cost).

2. , goal (Node).

3. , h [ Node,

Heuristic-Estimate).

4. .

. , Goals 1 Goals2, , .

1. Goal si.

2. Goalsl.

3. Goals2 Goalsl , regress, 17.5:

regress (Goalsl, A, Goals2)

, , 1 . :

s(Goalsl, Goals2, 1):-
member! Goal, Goalsl), %

achieves Action, Goal), I

cant Action, Condition preserves (Action, Goalsl), regress(Goalsl, Action, Goals2).

, , . , .

, . , , . , ( )


17.



on (a, b) , . 17.1, :

[ [ 1( ), clear [ 2), on (, a), clear (), < , 1)1, %

%

[ clear! a), clear [ b), on (, 1)], % ,

% movet , , 2)

[ on (, ) ] ] % ,

% move! , 1, )

, . , , , , . , , . . , . : Goals -> Action

, 17.6. , .

17.6. . satisfied, achieves, preserves, regress, addnew delete_all 17.5

i -." i :- [ 300, y.fy, ->).

s(Goals -> NextAction, NewGoals -> Action, 1):- % 1 member(Goal, Goals), achieves[ Action, Goal), cant Action, Condition), preserves! Action, Goals), regress! Goals, Actie NewGoals).

goali Goals -> Action):-

start(State), %

satisfied: State, Goals). ::- Goals

hi Goals -> Action, H):- %

start(State),

delete_all< Goals, State, Unsatisfied), i

length; Unsatisfied, H). %

(. 17.6) (. 12) . adds, deletes can ( 17.1 ). , impossible, a start, . , . 17.1, ;

start ( [ (, 1), (, 3), (, a), clear! b), clear [ ), clear (2), clear(4)].


 


 



II. Prolog


, , . 17.1, , , :?- bestfirstt [ on(a, b), on(b, ] -> stop, Plan).

stop, , , - . [ on (, ), on (b, ) ] - , , . , , .

Plan = [

[ clear i 2), on i , a), clear (), or! , 3), clear (b), on (a, 1)] ->

move(c, a, 2),

[ clear! ), on (, 3), clear! a), clear{ b), on [ , 1)1 -> move (b, 3, ),

[ clear! a!, clear! ), on (, 1), (b, )] -> move! , 1, ),

[ on! a, b), on! b, c) ] -> stop]

, , .





:


: 2015-10-01; !; : 514 |


:

:

: , .
==> ...

1942 - | 1561 -


© 2015-2024 lektsii.org - -

: 0.114 .