1. Trang chủ
  2. » Giáo án - Bài giảng

thuat toan AI-TTNT

30 364 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 30
Dung lượng 491,29 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Thuật toán LC-BFSLeast Cost -Breadth First Search=tìm kiếm chi phí ít nhất theo chiều Rộng trước tiên bạn phải tạo 1 file input.txt trong ổ đĩa C:/... q.QMax=MaxItems; q.QNumItems=0;

Trang 1

Thuật toán LC-BFS(Least Cost -Breadth First Search=tìm kiếm chi phí ít nhất theo chiều Rộng)

trước tiên bạn phải tạo 1 file input.txt trong ổ đĩa C:/

Trang 2

q.QMax=MaxItems;

q.QNumItems=0;

q.QFront=q.QRear= -1; //-1 tuc' la` chua co phan tu

nao trong Quenue

int IsQueueFull(const QUEUE &q)//kiem tra hang` doi co'

day` hay chua

int DeQueue(QUEUE &q , int newitem)//lay 1 pt o dau

Queue,co the lam Queue thay doi

Trang 3

int EnQueue(QUEUE &q , int &outitem)//them 1 pt o cuoi

Queue,co the lam Queue thay doi

Trang 6

if((g.A[s][i]!=0 && g.Previous[i]==-1) ||

(g.A[s][i]!=0 && k[s] +g.A[s][i]<k[i]))

Trang 8

LC BFS là thuật toán nâng cấp cua BFS

tạo 1 file input.txt nhu thaut toan LCBFS

// BFS.cpp : Defines the entry point for the console

Trang 9

int InitQueue(QUEUE &q,int MaxItems)

Trang 15

printf("\n\n");

}

Thuật Toán UCS

// UCS.cpp : Defines the entry point for the console

typedef struct map DoThi;

//cac ham dc khai bao

//void Doc_Mang(DoThi &d,char *fn,int &start,int &end) ;

//void Khoi_Tao(DoThi &d);

//void ThanhDong_UCS(DoThi &d,int start,int end);

int Path_ThanhDong_UCS(DoThi d,char *fn,int start,int

end);

// -//

//ham void main()

// -//

//ham doc file input.txt

void Doc_Mang(DoThi &d,char *fn,int &start,int &end)

Trang 16

//ham khoi tao

void Khoi_Tao(DoThi &d)

//ham thuat toan UCS

void ThanhDong_UCS(DoThi &d,int start,int end)

Trang 17

//ham tim tim duong dj tren thuat toan UCS

int Path_ThanhDong_UCS(DoThi d,char*fn,int start,int end)

Trang 19

typedef node *pnode;

void createStack(pstack &S);

void insertTop(pstack &S, int x);

void getTop(pstack &S, int &t);

void insert(pnode &H, int x);

void outputMatrix(Graph A);

void output(pnode H);

void readFile(char *path, Graph &A);

int isScalar(Graph A);//1: Yes - 0: No

int calculateOrderTip(Graph A, int o);

int isVisited(pnode C, int t);//1: Yes - 0: No

void findNextDoor(int Tip, Graph A, pnode &H);

void DFS(Graph A);

cout<<"Bac cua dinh la: "<<calculateOrderTip(A,x);

cout<<"\nDuyet Do thi theo DFS: ";

Trang 22

int calculateOrderTip(Graph A,int o)

Trang 23

findNextDoor(temp,A,H);//Finf all Tip

next-door to the current Tip

Trang 25

int nhapfile(dothi &l,char *fn,TT &start,TT &end)

Trang 26

int dua_vao_hangdoi(QUEUE &Q,TT &x)

Ngày đăng: 11/06/2015, 07:00

Xem thêm

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w