1 / 3

Kiểm tra lớp K58C – Ngày 20/1/2011

Kiểm tra lớp K58C – Ngày 20/1/2011.

herve
Télécharger la présentation

Kiểm tra lớp K58C – Ngày 20/1/2011

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Kiểmtralớp K58C – Ngày 20/1/2011 • Cho đồthịđườngđigiữacácthànhphốtrong slide phíasau. Chúngtacầntìmđườngđitừthànhphố A (Arad) đến B (Bucharest). (các con sốtrênmộtcạnhlàbiểudiễnchíphígiữahaithànhphố, cácsốbêntayphảiđồthịlàkhoảngcáchƠclittừcácthànhphốđếnthànhphốđích) • Cho thuậttoántìmkiếmtốtnhấtđầutiêntrong slide kếtiếp. • Yêucầu: Hãyhiểnthịtrạngtháicácbiến node, ordered-array, father khithựchiệnthuậttoántrênchođồthị ở trêntươngứngvới 3 hàmđánhgiá h nhưsau: • h(n) làtổng chi phítừthànhphốđầu (A) đếnthànhphố n • h(n) làkhoảngcáchƠclittừthànhphố n đếnthànhphốđích (B) • h làtổngcủahaihàmnóitrên

  2. Romania with step costs in km 374 253 329

  3. Cài đặt chi tiết giải thuật Best-first search Function General-Search(problem, ordered-array,h) returns a solution, or failure ordered-array make-queue(make-node(initial-state[problem])); father(initial-state[problem]) = empty; while (1) if ordered-array is empty then return failure; node = pop(ordered-array) ; // node with min h if test(node,Goal[problem]) then return path(node,father); expand-nodes adjacent-nodes(node, Operators[problem]); push(ordered-array, expand-nodes ,h); foreach ex-node in expand-nodes father(ex-node) = node; end Lấy các đỉnh kề với node, nhưng chưa xuất hiện trong ordered-array Function push(ordered-array, expand-nodes ,h); Chèncác nodes trong expand-nodes vàoordered-array saochomảngordered-arraysắptheothứtựtăng/giảmtheohàmh

More Related