当前位置: 首页 > news >正文

一种寻路的应用

应用背景

利用长途车进行货物转运的寻路计算。例如从深圳到大连。可以走有很多条长途车的路线。需要根据需求计算出最合适路线。不同的路线的总里程数、总价、需要的时间不一样。客户根据需求进行选择。主要有一些细节:

  1. 全国的长途车车站的数据的更新:

  2. 包括位置、发车班次时间点、车站间的里程数等等。常用的路线有18000多条 


重庆    重庆    重庆万盛客运中心    308    遵义    遵义市长途汽车站
重庆    重庆    重庆万盛客运中心    360    成都    成都北门汽车站
重庆    重庆    重庆渝中长途汽车站    157    武胜    武胜汽车站
重庆    重庆    重庆渝中长途汽车站    340    遵义    遵义市长途汽车站
重庆    重庆    重庆渝中长途汽车站    360    成都    成都北门汽车站
重庆    重庆    重庆渝中长途汽车站    467    巴中    巴中江北客运中心站
重庆    重庆    重庆渝中长途汽车站    502    广元    广元市长途汽车客运站 

  1. 同城转车的处理

  2. 有些城市有多个车站,可以在一个城市里转到另外一个车站,再转运到下一站

  3. 使用发车班次时间表进行总时长的计算

  4. 预留出合理的时间间隔。例如到达某一站是20:30,但是到下一站的车 最晚一班是15:00 点发车。所以只能等第2天的班车。还有的班次可能一周只有2趟车。 有时 到达某一站是15:00  下一站的发车时间也是15:00 这种就只能等下一班,因为赶不上。

代码实现

初始化

班车路线、城市、车站等

constructor TR_Manager.Create;
begin_result_path := Tlist<TR_Path>.Create;_Dict_Province := TDictionary<Integer, TProvince>.Create();_Dict_City := TDictionary<Integer, TCity>.Create();_Dict_City_Name := TDictionary<string, TCity>.Create();_ProvinceList := Tlist<TProvince>.Create();_StationList := Tlist<TStation>.Create();_Dict_Station := TDictionary<string, TStation>.Create();_StationPathList := Tlist<TStation_Path>.Create();_Dict_CityID_Station := TDictionary < Integer, Tlist < TStation >>.Create();_Dict_CityID_Xian_Station := TDictionary < Integer, TDictionary < string,Tlist<TStation> >>.Create(); // hfg 2016-07-23_StationPathNodeList := Tlist<TStation_Path_Node>.Create();_Dict_Station_Path_Node := TDictionary<TStation, TStation_Path_Node>.Create();_Dict_CityID_Path_Node := TDictionary < Integer, Tlist < TStation_Path_Node>>.Create();_Node_Tmp := Tlist<TStation_Path_Node>.Create();_Node_Tmp_2 := Tlist<TStation_Path_Node>.Create();_Node_Tmp_before_end := Tlist<TStation_Path_Node>.Create();
end;

寻路

StationName_Begin: 起点车站

Station_End: 终点车站

max_step: Integer = 6; 最大转车次数

allow_same_city: boolean = false 是否允许同城转运

function TR_Manager.get_path_quick(StationName_Begin: string;Station_End: Tlist<TStation>; max_step: Integer = 6;allow_same_city: boolean = false): boolean;
varStation: TStation;node_root, node, node_next: TStation_Path_Node;i, k, step, Node_Tmp_Count, Node_Tmp_2_Count,Node_Tmp_before_end_count: Integer;path: TR_Path;list: Tlist;city_station_list: Tlist<TStation_Path_Node>;
beginResult := false;clear_result_path();if Station_End = nil thenexit;if Station_End.Count <= 0 thenexit;if not(_Dict_Station.TryGetValue(StationName_begin, Station)) thenexit;if Station.CityID = Station_End[0].CityID thenbeginpath := TR_Path.Create;path.Mileage := 0;path.step := 1;path.StationList.Add(Station);for i := 0 to Station_End.Count - 1 dobeginif Station_End[i].Name <> Station.Name thenbeginpath.StationList.Add(Station_End[i]);Break;end;end;if path.StationList.Count < 2 thenpath.StationList.Add(Station);_result_path.Add(path);end;if not(_Dict_Station_Path_Node.TryGetValue(Station, node_root)) thenexit;for i := 0 to _StationPathNodeList.Count - 1 do_StationPathNodeList[i].reset();node_root.set_Step(0);_Node_Tmp[0] := node_root;Node_Tmp_Count := 1;Node_Tmp_before_end_count := 0;for i := 0 to Station_End.Count - 1 dobeginif _Dict_Station_Path_Node.TryGetValue(Station_End[i], node) thennode.set_is_before_end();end;for step := 1 to max_step dobeginNode_Tmp_2_Count := 0;for i := 0 to Node_Tmp_Count - 1 dobegintrynode := _Node_Tmp[i];if (node.is_before_end) thenbegin_Node_Tmp_before_end[Node_Tmp_before_end_count] := node;inc(Node_Tmp_before_end_count);if step > 1 thenContinue;end;for k := 0 to node.Next_Station.Count - 1 dobeginnode_next := node.Next_Station[k].Station_Node_Next;if node_next.is_end thenContinue;if not node_next.is_on_path thenbeginnode_next.path_mileage := node.path_mileage + node.Next_Station[k].Mileage;node_next.Path_Prior_Station := node;node_next.set_Step(step);if Node_Tmp_2_Count < _Node_Tmp_2.Count then_Node_Tmp_2[Node_Tmp_2_Count] := node_nextelse_Node_Tmp_2.Add(node_next);inc(Node_Tmp_2_Count);endelsebeginif (node_next.step = step) and (step > 1) thenbeginif node.path_mileage + node.Next_Station[k].Mileage < node_next.path_mileagethenbeginnode_next.path_mileage := node.path_mileage + node.Next_Station[k].Mileage;node_next.Path_Prior_Station := node;end;end;end;end;if allow_same_city thenbeginif _Dict_CityID_Path_Node.TryGetValue(node.Station.CityID,city_station_list) thenbeginfor k := 0 to city_station_list.Count - 1 dobeginnode_next := city_station_list[k];if node_next.is_end thenContinue;if not node_next.is_on_path thenbeginnode_next.path_mileage := node.path_mileage + 0;node_next.Path_Prior_Station := node;node_next.set_Step(step);if Node_Tmp_2_Count < _Node_Tmp_2.Count then_Node_Tmp_2[Node_Tmp_2_Count] := node_nextelse_Node_Tmp_2.Add(node_next);inc(Node_Tmp_2_Count);end;end;end;end;exceptNode_Tmp_2_Count := Node_Tmp_2_Count - 1;end;end;Node_Tmp_Count := 0;for i := 0 to Node_Tmp_2_Count - 1 dobeginif _Node_Tmp_2[i].is_on_path thenbeginif True thenif Node_Tmp_Count < _Node_Tmp.Count then_Node_Tmp[Node_Tmp_Count] := _Node_Tmp_2[i]else_Node_Tmp.Add(_Node_Tmp_2[i]);inc(Node_Tmp_Count);end;end;end;list := Tlist.Create();for i := 0 to Node_Tmp_before_end_count - 1 dobeginpath := TR_Path.Create;node := _Node_Tmp_before_end[i];path.Mileage := node.path_mileage + node.to_end_mileage;path.StationList.Add(node.end_Node.Station);path.StationList.Add(node.Station);node_next := node.Path_Prior_Station;for step := 1 to max_step + 1 dobeginif node_next = nil thenBreak;path.StationList.Add(node_next.Station);if node_next.step <= 0 thenBreak;node_next := node_next.Path_Prior_Stationend;path.StationList.Reverse();list.Add(path);end;list.Sort(@ComparePath_city);for i := 0 to list.Count - 1 do_result_path.Add(list[i]);FreeAndNil(list);Result := _result_path.Count > 0;
end;

操作说明

1、登陆时选择“宝安汽车站”

  1. 发布一条到北京的信息

  1. 在“深圳”里可以看到刚增加的信息

  1. 切换到“湖北武汉”,也可以看到这条信息

  1. 切换到“湖北武汉”,也可以看到这条信息

全部代码

unit U_city_manager;interfaceusesSystem.SysUtils, System.Types, System.Classes, Generics.Collections;typeTCounty = classprivate_Name: string;_CityID: Integer;publicconstructor Create;destructor Destroy; override;property Name: string read _Name write _Name;property CityID: Integer read _CityID write _CityID;end;TProvince = class;TCity = classprivate_ID: Integer;_Name: string;_Code: Integer;_TelCode: Integer;_CountyList: Tlist<TCounty>;Province: TProvince;procedure clear_CountyList();publicconstructor Create;destructor Destroy; override;property CountyList: Tlist<TCounty> read _CountyList;property ID: Integer read _ID write _ID;property Name: string read _Name write _Name;property Code: Integer read _Code write _Code;property TelCode: Integer read _TelCode write _TelCode;end;TProvince = classprivate_ID: Integer;_Name: string;_CardCode: string;_CityList: Tlist<TCity>;procedure clear_CityList();publicconstructor Create;destructor Destroy; override;property CityList: Tlist<TCity> read _CityList;property ID: Integer read _ID write _ID;property Name: string read _Name write _Name;property CardCode: string read _CardCode write _CardCode;end;TStation = classprivate_ProvinceName: string;_CityID: Integer;_CityName: string;_Name: string;_xian: string; // hfg 2016-07-23_address_id: Integer;publicconstructor Create;destructor Destroy; override;property ProvinceName: string read _ProvinceName write _ProvinceName;property CityID: Integer read _CityID write _CityID;property CityName: string read _CityName write _CityName;property Name: string read _Name write _Name;property xian: string read _xian write _xian; // hfg 2016-07-23property address_id: Integer read _address_id write _address_id;end;TStation_Path = classprivate_Station_Begin: TStation;_Station_End: TStation;_Mileage: Integer;publicconstructor Create;destructor Destroy; override;property Station_Begin: TStation read _Station_Begin write _Station_Begin;property Station_End: TStation read _Station_End write _Station_End;property Mileage: Integer read _Mileage write _Mileage;end;TStation_Path_Node = class;TStation_Next = classprivate_Station_Node_Next: TStation_Path_Node;_Mileage: Integer;publicconstructor Create;destructor Destroy; override;property Station_Node_Next: TStation_Path_Node read _Station_Node_Nextwrite _Station_Node_Next;property Mileage: Integer read _Mileage write _Mileage;end;TStation_Path_Node = classprivate_Station: TStation;_Next_Station: Tlist<TStation_Next>;_Prior_Station: Tlist<TStation_Next>;_is_on_path: boolean;_is_end: boolean;_step: Integer;_Path_Prior_Station: TStation_Path_Node;_path_mileage: Integer;_is_before_end: boolean;_end_Node: TStation_Path_Node;_to_end_mileage: Integer;procedure clear_Next_Station();procedure clear_Prior_Station();publicconstructor Create;destructor Destroy; override;procedure add_next(next_node: TStation_Path_Node; Mileage: Integer);procedure add_Prior(p_node: TStation_Path_Node; Mileage: Integer);property Station: TStation read _Station write _Station;property Next_Station: Tlist<TStation_Next> read _Next_Stationwrite _Next_Station;property is_on_path: boolean read _is_on_path;property is_end: boolean read _is_end;property step: Integer read _step;property path_mileage: Integer read _path_mileage write _path_mileage;property Path_Prior_Station: TStation_Path_Node read _Path_Prior_Stationwrite _Path_Prior_Station;property is_before_end: boolean read _is_before_end;property to_end_mileage: Integer read _to_end_mileage write _to_end_mileage;property end_Node: TStation_Path_Node read _end_Node;procedure reset();procedure set_Step(v: Integer);procedure set_is_before_end();end;TR_Path = classpublicstep: Integer;Mileage: Integer;StationList: Tlist<TStation>;publicconstructor Create;destructor Destroy; override;function get_txt(): string;function get_txt_with_city(): string;end;TR_Manager = classprivate_ProvinceList: Tlist<TProvince>;_Dict_Province: TDictionary<Integer, TProvince>;_Dict_City: TDictionary<Integer, TCity>;_Dict_City_Name: TDictionary<string, TCity>;_StationList: Tlist<TStation>;_Dict_Station: TDictionary<string, TStation>;_Dict_CityID_Station: TDictionary<Integer, Tlist<TStation>>;_Dict_CityID_Xian_Station: TDictionary<Integer, TDictionary<string, Tlist<TStation>>>;// hfg 2016-07-23_StationPathList: Tlist<TStation_Path>;_StationPathNodeList: Tlist<TStation_Path_Node>;_Dict_Station_Path_Node: TDictionary<TStation, TStation_Path_Node>;_Dict_CityID_Path_Node: TDictionary<Integer, Tlist<TStation_Path_Node>>;_Node_Tmp: Tlist<TStation_Path_Node>;_Node_Tmp_2: Tlist<TStation_Path_Node>;_Node_Tmp_before_end: Tlist<TStation_Path_Node>;_result_path: Tlist<TR_Path>;procedure clear_result_path();procedure clear_ProvinceList();procedure clear_StationList();procedure clear_StationPathList();procedure clear_StationPathNodeList();procedure clear_Dict_CityID_Xian_Station(); // hfg 2016-07-23procedure make_StationPathNodeList();publicconstructor Create;destructor Destroy; override;property ProvinceList: Tlist<TProvince> read _ProvinceList;property result_path: Tlist<TR_Path> read _result_path;procedure load_Province(fn: string);procedure load_Province_sl(sl: TStringList);procedure load_City(fn: string);procedure load_City_sl(sl: TStringList);procedure load_County(fn: string);procedure load_Path(fn: string);procedure load_Path_new(fn: string);procedure load_Path_new_sl(sl: TStringList); // 2016-10-03procedure load_xian(fn: string); // hfg 2016-07-23function get_Province_by_id(ID: Integer): TProvince;function get_City_by_id(ID: Integer): TCity;function get_City_by_name(ProvinceName, city_name: string): TCity;function get_City_by_full_name(full_city_name: string): TCity;function get_or_add_Station(ProvinceName, CityName, Name: string): TStation;function get_or_add_Station_new(city_id, Name, xian: string): TStation;procedure get_station_by_city_id(city_id: Integer;var list: Tlist<TStation>);procedure get_station_by_city_id_xian(city_id: Integer; xian: string;var list: Tlist<TStation>); // hfg 2016-07-23function get_path_quick(StationName_begin: string;Station_End: Tlist<TStation>; max_step: Integer = 6;allow_same_city: boolean = false): boolean;function get_path_quick_ex(Station_Begin: Tlist<TStation>;Station_End: Tlist<TStation>; max_step: Integer = 6;allow_same_city: boolean = false): boolean; // 2016-10-01function get_StationList: Tlist<TStation>;procedure save_Station(fn: string);property StationPathList: Tlist<TStation_Path> read _StationPathList;end;implementationuses u_address_def;function get_Province_ID_from_City_Code(v: Integer): Integer;
beginResult := v div 100;
end;function ComparePath_city(Item1, Item2: TR_Path): Integer;
beginResult := Item1.StationList.Count - Item2.StationList.Count;if Result = 0 thenResult := Item1.Mileage - Item2.Mileage;end;{ TR_Manager }
procedure TR_Manager.clear_Dict_CityID_Xian_Station; // hfg 2016-07-23
varpair: TPair<Integer, TDictionary<string, Tlist<TStation>>>;pair2: TPair<string, Tlist<TStation>>;
beginfor pair in _Dict_CityID_Xian_Station dobeginfor pair2 in pair.Value dobeginpair2.Value.Freeend;pair.Value.Free;end;_Dict_CityID_Xian_Station.Clear();
end;procedure TR_Manager.clear_ProvinceList;
vari: Integer;
beginfor i := 0 to _ProvinceList.Count - 1 do_ProvinceList[i].Free;_ProvinceList.Clear();_Dict_Province.Clear();_Dict_City.Clear();_Dict_City_Name.Clear();
end;procedure TR_Manager.clear_result_path;
vari: Integer;
beginfor i := 0 to _result_path.Count - 1 do_result_path[i].Free;_result_path.Clear();
end;procedure TR_Manager.clear_StationList;
vari: Integer;pair: TPair<Integer, Tlist<TStation>>;
begin_Dict_Station.Clear();for i := 0 to _StationList.Count - 1 do_StationList[i].Free;_StationList.Clear();for pair in _Dict_CityID_Station dobeginpair.Value.Free;end;_Dict_CityID_Station.Clear();
end;procedure TR_Manager.clear_StationPathList;
vari: Integer;
beginfor i := 0 to _StationPathList.Count - 1 do_StationPathList[i].Free;_StationPathList.Clear();
end;procedure TR_Manager.clear_StationPathNodeList;
vari: Integer;pair: TPair<Integer, Tlist<TStation_Path_Node>>;
begin_Dict_Station_Path_Node.Clear();for pair in _Dict_CityID_Path_Node dobeginpair.Value.Free;end;_Dict_CityID_Path_Node.Clear();for i := 0 to _StationPathNodeList.Count - 1 do_StationPathNodeList[i].Free;_StationPathNodeList.Clear();
end;constructor TR_Manager.Create;
begin_result_path := Tlist<TR_Path>.Create;_Dict_Province := TDictionary<Integer, TProvince>.Create();_Dict_City := TDictionary<Integer, TCity>.Create();_Dict_City_Name := TDictionary<string, TCity>.Create();_ProvinceList := Tlist<TProvince>.Create();_StationList := Tlist<TStation>.Create();_Dict_Station := TDictionary<string, TStation>.Create();_StationPathList := Tlist<TStation_Path>.Create();_Dict_CityID_Station := TDictionary < Integer, Tlist < TStation >>.Create();_Dict_CityID_Xian_Station := TDictionary < Integer, TDictionary < string,Tlist<TStation> >>.Create(); // hfg 2016-07-23_StationPathNodeList := Tlist<TStation_Path_Node>.Create();_Dict_Station_Path_Node := TDictionary<TStation, TStation_Path_Node>.Create();_Dict_CityID_Path_Node := TDictionary < Integer, Tlist < TStation_Path_Node>>.Create();_Node_Tmp := Tlist<TStation_Path_Node>.Create();_Node_Tmp_2 := Tlist<TStation_Path_Node>.Create();_Node_Tmp_before_end := Tlist<TStation_Path_Node>.Create();
end;destructor TR_Manager.Destroy;
beginclear_result_path();FreeAndNil(_result_path);clear_ProvinceList();FreeAndNil(_ProvinceList);FreeAndNil(_Dict_Province);FreeAndNil(_Dict_City);FreeAndNil(_Dict_City_Name);clear_StationList();FreeAndNil(_StationList);FreeAndNil(_Dict_Station);clear_StationPathList();FreeAndNil(_StationPathList);clear_StationPathNodeList();FreeAndNil(_StationPathNodeList);FreeAndNil(_Node_Tmp);FreeAndNil(_Node_Tmp_2);FreeAndNil(_Node_Tmp_before_end);clear_Dict_CityID_Xian_Station(); // hfg 2016-07-23FreeAndNil(_Dict_CityID_Xian_Station); // hfg 2016-07-23inherited;
end;function TR_Manager.get_City_by_full_name(full_city_name: string): TCity;
beginif not _Dict_City_Name.TryGetValue(full_city_name, Result) thenResult := nil;
end;function TR_Manager.get_City_by_id(ID: Integer): TCity;
beginif not _Dict_City.TryGetValue(ID, Result) thenResult := nil;
end;function TR_Manager.get_City_by_name(ProvinceName, city_name: string): TCity;
beginif not _Dict_City_Name.TryGetValue(ProvinceName + city_name, Result) thenResult := nil;
end;function TR_Manager.get_or_add_Station(ProvinceName, CityName, Name: string): TStation;
varcity: TCity;Station: TStation;CityID: Integer;l: Tlist<TStation>;
beginResult := nil;if _Dict_Station.TryGetValue(Name, Result) thenexit;if _Dict_City_Name.TryGetValue(ProvinceName + CityName, city) thenCityID := city.IDelsebeginCityID := 9999999;exit;end;Station := TStation.Create;Station.ProvinceName := ProvinceName;Station.CityID := CityID;Station.CityName := CityName;Station.Name := Name;_StationList.Add(Station);_Dict_Station.AddOrSetValue(Station.Name, Station);if (not _Dict_CityID_Station.TryGetValue(CityID, l)) thenbeginl := Tlist<TStation>.Create();_Dict_CityID_Station.AddOrSetValue(CityID, l);end;l.Add(Station);Result := Station;
end;function TR_Manager.get_or_add_Station_new(city_id, Name, xian: string): TStation;
varcity: TCity;Station: TStation;CityID: Integer;l: Tlist<TStation>;
beginResult := nil;if _Dict_Station.TryGetValue(Name, Result) thenexit;CityID := strtointdef(city_id, 9999999);city := get_City_by_id(CityID);if city = nil thenexit;Station := TStation.Create;Station.ProvinceName := city.Province._Name;Station.CityID := CityID;Station.CityName := city.Name;Station.Name := Name;Station.xian := xian;Station.address_id := get_city_xian_id(CityID, xian);_StationList.Add(Station);_Dict_Station.AddOrSetValue(Station.Name, Station);if (not _Dict_CityID_Station.TryGetValue(CityID, l)) thenbeginl := Tlist<TStation>.Create();_Dict_CityID_Station.AddOrSetValue(CityID, l);end;l.Add(Station);Result := Station;
end;function TR_Manager.get_path_quick(StationName_begin: string;Station_End: Tlist<TStation>; max_step: Integer = 6;allow_same_city: boolean = false): boolean;
varStation: TStation;node_root, node, node_next: TStation_Path_Node;i, k, step, Node_Tmp_Count, Node_Tmp_2_Count,Node_Tmp_before_end_count: Integer;path: TR_Path;list: Tlist;city_station_list: Tlist<TStation_Path_Node>;
beginResult := false;clear_result_path();if Station_End = nil thenexit;if Station_End.Count <= 0 thenexit;if not(_Dict_Station.TryGetValue(StationName_begin, Station)) thenexit;if Station.CityID = Station_End[0].CityID thenbeginpath := TR_Path.Create;path.Mileage := 0;path.step := 1;path.StationList.Add(Station);for i := 0 to Station_End.Count - 1 dobeginif Station_End[i].Name <> Station.Name thenbeginpath.StationList.Add(Station_End[i]);Break;end;end;if path.StationList.Count < 2 thenpath.StationList.Add(Station);_result_path.Add(path);end;if not(_Dict_Station_Path_Node.TryGetValue(Station, node_root)) thenexit;for i := 0 to _StationPathNodeList.Count - 1 do_StationPathNodeList[i].reset();node_root.set_Step(0);_Node_Tmp[0] := node_root;Node_Tmp_Count := 1;Node_Tmp_before_end_count := 0;for i := 0 to Station_End.Count - 1 dobeginif _Dict_Station_Path_Node.TryGetValue(Station_End[i], node) thennode.set_is_before_end();end;for step := 1 to max_step dobeginNode_Tmp_2_Count := 0;for i := 0 to Node_Tmp_Count - 1 dobegintrynode := _Node_Tmp[i];if (node.is_before_end) thenbegin_Node_Tmp_before_end[Node_Tmp_before_end_count] := node;inc(Node_Tmp_before_end_count);if step > 1 thenContinue;end;for k := 0 to node.Next_Station.Count - 1 dobeginnode_next := node.Next_Station[k].Station_Node_Next;if node_next.is_end thenContinue;if not node_next.is_on_path thenbeginnode_next.path_mileage := node.path_mileage + node.Next_Station[k].Mileage;node_next.Path_Prior_Station := node;node_next.set_Step(step);if Node_Tmp_2_Count < _Node_Tmp_2.Count then_Node_Tmp_2[Node_Tmp_2_Count] := node_nextelse_Node_Tmp_2.Add(node_next);inc(Node_Tmp_2_Count);endelsebeginif (node_next.step = step) and (step > 1) thenbeginif node.path_mileage + node.Next_Station[k].Mileage < node_next.path_mileagethenbeginnode_next.path_mileage := node.path_mileage + node.Next_Station[k].Mileage;node_next.Path_Prior_Station := node;end;end;end;end;if allow_same_city thenbeginif _Dict_CityID_Path_Node.TryGetValue(node.Station.CityID,city_station_list) thenbeginfor k := 0 to city_station_list.Count - 1 dobeginnode_next := city_station_list[k];if node_next.is_end thenContinue;if not node_next.is_on_path thenbeginnode_next.path_mileage := node.path_mileage + 0;node_next.Path_Prior_Station := node;node_next.set_Step(step);if Node_Tmp_2_Count < _Node_Tmp_2.Count then_Node_Tmp_2[Node_Tmp_2_Count] := node_nextelse_Node_Tmp_2.Add(node_next);inc(Node_Tmp_2_Count);end;end;end;end;exceptNode_Tmp_2_Count := Node_Tmp_2_Count - 1;end;end;Node_Tmp_Count := 0;for i := 0 to Node_Tmp_2_Count - 1 dobeginif _Node_Tmp_2[i].is_on_path thenbeginif True thenif Node_Tmp_Count < _Node_Tmp.Count then_Node_Tmp[Node_Tmp_Count] := _Node_Tmp_2[i]else_Node_Tmp.Add(_Node_Tmp_2[i]);inc(Node_Tmp_Count);end;end;end;list := Tlist.Create();for i := 0 to Node_Tmp_before_end_count - 1 dobeginpath := TR_Path.Create;node := _Node_Tmp_before_end[i];path.Mileage := node.path_mileage + node.to_end_mileage;path.StationList.Add(node.end_Node.Station);path.StationList.Add(node.Station);node_next := node.Path_Prior_Station;for step := 1 to max_step + 1 dobeginif node_next = nil thenBreak;path.StationList.Add(node_next.Station);if node_next.step <= 0 thenBreak;node_next := node_next.Path_Prior_Stationend;path.StationList.Reverse();list.Add(path);end;list.Sort(@ComparePath_city);for i := 0 to list.Count - 1 do_result_path.Add(list[i]);FreeAndNil(list);Result := _result_path.Count > 0;
end;function TR_Manager.get_path_quick_ex(Station_Begin,Station_End: Tlist<TStation>; max_step: Integer;allow_same_city: boolean): boolean;
varStation: TStation;node_root, node, node_next: TStation_Path_Node;m, i, k, step, Node_Tmp_Count, Node_Tmp_2_Count,Node_Tmp_before_end_count: Integer;path: TR_Path;list: Tlist;city_station_list: Tlist<TStation_Path_Node>;
beginResult := false;clear_result_path();if Station_Begin = nil thenexit;if Station_Begin.Count <= 0 thenexit;if Station_End = nil thenexit;if Station_End.Count <= 0 thenexit;for m := 0 to Station_Begin.Count - 1 dobeginStation := Station_Begin[m];if Station.CityID = Station_End[0].CityID thenbeginpath := TR_Path.Create;path.Mileage := 0;path.step := 1;path.StationList.Add(Station);for i := 0 to Station_End.Count - 1 dobeginif Station_End[i].Name <> Station.Name thenbeginpath.StationList.Add(Station_End[i]);Break;end;end;if path.StationList.Count < 2 thenpath.StationList.Add(Station);_result_path.Add(path);end;end;for i := 0 to _StationPathNodeList.Count - 1 do_StationPathNodeList[i].reset();Node_Tmp_Count := 0;for m := 0 to Station_Begin.Count - 1 dobeginStation := Station_Begin[m];if (_Dict_Station_Path_Node.TryGetValue(Station, node_root)) thenbegin_Node_Tmp[Node_Tmp_Count] := node_root;node_root.set_Step(0);Node_Tmp_Count := Node_Tmp_Count + 1;end;end;if Node_Tmp_Count = 0 thenexit;Node_Tmp_before_end_count := 0;for i := 0 to Station_End.Count - 1 dobeginif _Dict_Station_Path_Node.TryGetValue(Station_End[i], node) thennode.set_is_before_end();end;for step := 1 to max_step dobeginNode_Tmp_2_Count := 0;for i := 0 to Node_Tmp_Count - 1 dobegintrynode := _Node_Tmp[i];if (node.is_before_end) thenbegin_Node_Tmp_before_end[Node_Tmp_before_end_count] := node;inc(Node_Tmp_before_end_count);if step > 1 thenContinue;end;for k := 0 to node.Next_Station.Count - 1 dobeginnode_next := node.Next_Station[k].Station_Node_Next;if node_next.is_end thenContinue;if not node_next.is_on_path thenbeginnode_next.path_mileage := node.path_mileage + node.Next_Station[k].Mileage;node_next.Path_Prior_Station := node;node_next.set_Step(step);if Node_Tmp_2_Count < _Node_Tmp_2.Count then_Node_Tmp_2[Node_Tmp_2_Count] := node_nextelse_Node_Tmp_2.Add(node_next);inc(Node_Tmp_2_Count);endelsebeginif (node_next.step = step) and (step > 1) thenbeginif node.path_mileage + node.Next_Station[k].Mileage < node_next.path_mileagethenbeginnode_next.path_mileage := node.path_mileage + node.Next_Station[k].Mileage;node_next.Path_Prior_Station := node;end;end;end;end;if allow_same_city thenbeginif _Dict_CityID_Path_Node.TryGetValue(node.Station.CityID,city_station_list) thenbeginfor k := 0 to city_station_list.Count - 1 dobeginnode_next := city_station_list[k];if node_next.is_end thenContinue;if not node_next.is_on_path thenbeginnode_next.path_mileage := node.path_mileage + 0;node_next.Path_Prior_Station := node;node_next.set_Step(step);if Node_Tmp_2_Count < _Node_Tmp_2.Count then_Node_Tmp_2[Node_Tmp_2_Count] := node_nextelse_Node_Tmp_2.Add(node_next);inc(Node_Tmp_2_Count);end;end;end;end;exceptNode_Tmp_2_Count := Node_Tmp_2_Count - 1;end;end;Node_Tmp_Count := 0;for i := 0 to Node_Tmp_2_Count - 1 dobeginif _Node_Tmp_2[i].is_on_path thenbeginif True thenif Node_Tmp_Count < _Node_Tmp.Count then_Node_Tmp[Node_Tmp_Count] := _Node_Tmp_2[i]else_Node_Tmp.Add(_Node_Tmp_2[i]);inc(Node_Tmp_Count);end;end;end;list := Tlist.Create();for i := 0 to Node_Tmp_before_end_count - 1 dobeginpath := TR_Path.Create;node := _Node_Tmp_before_end[i];path.Mileage := node.path_mileage + node.to_end_mileage;path.StationList.Add(node.end_Node.Station);path.StationList.Add(node.Station);node_next := node.Path_Prior_Station;for step := 1 to max_step + 1 dobeginif node_next = nil thenBreak;path.StationList.Add(node_next.Station);if node_next.step <= 0 thenBreak;node_next := node_next.Path_Prior_Stationend;path.StationList.Reverse();list.Add(path);end;list.Sort(@ComparePath_city);for i := 0 to list.Count - 1 do_result_path.Add(list[i]);FreeAndNil(list);Result := _result_path.Count > 0;end;function TR_Manager.get_Province_by_id(ID: Integer): TProvince;
beginif not _Dict_Province.TryGetValue(ID, Result) thenResult := nil;
end;function TR_Manager.get_StationList: Tlist<TStation>;
beginResult := _StationList;
end;procedure TR_Manager.get_station_by_city_id(city_id: Integer;var list: Tlist<TStation>);
beginif not(_Dict_CityID_Station.TryGetValue(city_id, list)) thenlist := nil;
end;procedure TR_Manager.get_station_by_city_id_xian(city_id: Integer; xian: string;var list: Tlist<TStation>); // hfg 2016-07-23
vardict: TDictionary<string, Tlist<TStation>>;
beginif not _Dict_CityID_Xian_Station.TryGetValue(city_id, dict) thenbeginlist := nil;exit;end;if not dict.TryGetValue(xian, list) thenbeginlist := nil;exit;end;
end;procedure TR_Manager.load_City(fn: string);
varsl: TStringList;
beginsl := TStringList.Create;sl.LoadFromFile(fn);load_City_sl(sl);FreeAndNil(sl);
end;procedure TR_Manager.load_City_sl(sl: TStringList);
vari, pid: Integer;ss: TArray<String>;c: TCity;p: TProvince;
begin_Dict_City.Clear();_Dict_City_Name.Clear();for i := 0 to sl.Count - 1 dobeginss := sl[i].Split([#9]);if length(ss) < 0 thenContinue;if length(ss) >= 3 thenbeginc := TCity.Create;c.ID := strtointdef(ss[0], 0);c.Name := ss[1];if length(ss) = 4 thenbeginc.Code := strtointdef(ss[2], 0);c.TelCode := strtointdef(ss[3], 0);pid := get_Province_ID_from_City_Code(c.Code);endelsebeginpid := strtointdef(ss[2], 0);end;p := get_Province_by_id(pid);if p <> nil thenbeginp.CityList.Add(c);_Dict_City.AddOrSetValue(c.ID, c);_Dict_City_Name.AddOrSetValue(p.Name + c.Name, c);end;c.Province := p;end;SetLength(ss, 0);end;
end;procedure TR_Manager.load_County(fn: string);
vari, pid: Integer;sl: TStringList;ss: TArray<String>;city: TCity;county: TCounty;
beginsl := TStringList.Create;sl.LoadFromFile(fn);for i := 0 to sl.Count - 1 dobeginss := sl[i].Split([#9]);if length(ss) < 0 thenContinue;if length(ss) >= 2 thenbegincounty := TCounty.Create;county.CityID := strtointdef(ss[0], 0);county.Name := ss[1];city := get_City_by_id(pid);if city <> nil thenbegincity.CountyList.Add(county);end;end;SetLength(ss, 0);end;FreeAndNil(sl);
end;procedure TR_Manager.load_Path(fn: string);
vari, m: Integer;sl: TStringList;ss: TArray<String>;s_begin, s_end: TStation;sp: TStation_Path;
beginclear_StationList;clear_StationPathList;sl := TStringList.Create;sl.LoadFromFile(fn);for i := 0 to sl.Count - 1 dobeginss := sl[i].Split([#9]);if length(ss) < 0 thenContinue;if length(ss) >= 5 thenbeginget_or_add_Station(ss[0], ss[1], ss[2]);end;SetLength(ss, 0);end;sl.LoadFromFile(fn);for i := 0 to sl.Count - 1 dobeginss := sl[i].Split([#9]);if length(ss) < 0 thenContinue;if length(ss) >= 5 thenbeginif (_Dict_Station.TryGetValue(ss[2], s_begin)) and(_Dict_Station.TryGetValue(ss[5], s_end)) thenbeginm := Round(strtointdef(ss[3], 0));if m > 0 thenbeginsp := TStation_Path.Create;sp.Station_Begin := s_begin;sp.Station_End := s_end;sp.Mileage := m;_StationPathList.Add(sp);endelsebeginend;endelsebeginend;end;SetLength(ss, 0);end;FreeAndNil(sl);make_StationPathNodeList();
end;procedure TR_Manager.load_Path_new(fn: string);
varsl: TStringList;
begin// 2016-10-03sl := TStringList.Create;sl.LoadFromFile(fn);load_Path_new_sl(sl);FreeAndNil(sl);
end;procedure TR_Manager.load_Path_new_sl(sl: TStringList);
vari, m: Integer;ss: TArray<String>;s_begin, s_end: TStation;sp: TStation_Path;
begin// 2016-10-03clear_StationList;clear_StationPathList;for i := 0 to sl.Count - 1 dobeginss := sl[i].Split([#9]);if length(ss) < 0 thenContinue;if length(ss) >= 6 thenbeginget_or_add_Station_new(ss[0], ss[1], ss[2]);end;SetLength(ss, 0);end;for i := 0 to sl.Count - 1 dobeginss := sl[i].Split([#9]);if length(ss) < 0 thenContinue;if length(ss) >= 5 thenbeginif (_Dict_Station.TryGetValue(ss[1], s_begin)) and(_Dict_Station.TryGetValue(ss[5], s_end)) thenbeginm := Round(strtointdef(ss[3], 0));if m > 0 thenbeginsp := TStation_Path.Create;sp.Station_Begin := s_begin;sp.Station_End := s_end;sp.Mileage := m;_StationPathList.Add(sp);endelsebeginend;endelsebeginend;end;SetLength(ss, 0);end;make_StationPathNodeList();
end;procedure TR_Manager.load_Province(fn: string);
varsl: TStringList;
beginsl := TStringList.Create;sl.LoadFromFile(fn);load_Province_sl(sl);FreeAndNil(sl);
end;procedure TR_Manager.load_Province_sl(sl: TStringList);
vari: Integer;ss: TArray<String>;p: TProvince;
beginclear_ProvinceList();for i := 0 to sl.Count - 1 dobeginss := sl[i].Split([#9]);if length(ss) < 0 thenContinue;if length(ss) >= 2 thenbeginp := TProvince.Create;p.ID := strtointdef(ss[0], 0);p.Name := ss[1];if length(ss) >= 3 thenp.CardCode := ss[2];_ProvinceList.Add(p);_Dict_Province.AddOrSetValue(p.ID, p);end;SetLength(ss, 0);end;
end;procedure TR_Manager.load_xian(fn: string); // hfg 2016-07-23
vari: Integer;sl: TStringList;ss: TArray<String>;Station: TStation;dict: TDictionary<string, Tlist<TStation>>;list: Tlist<TStation>;pair: TPair<string, TStation>;procedure set_xian(v: string);beginif Station.xian = '' thenStation.xian := v;end;beginclear_Dict_CityID_Xian_Station();sl := TStringList.Create;sl.LoadFromFile(fn);sl.LoadFromFile(fn);for i := 0 to sl.Count - 1 dobeginss := sl[i].Split([#9]);if length(ss) = 2 thenbeginif _Dict_Station.TryGetValue(ss[0], Station) thenbeginset_xian(ss[1]);end;end;SetLength(ss, 0);end;for pair in _Dict_Station dobeginStation := pair.Value;if Station.xian <> '' thenbeginif not _Dict_CityID_Xian_Station.TryGetValue(Station.CityID, dict) thenbegindict := TDictionary < string, Tlist < TStation >> .Create();_Dict_CityID_Xian_Station.AddOrSetValue(Station.CityID, dict);end;if not dict.TryGetValue(Station.xian, list) thenbeginlist := Tlist<TStation>.Create();dict.AddOrSetValue(Station.xian, list);end;list.Add(Station);end;end;FreeAndNil(sl);
end;procedure TR_Manager.make_StationPathNodeList;
vari, cid: Integer;p, p2: TStation_Path_Node;c_list: Tlist<TStation_Path_Node>;
begin_Node_Tmp.Clear();clear_StationPathNodeList();for i := 0 to _StationList.Count - 1 dobeginp := TStation_Path_Node.Create;p.Station := _StationList[i];_Dict_Station_Path_Node.AddOrSetValue(p.Station, p);_StationPathNodeList.Add(p);_Node_Tmp.Add(nil);_Node_Tmp_2.Add(nil);_Node_Tmp_before_end.Add(nil);cid := _StationList[i].CityID;if not _Dict_CityID_Path_Node.TryGetValue(cid, c_list) thenbeginc_list := Tlist<TStation_Path_Node>.Create;_Dict_CityID_Path_Node.AddOrSetValue(cid, c_list);end;c_list.Add(p);end;for i := 0 to _StationPathList.Count - 1 dobeginif (_Dict_Station_Path_Node.TryGetValue(_StationPathList[i].Station_Begin,p)) and (_Dict_Station_Path_Node.TryGetValue(_StationPathList[i].Station_End, p2)) thenbeginp.add_next(p2, _StationPathList[i].Mileage);p2.add_Prior(p, _StationPathList[i].Mileage);end;end;end;procedure TR_Manager.save_Station(fn: string);
vari: Integer;sl: TStringList;s: string;Station: TStation;
beginsl := TStringList.Create;for i := 0 to _StationList.Count - 1 dobeginStation := _StationList[i];if i = 0 thens := 'select ' + Station.CityID.ToString() + ' as  CityID,' +QuotedStr(Station.Name) + ' as station'elses := 'union select ' + Station.CityID.ToString() + ',' +QuotedStr(Station.Name);sl.Add(s);end;sl.SaveToFile(fn);
end;{ TProvince }procedure TProvince.clear_CityList;
vari: Integer;
beginfor i := 0 to _CityList.Count - 1 do_CityList[i].Free;_CityList.Clear();
end;constructor TProvince.Create;
begin_CityList := Tlist<TCity>.Create();
end;destructor TProvince.Destroy;
beginclear_CityList();FreeAndNil(_CityList);inherited;
end;{ TCity }procedure TCity.clear_CountyList;
vari: Integer;
beginfor i := 0 to _CountyList.Count - 1 do_CountyList[i].Free;_CountyList.Clear();
end;constructor TCity.Create;
begin_CountyList := Tlist<TCounty>.Create();
end;destructor TCity.Destroy;
beginclear_CountyList();FreeAndNil(_CountyList);inherited;
end;{ TCounty }constructor TCounty.Create;
begin//
end;destructor TCounty.Destroy;
begininherited;
end;{ TStation }constructor TStation.Create;
begin//
end;destructor TStation.Destroy;
begininherited;
end;{ TStation_Path }constructor TStation_Path.Create;
begin//
end;destructor TStation_Path.Destroy;
begininherited;
end;{ TStation_Path_Node }procedure TStation_Path_Node.add_next(next_node: TStation_Path_Node;Mileage: Integer);
varn: TStation_Next;
beginn := TStation_Next.Create;n.Station_Node_Next := next_node;n.Mileage := Mileage;_Next_Station.Add(n);
end;procedure TStation_Path_Node.add_Prior(p_node: TStation_Path_Node;Mileage: Integer);
varn: TStation_Next;
beginn := TStation_Next.Create;n.Station_Node_Next := p_node;n.Mileage := Mileage;_Prior_Station.Add(n);
end;procedure TStation_Path_Node.clear_Next_Station;
vari: Integer;
beginfor i := 0 to _Next_Station.Count - 1 do_Next_Station[i].Free;_Next_Station.Clear;
end;procedure TStation_Path_Node.clear_Prior_Station;
vari: Integer;
beginfor i := 0 to _Prior_Station.Count - 1 do_Prior_Station[i].Free;_Prior_Station.Clear;
end;constructor TStation_Path_Node.Create;
begin_path_mileage := 0;_is_on_path := false;_step := -1;_Next_Station := Tlist<TStation_Next>.Create();_Prior_Station := Tlist<TStation_Next>.Create();
end;destructor TStation_Path_Node.Destroy;
beginclear_Next_Station();FreeAndNil(_Next_Station);clear_Prior_Station();FreeAndNil(_Prior_Station);inherited;
end;procedure TStation_Path_Node.reset;
begin_is_on_path := false;_is_end := false;_step := -1;_is_before_end := false;_path_mileage := 0;_Path_Prior_Station := nil;
end;procedure TStation_Path_Node.set_is_before_end;
vari: Integer;
begin_is_end := True;for i := 0 to _Prior_Station.Count - 1 dobeginif (_Prior_Station[i].Station_Node_Next.is_before_end) thenif _Prior_Station[i].Station_Node_Next._to_end_mileage < _Prior_Station[i]._Mileage thenContinue;_Prior_Station[i].Station_Node_Next._is_before_end := True;_Prior_Station[i].Station_Node_Next._end_Node := self;_Prior_Station[i].Station_Node_Next._to_end_mileage :=_Prior_Station[i]._Mileage;end;
end;procedure TStation_Path_Node.set_Step(v: Integer);
begin_step := v;_is_on_path := True;
end;{ TStation_Next }constructor TStation_Next.Create;
begin//
end;destructor TStation_Next.Destroy;
begininherited;
end;{ TR_Path }constructor TR_Path.Create;
beginStationList := Tlist<TStation>.Create();
end;destructor TR_Path.Destroy;
beginFreeAndNil(StationList);inherited;
end;function TR_Path.get_txt: string;
vari: Integer;
beginResult := '';for i := 0 to StationList.Count - 1 dobeginif i > 0 thenResult := Result + ' -> ';Result := Result + StationList[i].Name;end;Result := Result + ' (' + IntToStr(Mileage) + ')'
end;function TR_Path.get_txt_with_city: string;
vari: Integer;
beginResult := '';for i := 0 to StationList.Count - 1 dobeginif i > 0 thenResult := Result + '>';Result := Result + StationList[i].CityID.ToString() + '|' +StationList[i].Name;end;Result := Result + ':' + IntToStr(Mileage)
end;end.

相关文章:

一种寻路的应用

应用背景 利用长途车进行货物转运的寻路计算。例如从深圳到大连。可以走有很多条长途车的路线。需要根据需求计算出最合适路线。不同的路线的总里程数、总价、需要的时间不一样。客户根据需求进行选择。主要有一些细节&#xff1a; 全国的长途车车站的数据的更新&#xff1a; …...

编译openssl遇到错误Parse errors: No plan found in TAP output的解决方法

在编译openssl时 tar -zxvf openssl-1.1.1p.tar.gz cd openssl-1.1.1p ./config --prefix/usr --openssldir/etc/ssl --shared zlib make make test 遇到错误 Parse errors: No plan found in TAP output 解决方法&#xff1a; yum install perl-Test-Simple...

一文大白话讲清楚防抖和节流,设计封装防抖和节流,以及防抖和节流的应用场景

文章目录 一文大白话讲清楚防抖和节流&#xff0c;设计封装防抖和节流&#xff0c;以及防抖和节流的应用场景1. 防抖和节流的背景2. 节流3. 节流的应用场景4. 防抖5. 防抖应用场景 一文大白话讲清楚防抖和节流&#xff0c;设计封装防抖和节流&#xff0c;以及防抖和节流的应用场…...

Windows开启IIS后依然出现http error 503.the service is unavailable

问题背景 已启用IIS服务&#xff0c;配置步骤可以参考Windows10 IIS Web服务器安装配置 问题描述 在这一步浏览网站时&#xff0c;并没有出现默认首页&#xff0c;而是 http error 503 the service is unavailable 问题解决 参考 成功解决http error 503.the service is un…...

C++的封装(十四):《设计模式》这本书

很多C学习者学到对C语言有一定自信后&#xff0c;会去读一下《设计模式》这本书。希望能够提升自己的设计水平。 据我所知&#xff0c;围绕C语言出了很多书。因为正好赶上泡沫经济时代。大家一拥而上&#xff0c;自己半懂不懂就出书&#xff0c;抢着出书收割读者&#xff0c;出…...

牛客周赛73B:JAVA

链接&#xff1a;登录—专业IT笔试面试备考平台_牛客网 来源&#xff1a;牛客网 题目描述 \hspace{15pt}小红拿到了正整数 xxx &#xff0c;她希望你找到一个长度为 kkk 的区间&#xff0c;满足区间内恰好有 nnn 个数是 xxx 的倍数。你能帮帮她吗&#xff1f; 输入描述: …...

【Ubuntu 20.4安装截图软件 flameshot 】

步骤一&#xff1a; 安装命令&#xff1a; sudo apt-get install flameshot 步骤二&#xff1a; 设置快捷方式&#xff1a; Ubuntu20.4 设置菜单&#xff0c;点击 号 步骤三&#xff1a; 输入软件名称&#xff0c; 软件快捷命令&#xff08;flameshot gui&#xff09;&am…...

剑指Offer|LCR 014. 字符串的排列

LCR 014. 字符串的排列 给定两个字符串 s1 和 s2&#xff0c;写一个函数来判断 s2 是否包含 s1 的某个变位词。 换句话说&#xff0c;第一个字符串的排列之一是第二个字符串的 子串 。 示例 1&#xff1a; 输入: s1 "ab" s2 "eidbaooo" 输出: True 解…...

【Agent】Chatbot、Copilot与Agent如何帮助我们的提升效率?

人工智能&#xff08;AI&#xff09;技术的迅猛发展正在深刻改变我们的生活和工作方式。你是否曾想过&#xff0c;未来的工作场景会是什么样子&#xff1f;AI的崛起不仅仅是科技的进步&#xff0c;更是我们生活方式的革命。今天&#xff0c;我们将深入探讨三种主要的AI能力&…...

QT笔记- QTreeView + QFileSystemModel 当前位置的保存与恢复 #选中 #保存当前索引

保存当前位置 QString currentPath model->filePath(view->currentIndex()); // 获得当前位置路径 恢复位置 view->setCurrentIndex(model->index(currentPath)); // 设置此路径所在位置为当前位置...

OpenResty开发环境搭建

简介 OpenResty 是一个基于 Nginx的高性能 Web 平台&#xff0c;用于方便地搭建能够处理超高并发、扩展性极高的动态 Web 应用、Web 服务和动态网关。官方地址&#xff1a;http://openresty.org/cn/ 具备下列特点&#xff1a; 具备Nginx的完整功能基于Lua语言进行扩展&#…...

linux提示结构需要清理

1. df -hT 查看出问题的文件夹所在的挂载磁盘及文件格式 2. umount 挂载磁盘&#xff0c;如果提示在忙, lsof 目录查看正在使用的进程&#xff0c;将其kill掉 3. 修复磁盘 根据文件格式修复磁盘fsck.ext4 /dev/sda1 或者 xfs_repair /dev/sda1 4. 重启系统 “结构需要清理…...

【扩展卡尔曼滤波理论推导与实践】【理论】【2/3 公式推导】

目录 非线性系统泰勒展开卡尔曼滤波卡尔曼增益模型误差协方差矩阵 公式总结 本节默认你能够完整推导标准卡尔曼滤波&#xff0c;将会简化一些推导的描述。如果你还不会完整推导标准卡尔曼滤波&#xff0c;请先从 【卡尔曼滤波理论推导与实践】系列开始看起。 非线性系统 扩展…...

springboot494基于java的综合小区管理系统(论文+源码)_kaic

摘 要 如今社会上各行各业&#xff0c;都喜欢用自己行业的专属软件工作&#xff0c;互联网发展到这个时候&#xff0c;人们已经发现离不开了互联网。新技术的产生&#xff0c;往往能解决一些老技术的弊端问题。因为传统综合小区管理系统信息管理难度大&#xff0c;容错率低&am…...

深度学习blog-Transformer-注意力机制和编码器解码器

注意力机制&#xff1a;当我们看一个图像或者听一段音频时&#xff0c;会根据自己的需求&#xff0c;集中注意力在关键元素上&#xff0c;以获取相关信息。 同样地&#xff0c;注意力机制中的模型也会根据输入的不同部分&#xff0c;给它们不同的权重&#xff0c;并集中注意力在…...

敏感词 v0.24.0 新特性支持标签分类,内置实现多种策略

开源项目 敏感词核心 https://github.com/houbb/sensitive-word 敏感词控台 https://github.com/houbb/sensitive-word-admin 版本特性 大家好&#xff0c;我是老马。 敏感词标签分类一直是大家比较想要的一个功能特性&#xff0c;v0.24.0 了开始内置支持标签分类&#xff0c…...

随身 WiFi 连接 X-Wrt 共享网络与 IPv6 中继配置

本文首发于只抄博客&#xff0c;欢迎点击原文链接了解更多内容。 前言 之前分享的《随身 WiFi 通过 USB 连接路由器共享网络 扩展网络覆盖范围》介绍了随身 WiFi 通过 USB 连接到路由器共享网络&#xff0c;其中留下两个小问题没有解决&#xff1a; OpenWrt 无法识别中兴微的…...

Keil-编译按钮Translate,Build,Rebuild

在Keil编程环境中&#xff0c;有三个编译源文件相关的按钮Translate&#xff0c;Build&#xff0c;Rebuild&#xff1a; Translate 仅仅&#xff08;狭义&#xff09;编译一下当前编辑的源文件&#xff08;main.c 仅生成 main.o&#xff09;&#xff0c;并不生成最终可执行文件…...

No.1免费开源ERP:Odoo自定义字段添加到配置页中的技术分享

文 / 开源智造&#xff08;OSCG&#xff09; Odoo亚太金牌服务 在Odoo18之中&#xff0c;配置设定于管控各类系统配置层面发挥着关键之效用&#xff0c;使您能够对软件予以定制&#xff0c;以契合您特定的业务需求。尽管 Odoo 提供了一组强劲的默认配置选项&#xff0c;然而有…...

Linux 更改Jenkins使用其他账户启动

Linux 更改Jenkins使用其他账户启动 步骤一&#xff1a;修改 Jenkins 配置文件1. 编辑 Jenkins 的 systemd 服务文件&#xff1a;2. 在编辑器中添加以下内容&#xff1a;3. 保存并退出编辑器 步骤二&#xff1a;更改 Jenkins 目录的权限步骤三&#xff1a;重新加载 systemd 配置…...

19c补丁后oracle属主变化,导致不能识别磁盘组

补丁后服务器重启&#xff0c;数据库再次无法启动 ORA01017: invalid username/password; logon denied Oracle 19c 在打上 19.23 或以上补丁版本后&#xff0c;存在与用户组权限相关的问题。具体表现为&#xff0c;Oracle 实例的运行用户&#xff08;oracle&#xff09;和集…...

ES6从入门到精通:前言

ES6简介 ES6&#xff08;ECMAScript 2015&#xff09;是JavaScript语言的重大更新&#xff0c;引入了许多新特性&#xff0c;包括语法糖、新数据类型、模块化支持等&#xff0c;显著提升了开发效率和代码可维护性。 核心知识点概览 变量声明 let 和 const 取代 var&#xf…...

大话软工笔记—需求分析概述

需求分析&#xff0c;就是要对需求调研收集到的资料信息逐个地进行拆分、研究&#xff0c;从大量的不确定“需求”中确定出哪些需求最终要转换为确定的“功能需求”。 需求分析的作用非常重要&#xff0c;后续设计的依据主要来自于需求分析的成果&#xff0c;包括: 项目的目的…...

《Qt C++ 与 OpenCV:解锁视频播放程序设计的奥秘》

引言:探索视频播放程序设计之旅 在当今数字化时代,多媒体应用已渗透到我们生活的方方面面,从日常的视频娱乐到专业的视频监控、视频会议系统,视频播放程序作为多媒体应用的核心组成部分,扮演着至关重要的角色。无论是在个人电脑、移动设备还是智能电视等平台上,用户都期望…...

解锁数据库简洁之道:FastAPI与SQLModel实战指南

在构建现代Web应用程序时&#xff0c;与数据库的交互无疑是核心环节。虽然传统的数据库操作方式&#xff08;如直接编写SQL语句与psycopg2交互&#xff09;赋予了我们精细的控制权&#xff0c;但在面对日益复杂的业务逻辑和快速迭代的需求时&#xff0c;这种方式的开发效率和可…...

Go 语言接口详解

Go 语言接口详解 核心概念 接口定义 在 Go 语言中&#xff0c;接口是一种抽象类型&#xff0c;它定义了一组方法的集合&#xff1a; // 定义接口 type Shape interface {Area() float64Perimeter() float64 } 接口实现 Go 接口的实现是隐式的&#xff1a; // 矩形结构体…...

python如何将word的doc另存为docx

将 DOCX 文件另存为 DOCX 格式&#xff08;Python 实现&#xff09; 在 Python 中&#xff0c;你可以使用 python-docx 库来操作 Word 文档。不过需要注意的是&#xff0c;.doc 是旧的 Word 格式&#xff0c;而 .docx 是新的基于 XML 的格式。python-docx 只能处理 .docx 格式…...

UR 协作机器人「三剑客」:精密轻量担当(UR7e)、全能协作主力(UR12e)、重型任务专家(UR15)

UR协作机器人正以其卓越性能在现代制造业自动化中扮演重要角色。UR7e、UR12e和UR15通过创新技术和精准设计满足了不同行业的多样化需求。其中&#xff0c;UR15以其速度、精度及人工智能准备能力成为自动化领域的重要突破。UR7e和UR12e则在负载规格和市场定位上不断优化&#xf…...

实现弹窗随键盘上移居中

实现弹窗随键盘上移的核心思路 在Android中&#xff0c;可以通过监听键盘的显示和隐藏事件&#xff0c;动态调整弹窗的位置。关键点在于获取键盘高度&#xff0c;并计算剩余屏幕空间以重新定位弹窗。 // 在Activity或Fragment中设置键盘监听 val rootView findViewById<V…...

Pinocchio 库详解及其在足式机器人上的应用

Pinocchio 库详解及其在足式机器人上的应用 Pinocchio (Pinocchio is not only a nose) 是一个开源的 C 库&#xff0c;专门用于快速计算机器人模型的正向运动学、逆向运动学、雅可比矩阵、动力学和动力学导数。它主要关注效率和准确性&#xff0c;并提供了一个通用的框架&…...