Áp dụng thuật toán tối ưu ngọn lửa (mfo) để tối ưu chi phí thời gian

140 4 0
Áp dụng thuật toán tối ưu ngọn lửa (mfo) để tối ưu chi phí thời gian

Đ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

ĐẠI HỌC QUỐC GIA TP HCM TRƯỜNG ĐẠI HỌC BÁCH KHOA - - NGUYỄN DUY TỒN ÁP DỤNG THUẬT TỐN TỐI ƯU NGỌN LỬA (MFO) ĐỂ TỐI ƯU CHI PHÍ - THỜI GIAN Chuyên ngành: Quản Lý Xây Dựng Mã số: 8580302 LUẬN VĂN THẠC SĨ TP HỒ CHÍ MINH, tháng 01 năm 2023 CƠNG TRÌNH ĐƯỢC HỒN THÀNH TẠI TRƯỜNG ĐẠI HỌC BÁCH KHOA – ĐHQG - HCM Cán hướng dẫn khoa học 1: PGS.TS Phạm Vũ Hồng Sơn Chữ ký: Cán hướng dẫn khoa học 2: TS Chu Việt Cường Chữ ký: Cán chấm nhận xét 1: PGS TS Đỗ Tiến Sỹ Chữ ký: Cán chấm nhận xét 2: TS Đinh Công Tịnh Chữ ký: Luận văn thạc sĩ bảo vệ Trường Đại học Bách Khoa, ĐHQG Tp HCM ngày 09 tháng 01 năm 2023 Thành phần Hội đồng đánh giá luận văn thạc sĩ gồm: TS Nguyễn Anh Thư - Chủ tịch hội đồng PGS TS Trần Đức Học - Thư ký PGS TS Đỗ Tiến Sỹ - Phản biện TS Đinh Công Tịnh - Phản biện TS Nguyễn Thanh Việt - Ủy viên Xác nhận Chủ tịch Hội đồng đánh giá LV Trưởng Khoa quản lý chuyên ngành sau luận văn sửa chữa (nếu có) CHỦ TỊCH HỘI ĐỒNG TRƯỞNG KHOA KỸ THUẬT XÂY DỰNG LUẬN VĂN THẠC SĨ NGÀNH QUẢN LÝ XÂY DỰNG - 2023 ĐẠI HỌC QUỐC GIA TP.HCM CỘNG HÒA XÃ HỘI CHỦ NGHĨA VIỆT NAM TRƯỜNG ĐẠI HỌC BÁCH KHOA Độc lập - Tự - Hạnh phúc NHIỆM VỤ LUẬN VĂN THẠC SĨ Họ tên học viên: NGUYỄN DUY TOÀN MSHV : 2070222 Ngày, tháng, năm sinh: 15/08/1988 Nơi sinh: Đồng Nai Chuyên ngành: Mã số: 8580302 Quản lý xây dựng TÊN ĐỀ TÀI: ÁP DỤNG THUẬT TOÁN TỐI ƯU NGỌN LỬA (MFO) ĐỂ TỐI ƯU I CHI PHÍ-THỜI GIAN APPLYING MOTH-FLAME OPTIMIZATION ALGORITHM (MFO) IN TIMECOST OPTIMIZATION II NHIỆM VỤ VÀ NỘI DUNG Tìm hiểu nắm vững thuật toán tối ưu kiến lửa (MFO) Tìm hiểu cách kết hợp (hybrid) thuật tốn MFO với phương pháp tiếp cận trọng lượng thích ứng sửa đổi (MAWA) để giải toán tối ưu Đề xuất ví dụ dự án xây dựng lấy từ tài liệu kỹ thuật 7, 18, 63 hoạt động, điều tra cho thấy hiệu suất MAWA-MFO Xác định hàm mục tiêu tối ưu chí phí thời gian điều kiện ràng buộc Tìm đáp án cho tốn tối ưu chi phí thời gian giải thuật tốn MFO, MFO kết hợp, thuật tốn thơng dụng khác So sánh, nhận xét, phân tích đánh giá kết áp thuật toán khác (MFO, MFO kết hợp, …) Kết luận kiến nghị III NGÀY GIAO NHIỆM VỤ IV NGÀY HOÀN THÀNH NHIỆM VỤ: 18/12/2022 V : 05/09/2022 CÁN BỘ HƯỚNG DẪN: PGS.TS PHẠM VŨ HỒNG SƠN & TS CHU VIỆT CƯỜNG Tp Hồ Chí Minh, ngày 12 tháng 12 năm 2022 CÁN BỘ HƯỚNG DẪN PGS.TS Phạm Vũ Hồng Sơn CÁN BỘ HƯỚNG DẪN CHỦ NHIỆM BỘ MÔN ĐÀO TẠO TS Chu Việt Cường PGS.TS Lê Hoài Long TRƯỞNG KHOA KĨ THUẬT XÂY DỰNG HVTH: NGUYỄN DUY TOÀN i LUẬN VĂN THẠC SĨ NGÀNH QUẢN LÝ XÂY DỰNG - 2023 LỜI CẢM ƠN Luận văn thạt sĩ ngành quản lý xây dựng nằm hệ thống luận cuối khóa nhằm trang bị cho học viên cao học khả tự nghiên cứu, biết cách giải vấn đề cụ thể đặt thực tế xây dựng Đó trách nhiệm niềm tự hào học viên cao học Để hồn thành luận văn “áp dụng thuật tốn tối ưu lửa (MFO) để tối ưu chi phí-thời gian”, ngồi cố gắng nỗ lực thân, nhận giúp đỡ nhiều từ tập thể cá nhân Tôi xin gửi lời tri ân đến tập thể nhân dành cho giúp đỡ q báo Tơi xin gửi lời tri ân đến Thầy PGS.TS Phạm Vũ Hồng Sơn TS Chu Việt Cường, thầy tận tâm hướng dẫn, nhờ vào gợi ý thầy tơi hình thành nên ý tưởng thật tuyệt vời này, thầy truyền đạt hướng nghiên cứu để tơi hồn thành tốt luận văn Tơi xin chân thành cảm ơn quý Thầy Cô Khoa Kỹ Thuật Xây dựng, trường Đại học Bách Khoa Thành phố Hồ Chí Minh truyền dạy kiến thức q giá cho tơi, kiến thức thiếu đường nghiên cứu khoa học nghiệp sau Luận văn thạc sĩ hoàn thành thời gian quy định với nỗ lực thân, nhiên khơng thể khơng có thiếu sót Kính mong q Thầy, Cơ dẫn thêm để tơi bổ sung kiến thức hoàn thiện thân Xin trân trọng cảm ơn Tp Hồ Chí Minh, ngày 12 tháng 12 năm 2022 Nguyễn Duy Toàn HVTH: NGUYỄN DUY TOÀN ii LUẬN VĂN THẠC SĨ NGÀNH QUẢN LÝ XÂY DỰNG - 2023 TÓM TẮT Việc đẩy nhanh tiến độ giảm chi phí dự án tốn ln nhà định ln ưu tiên hàng đầu Bài tốn tối ưu Chi phí-Thời gian (TCO) sử dụng để có tập hợp cách tiếp cận khác đạt trạng thái cân Chi phíThời gian tối ưu Trong nghiên cứu này, để tìm tập hợp giải pháp Pareto, mơ hình tối ưu hố đa mục tiêu dựa thuật toán tối ưu hoá lửa (MFO) kết hợp với phương pháp trọng số thích ứng có điều chỉnh (MAWA), đề xuất Bốn ví dụ dự án xây dựng lấy từ tài liệu kỹ thuật từ đến 63 hoạt động cho thấy hiệu suất MAWA-MFO Kết so sánh với phương pháp mơ hình đề xuất trước chứng minh thuật tốn có tốc độ hội tụ kết tìm kiếm với độ xác cao HVTH: NGUYỄN DUY TỒN iii LUẬN VĂN THẠC SĨ NGÀNH QUẢN LÝ XÂY DỰNG - 2023 ABSTRACT Accelerating the project progress and reducing costs is always a top priority for decision makers The Time-Cost Optimization (TCO) problem is used to get a set of different approaches to achieve the optimal Time-Cost equilibrium In this study, finding a set of Pareto solutions, a multi-objective optimization model based on the Moth-flame optimization algorithm (MFO) combined with the Modified Adaptive Weighting Method (MAWA), is suggested Four examples of construction projects, taken from the technical documents through 63, show the performance of MAWA-MFO The results are compared with the previously proposed modeling methods, demonstrating that the new algorithm has a convergence speed and search results with higher accuracy HVTH: NGUYỄN DUY TOÀN iv LUẬN VĂN THẠC SĨ NGÀNH QUẢN LÝ XÂY DỰNG - 2023 LỜI CAM ĐOAN Tôi xin cam đoan luận văn tơi thực hướng dẫn PGS.TS Phạm Vũ Hồng Sơn TS Chu Việt Cường Các kết luận văn thật chưa công bố nghiên cứu khác Tôi xin chịu trách nhiệm cơng việc thực Tp Hồ Chí Minh, ngày 12 tháng 12 năm 2022 Nguyễn Duy Tồn HVTH: NGUYỄN DUY TỒN v LUẬN VĂN THẠC SĨ NGÀNH QUẢN LÝ XÂY DỰNG - 2023 MỤC LỤC NHIỆM VỤ LUẬN VĂN THẠC SĨ i TÓM TẮT iii ABSTRACT iv LỜI CAM ĐOAN v DANH MỤC CÁC HÌNH ix DANH MỤC CÁC CHỮ VIẾT TẮT xiii CHƯƠNG GIỚI THIỆU 1.1 Đặt vấn đề 1.2 Lựa chọn đề tài 1.3 Mục tiêu nghiên cứu 1.4 Phạm vi nghiên cứu 1.5 Đóng góp đề tài 1.6 Cấu trúc luận văn CHƯƠNG TỔNG QUAN 2.1 Các nghiên cứu trước 2.1.1 Q trình phát triển thuật tốn tối ưu đa mục tiêu 2.1.2 Các nghiên cứu tối ưu chi phí- thời gian 2.1.3 Các nghiên cứu nước 2.1.4 Các nghiên cứu nước CHƯƠNG PHƯƠNG PHÁP NGHIÊN CỨU 3.1 Quy trình nghiên cứu 3.2 Công cụ nghiên cứu 10 3.3 Các lý thuyết, thuật toán áp dụng 10 3.3.1 Phương pháp tìm kiếm Heuristic: 10 3.3.2 Phương pháp toán học (Mathematical Methods): 10 3.3.3 Phương pháp tìm kiếm Meta-Heuristic 11 HVTH: NGUYỄN DUY TOÀN vi LUẬN VĂN THẠC SĨ NGÀNH QUẢN LÝ XÂY DỰNG - 2023 3.3.4 Thuật toán tối ưu lửa Moth-Flame Optimization (MFO) 12 3.3.4.1 Cảm hứng hình thành thuật toán tối ưu lửa (MFO) 13 3.3.4.2 Toán tử thuật toán MFO 14 3.3.4.3 Giả thuyết thuật toán MFO 23 3.3.4.4 Tối ưu thời gian – chi phí (time -cost optimization – TCO) 24 CHƯƠNG MƠ HÌNH MƠ PHỎNG VÀ TRƯỜNG HỢP NGHIÊN CỨU 26 4.1 Mô hình MFO cho tốn TCO 26 4.2 Các trường hợp nghiên cứu 27 4.2.1 Case study 27 4.2.2 Case study 32 4.2.3 Case study 36 4.2.4 Case study 39 4.2.5 Case study – trường hợp thực tế 89 4.3 So sánh, đánh giá 93 4.3.1 Kết chi phí, thời gian nhận 93 4.3.2 Tốc độ hội tụ 93 4.3.3 Thời gian giải thuật 96 4.3.4 Nhận xét 96 CHƯƠNG KẾT LUẬN, KIẾN NGHỊ VÀ HƯỚNG NGHIÊN CỨU TRONG TƯƠNG LAI 97 5.1 Kết luận 97 5.2 Hướng nghiên cứu tương lai 97 TÀI LIỆU THAM KHẢO 98 PHỤ LỤC NGÔN NGỮ LẬP TRÌNH 100 Module xử lý liệu đầu vào 100 Module tối ưu Thời gian – Chi phí 119 2.1 Giải thuật MFO 119 HVTH: NGUYỄN DUY TOÀN vii LUẬN VĂN THẠC SĨ NGÀNH QUẢN LÝ XÂY DỰNG - 2023 2.2 Giải thuật MAWA 121 Module kết đầu 123 HVTH: NGUYỄN DUY TOÀN viii LUẬN VĂN THẠC SĨ NGÀNH QUẢN LÝ XÂY DỰNG - 2023 ES55 = max([EF52, EF53]) EF55 = ES55 + self.task55[int(choice[55-1])][1] ES56 = max([EF50, EF53]) EF56 = ES56 + self.task56[int(choice[56-1])][1] ES57 = max([EF51, EF54]) EF57 = ES57 + self.task57[int(choice[57-1])][1] ES58 = EF52 EF58 = ES58 + self.task58[int(choice[58-1])][1] ES59 = EF55 EF59 = ES59 + self.task59[int(choice[59-1])][1] ES60 = EF56 EF60 = ES60 + self.task60[int(choice[60-1])][1] ES61 = max([EF56, EF57]) EF61 = ES61 + self.task61[int(choice[61-1])][1] ES62 = EF60 EF62 = ES62 + self.task62[int(choice[62-1])][1] ES63 = EF61 EF63 = ES63 + self.task63[int(choice[63-1])][1] time = max([EF58, EF59, EF62, EF63]) # Backward LF18 = EF18 LS18 = LF18 - self.task18[int(choice[17])][0] LF17 = LS18 LS17 = LF17 - self.task17[int(choice[16])][0] LF16 = LS18 LS16 = LF16 - self.task16[int(choice[15])][0] LF15 = LS17 LS15 = LF15 - self.task15[int(choice[14])][0] LF14 = min([LS16, LS17]) LS14 = LF14 - self.task14[int(choice[13])][0] LF13 = LS16 LS13 = LF13 - self.task13[int(choice[12])][0] LF12 = LS15 LS12 = LF12 - self.task12[int(choice[11])][0] LF11 = LS17 LS11 = LF11 - self.task11[int(choice[10])][0] LF10 = min([LS12, LS14]) LS10 = LF10 - self.task10[int(choice[9])][0] LF9 = LS12 LS9 = LF9 - self.task9[int(choice[8])][0] LF8 = LS11 LS8 = LF8 - self.task8[int(choice[7])][0] HVTH: NGUYỄN DUY TOÀN 111 LUẬN VĂN THẠC SĨ NGÀNH QUẢN LÝ XÂY DỰNG - 2023 LF7 = LS11 LS7 = LF7 - self.task7[int(choice[6])][0] LF6 = min([LS8, LS9, LS10]) LS6 = LF6 - self.task6[int(choice[5])][0] LF5 = LS7 LS5 = LF5 - self.task5[int(choice[4])][0] LF4 = LS14 LS4 = LF4 - self.task4[int(choice[3])][0] LF3 = LS13 LS3 = LF3 - self.task3[int(choice[2])][0] LF2 = LS10 LS2 = LF2 - self.task2[int(choice[1])][0] LF1 = min([LS5, LS6]) LS1 = LF1 - self.task1[int(choice[0])][0] TF = np.zeros((7, 1)) TF[0] = LS1 - ES1 TF[1] = LS2 - ES2 TF[2] = LS3 - ES3 TF[3] = LS4 - ES4 TF[4] = LS5 - ES5 TF[5] = LS6 - ES6 TF[6] = LS7 - ES7 return np.array([idx for idx, value in enumerate(TF) if value == ]) + def objective(self, x): x = x - # Time + Cost choice = np.round(x) # Forward ES1 = EF1 = ES1 + self.task1[int(choice[1-1])][1] ES2 = EF2 = ES2 + self.task2[int(choice[2-1])][1] ES3 = EF3 = ES3 + self.task3[int(choice[3-1])][1] ES4 = EF4 = ES4 + self.task4[int(choice[4-1])][1] ES5 = EF5 = ES5 + self.task5[int(choice[5-1])][1] ES6 = EF1 EF6 = ES6 + self.task6[int(choice[6-1])][1] ES7 = EF1 EF7 = ES7 + self.task7[int(choice[7-1])][1] HVTH: NGUYỄN DUY TOÀN 112 LUẬN VĂN THẠC SĨ NGÀNH QUẢN LÝ XÂY DỰNG - 2023 ES8 = EF2 EF8 = ES8 + self.task8[int(choice[8-1])][1] ES9 = EF3 EF9 = ES9 + self.task9[int(choice[9-1])][1] ES10 = EF4 EF10 = ES10 + self.task10[int(choice[10-1])][1] ES11 = EF5 EF11 = ES11 + self.task11[int(choice[11-1])][1] ES12 = EF6 EF12 = ES12 + self.task12[int(choice[12-1])][1] ES13 = EF7 EF13 = ES13 + self.task13[int(choice[13-1])][1] ES14 = EF8 EF14 = ES14 + self.task14[int(choice[14-1])][1] ES15 = EF9 EF15 = ES15 + self.task15[int(choice[15-1])][1] ES16 = max([EF9, EF10]) EF16 = ES16 + self.task16[int(choice[16-1])][1] ES17 = EF10 EF17 = ES17 + self.task17[int(choice[17-1])][1] ES18 = max([EF10, EF11]) EF18 = ES18 + self.task18[int(choice[18-1])][1] ES19 = EF11 EF19 = ES19 + self.task19[int(choice[19-1])][1] ES20 = EF12 EF20 = ES20 + self.task20[int(choice[20-1])][1] ES21 = EF13 EF21 = ES21 + self.task21[int(choice[21-1])][1] ES22 = EF14 EF22 = ES22 + self.task22[int(choice[22-1])][1] ES23 = EF15 EF23 = ES23 + self.task23[int(choice[23-1])][1] ES24 = EF16 EF24 = ES24 + self.task24[int(choice[24-1])][1] ES25 = EF17 EF25 = ES25 + self.task25[int(choice[25-1])][1] ES26 = EF18 EF26 = ES26 + self.task26[int(choice[26-1])][1] ES27 = EF20 EF27 = ES27 + self.task27[int(choice[27-1])][1] ES28 = EF21 EF28 = ES28 + self.task28[int(choice[28-1])][1] HVTH: NGUYỄN DUY TOÀN 113 LUẬN VĂN THẠC SĨ NGÀNH QUẢN LÝ XÂY DỰNG - 2023 ES29 = EF22 EF29 = ES29 + self.task29[int(choice[29-1])][1] ES30 = EF23 EF30 = ES30 + self.task30[int(choice[30-1])][1] ES31 = max([EF19, EF25]) EF31 = ES31 + self.task31[int(choice[31-1])][1] ES32 = EF26 EF32 = ES32 + self.task32[int(choice[32-1])][1] ES33 = EF26 EF33 = ES33 + self.task33[int(choice[33-1])][1] ES34 = max([EF28, EF30]) EF34 = ES34 + self.task34[int(choice[34-1])][1] ES35 = max([EF24, EF27, EF29]) EF35 = ES35 + self.task35[int(choice[35-1])][1] ES36 = EF24 EF36 = ES36 + self.task36[int(choice[36-1])][1] ES37 = EF31 EF37 = ES37 + self.task37[int(choice[37-1])][1] ES38 = EF32 EF38 = ES38 + self.task38[int(choice[38-1])][1] ES39 = EF33 EF39 = ES39 + self.task39[int(choice[39-1])][1] ES40 = EF34 EF40 = ES40 + self.task40[int(choice[40-1])][1] ES41 = EF35 EF41 = ES41 + self.task41[int(choice[41-1])][1] ES42 = EF36 EF42 = ES42 + self.task42[int(choice[42-1])][1] ES43 = EF36 EF43 = ES43 + self.task43[int(choice[43-1])][1] ES44 = EF37 EF44 = ES44 + self.task44[int(choice[44-1])][1] ES45 = EF39 EF45 = ES45 + self.task45[int(choice[45-1])][1] ES46 = EF39 EF46 = ES46 + self.task46[int(choice[46-1])][1] ES47 = EF40 EF47 = ES47 + self.task47[int(choice[47-1])][1] ES48 = EF42 EF48 = ES48 + self.task48[int(choice[48-1])][1] ES49 = max([EF38, EF41, EF44]) EF49 = ES49 + self.task49[int(choice[49-1])][1] HVTH: NGUYỄN DUY TOÀN 114 LUẬN VĂN THẠC SĨ NGÀNH QUẢN LÝ XÂY DỰNG - 2023 ES50 = EF45 EF50 = ES50 + self.task50[int(choice[50-1])][1] ES51 = EF46 EF51 = ES51 + self.task51[int(choice[51-1])][1] ES52 = EF47 EF52 = ES52 + self.task52[int(choice[52-1])][1] ES53 = max([EF48, EF43]) EF53 = ES53 + self.task53[int(choice[53-1])][1] ES54 = EF49 EF54 = ES54 + self.task54[int(choice[54-1])][1] ES55 = max([EF52, EF53]) EF55 = ES55 + self.task55[int(choice[55-1])][1] ES56 = max([EF50, EF53]) EF56 = ES56 + self.task56[int(choice[56-1])][1] ES57 = max([EF51, EF54]) EF57 = ES57 + self.task57[int(choice[57-1])][1] ES58 = EF52 EF58 = ES58 + self.task58[int(choice[58-1])][1] ES59 = EF55 EF59 = ES59 + self.task59[int(choice[59-1])][1] ES60 = EF56 EF60 = ES60 + self.task60[int(choice[60-1])][1] ES61 = max([EF56, EF57]) EF61 = ES61 + self.task61[int(choice[61-1])][1] ES62 = EF60 EF62 = ES62 + self.task62[int(choice[62-1])][1] ES63 = EF61 EF63 = ES63 + self.task63[int(choice[63-1])][1] time = max([EF58, EF59, EF62, EF63]) # Backward """ LF18 = EF18 LS18 = LF18 - self.task18[int(choice[17])][0] LF17 = LS18 LS17 = LF17 - self.task17[int(choice[16])][0] LF16 = LS18 LS16 = LF16 - self.task16[int(choice[15])][0] LF15 = LS17 LS15 = LF15 - self.task15[int(choice[14])][0] LF14 = min([LS16, LS17]) LS14 = LF14 - self.task14[int(choice[13])][0] LF13 = LS16 HVTH: NGUYỄN DUY TOÀN 115 LUẬN VĂN THẠC SĨ NGÀNH QUẢN LÝ XÂY DỰNG - 2023 LS13 = LF13 - self.task13[int(choice[12])][0] LF12 = LS15 LS12 = LF12 - self.task12[int(choice[11])][0] LF11 = LS17 LS11 = LF11 - self.task11[int(choice[10])][0] LF10 = min([LS12, LS14]) LS10 = LF10 - self.task10[int(choice[9])][0] LF9 = LS12 LS9 = LF9 - self.task9[int(choice[8])][0] LF8 = LS11 LS8 = LF8 - self.task8[int(choice[7])][0] LF7 = LS11 LS7 = LF7 - self.task7[int(choice[6])][0] LF6 = min([LS8, LS9, LS10]) LS6 = LF6 - self.task6[int(choice[5])][0] LF5 = LS7 LS5 = LF5 - self.task5[int(choice[4])][0] LF4 = LS14 LS4 = LF4 - self.task4[int(choice[3])][0] LF3 = LS13 LS3 = LF3 - self.task3[int(choice[2])][0] LF2 = LS10 LS2 = LF2 - self.task2[int(choice[1])][0] LF1 = min([LS5, LS6]) LS1 = LF1 - self.task1[int(choice[0])][0] """ # TF = np.zeros((7, 1)) # TF[0] = LS1 - ES1 # TF[1] = LS2 - ES2 # TF[2] = LS3 - ES3 # TF[3] = LS4 - ES4 # TF[4] = LS5 - ES5 # TF[5] = LS6 - ES6 # TF[6] = LS7 - ES7 cost = for i in range(len(x)): match i: case 0: cost += case 1: cost += case 2: cost += case 3: cost += case 4: cost += case 5: cost += case 6: cost += case 7: cost += case 8: cost += case 9: cost += case 10:cost += case 11:cost += case 12:cost += HVTH: NGUYỄN DUY TOÀN self.task1[int(choice[0])][0] self.task2[int(choice[1])][0] self.task3[int(choice[2])][0] self.task4[int(choice[3])][0] self.task5[int(choice[4])][0] self.task6[int(choice[5])][0] self.task7[int(choice[6])][0] self.task8[int(choice[7])][0] self.task9[int(choice[8])][0] self.task10[int(choice[9])][0] self.task11[int(choice[10])][0] self.task12[int(choice[11])][0] self.task13[int(choice[12])][0] 116 LUẬN VĂN THẠC SĨ NGÀNH QUẢN LÝ XÂY DỰNG - 2023 case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case case 13:cost 14:cost 15:cost 16:cost 17:cost 18:cost 19:cost 20:cost 21:cost 22:cost 23:cost 24:cost 25:cost 26:cost 27:cost 28:cost 29:cost 30:cost 31:cost 32:cost 33:cost 34:cost 35:cost 36:cost 37:cost 38:cost 39:cost 40:cost 41:cost 42:cost 43:cost 44:cost 45:cost 46:cost 47:cost 48:cost 49:cost 50:cost 51:cost 52:cost 53:cost 54:cost 55:cost 56:cost 57:cost 58:cost 59:cost 60:cost 61:cost 62:cost += += += += += += += += += += += += += += += += += += += += += += += += += += += += += += += += += += += += += += += += += += += += += += += += += += self.task14[int(choice[13])][0] self.task15[int(choice[14])][0] self.task16[int(choice[15])][0] self.task17[int(choice[16])][0] self.task18[int(choice[17])][0] self.task19[int(choice[18])][0] self.task20[int(choice[19])][0] self.task21[int(choice[20])][0] self.task22[int(choice[21])][0] self.task23[int(choice[22])][0] self.task24[int(choice[23])][0] self.task25[int(choice[24])][0] self.task26[int(choice[25])][0] self.task27[int(choice[26])][0] self.task28[int(choice[27])][0] self.task29[int(choice[28])][0] self.task30[int(choice[29])][0] self.task31[int(choice[30])][0] self.task32[int(choice[31])][0] self.task33[int(choice[32])][0] self.task34[int(choice[33])][0] self.task35[int(choice[34])][0] self.task36[int(choice[35])][0] self.task37[int(choice[36])][0] self.task38[int(choice[37])][0] self.task39[int(choice[38])][0] self.task40[int(choice[39])][0] self.task41[int(choice[40])][0] self.task42[int(choice[41])][0] self.task43[int(choice[42])][0] self.task44[int(choice[43])][0] self.task45[int(choice[44])][0] self.task46[int(choice[45])][0] self.task47[int(choice[46])][0] self.task48[int(choice[47])][0] self.task49[int(choice[48])][0] self.task50[int(choice[49])][0] self.task51[int(choice[50])][0] self.task52[int(choice[51])][0] self.task53[int(choice[52])][0] self.task54[int(choice[53])][0] self.task55[int(choice[54])][0] self.task56[int(choice[55])][0] self.task57[int(choice[56])][0] self.task58[int(choice[57])][0] self.task59[int(choice[58])][0] self.task60[int(choice[59])][0] self.task61[int(choice[60])][0] self.task62[int(choice[61])][0] self.task63[int(choice[62])][0] # print(test_time) return np.array([time, cost + time * self.indirectCost]) ############################################################### MAIN # Tạo cơng thức tốn problem_63_case1 = Problem63(2300) print("Xuất biểu đồ: ") inp = input() select = True if inp.lower() == "yes" else False start = time.time() # Tạo lớp MAWAMFO HVTH: NGUYỄN DUY TOÀN 117 LUẬN VĂN THẠC SĨ NGÀNH QUẢN LÝ XÂY DỰNG - 2023 test = MAWAMFOArchive( objectiveFunction=problem_63_case1.objective, lowerBound=1, upperBound=np.array([4, 4, 4, 3, 4, 4, 4, 4, 5, 5, 5, 5, 4, 4, 4, 5, 4, 4, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]), dimension=63, iteration=450, population=180, case=63, plot=select) test.run() stop = time.time() print(f"Execution time = {stop - start}s") ######################################################## ALGORITHM MWAWMFO # Tạo lớp MAWAMFO class MAWAMFOArchive(BaseMFO): # Khởi tạo tham số đầu vào thuật toán MAWAMFO def init (self, objectiveFunction, lowerBound, upperBound, iteration, population, dimension, case=63, archive_size=100, plot=False): super(). init (objectiveFunction, iteration, population, dimension, lowerBound, upperBound) # Tham số lấy pareto front self.archive = None self.archive_cost = None self.G = None self.case = case self.n_grid = 10 self.alpha = 0.1 self.n_grid = 10 self.beta = self.gamma = self.archive_size = archive_size self.min_cost = np.inf # inf = infinitive = vô cực self.min_cost_with_time = None self.best_each_iteration = [] self.plot = plot # Khởi tạo vị trí Moth def initialization(self): return [MOMAWAAgent(self.lowerBound, self.upperBound, self.dimension) for _ in range(self.population)] # Lấy cost nhỏ vòng lặp def getBestEachIteration(self): = np.inf min_moth = None for i in self.archive: # check time or cost if i.fitness[1] > 1000: HVTH: NGUYỄN DUY TOÀN 118 LUẬN VĂN THẠC SĨ NGÀNH QUẢN LÝ XÂY DỰNG - 2023 # it is cost in if i.fitness[1] < min: = i.fitness[1] min_moth = copy.deepcopy(i) else: # it is cost in if i.fitness[0] < min: = i.fitness[0] min_moth = copy.deepcopy(i) self.best_each_iteration.append(min_moth) # Kiểm tra vị trí Moth có khỏi vùng tìm kiếm hay khơng def checkingBoundary(self): # Chạy N Moth # index = vị trí for index, moth in enumerate(self.moths): # Cập nhật vị trí moth thứ i khỏi vùng tìm kiếm position = moth.position moth.position[position = self.upperBound] self.moths[index].position = moth.position # Tính Time Cost Moth thứ i bundle_result = self.fobj(moth.position) moth.fitness = (bundle_result[0], bundle_result[1]) # (time, cost) # Cập nhật fitness moth thứ i self.moths[index].fitness = moth.fitness # Lấy cost moth nhỏ if self.moths[index].fitness[1] < self.min_cost: self.min_cost = self.moths[index].fitness[1] self.min_cost_with_time = self.moths[index].fitness def run(self): # Chạy MaxIter lần ( điều kiện dừng vòng lặp ) for i in range(self.iteration): # Gọi hàm iterateAlgorithm lần thứ i self.iterateAlgorithm(i) if not self.plot: archive_costs = get_cost_from_archive(self.archive) time_x = [i.fitness[0] for i in self.moths] cost_y = [i.fitness[1] for i in self.moths] plt.scatter(time_x, cost_y, marker="o", c="#202db8") plt.scatter(archive_costs[0, :], archive_costs[1, :], marker="x", c="#b11540") plt.show() Module tối ưu Thời gian – Chi phí 2.1 Giải thuật MFO # This function will apply MAWA Approach def iterateAlgorithm(self, currentIteration): # linearly decreased (3.14) # Tính số lửa numberOfFlames = round(self.population - (currentIteration + 1) * HVTH: NGUYỄN DUY TOÀN 119 LUẬN VĂN THẠC SĨ NGÀNH QUẢN LÝ XÂY DỰNG - 2023 (self.population - 1) / self.iteration) # checking boundary and calculate fitness self.checkingBoundary() # Tính combined_fitness moths dựa vào MAWA self.mawa_1st() # Nếu vòng lặp = if currentIteration == 0: # kiểm tra moths bị dominated self.moths = checking_dominance(self.moths) # lưu moths không bị dominated vào archive self.archive = get_dominated_wolves(self.moths) self.archive_cost = get_cost_from_archive(self.archive) self.G = create_hypercubes(self.archive_cost, self.n_grid, self.alpha) # Xác định index moths archive Grid for i in range(len(self.archive)): self.archive[i].grid_index, self.archive[i].grid_sub_index = get_grid_index(self.archive[i], self.G, self.n_grid) self.sortedMoths = copy.deepcopy(sorted(self.moths)) self.bestFlames = copy.deepcopy(self.sortedMoths) # vòng lặp > else: doubleMoths = sorted(self.previousMoths + self.bestFlames) self.sortedMoths = copy.deepcopy(doubleMoths[:self.population]) # Cập nhật lửa ( theo vị trí tốt đến dở ) self.bestFlames = copy.deepcopy(self.sortedMoths) self.bestFlame = copy.deepcopy(self.sortedMoths[0]) # Lưu vị trí moth vịng lặp trước self.previousMoths = copy.deepcopy(self.moths) # a linearly decreases from -1 to -2 to calculate t in Eq (3.12) a = -1 + (currentIteration + 1) * (-1 / self.iteration) # lặp N moth for i, moth in enumerate(self.moths): # lặp vị trí ( task ) để cập nhật vị trí ( tối ưu ) for j, position in enumerate(moth.position): d_alpha = np.absolute(self.sortedMoths[0].position[j] moth.position[j]) d_beta = np.absolute(self.sortedMoths[1].position[j] moth.position[j]) d_gamma = np.absolute(self.sortedMoths[2].position[j] moth.position[j]) d_avg = (d_alpha + d_beta + d_gamma) / distanceToFlame = np.absolute(self.sortedMoths[i].position[j] - moth.position[j]) # Eq (3.13) b = t = (a - 1) * np.random.rand() + ri = np.random.uniform(0.5, 1) # D in Eq (3.13) # Nếu moth thứ i < số lửa if i < numberOfFlames: # Eq (3.12) # Cập nhật vị trí moth thứ i vị trí thứ j HVTH: NGUYỄN DUY TOÀN 120 LUẬN VĂN THẠC SĨ NGÀNH QUẢN LÝ XÂY DỰNG - 2023 self.moths[i].position[j] = (ri * distanceToFlame + (1 - ri) * d_avg) * np.exp(b * t) * np.cos( t * * np.pi) + self.sortedMoths[i].position[j] # Nếu moth thứ i >= số lửa if i >= numberOfFlames: # Eq (3.12) self.moths[i].position[j] = (ri * distanceToFlame + (1 - ri) * d_avg) * np.exp(b * t) * np.cos( t * * np.pi) + self.sortedMoths[numberOfFlames 1].position[j] self.checkingBoundary() self.mawa_1st() # Xác định moth bị dominated self.moths = checking_dominance(self.moths) # Chọn moth không bị dominated non_dominated_wolves = get_dominated_wolves(self.moths) new_archive = self.archive + non_dominated_wolves # Xác định moth không bị dominated lưu vào archive self.archive = checking_dominance(new_archive) self.archive = get_dominated_wolves(self.archive) # Xác định index moths archive Grid for i in range(len(self.archive)): self.archive[i].grid_index, self.archive[i].grid_sub_index = get_grid_index(self.archive[i], self.G, self.n_grid) # Nếu số moth archive lớn archive_size if len(self.archive) > self.archive_size: extra = len(self.archive) - self.archive_size # Xoá moth archive self.archive = copy.deepcopy(delete_from_archive(self.archive, extra, self.gamma)) self.archive_cost = get_cost_from_archive(self.archive) self.G = create_hypercubes(self.archive_cost, self.n_grid, self.alpha) if self.plot: archive_costs = get_cost_from_archive(self.archive) time_x = [i.fitness[0] for i in self.moths] cost_y = [i.fitness[1] for i in self.moths] plt.scatter(time_x, cost_y, marker="o", c="#202db8") plt.scatter(archive_costs[0, :], archive_costs[1, :], marker="x", c="#b11540") plt.show() # Lưu giá trị tốt lần thứ currentIteration self.convergence.append(copy.deepcopy(self.bestFlame)) self.getBestEachIteration() 2.2 Giải thuật MAWA # get extreme points from current iteration and calculate combined_fitness of each agent def mawa(self): # get ztmin , ztmax and get zcmin , zcmax ztmin = np.inf HVTH: NGUYỄN DUY TOÀN 121 LUẬN VĂN THẠC SĨ NGÀNH QUẢN LÝ XÂY DỰNG - 2023 ztmax = np.NINF zcmin = np.inf zcmax = np.NINF for moth in self.moths: zt = moth.fitness[0] zc = moth.fitness[1] # get time # get cost if zt < ztmin: ztmin = zt if zt > ztmax: ztmax = zt if zc < zcmin: zcmin = zc if zc > zcmax: zcmax = zc # vc, vt, v, wc ,wt wt = wc = # cases if ztmin != ztmax and zcmin != zcmax: vt = ztmin / (ztmax - ztmin) vc = zcmin / (zcmax - zcmin) v = vt + vc wc = vc / v wt = vt / vc elif ztmin == ztmax and zcmin == zcmax: wt, wc = 0.5, 0.5 elif ztmin == ztmax and zcmin != zcmax: wc, wt = 0.1, 0.9 elif ztmin != ztmax and zcmin == zcmax: wc, wt = 0.9, 0.1 # calculate combined_fitness of each agent for index, moth in enumerate(self.moths): zt = moth.fitness[0] # get time zc = moth.fitness[1] # get cost gamma = np.random.rand() fitness = wt * ((ztmax - zt + gamma) / (ztmax - ztmin + gamma)) \ + wc * ((zcmax - zc + gamma) / (zcmax - zcmin + gamma)) self.moths[index].combined_fitness = -1 * fitness def mawa_1st(self): # get ztmin , ztmax and get zcmin , zcmax ztmin = np.inf ztmax = np.NINF zcmin = np.inf zcmax = np.NINF for moth in self.moths: zt = moth.fitness[0] zc = moth.fitness[1] # get time # get cost if zt < ztmin: HVTH: NGUYỄN DUY TOÀN 122 LUẬN VĂN THẠC SĨ NGÀNH QUẢN LÝ XÂY DỰNG - 2023 ztmin = zt if zt > ztmax: ztmax = zt if zc < zcmin: zcmin = zc if zc > zcmax: zcmax = zc # calculate combined_fitness of each agent for index, moth in enumerate(self.moths): zt = moth.fitness[0] # get time zc = moth.fitness[1] # get cost # vc, vt, v, wc ,wt wt = wc = # cases if ztmin != ztmax and zcmin != zcmax: vt = zt / (ztmax - ztmin) vc = zc / (zcmax - zcmin) v = vt + vc wc = vc / v wt = vt / v elif ztmin == ztmax and zcmin == zcmax: wt, wc = 0.5, 0.5 elif ztmin == ztmax and zcmin != zcmax: wc, wt = 0.1, 0.9 elif ztmin != ztmax and zcmin == zcmax: wc, wt = 0.9, 0.1 gamma = np.random.rand() fitness = wt * ((ztmax - zt + gamma) / (ztmax - ztmin + gamma)) \ + wc * ((zcmax - zc + gamma) / (zcmax - zcmin + gamma)) # Cập nhật combined_fitness moth thứ i (index) self.moths[index].combined_fitness = -1 * fitness ######################################################## END OF ALGORITHM Module kết đầu # Xuất kết for i, v in enumerate(test.best_each_iteration): print(f"{i + 1} \t- ({v.fitness[0]}, {v.fitness[1]})") # Kết với cost nhỏ print(f"Optimal cost = {test.min_cost_with_time}") set_archive = dict() for each_moth in test.archive: if f"({each_moth.fitness[0]}-{each_moth.fitness[1]})" in set_archive.keys(): continue set_archive.update({f"({each_moth.fitness[0]}{each_moth.fitness[1]})": each_moth}) print(f"({each_moth.fitness[0]}, {each_moth.fitness[1]}) {np.round(each_moth.position)}") HVTH: NGUYỄN DUY TOÀN 123 LUẬN VĂN THẠC SĨ NGÀNH QUẢN LÝ XÂY DỰNG - 2023 # Xuất kết hội tụ vào file excel data = { 'time': [i.fitness[0] for i in test.best_each_iteration], 'cost': [i.fitness[1] for i in test.best_each_iteration], } df = pd.DataFrame(data) df.to_excel(r'result/problem63a/res_demo.xlsx', index=False) # # # # # costs = [i.fitness[1] for i in test.best_each_iteration] plt.plot(np.linspace(1, test.iteration, num=test.iteration), costs) plt.xlabel("Iterations") plt.ylabel("Cost (USD)") plt.show() # Xuất kết pareto vào file excel pareto = { 'pareto': [f"({i.fitness[0]}, {i.fitness[1]}) {np.round(i.position)}" for i in set_archive.values()] } pareto_df = pd.DataFrame(pareto) pareto_df.to_excel(r'result/problem63a/pareto_demo.xlsx', index=False) HVTH: NGUYỄN DUY TOÀN 124 LUẬN VĂN THẠC SĨ NGÀNH QUẢN LÝ XÂY DỰNG - 2023 PHẦN LÝ LỊCH TRÍCH NGANG Họ tên: NGUYỄN DUY TỒN Ngày, tháng, năm sinh: 15/08/1988 Nơi sinh: Đồng Nai Địa liên lạc: 289, Ấp Bình Minh, Xã Xuân Hiệp, Huyện Xuân Lộc, Tỉnh Đồng Nai Email: toan.ndks@gmail.com Sđt: 0933223452 QUÁ TRÌNH ĐÀO TẠO Từ 2011 đến năm 2016: Đại học quy chuyên ngành Kỹ Thuật Xây Dựng, trường Đại Học Mở TPHCM Từ 2020 đến nay: Thạc sĩ chuyên ngành Quản lý Xây Dựng, trường Đại Học Bách Khoa TP Hồ Chí Minh Q TRÌNH CƠNG TÁC Từ 12/2016 đến nay: Cơng ty Cổ phần Tập đồn Xây dựng Hồ Bình HVTH: NGUYỄN DUY TỒN 125

Ngày đăng: 10/04/2023, 22:11

Tài liệu cùng người dùng

Tài liệu liên quan