A0001-Schedule

本文介绍了一个个人学习计划,强调不限时完成每个项目以追求极致理解,重视软硬件的自主可控,包括深入理解运行机理、自我改进和调试。计划中提到不追求原创,而是通过重写和不断改进提升技能,并分享了如何确定项目范围和实验步骤的注意事项。

Schedule

规则

  • 理论上一周完成一项、但不限制最长时间、以期接近极致

不要求原创、而要求对软硬件的自主可控:
1、完全了解运行机理与过程细节
2、在需要的时候可以自己改进、Debug、重写

say some:
1、使用一些新的方法来重写、即使已经有了可用的模块
2、不断地改进自已的方法
3、做完后看看别人的方法
4、熟悉已有的成果、这是往后得以提升的第一步

say some:
1、确定一个项目的范围、不要贪求大而全,聚焦一个问题做好即可
2、实验步骤要详细、结果记录可查,需要保留


2017

...
February..
07USART接口驱动开发-start
07SPI接口管理器第二个版本-pause.(太复杂、需要新的思路)
05学习完GitHub Guides-20h
January..
30正式将本项目放入GitHub-02h.(AVR_build-1019 or v1.1.0.20170113_alpha)
27学习GitHub Guides-start
21SPI接口管理器第二个版本-ing
13SPI接口管理器第二个版本(可暂停擦写过程)-restart

2016

...
November..
30测试完成SPI接口管理器-06h.(AVR_build-1018)
27完成SPI接口管理器第一个版本(不能暂停擦写过程)-32h.
24这周编码时间少、结构也不太清晰、而今早都变得清晰起来.
18SPI接口管理器-start
16阅读并测试数字示波器操作手册-05h
15完成SPI Flash接口(基本型-带阻塞)-31h.(AVR_build-1017)
October..
30SPI Flash的操作接口-start
29初步完成代码基本结构(测试OK)-00h(AVR_build-1016)
15修改事件管理并融入调度器-24h.(AVR_build-1016)
13移植混合调度器代码-06h
06重写了事件管理模块-05h.(AVR_build-1013)
September..
29开始整理代码结构-21.75h
[IMP] Import start [IMP] Import type - Excel file [IMP] Import from - D:\文档\工作簿1.xlsx [IMP] Import data [t_ebc_prod_instr] [ERR] ERROR: duplicate key value violates unique constraint "tmas_t_ebc_prod_instr_pk" DETAIL: Key (epi_id)=(A342B10893BA4D5999E58091AE0A2026) already exists. [ERR] INSERT INTO "tmas"."t_ebc_prod_instr" ("epi_id", "inv_organization_code", "prod_instr_no", "item_code", "item_name", "prod_model_code", "service_item_flag", "sku_number", "vendor_code", "mfg_site_code", "bom_version", "wip_class_code", "ppo_type_code", "order_category", "order_type", "inhouse_flag", "feed_mode", "bs_mode", "kit_relation_flag", "material_fullset_flag", "engineer_fullset_flag", "release_time", "plan_start_time", "plan_online_time", "plan_end_time", "actual_start_time", "actual_online_time", "actual_end_time", "bom_extact_time", "first_issue_date", "close_time", "cancel_time", "start_qty", "mrp_net_qty", "completed_qty", "scrapped_qty", "qty_uom", "completion_subinventory_name", "completion_locator_code", "released_by", "board_type", "routing", "routing_version", "factory_code", "eco", "eca", "inbound_complete_flag", "all_complete_flag", "open_qty", "write_off_reserved_qty", "net_supply_qty", "customer_bg_code", "auto_pr_flag", "ppo_status_code", "ppo_progress_code", "bs_po_number", "ppo_demand_number", "ppo_demand_plan_id", "manufacture_mode", "supply_mode", "prod_lifecycle", "supply_center_id", "supply_center_code", "demand_type_code", "source_bill_type", "source_bill_number", "original_bill_type", "original_bill_number", "prod_fulfillment", "prod_category", "responsible_department", "auto_routing_flag", "price_check_flag", "fullset_check_flag", "auto_bom_flag", "auto_inbound_flag", "allow_over_send_flag", "allow_over_recv_flag", "auto_schedule_flag", "bonded_flag", "oversea_flag", "manufacturer_category", "temporary_technology_flag", "verification_flag", "description", "log_msg", "version_number", "version_date", "created_by", "creation_date", "last_updated_by", "last_updated_date", "is_delete", "delete_by", "delete_date", "mfg_stage_type1", "mfg_stage_type2", "mfg_stage_type3", "data_from", "mixed_with_board_flag", "reference_flag", "plan_user", "no_used_qty", "item_class", "net_quantity", "bjitem_flag", "entity_type_name", "entity_subtype_name", "mfg_site_name", "is_model", "created_by_type", "source_service_name", "inventory_org_id", "hwip_release_time", "is_lock", "tmas_release_by", "tmas_release_time", "prod_instr_id", "start_qty_first", "plan_start_time_first", "workorder_plan_online_time", "workorder_plan_end_time", "po_writeoff_finished", "all_issue_flag", "revision_control_code", "eco_num") VALUES ('A342B10893BA4D5999E58091AE0A2026', 'DG1', 'DPZHT59G034', '51098HQW-001', '智能手机-Lamarr-AL00CK-LTE/WCDMA/GSM手机-USB线缆-内置锂离子电池*1/中式旅充*1-直板-釉金', 'Lamarr-AL00CK', 'N', '51098HQW', '021356', '021356_T', NULL, 'T1ZZ', NULL, NULL, NULL, 'Y', 'CS', NULL, 'N', NULL, NULL, to_timestamp('0001-01-01 12:14:00', 'YYYY-MM-DD HH24:MI:SS'), to_timestamp('0001-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), to_timestamp('0001-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), to_timestamp('0001-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), NULL, NULL, NULL, NULL, to_timestamp('0001-01-01 23:56:00', 'YYYY-MM-DD HH24:MI:SS'), NULL, NULL, 1500, 1500, 1450, 0, 'PCS', NULL, NULL, 'l00468209', NULL, '500354607', NULL, 'JUXIN', NULL, NULL, NULL, NULL, 50, 0, 50, NULL, NULL, '2', '4', NULL, 'cPlan20250916S01X4', '20250916', 'EMS', 'STO', 'Pilot', 'SZ', NULL, '排产需求-标准', 'PPO-Require', 'cPlan20250916S01X4', NULL, '51098HQW-001021356_T2534489', NULL, NULL, NULL, NULL, NULL, NULL, 'Y', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '智能手机-Lamarr-AL00CK-LTE/WCDMA/GSM手机-USB线缆-内置锂离子电池*1/中式旅充*1-直板-釉金', NULL, NULL, NULL, 'q00612034', to_timestamp('0001-01-01 11:36:00', 'YYYY-MM-DD HH24:MI:SS'), 'l00468209', to_timestamp('0001-01-01 10:30:00', 'YYYY-MM-DD HH24:MI:SS'), 0, NULL, NULL, '量产', NULL, NULL, 'PPO', 'N', 'N', 'l00468209', 50, 'FG', '1500', 'N', '标准', '正常生产', NULL, 'Y', NULL, NULL, '85443', to_timestamp('0001-01-01 12:15:11', 'YYYY-MM-DD HH24:MI:SS'), 'N', 'l00468209', to_timestamp('0001-01-01 12:14:32.573856', 'YYYY-MM-DD HH24:MI:SS.US'), '1127773644154404864', 1500, to_timestamp('0001-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), to_timestamp('0001-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), to_timestamp('0001-01-01 00:00:00', 'YYYY-MM [ERR] ERROR: duplicate key value violates unique constraint "tmas_t_ebc_prod_instr_pk" DETAIL: Key (epi_id)=(A0DEEB7053FC4D11884417D0D796352A) already exists. [ERR] INSERT INTO "tmas"."t_ebc_prod_instr" ("epi_id", "inv_organization_code", "prod_instr_no", "item_code", "item_name", "prod_model_code", "service_item_flag", "sku_number", "vendor_code", "mfg_site_code", "bom_version", "wip_class_code", "ppo_type_code", "order_category", "order_type", "inhouse_flag", "feed_mode", "bs_mode", "kit_relation_flag", "material_fullset_flag", "engineer_fullset_flag", "release_time", "plan_start_time", "plan_online_time", "plan_end_time", "actual_start_time", "actual_online_time", "actual_end_time", "bom_extact_time", "first_issue_date", "close_time", "cancel_time", "start_qty", "mrp_net_qty", "completed_qty", "scrapped_qty", "qty_uom", "completion_subinventory_name", "completion_locator_code", "released_by", "board_type", "routing", "routing_version", "factory_code", "eco", "eca", "inbound_complete_flag", "all_complete_flag", "open_qty", "write_off_reserved_qty", "net_supply_qty", "customer_bg_code", "auto_pr_flag", "ppo_status_code", "ppo_progress_code", "bs_po_number", "ppo_demand_number", "ppo_demand_plan_id", "manufacture_mode", "supply_mode", "prod_lifecycle", "supply_center_id", "supply_center_code", "demand_type_code", "source_bill_type", "source_bill_number", "original_bill_type", "original_bill_number", "prod_fulfillment", "prod_category", "responsible_department", "auto_routing_flag", "price_check_flag", "fullset_check_flag", "auto_bom_flag", "auto_inbound_flag", "allow_over_send_flag", "allow_over_recv_flag", "auto_schedule_flag", "bonded_flag", "oversea_flag", "manufacturer_category", "temporary_technology_flag", "verification_flag", "description", "log_msg", "version_number", "version_date", "created_by", "creation_date", "last_updated_by", "last_updated_date", "is_delete", "delete_by", "delete_date", "mfg_stage_type1", "mfg_stage_type2", "mfg_stage_type3", "data_from", "mixed_with_board_flag", "reference_flag", "plan_user", "no_used_qty", "item_class", "net_quantity", "bjitem_flag", "entity_type_name", "entity_subtype_name", "mfg_site_name", "is_model", "created_by_type", "source_service_name", "inventory_org_id", "hwip_release_time", "is_lock", "tmas_release_by", "tmas_release_time", "prod_instr_id", "start_qty_first", "plan_start_time_first", "workorder_plan_online_time", "workorder_plan_end_time", "po_writeoff_finished", "all_issue_flag", "revision_control_code", "eco_num") VALUES ('A0DEEB7053FC4D11884417D0D796352A', 'DG1', 'DPZHT5920MZ', '51098JNP-001', '智能手机-Lem-AL50C-LTE/WCDMA/GSM手机-USB线缆-内置锂离子电池*2/中式旅充*1-折叠-大溪地灰', 'Lem-AL50C', 'N', '51098JNP', '021356', '021356_T', NULL, 'T1ZZ', NULL, NULL, NULL, 'Y', 'CS', NULL, 'N', NULL, NULL, to_timestamp('0001-01-01 16:03:00', 'YYYY-MM-DD HH24:MI:SS'), to_timestamp('0001-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), to_timestamp('0001-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), to_timestamp('0001-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1000, 1000, 0, 0, 'PCS', NULL, NULL, 'c84372025', NULL, '950599630', NULL, 'JUXIN', NULL, NULL, NULL, NULL, 1000, 0, 1000, NULL, NULL, '2', '3', NULL, 'cPlan20250902S03V8', '20250902', 'EMS', 'STO', 'Develop', 'SZ', 'SCCN0002', '排产需求-标准', 'PPO-Require', 'cPlan20250902S03V8', NULL, '51098JNP-001021356_T2490661', NULL, NULL, NULL, NULL, NULL, NULL, 'Y', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '智能手机-Lem-AL50C-LTE/WCDMA/GSM手机-USB线缆-内置锂离子电池*2/中式旅充*1-折叠-大溪地灰', NULL, NULL, NULL, 'd00837601', to_timestamp('0001-01-01 21:12:00', 'YYYY-MM-DD HH24:MI:SS'), 'c84372025', to_timestamp('0001-01-01 15:11:00', 'YYYY-MM-DD HH24:MI:SS'), 0, NULL, NULL, '量产', NULL, NULL, 'PPO', 'N', 'N', 'c84372025', 1000, 'FG', '1000', 'N', '标准', '正常生产', NULL, 'Y', NULL, NULL, '85443', to_timestamp('0001-01-01 16:03:56', 'YYYY-MM-DD HH24:MI:SS'), 'N', 'c84372025', to_timestamp('0001-01-01 16:03:49.262737', 'YYYY-MM-DD HH24:MI:SS.US'), '1122845044082274304', 1000, to_timestamp('0001-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), to_timestamp('0001-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), to_timestamp('0001-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'N', 'N', '1', '[],[],[P_17202465;0 [ERR] ERROR: duplicate key value violates unique constraint "tmas_t_ebc_prod_instr_pk" DETAIL: Key (epi_id)=(4EF4E63DFC9348F092D9A5D28AC55A9F) already exists. [ERR] INSERT INTO "tmas"."t_ebc_prod_instr" ("epi_id", "inv_organization_code", "prod_instr_no", "item_code", "item_name", "prod_model_code", "service_item_flag", "sku_number", "vendor_code", "mfg_site_code", "bom_version", "wip_class_code", "ppo_type_code", "order_category", "order_type", "inhouse_flag", "feed_mode", "bs_mode", "kit_relation_flag", "material_fullset_flag", "engineer_fullset_flag", "release_time", "plan_start_time", "plan_online_time", "plan_end_time", "actual_start_time", "actual_online_time", "actual_end_time", "bom_extact_time", "first_issue_date", "close_time", "cancel_time", "start_qty", "mrp_net_qty", "completed_qty", "scrapped_qty", "qty_uom", "completion_subinventory_name", "completion_locator_code", "released_by", "board_type", "routing", "routing_version", "factory_code", "eco", "eca", "inbound_complete_flag", "all_complete_flag", "open_qty", "write_off_reserved_qty", "net_supply_qty", "customer_bg_code", "auto_pr_flag", "ppo_status_code", "ppo_progress_code", "bs_po_number", "ppo_demand_number", "ppo_demand_plan_id", "manufacture_mode", "supply_mode", "prod_lifecycle", "supply_center_id", "supply_center_code", "demand_type_code", "source_bill_type", "source_bill_number", "original_bill_type", "original_bill_number", "prod_fulfillment", "prod_category", "responsible_department", "auto_routing_flag", "price_check_flag", "fullset_check_flag", "auto_bom_flag", "auto_inbound_flag", "allow_over_send_flag", "allow_over_recv_flag", "auto_schedule_flag", "bonded_flag", "oversea_flag", "manufacturer_category", "temporary_technology_flag", "verification_flag", "description", "log_msg", "version_number", "version_date", "created_by", "creation_date", "last_updated_by", "last_updated_date", "is_delete", "delete_by", "delete_date", "mfg_stage_type1", "mfg_stage_type2", "mfg_stage_type3", "data_from", "mixed_with_board_flag", "reference_flag", "plan_user", "no_used_qty", "item_class", "net_quantity", "bjitem_flag", "entity_type_name", "entity_subtype_name", "mfg_site_name", "is_model", "created_by_type", "source_service_name", "inventory_org_id", "hwip_release_time", "is_lock", "tmas_release_by", "tmas_release_time", "prod_instr_id", "start_qty_first", "plan_start_time_first", "workorder_plan_online_time", "workorder_plan_end_time", "po_writeoff_finished", "all_issue_flag", "revision_control_code", "eco_num") VALUES ('4EF4E63DFC9348F092D9A5D28AC55A9F', 'DG1', 'DPZHT58E0GF', '51098EER-002', '智能手机-Icelan-AL10CS-LTE/WCDMA/GSM手机-USB线缆-内置锂离子电池*2/中式旅充*1-折叠-寰宇红', 'Icelan-AL10CS', 'N', '51098EER', '021356', '021356_T', NULL, 'T1ZZ', NULL, NULL, NULL, 'Y', 'CS', NULL, 'N', NULL, NULL, to_timestamp('0001-01-01 21:36:00', 'YYYY-MM-DD HH24:MI:SS'), to_timestamp('0001-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), to_timestamp('0001-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), to_timestamp('0001-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), NULL, NULL, to_timestamp('0001-01-01 22:30:00', 'YYYY-MM-DD HH24:MI:SS'), NULL, to_timestamp('0001-01-01 13:56:00', 'YYYY-MM-DD HH24:MI:SS'), to_timestamp('0001-01-01 23:31:01', 'YYYY-MM-DD HH24:MI:SS'), NULL, 1000, 1000, 1000, 0, 'PCS', NULL, NULL, 'h00544570', NULL, '500314573', NULL, 'JUXIN', NULL, NULL, NULL, NULL, 0, 0, 0, NULL, NULL, '4', '6', NULL, 'cPlan20250814S01WK', '20250814', 'EMS', 'STO', 'Develop', 'SZ', 'SCCN0002', '排产需求-标准', 'PPO-Require', 'cPlan20250814S01WK', NULL, '51098EER-002021356_T2430373', NULL, NULL, NULL, NULL, NULL, NULL, 'Y', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '智能手机-Icelan-AL10CS-LTE/WCDMA/GSM手机-USB线缆-内置锂离子电池*2/中式旅充*1-折叠-寰宇红', NULL, NULL, NULL, 'd00837601', to_timestamp('0001-01-01 17:52:00', 'YYYY-MM-DD HH24:MI:SS'), 'd00837601', to_timestamp('0001-01-01 23:31:00', 'YYYY-MM-DD HH24:MI:SS'), 0, NULL, NULL, '量产', NULL, NULL, 'PPO', 'N', 'N', 'h00544570', 0, 'FG', '1000', 'N', '标准', '正常生产', NULL, 'Y', NULL, NULL, '85443', to_timestamp('0001-01-01 21:36:16', 'YYYY-MM-DD HH24:MI:SS'), 'N', 'h00544570', to_timestamp('0001-01-01 21:36:00.014217', 'YYYY-MM-DD HH24:MI:SS.US'), '1115909347625631744', 1000, to_timestamp('0001-01-01 00:00:00', 'YYYY-MM-DD H [ERR] ERROR: duplicate key value violates unique constraint "tmas_t_ebc_prod_instr_pk" DETAIL: Key (epi_id)=(6B531483AA89488D99B0DCFFB92DFA65) already exists. [ERR] INSERT INTO "tmas"."t_ebc_prod_instr" ("epi_id", "inv_organization_code", "prod_instr_no", "item_code", "item_name", "prod_model_code", "service_item_flag", "sku_number", "vendor_code", "mfg_site_code", "bom_version", "wip_class_code", "ppo_type_code", "order_category", "order_type", "inhouse_flag", "feed_mode", "bs_mode", "kit_relation_flag", "material_fullset_flag", "engineer_fullset_flag", "release_time", "plan_start_time", "plan_online_time", "plan_end_time", "actual_start_time", "actual_online_time", "actual_end_time", "bom_extact_time", "first_issue_date", "close_time", "cancel_time", "start_qty", "mrp_net_qty", "completed_qty", "scrapped_qty", "qty_uom", "completion_subinventory_name", "completion_locator_code", "released_by", "board_type", "routing", "routing_version", "factory_code", "eco", "eca", "inbound_complete_flag", "all_complete_flag", "open_qty", "write_off_reserved_qty", "net_supply_qty", "customer_bg_code", "auto_pr_flag", "ppo_status_code", "ppo_progress_code", "bs_po_number", "ppo_demand_number", "ppo_demand_plan_id", "manufacture_mode", "supply_mode", "prod_lifecycle", "supply_center_id", "supply_center_code", "demand_type_code", "source_bill_type", "source_bill_number", "original_bill_type", "original_bill_number", "prod_fulfillment", "prod_category", "responsible_department", "auto_routing_flag", "price_check_flag", "fullset_check_flag", "auto_bom_flag", "auto_inbound_flag", "allow_over_send_flag", "allow_over_recv_flag", "auto_schedule_flag", "bonded_flag", "oversea_flag", "manufacturer_category", "temporary_technology_flag", "verification_flag", "description", "log_msg", "version_number", "version_date", "created_by", "creation_date", "last_updated_by", "last_updated_date", "is_delete", "delete_by", "delete_date", "mfg_stage_type1", "mfg_stage_type2", "mfg_stage_type3", "data_from", "mixed_with_board_flag", "reference_flag", "plan_user", "no_used_qty", "item_class", "net_quantity", "bjitem_flag", "entity_type_name", "entity_subtype_name", "mfg_site_name", "is_model", "created_by_type", "source_service_name", "inventory_org_id", "hwip_release_time", "is_lock", "tmas_release_by", "tmas_release_time", "prod_instr_id", "start_qty_first", "plan_start_time_first", "workorder_plan_online_time", "workorder_plan_end_time", "po_writeoff_finished", "all_issue_flag", "revision_control_code", "eco_num") VALUES ('6B531483AA89488D99B0DCFFB92DFA65', 'DG1', 'DPZHT58U046', '51098FKK-005', '智能手机-Verde-AL00C-LTE/WCDMA/GSM手机-USB线缆-内置锂离子电池*2/中式旅充*1-折叠-幻夜黑', 'Verde-AL00C', 'N', '51098FKK', '021356', '021356_T', NULL, 'T1ZZ', NULL, NULL, NULL, 'Y', 'CS', NULL, 'N', NULL, NULL, to_timestamp('0001-01-01 18:00:00', 'YYYY-MM-DD HH24:MI:SS'), to_timestamp('0001-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), to_timestamp('0001-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), to_timestamp('0001-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), NULL, NULL, to_timestamp('0001-01-01 10:45:00', 'YYYY-MM-DD HH24:MI:SS'), NULL, to_timestamp('0001-01-01 22:36:00', 'YYYY-MM-DD HH24:MI:SS'), to_timestamp('0001-01-01 12:02:18', 'YYYY-MM-DD HH24:MI:SS'), NULL, 1001, 1000, 1001, 0, 'PCS', NULL, NULL, 'l00638209', NULL, '950597229', NULL, 'JUXIN', NULL, NULL, NULL, NULL, 0, 0, 0, NULL, NULL, '4', '6', NULL, 'cPlan20250827S0218', '20250827', 'EMS', 'STO', 'Develop', 'SZ', 'SCCN0002', '排产需求-标准', 'PPO-Require', 'cPlan20250827S0218', NULL, '51098FKK-005021356_T2471560', NULL, NULL, NULL, NULL, NULL, NULL, 'Y', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '智能手机-Verde-AL00C-LTE/WCDMA/GSM手机-USB线缆-内置锂离子电池*2/中式旅充*1-折叠-幻夜黑', NULL, NULL, NULL, 'x00920590', to_timestamp('0001-01-01 17:30:00', 'YYYY-MM-DD HH24:MI:SS'), 'l00638209', to_timestamp('0001-01-01 12:02:00', 'YYYY-MM-DD HH24:MI:SS'), 0, NULL, NULL, '量产', NULL, NULL, 'PPO', 'N', 'N', 'l00638209', 0, 'FG', '1000', 'N', '标准', '正常生产', NULL, 'Y', NULL, NULL, '85443', to_timestamp('0001-01-01 18:00:28', 'YYYY-MM-DD HH24:MI:SS'), 'N', 'l00638209', to_timestamp('0001-01-01 18:00:17.808084', 'YYYY-MM-DD HH24:MI:SS.US'), '1120614989751361536', 1001, to_timestamp('0001-01-01 00:00:00', 'YYYY-MM-DD HH24:MI [IMP] Processed: 1000, Added: 0, Updated: 0, Deleted: 0, Errors: 1000 [IMP] Finished with error
09-30
function [schedule_table, best_metrics] = GA_schedule(orders_df, production_lines_df) %% === 初始化 Python 库 === obj = py.importlib.import_module('bj'); py.importlib.reload(obj); %% === 从 Python 获取数据 === orders_df = py.bj.fetch_orders(); production_lines_df = py.bj.fetch_production_lines(); %% === 安全转换函数 === to_double = @(x) cellfun(@(v) double(py.float(v)), cell(py.list(x)), 'UniformOutput', false); to_str = @(x) cellfun(@char, cell(py.list(x)), 'UniformOutput', false); % 订单数据处理 order_ids = to_double(py.getattr(orders_df, 'ORDER_ID'));disp(order_ids); order_dates = datetime(to_str(py.getattr(orders_df, 'ORDER_DATE')));disp(order_dates); due_dates = datetime(to_str(py.getattr(orders_df, 'DUE_DATE')));disp(due_dates); product_ids = to_double(py.getattr(orders_df, 'PRODUCT_ID'));disp(product_ids); product_names = to_str(py.getattr(orders_df, 'PRODUCT_NAME'));disp(product_names); product_spec = to_str(py.getattr(orders_df, 'SPECIFICATION_INFO'));disp(product_spec); order_quantities = to_double(py.getattr(orders_df, 'ORDER_QUANTITY'));disp(order_quantities); outstanding_quantities = to_double(py.getattr(orders_df, 'OUTSTANDING_QUANTITY'));disp(outstanding_quantities); % 产线数据处理 line_names = to_str(py.getattr(production_lines_df, 'LINE_NAME'));disp(line_names); line_ids = to_double(py.getattr(production_lines_df, 'LINE_ID'));disp(line_ids); line_rates = to_double(py.getattr(production_lines_df, 'LINE_RATE'));disp(line_rates); yield_rates = to_double(py.getattr(production_lines_df, 'YIELD_RATE'));disp(yield_rates); status = to_str(py.getattr(production_lines_df, 'STATUS'));disp(status); production_ids = to_double(py.getattr(production_lines_df, 'PRODUCT_ID'));disp(production_ids); % 构建订单个体结构体 num_orders = length(order_ids); orders = struct([]); for i = 1:num_orders orders(i).OrderID = order_ids{i}; orders(i).OrderDate = order_dates(i); orders(i).DueDate = due_dates(i); orders(i).ProductID = product_ids{i}; orders(i).ProductName = product_names{i}; orders(i).Specification = product_spec{i}; orders(i).OrderQuantity = order_quantities{i}; orders(i).OutstandingQuantity = outstanding_quantities{i}; end for i = 1:num_orders disp(orders(i)) end % 构建产线个体结构体 num_lines = length(line_ids); productions = struct([]); for j = 1:num_lines productions(j).LineID = line_ids{j}; productions(j).LineName = line_names{j}; productions(j).LineRate = line_rates{j}; productions(j).YieldRate = yield_rates{j} / 100; productions(j).Status = status{j}; productions(j).ProductID = production_ids{j}; end for j = 1:num_lines disp(productions(j)) end %% === GA 整体排程(修正版:以订单时间为基准,用 datetime('now')) === % ---------- GA 参数(可调) ---------- ga_params.pop_size = 60; ga_params.max_gen = 200; ga_params.crossover_rate = 0.8; ga_params.mutation_rate = 0.25; ga_params.tournament_k = 3; num_orders = length(orders); num_lines = length(productions); % ---------- 基线时间(以所有订单最早订单日期为起点) ---------- all_order_dates = [orders.OrderDate]; baseline_start = min(all_order_dates); % ---------- 兼容产线(考虑产品匹配 + 状态) ---------- compatible_lines = cell(num_orders,1); for i = 1:num_orders pid = orders(i).ProductID; idxs = []; for j = 1:num_lines if isequal(productions(j).ProductID, pid) && strcmpi(productions(j).Status,'正常') idxs(end+1) = j; end end compatible_lines{i} = idxs; end % ---------- 计算加工所需时间(返回 duration) ---------- calc_proc_duration = @(qty, rate, yield) hours(qty ./ (rate .* yield)); % ---------- simulate_schedule: 给定序列 seq 与分配 assign,模拟排程并返回 schedule 与 metrics ---------- function [schedule, metrics] = simulate_schedule(orders, productions, seq, assign, compatible_lines, calc_proc_duration, baseline_start) num_orders_local = length(seq); line_available = repmat(baseline_start, length(productions), 1); schedule = repmat(struct(), num_orders_local, 1); total_late_hours = 0; latest_finish = baseline_start; penalty_unassigned = 0; for k = 1:num_orders_local i = seq(k); schedule(k).Seq = k; schedule(k).OrderID = orders(i).OrderID; schedule(k).OrderDate = orders(i).OrderDate; schedule(k).DueDate = orders(i).DueDate; schedule(k).ProductID = orders(i).ProductID; schedule(k).ProductName = orders(i).ProductName; schedule(k).Specification = orders(i).Specification; schedule(k).OrderQuantity = orders(i).OrderQuantity; schedule(k).OutstandingQuantity = orders(i).OutstandingQuantity; assigned_line = assign(i); if isnan(assigned_line) || isempty(assigned_line) schedule(k).AssignedLineID = NaN; schedule(k).AssignedLineName = ''; schedule(k).StartTime = NaT; schedule(k).EndTime = NaT; schedule(k).ProcDuration = duration(0,0,0); penalty_unassigned = penalty_unassigned + 1e6; continue; end if ~ismember(assigned_line, compatible_lines{i}) schedule(k).AssignedLineID = productions(assigned_line).LineID; schedule(k).AssignedLineName = productions(assigned_line).LineName; schedule(k).StartTime = NaT; schedule(k).EndTime = NaT; schedule(k).ProcDuration = duration(0,0,0); penalty_unassigned = penalty_unassigned + 1e5; continue; end qty = double(orders(i).OutstandingQuantity); rate = double(productions(assigned_line).LineRate); yld = double(productions(assigned_line).YieldRate); if rate <= 0 || yld <= 0 proc_dur = hours(1e6); else proc_dur = calc_proc_duration(qty, rate, yld); end est_start = max(line_available(assigned_line), orders(i).OrderDate); est_end = est_start + proc_dur; line_available(assigned_line) = est_end; schedule(k).AssignedLineID = productions(assigned_line).LineID; schedule(k).AssignedLineName = productions(assigned_line).LineName; schedule(k).StartTime = est_start; schedule(k).EndTime = est_end; schedule(k).ProcDuration = proc_dur; late_h = max(0, hours(est_end - orders(i).DueDate)); total_late_hours = total_late_hours + late_h; if est_end > latest_finish latest_finish = est_end; end end metrics.total_late_hours = total_late_hours; metrics.latest_finish = latest_finish; metrics.penalty_unassigned = penalty_unassigned; end % ---------- 初始化种群 ---------- population = repmat(struct('seq', [], 'assign', [], 'fitness', []), ga_params.pop_size, 1); for p = 1:ga_params.pop_size seq = double(randperm(num_orders)); assign = nan(num_orders,1); for i = 1:num_orders cl = compatible_lines{i}; if ~isempty(cl) assign(i) = double(cl(randi(length(cl)))); else assign(i) = NaN; end end assign = double(assign); seq = double(seq); population(p).seq = seq; population(p).assign = assign; [~, metrics] = simulate_schedule(orders, productions, seq, assign, compatible_lines, calc_proc_duration, baseline_start); finish_hours = hours(metrics.latest_finish - baseline_start); population(p).fitness = metrics.total_late_hours + 0.0001*finish_hours + metrics.penalty_unassigned; end % ---------- GA 主循环(修复 assign 报错) ---------- best_history = nan(ga_params.max_gen,1); for gen = 1:ga_params.max_gen newpop = population; [~, idxs_pop] = sort([population.fitness]); newpop(1) = population(idxs_pop(1)); for slot = 2:ga_params.pop_size p1 = tournament_select(population, ga_params.tournament_k); p2 = tournament_select(population, ga_params.tournament_k); p1.seq = double(p1.seq); p1.assign = double(p1.assign); p2.seq = double(p2.seq); p2.assign = double(p2.assign); child = p1; if rand < ga_params.crossover_rate child.seq = order_crossover(p1.seq, p2.seq); child.assign = assign_crossover(p1.assign, p2.assign); end if rand < ga_params.mutation_rate child.seq = swap_mutation(child.seq); end if rand < ga_params.mutation_rate child.assign = assignment_mutation(child.assign, compatible_lines); end [~, metrics] = simulate_schedule(orders, productions, child.seq, child.assign, compatible_lines, calc_proc_duration, baseline_start); finish_hours = hours(metrics.latest_finish - baseline_start); child.fitness = metrics.total_late_hours + 0.0001*finish_hours + metrics.penalty_unassigned; newpop(slot) = child; end population = newpop; best_history(gen) = min([population.fitness]); end % ---------- 最优解与展示 ---------- [~, idxs] = sort([population.fitness]); best_ind = population(idxs(1)); [best_schedule, best_metrics] = simulate_schedule(orders, productions, best_ind.seq, best_ind.assign, compatible_lines, calc_proc_duration, baseline_start); n = length(best_schedule); Seq = zeros(n,1); OrderID = zeros(n,1); OrderDate = NaT(n,1); DueDate = NaT(n,1); ProductID = zeros(n,1); ProductName = strings(n,1); Specification = strings(n,1); OrderQuantity = zeros(n,1); OutstandingQuantity = zeros(n,1); AssignedLineID = zeros(n,1); AssignedLineName = strings(n,1); StartTime = NaT(n,1); EndTime = NaT(n,1); ProcDuration = duration(zeros(n,1),0,0); for k = 1:n s = best_schedule(k); Seq(k) = s.Seq; OrderID(k) = s.OrderID; OrderDate(k) = s.OrderDate; DueDate(k) = s.DueDate; ProductID(k) = s.ProductID; ProductName(k) = string(s.ProductName); Specification(k) = string(s.Specification); OrderQuantity(k) = s.OrderQuantity; OutstandingQuantity(k) = s.OutstandingQuantity; AssignedLineID(k) = s.AssignedLineID; AssignedLineName(k) = string(s.AssignedLineName); StartTime(k) = s.StartTime; EndTime(k) = s.EndTime; ProcDuration(k) = s.ProcDuration; end for k = 1:n if isnan(AssignedLineID(k)) || AssignedLineID(k) == 0 AssignedLineID(k) = -1; AssignedLineName(k) = "待确认"; StartTime(k) = NaT; EndTime(k) = NaT; ProcDuration(k) = duration(0,0,0); end end valid_idx = ~isnat(StartTime); invalid_idx = isnat(StartTime); [~, sort_idx_valid] = sort(StartTime(valid_idx)); [~, sort_idx_invalid] = sort(OrderDate(invalid_idx)); valid_indices = find(valid_idx); invalid_indices = find(invalid_idx); final_idx = [valid_indices(sort_idx_valid); invalid_indices(sort_idx_invalid)]; Seq = (1:n)'; OrderID = OrderID(final_idx); OrderDate = OrderDate(final_idx); DueDate = DueDate(final_idx); ProductID = ProductID(final_idx); ProductName = ProductName(final_idx); Specification = Specification(final_idx); OrderQuantity = OrderQuantity(final_idx); OutstandingQuantity = OutstandingQuantity(final_idx); AssignedLineID = AssignedLineID(final_idx); AssignedLineName = AssignedLineName(final_idx); StartTime = StartTime(final_idx); EndTime = EndTime(final_idx); ProcDuration = ProcDuration(final_idx); schedule_table = table(Seq, OrderID, OrderDate, DueDate, ProductID, ProductName, ... Specification, OrderQuantity, OutstandingQuantity, AssignedLineID, ... AssignedLineName, StartTime, EndTime, ProcDuration); schedule_table.StartTime.Format = 'yyyy-MM-dd HH:mm:ss'; schedule_table.EndTime.Format = 'yyyy-MM-dd HH:mm:ss'; schedule_table.OrderDate.Format = 'yyyy-MM-dd HH:mm:ss'; schedule_table.DueDate.Format = 'yyyy-MM-dd HH:mm:ss'; disp("=== ✅ 排程结果(按开始时间排序) ==="); disp(schedule_table); disp('=== 排产指标 ==='); disp(best_metrics); %% ---------- 复用辅助函数 ---------- function p = tournament_select(pop, k) n = numel(pop); idx = randi(n, [k,1]); [~, bestidx] = min([pop(idx).fitness]); p = pop(idx(bestidx)); end function child_seq = order_crossover(a, b) n = length(a); p1 = sort(randi(n, [1,2])); seg = a(p1(1):p1(2)); rest = b(~ismember(b, seg)); child_seq = [rest(1:p1(1)-1), seg, rest(p1(1):end)]; end function child_assign = assign_crossover(a, b) a = double(a); b = double(b); n = length(a); cp = randi(n-1); child_assign = [a(1:cp); b(cp+1:end)]; end function s = swap_mutation(seq) n = length(seq); i = randi(n); j = randi(n); tmp = seq(i); seq(i) = seq(j); seq(j) = tmp; s = seq; end function asg = assignment_mutation(asg, compatible_lines) asg = double(asg); n = length(asg); i = randi(n); cl = compatible_lines{i}; if ~isempty(cl) asg(i) = double(cl(randi(length(cl)))); else asg(i) = NaN; end end end 我这段matlab代码报错:此类型的变量支持使用点进行索引。 出错 GA_schedule (第 213 行) child.assign = assign_crossover(p1.assign, p2.assign); ^^^^^^^^^ >> 是为什么?要怎么解决
10-29
【无人机】基于改进粒子群算法的无人机路径规划研究[和遗传算法、粒子群算法进行比较](Matlab代码实现)内容概要:本文围绕基于改进粒子群算法的无人机路径规划展开研究,重点探讨了在复杂环境中利用改进粒子群算法(PSO)实现无人机三维路径规划的方法,并将其与遗传算法(GA)、标准粒子群算法等传统优化算法进行对比分析。研究内容涵盖路径规划的多目标优化、避障策略、航路点约束以及算法收敛性和寻优能力的评估,所有实验均通过Matlab代码实现,提供了完整的仿真验证流程。文章还提到了多种智能优化算法在无人机路径规划中的应用比较,突出了改进PSO在收敛速度和全局寻优方面的优势。; 适合人群:具备一定Matlab编程基础和优化算法知识的研究生、科研人员及从事无人机路径规划、智能优化算法研究的相关技术人员。; 使用场景及目标:①用于无人机在复杂地形或动态环境下的三维路径规划仿真研究;②比较同智能优化算法(如PSO、GA、蚁群算法、RRT等)在路径规划中的性能差异;③为多目标优化问题提供算法选型和改进思路。; 阅读建议:建议读者结合文中提供的Matlab代码进行实践操作,重点关注算法的参数设置、适应度函数设计及路径约束处理方式,同时可参考文中提到的多种算法对比思路,拓展到其他智能优化算法的研究与改进中。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值