|
From: subversion c. n. <tra...@li...> - 2017-12-29 21:33:17
|
Revision: 1694
http://sourceforge.net/p/transims/code/1694
Author: davidroden
Date: 2017-12-29 21:33:14 +0000 (Fri, 29 Dec 2017)
Log Message:
-----------
TRANSIMS Version 7.1 -- to AECOM branch 1693
Data_Service
The Write_Plan_Skims method was expanded to create a map file if one was not provided. The Write_Plan_Ptrs method was expanded to write a new plan skims file as well.
PlanPrep 7.1.17
Exporting a plan file to a new format or to a plan skims file will write the output data directly without reading the file into memory if the application is run with a single thread.
PlanSelect 7.1.2
The option was added to write the selected plans to a plan skims file.
PlanSum 7.1.9
The plan skim file will now be written based on the plan pointer sort option at the same time as the plan file is written.
Router 7.1.42
The walk and bike travel time calculations were modified on links with facility types WALKWAY and BIKEWAY. The travel time on these links are pulled directly from the link file rather than calculated based on the link length and the walk or bike speed keys.
ModeChoice 7.1.18
The PLAN_SKIMS_IN_MEMORY key is now available for plan processing without the calibration option. In this case, the plan skims or plan files are read into memory as tour skims and sorted using the trip index. A bug was fixed in the output plan processing when tours were not available for all modes. The new plan skim file can write the tour skim records if a new plan file is not created. Otherwise the plan skim file will include the each leg of the selected tours. The plan skim file will now be written based on the plan pointer sort option at the same time as the plan file is written.
Modified Paths:
--------------
version7/branches/aecom/Transims70/Data_Service/Write_Plan_Skims.cpp
version7/branches/aecom/Transims70/Data_Service/Write_Plans.cpp
version7/branches/aecom/Transims70/Include/Plan_Skim_File.hpp
version7/branches/aecom/Transims70/Include/Trip_Index.hpp
version7/branches/aecom/Transims70/ModeChoice/Choice_Data.cpp
version7/branches/aecom/Transims70/ModeChoice/Choice_Process.cpp
version7/branches/aecom/Transims70/ModeChoice/Control.cpp
version7/branches/aecom/Transims70/ModeChoice/Execute.cpp
version7/branches/aecom/Transims70/ModeChoice/ModeChoice.cpp
version7/branches/aecom/Transims70/ModeChoice/ModeChoice.hpp
version7/branches/aecom/Transims70/ModeChoice/ModeChoice.vcxproj
version7/branches/aecom/Transims70/ModeChoice/ModeChoice.vcxproj.filters
version7/branches/aecom/Transims70/ModeChoice/Mode_Splits.cpp
version7/branches/aecom/Transims70/ModeChoice/Read_Plan_Skims.cpp
version7/branches/aecom/Transims70/ModeChoice/Read_Plans.cpp
version7/branches/aecom/Transims70/ModeChoice/Zone_Tables.cpp
version7/branches/aecom/Transims70/PlanPrep/Control.cpp
version7/branches/aecom/Transims70/PlanPrep/Execute.cpp
version7/branches/aecom/Transims70/PlanPrep/PlanPrep.cpp
version7/branches/aecom/Transims70/PlanPrep/PlanPrep.hpp
version7/branches/aecom/Transims70/PlanPrep/Process_Plan.cpp
version7/branches/aecom/Transims70/PlanPrep/Read_Plans.cpp
version7/branches/aecom/Transims70/PlanSelect/Control.cpp
version7/branches/aecom/Transims70/PlanSelect/PlanSelect.cpp
version7/branches/aecom/Transims70/PlanSelect/PlanSelect.hpp
version7/branches/aecom/Transims70/PlanSelect/Read_Plans.cpp
version7/branches/aecom/Transims70/PlanSum/Execute.cpp
version7/branches/aecom/Transims70/PlanSum/PlanSum.cpp
version7/branches/aecom/Transims70/Router/Router.cpp
version7/branches/aecom/Transims70/Router_Service/Node_Path.cpp
version7/branches/aecom/Transims70/Router_Service/Transit_Access.cpp
Added Paths:
-----------
version7/branches/aecom/Transims70/ModeChoice/Memory_Skims.cpp
version7/branches/aecom/Transims70/ModeChoice/Read_Process.cpp
version7/branches/aecom/Transims70/ModeChoice/Read_Skims.cpp
version7/branches/aecom/Transims70/ModeChoice/Select_Plans.cpp
version7/branches/aecom/Transims70/ModeChoice/Skim_Choice.cpp
Modified: version7/branches/aecom/Transims70/Data_Service/Write_Plan_Skims.cpp
===================================================================
--- version7/branches/aecom/Transims70/Data_Service/Write_Plan_Skims.cpp 2017-12-22 19:06:29 UTC (rev 1693)
+++ version7/branches/aecom/Transims70/Data_Service/Write_Plan_Skims.cpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -19,6 +19,21 @@
Show_Message (String ("Writing %s -- Record") % file->File_Type ());
Set_Progress ();
+ //---- build the map ----
+
+ if (plan_skim_map.size () == 0 && plan_skim_array.size () > 0) {
+ Trip_Index trip_index;
+ Plan_Skim_Itr skim_itr;
+
+ for (count = 0, skim_itr = plan_skim_array.begin (); skim_itr != plan_skim_array.end (); skim_itr++, count++) {
+ skim_itr->Get_Index (trip_index);
+ plan_skim_map.insert (Trip_Map_Data (trip_index, count));
+ }
+ count = 0;
+ }
+
+ //---- write the skim records ----
+
for (itr = plan_skim_map.begin (); itr != plan_skim_map.end (); itr++) {
Show_Progress ();
Modified: version7/branches/aecom/Transims70/Data_Service/Write_Plans.cpp
===================================================================
--- version7/branches/aecom/Transims70/Data_Service/Write_Plans.cpp 2017-12-22 19:06:29 UTC (rev 1693)
+++ version7/branches/aecom/Transims70/Data_Service/Write_Plans.cpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -167,15 +167,27 @@
void Data_Service::Write_Plan_Ptrs (void)
{
- int index;
+ int index, count;
+ bool skim_flag;
Plan_Ptr_Itr plan_itr;
Plan_Ptr plan_ptr;
+ Plan_Skim_Data plan_skim;
+ Plan_Skim_File *new_skim_file;;
Plan_File *new_plan_file = System_Plan_File (true);
Show_Message (String ("Writing %s -- Record") % new_plan_file->File_Type ());
Set_Progress ();
+ skim_flag = System_File_Flag (NEW_PLAN_SKIM);
+ count = 0;
+
+ if (skim_flag) {
+ new_skim_file = System_Plan_Skim_File (true);
+ } else {
+ new_skim_file = 0;
+ }
+
if (new_plan_file->Sort_Type () == TRAVELER_SORT) {
Trip_Index trip_index;
Trip_Map_Itr trip_itr;
@@ -192,6 +204,11 @@
new_plan_file->Write_Plan (*plan_ptr);
+ if (skim_flag) {
+ plan_skim.Put_Data (*plan_ptr);
+
+ count += Put_Plan_Skim_Data (*new_skim_file, plan_skim);
+ }
delete plan_ptr;
}
} else if (new_plan_file->Sort_Type () == TIME_SORT) {
@@ -210,6 +227,11 @@
new_plan_file->Write_Plan (*plan_ptr);
+ if (skim_flag) {
+ plan_skim.Put_Data (*plan_ptr);
+
+ count += Put_Plan_Skim_Data (*new_skim_file, plan_skim);
+ }
delete plan_ptr;
}
} else {
@@ -219,6 +241,11 @@
new_plan_file->Write_Plan (*plan_ptr);
+ if (skim_flag) {
+ plan_skim.Put_Data (*plan_ptr);
+
+ count += Put_Plan_Skim_Data (*new_skim_file, plan_skim);
+ }
delete plan_ptr;
}
}
@@ -226,4 +253,9 @@
new_plan_file->Close ();
new_plan_file->Print_Summary (false, process);
+
+ if (skim_flag) {
+ new_skim_file->Close ();
+ Print (2, String ("%s Records = %d") % new_skim_file->File_Type () % count);
+ }
}
Modified: version7/branches/aecom/Transims70/Include/Plan_Skim_File.hpp
===================================================================
--- version7/branches/aecom/Transims70/Include/Plan_Skim_File.hpp 2017-12-22 19:06:29 UTC (rev 1693)
+++ version7/branches/aecom/Transims70/Include/Plan_Skim_File.hpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -71,6 +71,8 @@
bool Read_Record (int index = 0);
bool Write_Record (int index = 0);
+ int Add_Index (void) { return ((int) data_array.size () + 1); }
+
bool Rewind (void) { return (data_array.Rewind ()); }
Db_Data_Array data_array;
Modified: version7/branches/aecom/Transims70/Include/Trip_Index.hpp
===================================================================
--- version7/branches/aecom/Transims70/Include/Trip_Index.hpp 2017-12-22 19:06:29 UTC (rev 1693)
+++ version7/branches/aecom/Transims70/Include/Trip_Index.hpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -69,4 +69,10 @@
typedef vector <Trip_Index> Trip_Index_Array;
typedef Trip_Index_Array::iterator Trip_Index_Itr;
+typedef vector <Trip_Map> Trip_Map_Array;
+typedef Trip_Map_Array::iterator Trip_Map_Array_Itr;
+
+typedef vector <Trip_Map_Itr> Trip_Map_Itr_Array;
+typedef Trip_Map_Itr_Array::iterator Trip_Map_Itr_Array_Itr;
+
#endif
Modified: version7/branches/aecom/Transims70/ModeChoice/Choice_Data.cpp
===================================================================
--- version7/branches/aecom/Transims70/ModeChoice/Choice_Data.cpp 2017-12-22 19:06:29 UTC (rev 1693)
+++ version7/branches/aecom/Transims70/ModeChoice/Choice_Data.cpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -16,14 +16,23 @@
Plan_Skim_File_Ptr skim_ptr;
Int_Map_Itr map_itr;
Split_Data split_data;
+ Plan_Array tour;
//---- set the plan skim records ----
+ if (thread_flag && !plan_skim_flag) {
+ split_data.plan_tours.assign (index_array.size (), tour);
+ }
+
for (i = 0, index_itr = index_array.begin (); index_itr != index_array.end (); index_itr++, i++) {
skim_ptr = plan_skims [i];
if (*index_itr == trip_index) {
skim_ptr->Record (index_skims [i]->Record ());
+
+ if (thread_flag && !plan_skim_flag) {
+ split_data.plan_tours [i] = plan_tours [i];
+ }
} else {
skim_ptr->Reset_Record ();
}
@@ -35,9 +44,6 @@
//---- copy the plans ----
if (thread_flag) {
- if (!plan_skim_flag) {
- split_data.plan_tours = plan_tours;
- }
split_queue.Put (split_data);
} else {
(*choice_process)->Mode_Splits (split_data);
Modified: version7/branches/aecom/Transims70/ModeChoice/Choice_Process.cpp
===================================================================
--- version7/branches/aecom/Transims70/ModeChoice/Choice_Process.cpp 2017-12-22 19:06:29 UTC (rev 1693)
+++ version7/branches/aecom/Transims70/ModeChoice/Choice_Process.cpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -216,9 +216,16 @@
}
}
- if (exe->plan_flag) {
- if (!exe->plan_skim_flag) {
- exe->plan_ptr_array.insert (exe->plan_ptr_array.end (), plan_ptr_array.begin (), plan_ptr_array.end ());
+ if (exe->new_plan_flag) {
+ exe->plan_ptr_array.insert (exe->plan_ptr_array.end (), plan_ptr_array.begin (), plan_ptr_array.end ());
+ } else if (exe->new_skim_flag) {
+ exe->plan_skim_array.insert (exe->plan_skim_array.end (), new_skim_array.begin (), new_skim_array.end ());
+ }
+ if (exe->new_plan_flag && exe->skim_memory_flag) {
+ Trip_Map_Itr itr;
+
+ for (itr = trip_mode.begin (); itr != trip_mode.end (); itr++) {
+ exe->trip_mode.insert (*itr);
}
}
}
Modified: version7/branches/aecom/Transims70/ModeChoice/Control.cpp
===================================================================
--- version7/branches/aecom/Transims70/ModeChoice/Control.cpp 2017-12-22 19:06:29 UTC (rev 1693)
+++ version7/branches/aecom/Transims70/ModeChoice/Control.cpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -27,7 +27,9 @@
Integer_List int_list;
Plan_File_Ptr file;
Plan_Skim_File_Ptr skim_ptr;
+ Plan_Skim_File_Itr skim_itr;
Plan_Skim_Data_Ptr data_ptr;
+ Trip_Map skim_map;
Int_Itr int_itr;
Converge_Service::Program_Control ();
@@ -1009,9 +1011,7 @@
skim_memory_flag = Get_Control_Flag (PLAN_SKIMS_IN_MEMORY);
if (skim_memory_flag) {
- Plan_Skim_File_Itr itr;
-
- for (itr = plan_skims.begin (); itr != plan_skims.end (); itr++) {
+ for (skim_itr = plan_skims.begin (); skim_itr != plan_skims.end (); skim_itr++) {
data_ptr = new Plan_Skim_Data_Array;
data_ptr->Plan_Skim_File::File_Access (MODIFY);
@@ -1019,6 +1019,7 @@
data_ptr->Plan_Skim_File::Create_Fields ();
plan_skim_arrays.push_back (data_ptr);
+ skim_index_array.push_back (skim_map);
}
}
}
@@ -1062,8 +1063,28 @@
data_file.Create (Project_Filename (key));
data_flag = true;
}
+ } else {
+
+ //---- plan skims in memory -----
+
+ if (plan_flag) {
+ skim_memory_flag = Get_Control_Flag (PLAN_SKIMS_IN_MEMORY);
+
+ if (skim_memory_flag) {
+ for (skim_itr = plan_skims.begin (); skim_itr != plan_skims.end (); skim_itr++) {
+ data_ptr = new Plan_Skim_Data_Array;
+
+ data_ptr->Plan_Skim_File::File_Access (MODIFY);
+ data_ptr->Plan_Skim_File::File_Format (BINARY);
+ data_ptr->Plan_Skim_File::Create_Fields ();
+
+ plan_skim_arrays.push_back (data_ptr);
+ skim_index_array.push_back (skim_map);
+ }
+ }
+ }
}
-
+
//---- create the new choice detail file ----
#ifdef DUMP_DATA
Modified: version7/branches/aecom/Transims70/ModeChoice/Execute.cpp
===================================================================
--- version7/branches/aecom/Transims70/ModeChoice/Execute.cpp 2017-12-22 19:06:29 UTC (rev 1693)
+++ version7/branches/aecom/Transims70/ModeChoice/Execute.cpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -104,13 +104,19 @@
}
}
+ thread_flag = (Num_Threads () > 1);
+
+ //---- read skims into memory ----
+
+ if (skim_memory_flag) {
+ Read_Skims ();
+ }
+
//---- choice processing threads ----
Show_Message ("Creating Choice Processor =");
Set_Progress ();
- thread_flag = (Num_Threads () > 1);
-
choice_process = new Choice_Process * [Num_Threads ()];
if (thread_flag) {
@@ -143,7 +149,9 @@
save_summit_flag = (save_flag && summit_flag);
save_access_flag = ((save_flag || iter_save_flag) && access_flag);
- if (plan_skim_flag) {
+ if (skim_memory_flag) {
+ Skim_Choice ();
+ } else if (plan_skim_flag) {
Read_Plan_Skims ();
} else if (plan_flag) {
if (System_File_Flag (NEW_PARK_DEMAND)) {
@@ -154,6 +162,15 @@
Zone_Tables ();
}
+ if (thread_flag) {
+ for (i = 0; i < Num_Threads (); i++) {
+ choice_process [i]->Sum_Totals ();
+ }
+ if (skim_memory_flag && new_plan_flag) {
+ Select_Plans ();
+ }
+ }
+
//---- calibrate the constants ----
if (calib_flag) {
@@ -169,8 +186,12 @@
//---- update the parking penalties ----
if (penalty_update_flag) {
+ bool qflag = Quiet ();
+ Quiet (true);
Update_Parking_Penalties (false);
+ Quiet (qflag);
}
+
if (save_flag) break;
if (iter_save_flag) {
@@ -269,10 +290,14 @@
Write_Park_Demand ();
}
- //---- write plans ----
+ //---- write plans and skims ----
- if (thread_flag && new_plan_flag) {
- Write_Plan_Ptrs ();
+ if (thread_flag) {
+ if (new_plan_flag) {
+ Write_Plan_Ptrs ();
+ } else if (new_skim_flag) {
+ Write_Plan_Skims ();
+ }
}
//---- close the choice detail file ----
Added: version7/branches/aecom/Transims70/ModeChoice/Memory_Skims.cpp
===================================================================
--- version7/branches/aecom/Transims70/ModeChoice/Memory_Skims.cpp (rev 0)
+++ version7/branches/aecom/Transims70/ModeChoice/Memory_Skims.cpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -0,0 +1,90 @@
+//*********************************************************
+// Memory_Skims.cpp - read the skims into memory
+//*********************************************************
+
+#include "ModeChoice.hpp"
+
+//---------------------------------------------------------
+// Memory_Skims
+//---------------------------------------------------------
+
+void ModeChoice::Read_Process::Memory_Skims (int i)
+{
+ int index;
+ bool msg_flag;
+
+ Trip_Index trip_index, tour_index;
+ Trip_Map_Itr trip_itr;
+ Plan_Data plan_data;
+ Plan_Skim_Data data;
+
+ Plan_File *plan_file;
+ Plan_Skim_File *plan_skim_file;
+ Plan_Skim_Data_Ptr plan_skim;
+ Trip_Map *skim_index;
+
+ skim_index = &exe->skim_index_array [i];
+ plan_skim = exe->plan_skim_arrays [i];
+
+ msg_flag = (i == 0 || !exe->thread_flag);
+
+ if (exe->plan_skim_flag) {
+ plan_skim_file = exe->plan_skim_files [i];
+
+ while (plan_skim_file->Read_Record ()) {
+ if (msg_flag) exe->Show_Progress ();
+
+ plan_skim_file->Get_Index (trip_index);
+
+ //---- check for a tour leg ----
+
+ if (exe->tour_choice_flag && trip_index.Trip () > 1) {
+ tour_index = trip_index;
+ tour_index.Trip (1);
+
+ trip_itr = skim_index->find (tour_index);
+
+ if (trip_itr != skim_index->end ()) {
+ plan_skim->Read_Record (trip_itr->second);
+ plan_skim->Add_Leg (plan_skim_file->Get_Data (data));
+ plan_skim->Write_Record (trip_itr->second);
+ continue;
+ }
+ }
+ index = plan_skim->Add_Index ();
+
+ skim_index->insert (Trip_Map_Data (trip_index, index));
+
+ plan_skim->Put_Data (plan_skim_file->Get_Data (data));
+ plan_skim->Write_Record ();
+ }
+ } else {
+ plan_file = exe->plan_files [i];
+
+ while (plan_file->Read_Plan (plan_data)) {
+ if (msg_flag) exe->Show_Progress ();
+
+ plan_data.Get_Index (trip_index);
+
+ if (exe->tour_choice_flag && trip_index.Trip () > 1) {
+ tour_index = trip_index;
+ tour_index.Trip (1);
+
+ trip_itr = skim_index->find (tour_index);
+
+ if (trip_itr != skim_index->end ()) {
+ plan_skim->Read_Record (trip_itr->second);
+ plan_skim->Add_Leg (plan_data);
+ plan_skim->Write_Record (trip_itr->second);
+ continue;
+ }
+ }
+ index = plan_skim->Add_Index ();
+
+ skim_index->insert (Trip_Map_Data (trip_index, index));
+
+ plan_skim->Put_Data (plan_data);
+ plan_skim->Write_Record ();
+ }
+ }
+}
Modified: version7/branches/aecom/Transims70/ModeChoice/ModeChoice.cpp
===================================================================
--- version7/branches/aecom/Transims70/ModeChoice/ModeChoice.cpp 2017-12-22 19:06:29 UTC (rev 1693)
+++ version7/branches/aecom/Transims70/ModeChoice/ModeChoice.cpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -11,7 +11,7 @@
ModeChoice::ModeChoice (void) : Converge_Service ()
{
Program ("ModeChoice");
- Version (16);
+ Version (18);
Title ("Mode Choice Processing");
System_File_Type required_files[] = {
Modified: version7/branches/aecom/Transims70/ModeChoice/ModeChoice.hpp
===================================================================
--- version7/branches/aecom/Transims70/ModeChoice/ModeChoice.hpp 2017-12-22 19:06:29 UTC (rev 1693)
+++ version7/branches/aecom/Transims70/ModeChoice/ModeChoice.hpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -113,6 +113,9 @@
Plan_Skim_File *new_plan_skim;
Plan_Skim_Data_Arrays plan_skim_arrays;
+ Trip_Map_Array skim_index_array;
+ Trip_Map trip_mode;
+
Db_Header segment_file, target_file, constant_file, calib_file, prod_file, attr_file, bias_file;
Db_File script_file, summary_file, market_file, data_file, mode_seg_file;
#ifdef DUMP_DATA
@@ -156,11 +159,14 @@
void Segment_Map (void);
void Read_Targets (void);
void Target_Header (void);
+ void Read_Skims (void);
+ void Skim_Choice (void);
void Read_Plans (void);
bool Transit_Crowding (Plan_Ptr plan_ptr);
void Read_Plan_Skims (void);
void Choice_Data (Trip_Index trip_index);
void Zone_Tables (void);
+ void Select_Plans (void);
bool Adjust_Constants (void);
void Calib_Header (void);
void Mode_Summary (int segment = 0);
@@ -190,11 +196,34 @@
typedef Bounded_Queue <Split_Data> Split_Queue;
Split_Queue split_queue;
+
+ typedef Bounded_Queue <int> Skim_Number;
+
+ Skim_Number skim_number;
bool thread_flag;
Threads threads;
//---------------------------------------------------------
+ // Read_Process - read skim files
+ //---------------------------------------------------------
+
+ class Read_Process
+ {
+ public:
+ Read_Process (ModeChoice *_exe);
+
+ void operator()();
+
+ void Memory_Skims (int i);
+
+ private:
+ ModeChoice *exe;
+ };
+
+ Read_Process **read_process;
+
+ //---------------------------------------------------------
// Choice_Process - mode split processings
//---------------------------------------------------------
@@ -235,8 +264,10 @@
Dbls_Array values;
Doubles mode_sum;
Integers mode_plan;
+ Trip_Map trip_mode;
Plan_Ptr_Array plan_ptr_array;
+ Plan_Skim_Array new_skim_array;
};
Choice_Process **choice_process;
Modified: version7/branches/aecom/Transims70/ModeChoice/ModeChoice.vcxproj
===================================================================
--- version7/branches/aecom/Transims70/ModeChoice/ModeChoice.vcxproj 2017-12-22 19:06:29 UTC (rev 1693)
+++ version7/branches/aecom/Transims70/ModeChoice/ModeChoice.vcxproj 2017-12-29 21:33:14 UTC (rev 1694)
@@ -169,6 +169,7 @@
<ClCompile Include="Crowding.cpp" />
<ClCompile Include="Execute.cpp" />
<ClCompile Include="Get_Zone_Data.cpp" />
+ <ClCompile Include="Memory_Skims.cpp" />
<ClCompile Include="ModeChoice.cpp" />
<ClCompile Include="Mode_Splits.cpp" />
<ClCompile Include="Mode_Summary.cpp" />
@@ -176,9 +177,13 @@
<ClCompile Include="Read_Mode_Bias.cpp" />
<ClCompile Include="Read_Plans.cpp" />
<ClCompile Include="Read_Plan_Skims.cpp" />
+ <ClCompile Include="Read_Process.cpp" />
+ <ClCompile Include="Read_Skims.cpp" />
<ClCompile Include="Read_Targets.cpp" />
<ClCompile Include="Run_Model.cpp" />
<ClCompile Include="Segment_Map.cpp" />
+ <ClCompile Include="Select_Plans.cpp" />
+ <ClCompile Include="Skim_Choice.cpp" />
<ClCompile Include="Value_Summary.cpp" />
<ClCompile Include="Write_Market.cpp" />
<ClCompile Include="Write_Mode_Seg.cpp" />
Modified: version7/branches/aecom/Transims70/ModeChoice/ModeChoice.vcxproj.filters
===================================================================
--- version7/branches/aecom/Transims70/ModeChoice/ModeChoice.vcxproj.filters 2017-12-22 19:06:29 UTC (rev 1693)
+++ version7/branches/aecom/Transims70/ModeChoice/ModeChoice.vcxproj.filters 2017-12-29 21:33:14 UTC (rev 1694)
@@ -94,5 +94,20 @@
<ClCompile Include="Crowding.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="Memory_Skims.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Read_Process.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Read_Skims.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Skim_Choice.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Select_Plans.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
Modified: version7/branches/aecom/Transims70/ModeChoice/Mode_Splits.cpp
===================================================================
--- version7/branches/aecom/Transims70/ModeChoice/Mode_Splits.cpp 2017-12-22 19:06:29 UTC (rev 1693)
+++ version7/branches/aecom/Transims70/ModeChoice/Mode_Splits.cpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -28,6 +28,7 @@
Plan_Itr plan_itr;
Plan_Ptr plan_ptr;
Trip_Index trip_index;
+ Plan_Skim_Data skim;
Plan_Skim_File_Itr skim_itr;
Plan_Skim_File_Ptr skim_ptr;
@@ -176,6 +177,7 @@
#endif
for (i = 0; i < exe->num_modes; i++) {
sum = mode_sum [i];
+
if (sum > zero_sum) {
utility [i] = exp (sum);
#ifdef DUMP_DATA
@@ -297,146 +299,161 @@
num = -1;
for (i = 0; i < exe->num_modes; i++) {
- if (exe->mode_nested [i] < 0 && utility [i] > 0) {
- sum += utility [i] * value;
+ if (exe->mode_nested [i] >= 0 || utility [i] <= 0) continue;
+ sum += utility [i] * value;
- //---- save the choice ----
+ if (prob > sum) continue;
- if (prob <= sum) {
+ //---- save the choice ----
- #ifdef DUMP_DATA
- if (exe->dump_flag) {
- exe->dump_file.File () << (String ("\nselect mode=%d plan=%d") % i % mode_plan [i]);
+ #ifdef DUMP_DATA
+ if (exe->dump_flag) {
+ exe->dump_file.File () << (String ("\nselect mode=%d plan=%d") % i % mode_plan [i]);
+ }
+ #endif
+ map_itr = exe->plan_num_map.find (mode_plan [i]);
+ if (map_itr == exe->plan_num_map.end ()) break;
+
+ num = map_itr->second;
+
+ trips = plan_skims->at (num)->Get_Integer (exe->num_legs_field);
+
+ if (exe->sum_flag) {
+ for (j = 0; j <= exe->const_field; j++) {
+ dvalue = values [i] [j] * trips;
+
+ if (exe->mode_value_flag) {
+ (*value_sum_ptr) [0] [i] [j] += dvalue;
}
- #endif
- map_itr = exe->plan_num_map.find (mode_plan [i]);
- if (map_itr == exe->plan_num_map.end ()) break;
+ if (exe->seg_value_flag) {
+ (*value_sum_ptr) [segment] [i] [j] += dvalue;
+ }
+ }
+ }
+ if (exe->summary_flag) {
+ (*market_seg_ptr) [0] [i] [model] += trips;
+ (*market_seg_ptr) [0] [i] [exe->num_models] += trips;
+ (*market_seg_ptr) [0] [exe->num_modes] [model] += trips;
+ (*market_seg_ptr) [0] [exe->num_modes] [exe->num_models] += trips;
+ }
+ if (exe->market_flag && segment > 0) {
+ (*market_seg_ptr) [segment] [i] [model] += trips;
+ (*market_seg_ptr) [segment] [i] [exe->num_models] += trips;
+ (*market_seg_ptr) [segment] [exe->num_modes] [model] += trips;
+ (*market_seg_ptr) [segment] [exe->num_modes] [exe->num_models] += trips;
+ }
+ if (exe->prod_sum_flag) {
+ (*prod_share_ptr) [i] [o1] += trips;
+ (*prod_share_ptr) [exe->num_modes] [o1] += trips;
+ }
+ if (exe->attr_sum_flag) {
+ (*attr_share_ptr) [i] [d1] += trips;
+ (*attr_share_ptr) [exe->num_modes] [d1] += trips;
+ }
- num = map_itr->second;
+ //---- identified nested models ----
- trips = plan_skims->at (num)->Get_Integer (exe->num_legs_field);
+ mode = i;
- if (exe->sum_flag) {
- for (j = 0; j <= exe->const_field; j++) {
- dvalue = values [i] [j] * trips;
+ for (n = exe->num_nests - 1; n >= 0; n--) {
+ nest = -1;
+ nest_ptr = &exe->nested_modes [n];
- if (exe->mode_value_flag) {
- (*value_sum_ptr) [0] [i] [j] += dvalue;
- }
- if (exe->seg_value_flag) {
- (*value_sum_ptr) [segment] [i] [j] += dvalue;
- }
- }
+ for (mode_itr = nest_ptr->begin (); mode_itr != nest_ptr->end (); mode_itr++) {
+ if (*mode_itr == mode) {
+ nest = exe->nest_mode [n];
+ break;
}
+ }
+
+ if (nest >= 0) {
if (exe->summary_flag) {
- (*market_seg_ptr) [0] [i] [model] += trips;
- (*market_seg_ptr) [0] [i] [exe->num_models] += trips;
- (*market_seg_ptr) [0] [exe->num_modes] [model] += trips;
- (*market_seg_ptr) [0] [exe->num_modes] [exe->num_models] += trips;
+ (*market_seg_ptr) [0] [nest] [model] += trips;
+ (*market_seg_ptr) [0] [nest] [exe->num_models] += trips;
}
if (exe->market_flag && segment > 0) {
- (*market_seg_ptr) [segment] [i] [model] += trips;
- (*market_seg_ptr) [segment] [i] [exe->num_models] += trips;
- (*market_seg_ptr) [segment] [exe->num_modes] [model] += trips;
- (*market_seg_ptr) [segment] [exe->num_modes] [exe->num_models] += trips;
+ (*market_seg_ptr) [segment] [nest] [model] += trips;
+ (*market_seg_ptr) [segment] [nest] [exe->num_models] += trips;
}
if (exe->prod_sum_flag) {
- (*prod_share_ptr) [i] [o1] += trips;
- (*prod_share_ptr) [exe->num_modes] [o1] += trips;
+ (*prod_share_ptr) [nest] [o1] += trips;
}
if (exe->attr_sum_flag) {
- (*attr_share_ptr) [i] [d1] += trips;
- (*attr_share_ptr) [exe->num_modes] [d1] += trips;
+ (*attr_share_ptr) [nest] [d1] += trips;
}
+ mode = nest;
+ }
+ }
- //---- identified nested models ----
+ //---- save the plan ----
- mode = i;
+ if (exe->save_flag) {
- for (n = exe->num_nests - 1; n >= 0; n--) {
- nest = -1;
- nest_ptr = &exe->nested_modes [n];
-
- for (mode_itr = nest_ptr->begin (); mode_itr != nest_ptr->end (); mode_itr++) {
- if (*mode_itr == mode) {
- nest = exe->nest_mode [n];
- break;
- }
+ if (exe->new_plan_flag) {
+ if (exe->skim_memory_flag) {
+ if (exe->thread_flag) {
+ trip_mode.insert (Trip_Map_Data (trip_index, num));
+ } else {
+ exe->trip_mode.insert (Trip_Map_Data (trip_index, num));
}
-
- if (nest >= 0) {
- if (exe->summary_flag) {
- (*market_seg_ptr) [0] [nest] [model] += trips;
- (*market_seg_ptr) [0] [nest] [exe->num_models] += trips;
- }
- if (exe->market_flag && segment > 0) {
- (*market_seg_ptr) [segment] [nest] [model] += trips;
- (*market_seg_ptr) [segment] [nest] [exe->num_models] += trips;
- }
- if (exe->prod_sum_flag) {
- (*prod_share_ptr) [nest] [o1] += trips;
- }
- if (exe->attr_sum_flag) {
- (*attr_share_ptr) [nest] [d1] += trips;
- }
- mode = nest;
- }
+ break;
}
+ if (exe->thread_flag) {
+ plan_tour_ptr = &split_data.plan_tours [num];
+ } else {
+ plan_tour_ptr = &exe->plan_tours [num];
+ }
+ mode = -1;
- //---- save the plan ----
+ for (plan_itr = plan_tour_ptr->begin (); plan_itr != plan_tour_ptr->end (); plan_itr++) {
+ if (exe->auto_occ_flag && plan_itr->Mode () >= HOV2_MODE && plan_itr->Mode () <= HOV4_MODE) {
+ if (mode < 0) {
+ prob = Random (seed + 1).Probability ();
+ Veh_Type_Data *veh_type_ptr = &exe->veh_type_array [plan_itr->Veh_Type ()];
+ mode = plan_itr->Mode ();
- if (exe->save_flag) {
- if (exe->new_skim_flag && !exe->thread_flag) {
- Plan_Skim_Data skim;
- exe->new_plan_skim->Put_Data (exe->plan_skims [num]->Get_Data (skim));
- if (!exe->new_plan_skim->Write ()) {
- exe->Error ("Writing New Plan Skim File");
+ if (veh_type_ptr->Occupancy () > 0) {
+ prob *= veh_type_ptr->Occupancy () / 100.0;
+ if (prob > 1.0) {
+ mode = RIDE_MODE;
+ }
+ }
}
+ plan_itr->Mode (mode);
+ if (mode == RIDE_MODE) {
+ plan_itr->Vehicle (-1);
+ plan_itr->Veh_Type (0);
+ }
+ } else if (exe->rider_flag && plan_itr->Transit_Mode_Flag ()) { //******************//
+ exe->line_array.Sum_Riders (*plan_itr);
}
- if (exe->new_plan_flag) {
- if (exe->thread_flag) {
- plan_tour_ptr = &split_data.plan_tours [num];
- } else {
- plan_tour_ptr = &exe->plan_tours [num];
- }
+ if (exe->thread_flag) {
+ plan_ptr = new Plan_Data (*plan_itr);
- mode = -1;
+ plan_ptr_array.push_back (plan_ptr);
+ } else {
+ exe->new_plan_file->Write_Plan (*plan_itr);
- for (plan_itr = plan_tour_ptr->begin (); plan_itr != plan_tour_ptr->end (); plan_itr++) {
- if (exe->auto_occ_flag && plan_itr->Mode () >= HOV2_MODE && plan_itr->Mode () <= HOV4_MODE) {
- if (mode < 0) {
- prob = Random (seed + 1).Probability ();
- Veh_Type_Data *veh_type_ptr = &exe->veh_type_array [plan_itr->Veh_Type ()];
- mode = plan_itr->Mode ();
+ if (exe->new_skim_flag) {
+ skim.Put_Data (*plan_itr);
- if (veh_type_ptr->Occupancy () > 0) {
- prob *= veh_type_ptr->Occupancy () / 100.0;
- if (prob > 1.0) {
- mode = RIDE_MODE;
- }
- }
- }
- plan_itr->Mode (mode);
- if (mode == RIDE_MODE) {
- plan_itr->Vehicle (-1);
- plan_itr->Veh_Type (0);
- }
- } else if (exe->rider_flag && plan_itr->Transit_Mode_Flag ()) { //******************//
- exe->line_array.Sum_Riders (*plan_itr);
- }
- if (exe->thread_flag) {
- plan_ptr = new Plan_Data (*plan_itr);
-
- plan_ptr_array.push_back (plan_ptr);
- } else {
- exe->new_plan_file->Write_Plan (*plan_itr);
- }
+ exe->Put_Plan_Skim_Data (*exe->new_plan_skim, skim);
}
}
}
- break;
+ } else if (exe->new_skim_flag) {
+ if (exe->thread_flag) {
+ new_skim_array.push_back (plan_skims->at (num)->Get_Data (skim));
+ } else {
+ exe->new_plan_skim->Put_Data (exe->plan_skims [num]->Get_Data (skim));
+
+ if (!exe->new_plan_skim->Write ()) {
+ exe->Error ("Writing New Plan Skim File");
+ }
+ }
}
}
+ break;
}
}
Modified: version7/branches/aecom/Transims70/ModeChoice/Read_Plan_Skims.cpp
===================================================================
--- version7/branches/aecom/Transims70/ModeChoice/Read_Plan_Skims.cpp 2017-12-22 19:06:29 UTC (rev 1693)
+++ version7/branches/aecom/Transims70/ModeChoice/Read_Plan_Skims.cpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -15,29 +15,25 @@
Trip_Index trip_index, min_index;
Trip_Index_Array read_index;
Trip_Index_Itr index_itr;
+ Trip_Map_Itr map_itr;
+ Trip_Map_Itr_Array map_itr_array;
+ Trip_Map_Itr_Array_Itr map_array_itr;
+ Trip_Map_Array_Itr trip_map_itr;
Plan_Skim_File_Itr skim_itr;
- Plan_Skim_Data_Itr data_itr;
+ Plan_Skim_Sort_Itr data_itr;
Plan_Skim_Data data;
- memory_flag = false;
park_cap_flag = ((System_File_Flag (NEW_PARK_DEMAND) && save_flag) || penalty_update_flag);
if (calib_flag) {
- if (save_flag && new_skim_flag) {
+ if (save_flag && new_skim_flag && !thread_flag) {
Show_Message (String ("Iteration %d Writing Plan Skims -- Record") % iteration);
} else {
Show_Message (String ("Iteration %d Reading Plan Skims -- Record") % iteration);
}
if (iteration > 1) {
- if (skim_memory_flag) {
- memory_flag = true;
- for (data_itr = plan_skim_arrays.begin (); data_itr != plan_skim_arrays.end (); data_itr++) {
- (*data_itr)->Rewind ();
- }
- } else {
- for (skim_itr = plan_skim_files.begin (); skim_itr != plan_skim_files.end (); skim_itr++) {
- (*skim_itr)->Rewind ();
- }
+ for (skim_itr = plan_skim_files.begin (); skim_itr != plan_skim_files.end (); skim_itr++) {
+ (*skim_itr)->Rewind ();
}
}
//---- clear the parking demand ----
@@ -60,9 +56,10 @@
i = (int) plan_skims.size ();
index_array.assign (i, trip_index);
read_index.assign (i, trip_index);
+
+ //---- process each trip ----
while (trip_index.Household () < MAX_INTEGER) {
- Show_Progress ();
//---- read the next ----
@@ -71,51 +68,38 @@
for (i = 0, index_itr = index_array.begin (); index_itr != index_array.end (); index_itr++, i++) {
if (*index_itr <= trip_index) {
- if (memory_flag) {
- if (plan_skim_arrays [i]->Read_Record ()) {
- index_skims [i]->Record (plan_skim_arrays [i]->Record ());
- index_skims [i]->Get_Index (*index_itr);
+ if (read_index [i].Household () == 0) {
+ if (plan_skim_files [i]->Read_Record ()) {
+ plan_skim_files [i]->Get_Index (read_index [i]);
} else {
- index_itr->Household (MAX_INTEGER);
+ read_index [i].Household (MAX_INTEGER);
}
- } else {
- if (read_index [i].Household () == 0) {
- if (plan_skim_files [i]->Read_Record ()) {
- plan_skim_files [i]->Get_Index (read_index [i]);
- } else {
- read_index [i].Household (MAX_INTEGER);
- }
- }
- *index_itr = read_index [i];
- if (read_index [i].Household () == MAX_INTEGER) continue;
+ }
+ *index_itr = read_index [i];
+ if (read_index [i].Household () == MAX_INTEGER) continue;
- index_skims [i]->Put_Data (plan_skim_files [i]->Get_Data (data));
+ index_skims [i]->Put_Data (plan_skim_files [i]->Get_Data (data));
- if (plan_skim_files [i]->Read_Record ()) {
- plan_skim_files [i]->Get_Index (read_index [i]);
+ if (plan_skim_files [i]->Read_Record ()) {
+ plan_skim_files [i]->Get_Index (read_index [i]);
- if (tour_choice_flag) {
- while (read_index [i].Household () < MAX_INTEGER) {
- if (read_index [i].Household () != index_itr->Household () || read_index [i].Person () != index_itr->Person () ||
- read_index [i].Tour () != index_itr->Tour ()) {
- break;
- }
- index_skims [i]->Add_Leg (plan_skim_files [i]->Get_Data (data));
+ if (tour_choice_flag) {
+ while (read_index [i].Household () < MAX_INTEGER) {
+ if (read_index [i].Household () != index_itr->Household () || read_index [i].Person () != index_itr->Person () ||
+ read_index [i].Tour () != index_itr->Tour ()) {
+ break;
+ }
+ index_skims [i]->Add_Leg (plan_skim_files [i]->Get_Data (data));
- if (plan_skim_files [i]->Read_Record ()) {
- plan_skim_files [i]->Get_Index (read_index [i]);
- } else {
- read_index [i].Household (MAX_INTEGER);
- }
+ if (plan_skim_files [i]->Read_Record ()) {
+ plan_skim_files [i]->Get_Index (read_index [i]);
+ } else {
+ read_index [i].Household (MAX_INTEGER);
}
}
- } else {
- read_index [i].Household (MAX_INTEGER);
}
- if (skim_memory_flag) {
- plan_skim_arrays [i]->Record (index_skims [i]->Record ());
- plan_skim_arrays [i]->Write_Record ();
- }
+ } else {
+ read_index [i].Household (MAX_INTEGER);
}
}
if (*index_itr < min_index) {
@@ -124,7 +108,14 @@
}
if (min_index.Household () == MAX_INTEGER) break;
+ //---- check for an incomplete tour ----
+
+ if (min_index.Household () == trip_index.Household () && min_index.Person () == trip_index.Person () && min_index.Tour () == trip_index.Tour ()) {
+ trip_index = min_index;
+ continue;
+ }
trip_index = min_index;
+ Show_Progress ();
//---- mode choice ----
@@ -132,10 +123,6 @@
}
if (thread_flag) {
split_queue.Complete_Work ();
-
- for (i = 0; i < Num_Threads (); i++) {
- choice_process [i]->Sum_Totals ();
- }
}
if (calib_flag) {
End_Progress (false);
Modified: version7/branches/aecom/Transims70/ModeChoice/Read_Plans.cpp
===================================================================
--- version7/branches/aecom/Transims70/ModeChoice/Read_Plans.cpp 2017-12-22 19:06:29 UTC (rev 1693)
+++ version7/branches/aecom/Transims70/ModeChoice/Read_Plans.cpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -16,8 +16,11 @@
Trip_Index trip_index, min_index;
Trip_Index_Array read_index;
Trip_Index_Itr index_itr;
+ Trip_Map_Itr map_itr;
+ Trip_Map_Itr_Array map_itr_array;
+ Trip_Map_Itr_Array_Itr map_array_itr;
+ Trip_Map_Array_Itr trip_map_itr;
Plan_File_Itr plan_itr;
- Plan_Skim_Data_Itr data_itr;
Plan_Data plan_data;
Plan_Ptr plan_ptr;
Plan_Array mode_plans, tour;
@@ -24,25 +27,15 @@
park_cap_flag = ((System_File_Flag (NEW_PARK_DEMAND) && save_flag) || penalty_update_flag);
- memory_flag = false;
-
if (calib_flag) {
- if (save_flag && new_plan_flag) {
+ if (save_flag && new_plan_flag && !thread_flag) {
Show_Message (String ("Iteration %d Writing Plans -- Record") % iteration);
- skim_memory_flag = false;
} else {
Show_Message (String ("Iteration %d Reading Plans -- Record") % iteration);
}
if (iteration > 1) {
- if (skim_memory_flag) {
- memory_flag = true;
- for (data_itr = plan_skim_arrays.begin (); data_itr != plan_skim_arrays.end (); data_itr++) {
- (*data_itr)->Rewind ();
- }
- } else {
- for (plan_itr = plan_files.begin (); plan_itr != plan_files.end (); plan_itr++) {
- (*plan_itr)->Rewind ();
- }
+ for (plan_itr = plan_files.begin (); plan_itr != plan_files.end (); plan_itr++) {
+ (*plan_itr)->Rewind ();
}
//---- clear the ridership and parking demand ----
@@ -72,97 +65,74 @@
read_index.assign (num, trip_index);
mode_plans.assign (num, plan_data);
-
+ plan_tours.assign (num, tour);
+
while (trip_index.Household () < MAX_INTEGER) {
- Show_Progress ();
//---- read the next ----
min_index.Household (MAX_INTEGER);
- if (!plan_skim_flag) {
- plan_tours.assign (num, tour);
- }
for (i = 0, index_itr = index_array.begin (); index_itr != index_array.end (); index_itr++, i++) {
if (*index_itr <= trip_index) {
- if (memory_flag) {
- if (plan_skim_arrays [i]->Read_Record ()) {
- index_skims [i]->Record (plan_skim_arrays [i]->Record ());
- index_skims [i]->Get_Index (*index_itr);
+ plan_ptr = &mode_plans [i];
+
+ if (read_index [i].Household () == 0) {
+ if (plan_files [i]->Read_Plan (*plan_ptr)) {
+ plan_ptr->Get_Index (read_index [i]);
} else {
- (*index_itr).Household (MAX_INTEGER);
+ read_index [i].Household (MAX_INTEGER);
}
+ }
+ *index_itr = read_index [i];
+ if (read_index [i].Household () == MAX_INTEGER) continue;
+
+ if (plan_ptr->Transit_Mode_Flag () && System_File_Flag (RIDERSHIP)) {
+ crowd_flag = Transit_Crowding (plan_ptr);
} else {
- plan_ptr = &mode_plans [i];
+ crowd_flag = false;
+ }
+ index_skims [i]->Put_Data (*plan_ptr);
- if (read_index [i].Household () == 0) {
- if (plan_files [i]->Read_Plan (*plan_ptr)) {
- plan_ptr->Get_Index (read_index [i]);
- } else {
- read_index [i].Household (MAX_INTEGER);
- }
- }
- *index_itr = read_index [i];
- if (read_index [i].Household () == MAX_INTEGER) continue;
+ plan_tours [i].assign (1, *plan_ptr);
- if (plan_ptr->Transit_Mode_Flag () && System_File_Flag (RIDERSHIP)) {
- crowd_flag = Transit_Crowding (plan_ptr);
- } else {
- crowd_flag = false;
- }
- index_skims [i]->Put_Data (*plan_ptr);
+ if (plan_files [i]->Read_Plan (*plan_ptr)) {
+ plan_ptr->Get_Index (read_index [i]);
- if (!plan_skim_flag) {
- plan_tours [i].assign (1, *plan_ptr);
- }
-
- if (plan_files [i]->Read_Plan (*plan_ptr)) {
- plan_ptr->Get_Index (read_index [i]);
-
- if (tour_choice_flag) {
- while (read_index [i].Household () < MAX_INTEGER) {
- if (read_index [i].Household () != index_itr->Household () || read_index [i].Person () != index_itr->Person () ||
- read_index [i].Tour () != index_itr->Tour ()) {
- break;
+ if (tour_choice_flag) {
+ while (read_index [i].Household () < MAX_INTEGER) {
+ if (read_index [i].Household () != index_itr->Household () || read_index [i].Person () != index_itr->Person () ||
+ read_index [i].Tour () != index_itr->Tour ()) {
+ break;
+ }
+ if (!crowd_flag) {
+ if (plan_ptr->Transit_Mode_Flag () && System_File_Flag (RIDERSHIP)) {
+ crowd_flag = Transit_Crowding (plan_ptr);
+ } else {
+ crowd_flag = false;
}
- if (!crowd_flag) {
- if (plan_ptr->Transit_Mode_Flag () && System_File_Flag (RIDERSHIP)) {
- crowd_flag = Transit_Crowding (plan_ptr);
- } else {
- crowd_flag = false;
- }
- if (crowd_flag) {
- index_skims [i]->Put_Data (*plan_ptr);
+ if (crowd_flag) {
+ index_skims [i]->Put_Data (*plan_ptr);
- if (!plan_skim_flag) {
- plan_tours [i].assign (1, *plan_ptr);
- }
- } else {
- index_skims [i]->Add_Leg (*plan_ptr);
+ plan_tours [i].assign (1, *plan_ptr);
+ } else {
+ index_skims [i]->Add_Leg (*plan_ptr);
- if (!plan_skim_flag) {
- plan_tours [i].push_back (*plan_ptr);
- }
- }
+ plan_tours [i].push_back (*plan_ptr);
}
- if (plan_files [i]->Read_Plan (*plan_ptr)) {
- plan_ptr->Get_Index (read_index [i]);
- } else {
- read_index [i].Household (MAX_INTEGER);
- }
}
- } else {
- plan_tours [i].push_back (*plan_ptr);
+ if (plan_files [i]->Read_Plan (*plan_ptr)) {
+ plan_ptr->Get_Index (read_index [i]);
+ } else {
+ read_index [i].Household (MAX_INTEGER);
+ }
}
- } else {
- read_index [i].Household (MAX_INTEGER);
}
- if (skim_memory_flag) {
- plan_skim_arrays [i]->Record (index_skims [i]->Record ());
- plan_skim_arrays [i]->Write_Record ();
- }
+ } else {
+ read_index [i].Household (MAX_INTEGER);
}
+
}
if (*index_itr < min_index) {
min_index = *index_itr;
@@ -170,7 +140,14 @@
}
if (min_index.Household () == MAX_INTEGER) break;
+ //---- check for an incomplete tour ----
+
+ if (min_index.Household () == trip_index.Household () && min_index.Person () == trip_index.Person () && min_index.Tour () == trip_index.Tour ()) {
+ trip_index = min_index;
+ continue;
+ }
trip_index = min_index;
+ Show_Progress ();
//---- mode choice ----
@@ -179,14 +156,9 @@
}
if (thread_flag) {
split_queue.Complete_Work ();
-
- for (i = 0; i < Num_Threads (); i++) {
- choice_process [i]->Sum_Totals ();
- }
}
if (calib_flag) {
End_Progress (false);
-
} else {
End_Progress (clock ());
}
Added: version7/branches/aecom/Transims70/ModeChoice/Read_Process.cpp
===================================================================
--- version7/branches/aecom/Transims70/ModeChoice/Read_Process.cpp (rev 0)
+++ version7/branches/aecom/Transims70/ModeChoice/Read_Process.cpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -0,0 +1,31 @@
+
+//*********************************************************
+// Read_Process.cpp - read skim process
+//*********************************************************
+
+#include "ModeChoice.hpp"
+
+//---------------------------------------------------------
+// Read_Process constructor
+//---------------------------------------------------------
+
+ModeChoice::Read_Process::Read_Process (ModeChoice *_exe)
+{
+ exe = _exe;
+}
+
+//---------------------------------------------------------
+// Read_Process operator
+//---------------------------------------------------------
+
+void ModeChoice::Read_Process::operator()()
+{
+ //---- process each choice ----
+
+ int number;
+
+ while (exe->skim_number.Get (number)) {
+ Memory_Skims (number);
+ exe->skim_number.Finished ();
+ }
+}
Added: version7/branches/aecom/Transims70/ModeChoice/Read_Skims.cpp
===================================================================
--- version7/branches/aecom/Transims70/ModeChoice/Read_Skims.cpp (rev 0)
+++ version7/branches/aecom/Transims70/ModeChoice/Read_Skims.cpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -0,0 +1,61 @@
+//*********************************************************
+// Read_Skims.cpp -- read skims into memory
+//*********************************************************
+
+#include "ModeChoice.hpp"
+
+//---------------------------------------------------------
+// Read_Skims
+//---------------------------------------------------------
+
+void ModeChoice::Read_Skims (void)
+{
+ int i, num, size;
+ Int_Map_Itr map_itr;
+ Threads read_threads;
+
+ //---- read skims into memory ----
+
+ size = (int) plan_num_map.size ();
+
+ num = MIN (size, Num_Threads ());
+
+ read_process = new Read_Process * [size];
+
+ if (thread_flag) {
+ skim_number.Max_Records (size);
+
+ for (i = 0; i < num; i++) {
+ Show_Progress ();
+ Read_Process *ptr = read_process [i] = new Read_Process (this);
+ read_threads.push_back (thread (ref (*ptr)));
+ }
+ Show_Message ("Reading Skims into Memory -- Record");
+ Set_Progress ();
+
+ skim_number.Start_Work ();
+
+ for (map_itr = plan_num_map.begin (); map_itr != plan_num_map.end (); map_itr++) {
+ skim_number.Put (map_itr->second);
+ }
+ skim_number.End_of_Work ();
+ read_threads.Join_All ();
+ End_Progress (clock ());
+
+ for (i = 0; i < num; i++) {
+ delete read_process [i];
+ }
+ } else {
+ *read_process = new Read_Process (this);
+
+ for (map_itr = plan_num_map.begin (); map_itr != plan_num_map.end (); map_itr++) {
+ Show_Message (String ("Reading Skim %d into Memory -- Record") % map_itr->first);
+ Set_Progress ();
+
+ (*read_process)->Memory_Skims (map_itr->second);
+
+ End_Progress (clock ());
+ }
+ }
+}
+
Added: version7/branches/aecom/Transims70/ModeChoice/Select_Plans.cpp
===================================================================
--- version7/branches/aecom/Transims70/ModeChoice/Select_Plans.cpp (rev 0)
+++ version7/branches/aecom/Transims70/ModeChoice/Select_Plans.cpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -0,0 +1,95 @@
+//*********************************************************
+// Select_Plans - copy plans to output array
+//*********************************************************
+
+#include "ModeChoice.hpp"
+
+#include <math.h>
+
+//---------------------------------------------------------
+// Select_Plans
+//---------------------------------------------------------
+
+void ModeChoice::Select_Plans (void)
+{
+ int i, mode, seed;
+ double prob;
+
+ Trip_Index trip_index;
+ Trip_Map_Itr trip_itr;
+ Plan_File_Itr plan_itr;
+ Plan_Data plan_data, *plan_ptr;
+
+ //---- clear the ridership and parking demand ----
+
+ if (rider_flag) {
+ line_array.Zero_Riders ();
+ }
+ if (penalty_update_flag) {
+ park_demand_array.Zero_Demand ();
+ }
+ Show_Message ("Selecting Choosen Plans -- Record");
+ Set_Progress ();
+
+ mode = -1;
+
+ //---- process each file ----
+
+ for (i = 0, plan_itr = plan_files.begin (); plan_itr != plan_files.end (); plan_itr++, i++) {
+ (*plan_itr)->Rewind ();
+
+ while ((*plan_itr)->Read_Plan (plan_data)) {
+
+ plan_data.Get_Index (trip_index);
+ trip_index.Trip (1);
+
+ trip_itr = trip_mode.find (trip_index);
+ if (trip_itr == trip_mode.end ()) {
+ plan_data.Get_Index (trip_index);
+
+ trip_itr = trip_mode.find (trip_index);
+ if (trip_itr == trip_mode.end ()) {
+ continue;
+ }
+ }
+
+ if (trip_itr->second != i) continue;
+
+ Show_Progress ();
+
+ if (plan_data.Trip () == 1) {
+ mode = -1;
+ }
+ seed = (int) ((double) random_seed + plan_data.Household () + plan_data.Person () + plan_data.Tour () + plan_data.Trip ());
+
+ if (auto_occ_flag && plan_data.Mode () >= HOV2_MODE && plan_data.Mode () <= HOV4_MODE) {
+ if (mode < 0) {
+ prob = Random (seed + 1).Probability ();
+ Veh_Type_Data *veh_type_ptr = &veh_type_array [plan_data.Veh_Type ()];
+ mode = plan_data.Mode ();
+
+ if (veh_type_ptr->Occupancy () > 0) {
+ prob *= veh_type_ptr->Occupancy () / 100.0;
+ if (prob > 1.0) {
+ mode = RIDE_MODE;
+ }
+ }
+ }
+ plan_data.Mode (mode);
+
+ if (mode == RIDE_MODE) {
+ plan_data.Vehicle (-1);
+ plan_data.Veh_Type (0);
+ }
+ } else if (rider_flag && plan_data.Transit_Mode_Flag ()) { //******************//
+ line_array.Sum_Riders (plan_data);
+ }
+
+ plan_ptr = new Plan_Data (plan_data);
+
+ plan_ptr_array.push_back (plan_ptr);
+ }
+ (*plan_itr)->Close ();
+ }
+ End_Progress (clock ());
+}
Added: version7/branches/aecom/Transims70/ModeChoice/Skim_Choice.cpp
===================================================================
--- version7/branches/aecom/Transims70/ModeChoice/Skim_Choice.cpp (rev 0)
+++ version7/branches/aecom/Transims70/ModeChoice/Skim_Choice.cpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -0,0 +1,106 @@
+//*********************************************************
+// Skim_Choice.cpp - choice between plan skims
+//*********************************************************
+
+#include "ModeChoice.hpp"
+
+//---------------------------------------------------------
+// Skim_Choice
+//---------------------------------------------------------
+
+void ModeChoice::Skim_Choice (void)
+{
+ int i;
+
+ Trip_Index trip_index, min_index;
+ Trip_Index_Itr index_itr;
+ Trip_Map_Itr map_itr;
+ Trip_Map_Itr_Array map_itr_array;
+ Trip_Map_Itr_Array_Itr map_array_itr;
+ Trip_Map_Array_Itr trip_map_itr;
+
+ park_cap_flag = ((System_File_Flag (NEW_PARK_DEMAND) && save_flag) || penalty_update_flag);
+
+ if (calib_flag) {
+ if (save_flag && new_skim_flag) {
+ Show_Message (String ("Iteration %d Writing Plan Skims -- Record") % iteration);
+ } else {
+ Show_Message (String ("Iteration %d Choosing Plan Skims -- Record") % iteration);
+ }
+ if (iteration > 1) {
+
+ //---- clear the parking demand ----
+
+ if (penalty_update_flag) {
+ park_demand_array.Zero_Demand ();
+ }
+ }
+ } else {
+ Show_Message ("Choosing Plan Skims -- Record");
+ }
+ Set_Progress ();
+
+ for (trip_map_itr = skim_index_array.begin (); trip_map_itr != skim_index_array.end (); trip_map_itr++) {
+ map_itr_array.push_back (trip_map_itr->begin ());
+ }
+
+ //---- process each trip ----
+
+ if (thread_flag) {
+ split_queue.Start_Work ();
+ }
+ trip_index.Household (0);
+
+ i = (int) plan_skims.size ();
+ index_array.assign (i, trip_index);
+
+ //---- process each trip ----
+
+ while (trip_index.Household () < MAX_INTEGER) {
+
+ //---- read the next ----
+
+ min_index.Household (MAX_INTEGER);
+
+ for (i = 0, index_itr = index_array.begin (); index_itr != index_array.end (); index_itr++, i++) {
+ if (*index_itr <= trip_index) {
+
+ if (map_itr_array [i] != skim_index_array [i].end ()) {
+ *index_itr = map_itr_array [i]->first;
+
+ plan_skim_arrays [i]->Read_Record (map_itr_array [i]->second);
+ index_skims [i]->Record (plan_skim_arrays [i]->Record ());
+
+ map_itr_array [i]++;
+ } else {
+ index_itr->Household (MAX_INTEGER);
+ }
+ }
+ if (*index_itr < min_index) {
+ min_index = *index_itr;
+ }
+ }
+ if (min_index.Household () == MAX_INTEGER) break;
+
+ //---- check for an incomplete tour ----
+
+ if (min_index.Household () == trip_index.Household () && min_index.Person () == trip_index.Person () && min_index.Tour () == trip_index.Tour ()) {
+ trip_index = min_index;
+ continue;
+ }
+ trip_index = min_index;
+ Show_Progress ();
+
+ //---- mode choice ----
+
+ Choice_Data (trip_index);
+ }
+ if (thread_flag) {
+ split_queue.Complete_Work ();
+ }
+ if (calib_flag) {
+ End_Progress (false);
+ } else {
+ End_Progress (clock ());
+ }
+}
Modified: version7/branches/aecom/Transims70/ModeChoice/Zone_Tables.cpp
===================================================================
--- version7/branches/aecom/Transims70/ModeChoice/Zone_Tables.cpp 2017-12-22 19:06:29 UTC (rev 1693)
+++ version7/branches/aecom/Transims70/ModeChoice/Zone_Tables.cpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -148,11 +148,6 @@
}
}
}
- if (thread_flag) {
- for (i = 0; i < Num_Threads (); i++) {
- choice_process [i]->Sum_Totals ();
- }
- }
if (!calib_flag) End_Progress (clock ());
if (lost_flag && save_flag) {
Modified: version7/branches/aecom/Transims70/PlanPrep/Control.cpp
===================================================================
--- version7/branches/aecom/Transims70/PlanPrep/Control.cpp 2017-12-22 19:06:29 UTC (rev 1693)
+++ version7/branches/aecom/Transims70/PlanPrep/Control.cpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -16,6 +16,8 @@
//---- create the network files ----
Select_Service::Program_Control ();
+
+ thread_flag = (Num_Threads () > 1);
if (select_org_zones || select_des_zones || select_polygon || select_subareas) {
if (!System_File_Flag (NODE) || !System_File_Flag (LINK) || !System_File_Flag (LOCATION)) {
@@ -227,4 +229,8 @@
reroute_percent = Get_Control_Double (REROUTE_PERCENTAGE);
}
+
+ if (!thread_flag && plan_flag && (new_plan_flag || plan_skim_flag) && !merge_flag && !subarea_flag && !combine_flag && !repair_flag && !reroute_flag) {
+ export_flag = true;
+ }
}
Modified: version7/branches/aecom/Transims70/PlanPrep/Execute.cpp
===================================================================
--- version7/branches/aecom/Transims70/PlanPrep/Execute.cpp 2017-12-22 19:06:29 UTC (rev 1693)
+++ version7/branches/aecom/Transims70/PlanPrep/Execute.cpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -11,7 +11,6 @@
void PlanPrep::Execute (void)
{
int i;
- thread_flag = (Num_Threads () > 1);
//---- read the network data ----
@@ -84,7 +83,7 @@
}
//---- write the new plan file ----
- if (new_plan_flag || plan_skim_flag) {
+ if (!export_flag && (new_plan_flag || plan_skim_flag)) {
Write_Plans ();
}
Modified: version7/branches/aecom/Transims70/PlanPrep/PlanPrep.cpp
===================================================================
--- version7/branches/aecom/Transims70/PlanPrep/PlanPrep.cpp 2017-12-22 19:06:29 UTC (rev 1693)
+++ version7/branches/aecom/Transims70/PlanPrep/PlanPrep.cpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -11,7 +11,7 @@
PlanPrep::PlanPrep (void) : Select_Service ()
{
Program ("PlanPrep");
- Version (12);
+ Version (13);
Title ("Travel Plan Processing Utility");
System_File_Type optional_files [] = {
@@ -62,7 +62,7 @@
num_repair = repair_plans = num_subarea_merge = num_new_skims = num_constraints = num_merge_files = check_sum = check_sum_type = 0;
select_flag = merge_flag = subarea_flag = combine_flag = output_flag = new_plan_flag = new_trip_flag = new_select_flag = false;
- repair_flag = skim_flag = plan_skim_flag = plan_flag = check_sum_flag = false;
+ repair_flag = skim_flag = plan_skim_flag = plan_flag = check_sum_flag = export_flag = false;
shift_start_flag = shift_end_flag = reroute_flag = false;
shift_rate = 0.0;
shift_factor = 1.0;
Modified: version7/branches/aecom/Transims70/PlanPrep/PlanPrep.hpp
===================================================================
--- version7/branches/aecom/Transims70/PlanPrep/PlanPrep.hpp 2017-12-22 19:06:29 UTC (rev 1693)
+++ version7/branches/aecom/Transims70/PlanPrep/PlanPrep.hpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -46,7 +46,7 @@
int new_format, num_repair, num_subarea_merge, repair_plans, num_constraints, num_new_skims, num_merge_files;
int check_sum, check_sum_type, num_reroute, num_shifted;
bool select_flag, merge_flag, subarea_flag, combine_flag, output_flag, new_plan_flag, new_trip_flag, new_select_flag;
- bool repair_flag, plan_skim_flag, skim_flag, plan_flag, check_sum_flag;
+ bool repair_flag, plan_skim_flag, skim_flag, plan_flag, check_sum_flag, export_flag;
bool park_list_flag, route_list_flag, shift_start_flag, shift_end_flag, reroute_flag;
double max_ratio, max_factor, shift_rate, shift_factor, reroute_percent;
Dtime low_from, high_from, low_to, high_to, reroute_start, reroute_end;
Modified: version7/branches/aecom/Transims70/PlanPrep/Process_Plan.cpp
===================================================================
--- version7/branches/aecom/Transims70/PlanPrep/Process_Plan.cpp 2017-12-22 19:06:29 UTC (rev 1693)
+++ version7/branches/aecom/Transims70/PlanPrep/Process_Plan.cpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -154,7 +154,17 @@
keep_flag = false;
}
} else {
- plan_ptr_array_ptr->push_back (plan_ptr);
+ if (exe->export_flag) {
+ if (exe->new_plan_flag) {
+ exe->new_plan_file->Write_Plan (*plan_ptr);
+ }
+ if (exe->plan_skim_flag) {
+ exe->plan_skim_file->Write_Plan_Skim (*plan_ptr);
+ num_new_skims++;
+ }
+ } else {
+ plan_ptr_array_ptr->push_back (plan_ptr);
+ }
}
}
}
Modified: version7/branches/aecom/Transims70/PlanPrep/Read_Plans.cpp
===================================================================
--- version7/branches/aecom/Transims70/PlanPrep/Read_Plans.cpp 2017-12-22 19:06:29 UTC (rev 1693)
+++ version7/branches/aecom/Transims70/PlanPrep/Read_Plans.cpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -20,7 +20,7 @@
}
//---- write the process message ----
- if (plan_flag) {
+ if (plan_flag && !export_flag) {
process_type = "Reading";
} else if (subarea_flag) {
process_type = "Subarea";
Modified: version7/branches/aecom/Transims70/PlanSelect/Control.cpp
===================================================================
--- version7/branches/aecom/Transims70/PlanSelect/Control.cpp 2017-12-22 19:06:29 UTC (rev 1693)
+++ version7/branches/aecom/Transims70/PlanSelect/Control.cpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -26,6 +26,14 @@
new_plan_file->Write_Header ();
}
+ new_skim_flag = System_File_Flag (NEW_PLAN_SKIM);
+
+ if (new_skim_flag) {
+ new_skim_file = System_Plan_Skim_File (true);
+ new_skim_file->Sort_Type (plan_file->Sort_Type ());
+ new_skim_file->Write_Header ();
+ }
+
new_select_flag = System_File_Flag (NEW_SELECTION);
Print (2, String ("%s Control Keys:") % Program ());
Modified: version7/branches/aecom/Transims70/PlanSelect/PlanSelect.cpp
===================================================================
--- version7/branches/aecom/Transims70/PlanSelect/PlanSelect.cpp 2017-12-22 19:06:29 UTC (rev 1693)
+++ version7/branches/aecom/Transims70/PlanSelect/PlanSelect.cpp 2017-12-29 21:33:14 UTC (rev 1694)
@@ -11,7 +11,7 @@
PlanSelect::PlanSelect (void) : Select_Service ()
{
Program ("PlanSelect");
- Version (1);
+ Version (2);
Title ("Travel Plan Selection Utility");
System_File_Type required_files [] = {
@@ -18,7 +18,7 @@
PLAN, END_FILE
};
System_File_Type optional_files [] = {
- LINK, NODE, TRANSIT_STOP, TRANSIT_ROUTE, TRANSIT_DRIVER, VEHICLE_TYPE, PERFORMANCE, SELECTION, NEW_SELECTION, NEW_PLAN, END_FILE
+ LINK, NODE, TRANSIT_STOP, TRANSIT_ROUTE, TRANSIT_DRIVER, VEHICLE_TYPE, PERFORMANCE, SELECTION, NEW_SELECTION, NEW_PLAN, NEW_PLAN_SKIM, END_FILE
};
int file_service_keys [] = {
SAVE_LANE_USE_FLOWS, 0
@@ -53,7 +53,7 @@
Report_List (reports);
Sum_Flow_Flag (true);
- new_plan_flag = new_select_flag = false;
+ new_plan_flag = new_skim_flag = new_select_flag = false;
plan_file = new_plan_file = 0;
Mod...
[truncated message content] |