.


:




:

































 

 

 

 





12.4.1. *

, : . . , "" -


12.



, ', ' .

, * ( , 12,1) . , , . ( ), . . * . , , .

*, . (. 11). . , .

. IDA* (Iterative Deepening A* - * ), RBFS (Recursive Best-First Search - ).

12.4.2. IDA*

IDA* (Iterative Deepening A* - * ) , . . . IDA* (.. f- ). IDA* , . * .

Bound:- f(StartNode); Repeat

, StartNode, ,

N , f(H) £ Bound;

if

then , " ",

Else

NewBound f- , Bound:

KewBound = r.ir. {f ■:;; I N, , /(H) > Bound } Bound: - KewBound until " "

* (. 12.2, 6), , f(s) = 6, IDA* :



II. Prolog


Bound = f(s) = 6

, f S 6. .

s, :

f () =7 > Bound

f[e) = 9 > Bound

NewBound = min (7, 9} =7 , f < 1, s. f-, , b .

NewBound = min { f(b), f(e)} " min{ 8, 9) = 8 Bound : 9 (f(e)), 10 (f(c)), 11 [tit)). . Bound =11 " ",

IDA*, , , . , IDA*, , , , . , £. f-. , . , f-, , . f-. f-, , ( ), , IDA*, .

IDA* . , f(8) g (N) + h(N) . h (.. h{N) < h* (N) ), IDA* .

IDA* , {.. f-). , , £ , f = g + h. f , . f , . , f , N' : s (N, '), £ () S £ ( '}. , f f- , f- . , f f-, , . , , f .

IDA* Prolog 12.4. Prolog. f- next_bound(Bound)

assert retract. . (


12.



retract assert ) 99999. , f-. , N , f] < Bound. , , f (N) > Bound, f(K) Next Bound ( next_bound(NextBound)). f (N) < NextBound, nextjbound f ().

12.6. £, IDA* .

12.7. IDA*, 12.4, " " / totdist/, 12.2. h ( ) (totdist/). f/2 ( IDA*) , f {N ) = () + .(). g(N) g- (, = GrTilePosltions). " ", 12.2.

[1/2,3/3,3/1,1/3,3/2,1/1,2/3, 2/1,2/2]. , * ( 12.2) IDA* { ).

12.4. *

* idastar { Start, Solution):

% IDA*,- Start - , % Solution -

% I

idastari Start, Solution):-retract!. next_bourid <_J |, fail

assertat next_bound (0)), idastarO< Start, Solution).

idastarO[ Start, Sol):-

i % % f- % ; % % %

retract (nextjbound(Bound)), asserta{ nextjbound(99999)), f[ Start, F!, df([Start], F, Bound, Sol)

nextjaoundt NextBound;, MextBound < 93, idastarOt Start, Sol).

I df(Path, F, Bound, Sol): % Bound. Path - % ( ), I F f- , .. Path

df([ l Ns!, F, Bound, [ | Ball:-
F =< Bound,
goal! N). % -



II. Prolog


f- N N

df([Ml S3], F, Bound, Sol):-F -< Bound,

s(N, HI), not member (HI, Ns), 1 f(N1, Fl), df([N1,NI He], Fl, Bound, Sol).

% Bound %

df(_, F, Bound, _):-F > Bound, updatenextbound[ F),

fail.


update_next_boimd (F): -next_bound(Bound},

Bound =< F, ]

retract(next_bound(Bound)),!, assertat next bound(F)}.


%


12.4.3. RBFS

IDA* , . , , RBFS (Recursive Best-First Search - ). RBFS *, 12.1 ( , , RBFS!). * RBFS , , . RBFS ( ), . RBFS ( IDA*) . RBFS , , - f- . f- f- , * "" f , ( ),

f {N). ;:, ( ).

F(N). f- ( , - N).

F(N) .

F(N> = f(N), N () .

F(N} = min{ FfNi) | Ni - N) .

*, RBFS , f-. F- ( F- , .. F- , ). , N (.. F-). N N f- Bound. ( F [) > Bound) ,


12.



 


N, . F(U] , .

F- , , . . , , . F(N) > f (N), , N F{N) N, . , Ni N f (Ni> . F(Ni) :

f{Ni) <F(N), F(M;) = F[N), F(NiJ = fCN;)

: F[Hi)= raax{F(H), f (N,) }

, , f(N1) < (), F- . S Hi. : Ni ( ) , F(Ni> F(N). , , F(N) .

RBPS (. . 12.2). . 12.7 ( ), . ( *) . . . 12.7 , , F- . (F{a) < F{e}). Bound = 9 (.. , F(e); ). ( ) , F{c) 10 > Bound. ( ) , , F(c) = 10 F(a) 10 ( ). (F(e) = 9 < 10 = F{a]) Bound = 10 = F(a). f, F(f) = 11 > Bound ( ). , F(e) 11 ( ). Bound = 11. , f () = 6 < F{a). F- , F(b) 10. F- , F(c) 10. Bound = - 1 , d, F(d) = 12 ( ). t.

RBFS. F- . :

NewF(, F(N), Bound)

N , F- F (N). Bound, .:, F- N, NewF, . . , , . NewF 12.5.

270 II. Prolog


70>05 7<jJ9 10 09

 

\ 10  
JK,
10 0 9 10 0 "
4   "|
  "
10
12 0 011 12  

. 12.7, RBFS , . 12.2; F- ( )

12.5. F- RBFS

function Hewf(, F(H), Bound) begin

if F(N) > Bound then NewF;= F(N)

else if goal(H) then

else if then NewF:= infinity ( )

else

Begin

for Hi, N do if f [HI < F!N} then F!Nil:max [ F(N), f (Nil) else F(Hi):= f (Mi); Ni F-; while {Hi) S Bound and F ffli) < infinity do begin

Boundl:= min(Bound, F- Hi );


12.



F(Ni>:= KewF(Hi [ F[Ht), Boundl); Hi, ,... F(Ni) end NewF: = F(Ni) end end

RBFS Prolog 12.6. *, 12,

rbfs! Path, SiblingNodes, Bound, NevmestFF, Solved, Solution) RBFS. .

Path. , .

SiblingNodes. , , .. Path.

Bound. F-

SiblingNodes.

MewBestFF. F-
Bound.

■ Solved. SiblingNodes (Solved = yes, , Solved = no, Bound, Solved = never, , ).

Solution. , Solved - yes, -
.

, , , f- F-, . Node = (State, G/F/FF)

G State, F , f (State}, a FF - W (State , F f-, a FF -F-. rbfs SiblingNodes Bound NewBestFF NewF, 12.5.

12.6. , ( RBFS)

% ,

% , - RBFS.

% , f- 99999

bestfirst(Start, Solution): Solution - Start

bestfirstf Start, Solution):-

rbfsl ['], ((Start, 0/0/0) ], 99999, _, yes, Solution).

% rbfs (Path, SiblingNcdes, Bound, NewBestFF, Solved, Solution):

1 Path - ,

I SiblingNodes - Path

Bound - F- sibiingModes



II. Prolog e


% NewBestFF - f- ,
% Bound

% Solved - yes, no:■:,-;: never

1 Solution - , Solved = yes

% : Node - (State, G/F/FF)

4 G - State, F - £-

% State, FF - 1 - State

rbfst Path, [ -{Node, G/F/FF) I Modes], Bound, FF, no, _):-FF > Bound,!.

rbfs{ Path, [ [ Node, G/F/FF) ], _, _, yes, [Node I Path]):-

F = FF, % ,

% ,- F=FF goalt Node).

rbfst _, [],_,_, never, _):-!. i ,

% !

rbfs(Path, ((Node, G/F/FF) I Ns ], Bound, NewFF, Solved, Sol):-

FF =< Bound, i Bound -

findall [ Child/Cost,

[s. Node, Child, Cost), not member [ Child, Path)),
Children),
inherit{ F, FF, InheritedFF), % FF
succlist(G, InheritedFF, Children, SuccNodes), %
bestfft Ns, NextBeStFF), % . FF

% min[ Bound, NextBestFF, Bound2), I,

rbfst [Node I Path], SuccNodes, Bound2, NewFF2, Solved2, Sol), continue (Path, [ (Node, G/F/NewFF2 > INs ], Bound, NewFF, Solved'2, Solved, Sol).

I continue) Path, Nodes, Sound, NewFF, ChildSolved, Solved, Solution)

continue! Path, [N I Ns], Bound, NewFF, never. Solved, Sol):-!,

rbfs(Path, Ns, Bound, NewFF, Solved, Sol). % N -

continue! _, _, _, _, yes, yes, Sol).

continue Path, (N I Ns], Bound, NewFF, no. Solved, Sol):-

insert,- N, Ns, NewNs),!, %

% rbfs{ Path, NewNs, Bound, NewFF, Solved, Sol).

succlist (_, _, [], []).

SuCCliSttGO, InheritedFF, [Node/C I NCsJ, Nodes):-G is GO + h(Node, H), F is G + H,

max (F, InheritedFF, FF),

succlistt GO, InheritedFF, NCs, Nodes2>,

insert; (Node, G/F/FF), Nodes2, Nodes).

inheritf F, FF, FF):- % FF-
FF > F,!. , FF-

% F-

inherit,- F, FF, 0).

insert,- (N, G/F/FF), Nodes, I (N, G/F/FF) | Nodes]):-bestff(Nodes, FF2), FF =< FF2,!.

12. 273


insert) N, till I Ms), (Ml I NslJ):-insert (N, Ms, Nsl).

bestffl [ (H, F/G/FF) 1 Ms], FF). % - FF-

bestff ([], 99999). I - FF-

% " "

RBFS. -, , . , . IDA*. -, * IDA*, RBFS ;.

12.8. , . 12.2. A*, IDA* RBFS { )?

12.9. , . 12.8. , - , 1 - . , ( ) RBFS. F(b) F(c) ?



 


. 12.8. ; f- ; 1

12.10. F- RBFS ( ). , . : RBFS , f- . , RBFS F- 8.

12.11. A*, IDA* RBFS " ". , , ( ).



II. Prolog


, . .

, , . *, .

*
, ,
.
.

, *, , .

* . , . .

IDA* , , , . , IDA*, , f-, , , f-, .

RBFS , , , IDA*.

IDA* RBFS . .

" " .

:

;

;

;

^*, IDA*, RBFS;

, ;

;

.





:


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


:

:

, .
==> ...

1879 - | 1675 -


© 2015-2024 lektsii.org - -

: 0.118 .