综合算法03—FrankWolfe_BPR配流算法

本文通过一个算例分析了FrankWolfe算法在BPR阻抗函数下的配流问题。在给定的路网中,从节点1到节点9存在7500的OD需求。经过算法计算,得到了相应的配流结果。详细计算步骤及程序可在指定链接中获取。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

%% 算法符号及程序说明
%说明:本程序为采用美国联邦公路阻抗函数BPR时的frankwolfe算法,考虑了换乘(已经将等待时
%间考虑在内并在K短路的确定过程中计算)及拥挤附加时间,在路网情况已知时配流并求出费用值。
%计算条件:根据K短路算法计算出考虑换乘的路径-路段关系矩阵和边权。
%缺点:BPR函数或许不能准确的描述轨道交通系统的路段阻抗,列车的能力也不能用程序中那么简单
%代替(但是,这无关紧要,暂时可以认为是正确的,后续可以用已知的路段函元胞和能力矩阵替换)
%下一步研究方向:网络配流--所有OD对之间的配流。
%==============================================================================
%符号体系:
%   Q-OD需求量
%  Cs-路段额定能力(列车座位数)
%Cmax-路段极限能力(列车座位数+人均面积达标的时的站立人数)
%   t-路段阻抗函数(值)
%numf-起点到终点的路径数量(自己按照K短路算法进行定义)
%numx-网络中的路段数量(直接连接两节点的边数,包含所有路段)
%   W-边权(0流量时的阻抗),在该程序中,通过调用K短路换乘算法自动标号索引得出。
%Transfer_time-某路径的路段换乘时间
%   G-路段拥挤附加时间
%   A-一般拥挤放大系数(介于0到等车时间之间),可以看作一个综合系数,指部分人选择挤车,部分人选择下趟列车。
%   B-特别拥挤放大系数(等车时间,与发车频率对应),如果过度拥挤,则无法乘车的人必须等待后车到来,等1趟时间加B,等2趟,时间加2B,等几趟由无法乘车人数与极限能力决定。
%   L-路网路线矩阵(0-1矩阵,表示路线与路段的关系,1为包含,0为不包含)
% Mxf-路径与路段的关系矩阵(每一行表示一个路径,矩阵值为1表示经过该路段,否则不经过该路段)
%cont-当前配流次数
%Ckrs-路径配流结果(更新后的阻抗值)
%  X1-当前配流结果
%  Y1-辅助流量
%   S-搜索方向
%lmbda-搜索步长
%  X2-新的迭代点
%   Z-目标函数(通用配流目标函数,可认为是费用)
%==============================================================================
clear all
format
clc
warning off
disp('========================================================================');
disp('                           《FrankWolfe_BPR配流算法》');
disp('运行环境:MATLAB 8.3.0.532 ');
disp('制 作 人:兰州交通大学   刘志祥');
disp('完成时间:2015-12-30');
disp('Q      Q:531548824');
disp('请提出宝贵的意见!');
disp('=========================================================================');

disp('----------------------------------------------------------------------')
fprintf('问题描述:已知路网数据(Road_Net)和线路数据(Line_Station)及OD需求(Q),\n求指定OD对的配流结果.\n\n');
disp('----------------------------------------------------------------------')

%% 定义变量及常数
syms lambda real
for i=1:100
    syms x(i) real;
end
cont=0;
e=inf;
A=2;
B=5;
cs=1460;
cmax=2070;
Q=7500; 

%% 输入路网数据
%例1
% Road_Net=[0 15 5 inf;15 0 inf 20;5 inf 0 25;inf 20 25 0];             %路网关联矩阵,表示点到点的距离(或时间、费用)
%例2
Road_Net =[
     0     2   Inf     1   Inf   Inf   Inf   Inf   Inf
     2     0     3   Inf     3   Inf   Inf   Inf   Inf
   Inf     3     0   Inf   Inf     2   Inf   Inf   Inf
     1   Inf   Inf     0     3   Inf     5   Inf   Inf
   Inf     3   Inf     3     0     1   Inf     2   Inf
   Inf   Inf     2   Inf     1     0   Inf   Inf     3
   Inf   Inf   Inf     5   Inf   Inf     0     2   Inf
   Inf   Inf   Inf   Inf     2   Inf     2     0     4
   Inf   Inf   Inf   Inf   Inf     3   Inf     4     0];
Line_Station={[1 2 3 6 9 8 7 4],[2 5 8 9],[1 4 5 6]};

%% 调用KSP(K shortest path)计算出W,L,Mxf
[W_Section,Line_Section_01Mat,Mxf]=KSP(Road_Net,Line
求解交通流量分配模型的有效方法 #include "stdafx.h" #include #include #include "os.h" #include "my_types.h" #include "md_alloc.h" #include "my_util.h" #include "message.h" #include "tui.h" #include "meta.h" #include "link_functions.h" #include "od_table.h" #include "od_flow.h" #include "mincostroutes.h" #include "ls_bisect.h" #include "fw_status.h" extern int no_zones, no_nodes, no_links; /* Gloabal variables */ my_float **ODflow, TotalODflow; /* Local Declarations */ /* void FW(void); Should there be a function for fw, or should it be included in main? */ static void Init(char *tuiFileName); static void Close(char *tuiFileName); static void InitODflow(void); static void CloseODflow(void); /* End of local declarations. */ void main(int argc, char **argv ) { my_float *MainVolume, *SubVolume, *SDVolume, Lambda; int **MinPathPredLink; struct fw_status_struct fw_status; char *tuiFileName; StatusMessage("General", "Ready, set, go..."); switch(argc){ case 2: tuiFileName=argv[1]; break; case 1: tuiFileName="control.tui"; break; default: ExitMessage("Wrong number of command line arguments (%d). \n" "Syntax: fw .", argc-1); } Init(tuiFileName); MainVolume = (my_float*)Alloc_1D(no_links, sizeof(my_float) ); SDVolume = SubVolume = (my_float*)Alloc_1D(no_links, sizeof(my_float) ); /* Compute search direction and sub-volume in the same place. */ MinPathPredLink = (int**)Alloc_2D(no_zones,no_nodes, sizeof(int)); InitFWstatus(&fw_status); FindMinCostRoutes (MinPathPredLink, NULL); Assign (ODflow,MinPathPredLink,MainVolume); FirstFWstatus(MainVolume, &fw_status); UpdateLinkCost(MainVolume); for ( fw_status.Iteration = 1; ContinueFW(fw_status); fw_status.Iteration++) { FindMinCostRoutes (MinPathPredLink, NULL); Assign (ODflow,MinPathPredLink,SubVolume); VolumeDifference( SubVolume, MainVolume, SDVolume); /* Which yields the search direction. */ Lambda = LinksSDLineSearch ( MainVolume, SDVolum
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值