Frank wolfe

时间:2016-06-21 14:08:39
【文件属性】:

文件名称:Frank wolfe

文件大小:32KB

文件格式:ZIP

更新时间:2016-06-21 14:08:39

frank wolfe

求解交通流量分配模型的有效方法 #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, SDVolume ); UpdateFWstatus(MainVolume, SDVolume, &fw_status); UpdateVolume ( MainVolume, SDVolume, Lambda ); UpdateLinkCost (MainVolume); } CloseFWstatus(MainVolume); free(MainVolume); free(SubVolume); Free_2D((void**)MinPathPredLink,no_zones,no_nodes); Close(tuiFileName); StatusMessage("General","The end"); } static void Init(char *tuiFileName){ tuiInit(tuiFileName); InitLinks(); InitODflow(); InitLineSearch(); } static void Close(char *tuiFileName){ StatusMessage("General", "Closing all modules"); tuiClose(tuiFileName); CloseLinks(); CloseODflow(); CloseLineSearch(); } static void InitODflow(void){ char *ODflowFileName; int input_no_zones; double Factor=1.0; struct meta_struct meta_data; tuiGetInputFileName( "OD flow file name", TRUE, &ODflowFileName); StatusMessage("General", "Reading OD flow file '%s'", ODflowFileName); ODflow = Read_ODflow (ODflowFileName, &TotalODflow, &input_no_zones, &meta_data); if(input_no_zones != no_zones) ExitMessage("OD flow file '%s' is for %d zones, and not for %d zones.", ODflowFileName , input_no_zones, no_zones); tuiGetDouble( "OD flow factor", FALSE, &Factor); if(Factor <= 0.0) ExitMessage( "OD flow factor %lf is invalid, if must be positive.", Factor); if(Factor != 1.0) Factor_ODtable (ODflow, (my_float) Factor, no_zones) ; } static void CloseODflow(void){ Free_2D((void **)ODflow, no_zones, no_zones); }


【文件预览】:
Source
----tap()
--------ls_bisect.cpp(2KB)
--------fw.cpp(3KB)
--------mincostroutes.cpp(7KB)
--------links.cpp(15KB)
--------od_table.cpp(10KB)
--------od_flow.cpp(8KB)
--------nodes.cpp(3KB)
--------fw_status.cpp(4KB)
----util()
--------my_list.cpp(8KB)
--------meta.cpp(5KB)
--------tui.cpp(11KB)
--------message_pc.cpp(1KB)
--------md_alloc.cpp(4KB)
--------my_util.cpp(5KB)
Include
----tap()
--------ls_bisect.h(187B)
--------links.h(670B)
--------od_table.h(1KB)
--------link_functions.h(2KB)
--------od_flow.h(660B)
--------nodes.h(73B)
--------fw_status.h(561B)
--------mincostroutes.h(455B)
----util()
--------pc()
--------my_list.h(1KB)
--------os.h(115B)
--------tui.h(549B)
--------unix()
--------my_util.h(820B)
--------md_alloc.h(407B)
--------my_types.h(413B)
--------message.h(278B)
--------meta.h(531B)

网友评论

  • 能用,得仔细看呀呵呵