|
From: subversion c. n. <tra...@li...> - 2018-12-20 02:43:29
|
Revision: 1715
http://sourceforge.net/p/transims/code/1715
Author: davidroden
Date: 2018-12-20 02:43:27 +0000 (Thu, 20 Dec 2018)
Log Message:
-----------
TRANSIMS Version 7.3 from AECOM branch 1714
Modified Paths:
--------------
version7/trunk/Transims70/Converge_Service/Control.cpp
version7/trunk/Transims70/Converge_Service/Get_Trip_Data.cpp
version7/trunk/Transims70/Converge_Service/Selection_Score.cpp
version7/trunk/Transims70/Converge_Service/Write_Plan_Files.cpp
version7/trunk/Transims70/ConvertTrips/Adjust_Trips.cpp
version7/trunk/Transims70/ConvertTrips/Control.cpp
version7/trunk/Transims70/ConvertTrips/ConvertTrips.cpp
version7/trunk/Transims70/ConvertTrips/ConvertTrips.hpp
version7/trunk/Transims70/ConvertTrips/ConvertTrips.vcxproj
version7/trunk/Transims70/ConvertTrips/ConvertTrips.vcxproj.filters
version7/trunk/Transims70/ConvertTrips/Execute.cpp
version7/trunk/Transims70/ConvertTrips/Get_Trip_Data.cpp
version7/trunk/Transims70/ConvertTrips/Read_Trip_Table.cpp
version7/trunk/Transims70/ConvertTrips/Set_Trip.cpp
version7/trunk/Transims70/ConvertTrips/Tour_Process.cpp
version7/trunk/Transims70/Data_Service/Performance_Data.cpp
version7/trunk/Transims70/Data_Service/Read_Plans.cpp
version7/trunk/Transims70/Data_Service/Read_Problems.cpp
version7/trunk/Transims70/Data_Service/Read_Trips.cpp
version7/trunk/Transims70/Data_Service/Write_Trips.cpp
version7/trunk/Transims70/File_Service/Fare_File.cpp
version7/trunk/Transims70/File_Service/File_Service.vcxproj
version7/trunk/Transims70/File_Service/File_Service.vcxproj.filters
version7/trunk/Transims70/File_Service/Plan_Skim_File.cpp
version7/trunk/Transims70/File_Service/Plan_Sum_File.cpp
version7/trunk/Transims70/File_Service/Trip_File.cpp
version7/trunk/Transims70/GTFSData/GTFSData.cpp
version7/trunk/Transims70/Include/Execution_Service.hpp
version7/trunk/Transims70/Include/Performance_Data.hpp
version7/trunk/Transims70/Include/Router_Service.hpp
version7/trunk/Transims70/Include/System_Defines.hpp
version7/trunk/Transims70/Include/Trip_Data.hpp
version7/trunk/Transims70/Include/Trip_File.hpp
version7/trunk/Transims70/LinkSum/LinkSum.cpp
version7/trunk/Transims70/MatrixData/Control.cpp
version7/trunk/Transims70/MatrixData/Execute.cpp
version7/trunk/Transims70/MatrixData/MatrixData.cpp
version7/trunk/Transims70/MatrixData/MatrixData.hpp
version7/trunk/Transims70/MatrixData/MatrixData.vcxproj
version7/trunk/Transims70/MatrixData/MatrixData.vcxproj.filters
version7/trunk/Transims70/MatrixData/Read_Matrix.cpp
version7/trunk/Transims70/NetDiff/NetDiff.cpp
version7/trunk/Transims70/NetPrep/NetPrep.cpp
version7/trunk/Transims70/NewFormat/NewFormat.cpp
version7/trunk/Transims70/PathSkim/Save_Plans.cpp
version7/trunk/Transims70/PerfPrep/Load_Transit_Data.cpp
version7/trunk/Transims70/PlanCompare/PlanCompare.cpp
version7/trunk/Transims70/PlanCompare/Read_Plans.cpp
version7/trunk/Transims70/PlanPrep/PlanPrep.cpp
version7/trunk/Transims70/PlanSelect/PlanSelect.cpp
version7/trunk/Transims70/PlanSelect/PlanSelect.hpp
version7/trunk/Transims70/PlanSelect/Read_Plans.cpp
version7/trunk/Transims70/PlanSelect/Read_Vol_Cnt.cpp
version7/trunk/Transims70/PlanSum/PlanSum.cpp
version7/trunk/Transims70/PlanSum/Process_Plan.cpp
version7/trunk/Transims70/PlanTrips/Put_Trip_Data.cpp
version7/trunk/Transims70/Relocate/Get_Trip_Data.cpp
version7/trunk/Transims70/Router/Router.cpp
version7/trunk/Transims70/Router_Service/Control.cpp
version7/trunk/Transims70/Router_Service/Drive_Path.cpp
version7/trunk/Transims70/Router_Service/Execute.cpp
version7/trunk/Transims70/Router_Service/Parking_Access.cpp
version7/trunk/Transims70/Router_Service/Plan_Build.cpp
version7/trunk/Transims70/Router_Service/Plan_Flow.cpp
version7/trunk/Transims70/Router_Service/Plan_Processing.cpp
version7/trunk/Transims70/Router_Service/Plan_Update.cpp
version7/trunk/Transims70/Router_Service/Router_Service.cpp
version7/trunk/Transims70/Router_Service/Sum_Demand.cpp
version7/trunk/Transims70/SysLib/Dbfile/Db_Header.cpp
version7/trunk/Transims70/SysLib/Dbfile/Db_Record.cpp
version7/trunk/Transims70/SysLib/Service/Execution_Service.cpp
version7/trunk/Transims70/SysLib/Service/Static_Service.cpp
version7/trunk/Transims70/SysLib/Tools/String.cpp
version7/trunk/Transims70/TransitNet/TransitNet.cpp
version7/trunk/Transims70/TripPrep/Control.cpp
version7/trunk/Transims70/TripPrep/Execute.cpp
version7/trunk/Transims70/TripPrep/Read_Trips.cpp
version7/trunk/Transims70/TripPrep/TripPrep.cpp
version7/trunk/Transims70/TripPrep/TripPrep.hpp
version7/trunk/Transims70/TripSum/Diurnal_Report.cpp
version7/trunk/Transims70/TripSum/Read_Trips.cpp
version7/trunk/Transims70/TripSum/Time_Report.cpp
version7/trunk/Transims70/TripSum/TripSum.cpp
version7/trunk/Transims70/TripSum/TripSum.hpp
version7/trunk/Transims70/TripSum/Write_Loc_Shares.cpp
version7/trunk/Transims70/TripSum/Write_Time.cpp
version7/trunk/Transims70/TripSum/Write_Trip_Length.cpp
version7/trunk/Transims70/TripSum/Write_Trip_Time.cpp
version7/trunk/Transims70/Validate/Control.cpp
version7/trunk/Transims70/Validate/Execute.cpp
version7/trunk/Transims70/Validate/Validate.cpp
version7/trunk/Transims70/Validate/Validate.hpp
version7/trunk/Transims70/Validate/Validate.vcxproj
version7/trunk/Transims70/Validate/Validate.vcxproj.filters
Added Paths:
-----------
version7/trunk/Transims70/ConvertTrips/Zone_Nodes.cpp
version7/trunk/Transims70/File_Service/Vol_Count_File.cpp
version7/trunk/Transims70/Include/Vol_Count_File.hpp
version7/trunk/Transims70/MatrixData/Factor_Matrix.cpp
version7/trunk/Transims70/Validate/Read_Volume_Count.cpp
version7/trunk/Transims70/Validate/Write_Vol_Cnt_File.cpp
Modified: version7/trunk/Transims70/Converge_Service/Control.cpp
===================================================================
--- version7/trunk/Transims70/Converge_Service/Control.cpp 2018-12-20 02:38:46 UTC (rev 1714)
+++ version7/trunk/Transims70/Converge_Service/Control.cpp 2018-12-20 02:43:27 UTC (rev 1715)
@@ -21,8 +21,8 @@
Converge_Step_Data step_data;
- Integer_List max_iter_list, min_cost_list, max_cost_list, min_score_list;
- Double_List init_fac_list, fac_inc_list, max_fac_list, per_time_list, per_cost_list;
+ Integer_List max_iter_list, min_cost_list, max_cost_list;
+ Double_List init_fac_list, fac_inc_list, max_fac_list, per_time_list, per_cost_list, min_score_list;
Double_List min_time_ratio_list, max_time_ratio_list, min_penalty_list, max_penalty_list;
Double_List link_gap_list, trip_gap_list, toll_gap_list, transit_gap_list, parking_gap_list, ratio_gap_list, max_per_list;
Dtime_List min_time_list, max_time_list;
@@ -381,7 +381,7 @@
//---- mininum selection score ----
- step_itr->min_select_score = min_score_list.Best (i);
+ step_itr->min_select_score = DTOI (min_score_list.Best (i) * BASE_SCORE / 100);
//---- maximum percent selected ----
Modified: version7/trunk/Transims70/Converge_Service/Get_Trip_Data.cpp
===================================================================
--- version7/trunk/Transims70/Converge_Service/Get_Trip_Data.cpp 2018-12-20 02:38:46 UTC (rev 1714)
+++ version7/trunk/Transims70/Converge_Service/Get_Trip_Data.cpp 2018-12-20 02:43:27 UTC (rev 1715)
@@ -12,7 +12,7 @@
{
if (Data_Service::Get_Trip_Data (file, trip_rec)) {
- file.Add_Trip (trip_rec.Household (), trip_rec.Person (), trip_rec.Tour ());
+ file.Add_Trip (trip_rec.Household (), trip_rec.Person (), trip_rec.Tour (), trip_rec.Trips ());
return (Set_Trip_Data (trip_rec));
}
Modified: version7/trunk/Transims70/Converge_Service/Selection_Score.cpp
===================================================================
--- version7/trunk/Transims70/Converge_Service/Selection_Score.cpp 2018-12-20 02:38:46 UTC (rev 1714)
+++ version7/trunk/Transims70/Converge_Service/Selection_Score.cpp 2018-12-20 02:43:27 UTC (rev 1715)
@@ -11,16 +11,17 @@
int Converge_Service::Selection_Score (Plan_Data &old_plan, Plan_Data &new_plan, int &type)
{
Dtime time1, time2, time_diff, tod, duration;
- int cost1, cost2, cost_diff, score, ratio;
+ int cost1, cost2, cost_diff, score, max_score, ratio;
double prob;
- score = 100;
+ max_score = score = DTOI (MIN (new_plan.Trips (), Max_Trip_Factor ()) * BASE_SCORE);
+
type = NO_SELECT_TYPE;
if (!new_plan.Path_Problem ()) {
if (new_plan.Problem () == PARK_CAP_PROBLEM || new_plan.Problem () == BOARDING_PROBLEM) {
- score = step_itr->min_select_score;
+ score = MIN (step_itr->min_select_score * max_score / BASE_SCORE, max_score);
if (new_plan.Problem () == PARK_CAP_PROBLEM) {
type = PARKING_PROBLEM_TYPE;
} else {
@@ -32,14 +33,14 @@
//---- time ratio selection ----
- if (score < 100 && step_itr->time_ratio_flag) {
+ if (score < max_score && step_itr->time_ratio_flag) {
ratio = new_plan.Time_Ratio ();
if (ratio > step_itr->max_time_ratio) {
- score = 100;
+ score = max_score;
type = TIME_RATIO_TYPE;
} else if (ratio >= step_itr->min_time_ratio) {
- ratio = (ratio - step_itr->min_time_ratio) * 100 / step_itr->max_min_time_ratio;
+ ratio = MIN ((ratio - step_itr->min_time_ratio) * max_score / step_itr->max_min_time_ratio, max_score);
if (ratio > score) {
type = TIME_RATIO_TYPE;
score = ratio;
@@ -49,14 +50,14 @@
//---- penalty ratio selection ----
- if (score < 100 && step_itr->penalty_ratio_flag) {
+ if (score < max_score && step_itr->penalty_ratio_flag) {
ratio = new_plan.Penalty_Ratio ();
if (ratio > step_itr->max_penalty_ratio) {
- score = 100;
+ score = max_score;
type = PENALTY_RATIO_TYPE;
} else if (ratio >= step_itr->min_penalty_ratio) {
- ratio = (ratio - step_itr->min_penalty_ratio) * 100 / step_itr->max_min_penalty_ratio;
+ ratio = MIN ((ratio - step_itr->min_penalty_ratio) * max_score / step_itr->max_min_penalty_ratio, max_score);
if (ratio > score) {
type = PENALTY_RATIO_TYPE;
score = ratio;
@@ -66,7 +67,7 @@
//---- select the plan to keep ----
- if (score < 100 && old_plan.size () > 0 && !old_plan.Path_Problem () && old_plan.Impedance () > 0) {
+ if (score < max_score && old_plan.size () > 0 && !old_plan.Path_Problem () && old_plan.Impedance () > 0) {
//---- compare plan times ----
@@ -77,7 +78,7 @@
time_diff = time1 - time2;
if (time_diff > step_itr->max_time_diff) {
- score = 100;
+ score = max_score;
type = TRAVEL_TIME_TYPE;
} else if (time_diff >= step_itr->min_time_diff && time2 > 0) {
prob = (double) time_diff / time2;
@@ -84,13 +85,13 @@
if (prob >= step_itr->percent_time_diff) {
if (step_itr->max_min_time_diff > 1) {
time_diff = time_diff - step_itr->min_time_diff;
- ratio = 100 * time_diff / step_itr->max_min_time_diff;
+ ratio = MIN (max_score * time_diff / step_itr->max_min_time_diff, max_score);
if (ratio > score) {
type = TRAVEL_TIME_TYPE;
score = ratio;
}
} else {
- score = 100;
+ score = max_score;
type = TRAVEL_TIME_TYPE;
}
}
@@ -99,7 +100,7 @@
//---- compare plan costs ----
- if (score < 100 && step_itr->cost_diff_flag) {
+ if (score < max_score && step_itr->cost_diff_flag) {
cost1 = new_plan.Impedance ();
cost2 = old_plan.Impedance ();
@@ -106,7 +107,7 @@
cost_diff = cost1 - cost2;
if (cost_diff > step_itr->max_cost_diff) {
- score = 100;
+ score = max_score;
type = IMPEDANCE_TYPE;
} else if (cost_diff >= step_itr->min_cost_diff && cost2 > 0) {
prob = (double) cost_diff / cost2;
@@ -113,13 +114,13 @@
if (prob >= step_itr->percent_cost_diff) {
if (step_itr->max_min_cost_diff > 1) {
cost_diff = cost_diff - step_itr->min_cost_diff;
- ratio = 100 * cost_diff / step_itr->max_min_cost_diff;
+ ratio = MIN (max_score * cost_diff / step_itr->max_min_cost_diff, max_score);
if (ratio > score) {
type = IMPEDANCE_TYPE;
ratio = score;
}
} else {
- score = 100;
+ score = max_score;
type = IMPEDANCE_TYPE;
}
}
@@ -130,9 +131,9 @@
if (score == 0) {
prob = 1.0 - ((double) new_plan.Impedance () / (new_plan.Impedance () + old_plan.Impedance ()));
- score = MIN (MAX ((int) (100 * fabs (prob - 0.5) * 2.0 + 0.5), 0), 100);
+ score = MIN (MAX ((int) (max_score * fabs (prob - 0.5) * 2.0 + 0.5), 0), max_score);
- if (score >= step_itr->min_select_score) {
+ if (score >= MIN (step_itr->min_select_score * max_score / BASE_SCORE, max_score)) {
type = SELECT_DIFFERENCE_TYPE;
} else {
//score = 0;
Modified: version7/trunk/Transims70/Converge_Service/Write_Plan_Files.cpp
===================================================================
--- version7/trunk/Transims70/Converge_Service/Write_Plan_Files.cpp 2018-12-20 02:38:46 UTC (rev 1714)
+++ version7/trunk/Transims70/Converge_Service/Write_Plan_Files.cpp 2018-12-20 02:43:27 UTC (rev 1715)
@@ -141,7 +141,7 @@
Warning ("Writing ") << new_problem_file->File_Type ();
new_problem_flag = false;
}
- new_problem_file->Add_Trip (plan.Household (), plan.Person (), plan.Tour ());
+ new_problem_file->Add_Trip (plan.Household (), plan.Person (), plan.Tour (), plan.Trips ());
}
}
}
Modified: version7/trunk/Transims70/ConvertTrips/Adjust_Trips.cpp
===================================================================
--- version7/trunk/Transims70/ConvertTrips/Adjust_Trips.cpp 2018-12-20 02:38:46 UTC (rev 1714)
+++ version7/trunk/Transims70/ConvertTrips/Adjust_Trips.cpp 2018-12-20 02:43:27 UTC (rev 1715)
@@ -255,7 +255,7 @@
Warning ("Writing ") << problem_file->File_Type ();
problem_flag = false;
}
- problem_file->Add_Trip (trip_itr->Household (), trip_itr->Person (), trip_itr->Tour ());
+ problem_file->Add_Trip (trip_itr->Household (), trip_itr->Person (), trip_itr->Tour (), trip_itr->Trips ());
}
continue;
}
Modified: version7/trunk/Transims70/ConvertTrips/Control.cpp
===================================================================
--- version7/trunk/Transims70/ConvertTrips/Control.cpp 2018-12-20 02:38:46 UTC (rev 1714)
+++ version7/trunk/Transims70/ConvertTrips/Control.cpp 2018-12-20 02:43:27 UTC (rev 1715)
@@ -69,6 +69,26 @@
hhold_id = Get_Control_Integer (FIRST_HOUSEHOLD_NUMBER);
+ //---- od output type ----
+
+ od_output_type = ID_Code (Get_Control_Text (OD_OUTPUT_TYPE));
+ if (od_output_type == NO_ID) od_output_type = LOCATION_ID;
+ if (od_output_type != LOCATION_ID && od_output_type != ZONE_ID && od_output_type != NODE_ID) {
+ Error ("OD Output Type is Out-of-Range (LOCATION, ZONE, NODE)");
+ }
+ zone_node_flag = (od_output_type == NODE_ID);
+
+ //---- fractional trip flag ----
+
+ fraction_flag = Get_Control_Flag (FRACTIONAL_TRIP_FLAG);
+
+ if (fraction_flag) {
+
+ //---- minimum trip value ----
+
+ min_trips = Get_Control_Double (MINIMUM_TRIP_VALUE);
+ }
+
//---- get the additional travel time ----
additional_time = Get_Control_Time (ADDITIONAL_TRAVEL_TIME);
Modified: version7/trunk/Transims70/ConvertTrips/ConvertTrips.cpp
===================================================================
--- version7/trunk/Transims70/ConvertTrips/ConvertTrips.cpp 2018-12-20 02:38:46 UTC (rev 1714)
+++ version7/trunk/Transims70/ConvertTrips/ConvertTrips.cpp 2018-12-20 02:43:27 UTC (rev 1715)
@@ -11,7 +11,7 @@
ConvertTrips::ConvertTrips (void) : Select_Service ()
{
Program ("ConvertTrips");
- Version (1);
+ Version (0);
Title ("Trip Table Conversion Utility");
System_File_Type required_files [] = {
@@ -36,6 +36,9 @@
};
Control_Key converttrips_keys [] = { //--- code, key, level, status, type, default, range, help ----
{ FIRST_HOUSEHOLD_NUMBER, "FIRST_HOUSEHOLD_NUMBER", LEVEL0, OPT_KEY, INT_KEY, "1", "1..1000000000", NO_HELP },
+ { OD_OUTPUT_TYPE, "OD_OUTPUT_TYPE", LEVEL0, OPT_KEY, TEXT_KEY, "LOCATION", "LOCATION, ZONE, NODE", NO_HELP },
+ { FRACTIONAL_TRIP_FLAG, "FRACTIONAL_TRIP_FLAG", LEVEL0, OPT_KEY, BOOL_KEY, "FALSE", BOOL_RANGE, NO_HELP },
+ { MINIMUM_TRIP_VALUE, "MINIMUM_TRIP_VALUE", LEVEL0, OPT_KEY, FLOAT_KEY, "0.01", "0.001..1.0", NO_HELP },
{ ADDITIONAL_TRAVEL_TIME, "ADDITIONAL_TRAVEL_TIME", LEVEL0, OPT_KEY, TIME_KEY, "0 minutes", "0..30 minutes", NO_HELP },
{ TOUR_DATA_FILE, "TOUR_DATA_FILE", LEVEL0, OPT_KEY, IN_KEY, "", FILE_RANGE, NO_HELP },
{ TOUR_DATA_FORMAT, "TOUR_DATA_FORMAT", LEVEL0, OPT_KEY, TEXT_KEY, "TAB_DELIMITED", FORMAT_RANGE, FORMAT_HELP },
@@ -111,14 +114,17 @@
Time_Table_Flag (true);
equiv_flag = skim_flag = zone_loc_flag = tour_flag = script_flag = diurnal_flag = false;
- new_hhold_flag = new_veh_flag = problem_flag = zone_sum_flag = false;
+ new_hhold_flag = new_veh_flag = problem_flag = zone_sum_flag = fraction_flag = zone_node_flag = false;
+ od_output_type = LOCATION_ID;
num_zone = additional_time = 0;
tot_tours = tot_trips = tot_errors = 0;
- new_trips = new_hholds = new_persons = new_vehicles = 0;
+ new_trips = 0;
+ new_hholds = new_persons = new_vehicles = 0;
tot_add = tot_del = 0.0;
group_number = 0;
skim_ptr = 0;
+ min_trips = 0;
trip_copy = hhold_copy = veh_copy = 0;
max_hh_in = max_veh_in = 0;
Modified: version7/trunk/Transims70/ConvertTrips/ConvertTrips.hpp
===================================================================
--- version7/trunk/Transims70/ConvertTrips/ConvertTrips.hpp 2018-12-20 02:38:46 UTC (rev 1714)
+++ version7/trunk/Transims70/ConvertTrips/ConvertTrips.hpp 2018-12-20 02:43:27 UTC (rev 1715)
@@ -33,7 +33,8 @@
protected:
enum ConvertTrips_Keys {
- FIRST_HOUSEHOLD_NUMBER = 1, ADDITIONAL_TRAVEL_TIME, TOUR_DATA_FILE, TOUR_DATA_FORMAT,
+ FIRST_HOUSEHOLD_NUMBER = 1, OD_OUTPUT_TYPE, FRACTIONAL_TRIP_FLAG, MINIMUM_TRIP_VALUE,
+ ADDITIONAL_TRAVEL_TIME, TOUR_DATA_FILE, TOUR_DATA_FORMAT,
TOUR_HOUSEHOLD_FIELD, TOUR_PERSON_FIELD, TOUR_NUMBER_FIELD, TOUR_PURPOSE_FIELD,
TOUR_MODE_FIELD, TOUR_ORIGIN_FIELD, TOUR_DESTINATION_FIELD, TOUR_STOP_OUT_FIELD,
TOUR_STOP_IN_FIELD, TOUR_START_FIELD, TOUR_RETURN_FIELD, TOUR_GROUP_FIELD, TOUR_GROUP_SCRIPT,
@@ -60,13 +61,12 @@
TIME_EQUIV, ZONE_EQUIV, TRAVELER_SCRIPT, TRAVELER_STACK, ZONE_TRIP_ENDS };
bool time_flag, equiv_flag, skim_flag, zone_loc_flag, tour_flag, script_flag, diurnal_flag;
- bool new_hhold_flag, new_veh_flag, problem_flag, zone_sum_flag;
- int num_zone, tot_tours, tot_trips, tot_errors, group_number;
- int hhold_id, new_trips, new_hholds, new_persons, new_vehicles;
- int trip_copy, hhold_copy, veh_copy, max_hh_in, max_veh_in;
+ bool new_hhold_flag, new_veh_flag, problem_flag, zone_sum_flag, fraction_flag, zone_node_flag;
+ int num_zone, group_number, hhold_id, new_hholds, new_persons, new_vehicles;
+ int trip_copy, hhold_copy, veh_copy, max_hh_in, max_veh_in, od_output_type;
int group_fld, org_fld, des_fld, start_fld, mode_fld, purpose_fld, duration_fld, constraint_fld, priority_fld, veh_type_fld, passengers_fld, type_fld;
Dtime additional_time, midnight, minute, two_minutes, five_minutes, ten_minutes, one_hour;
- double tot_add, tot_del;
+ double tot_add, tot_del, tot_tours, tot_trips, tot_errors, new_trips, min_trips;
Trip_File *trip_file;
Household_File *household_file;
@@ -75,6 +75,7 @@
Random random_org, random_des, random_tod, random_stop, random_duration, random_return;
Time_Periods tour_periods;
Integers zone_loc, org_out, des_out, *org_ptr, *des_ptr;
+ Ints_Array zone_node;
Doubles org_in, des_in;
Int_Map field_map;
@@ -100,10 +101,11 @@
void Compile_Scripts (void);
void Zone_Location (void);
+ void Zone_Nodes (void);
void Parking_Check (void);
void Tour_Processing (void);
void Read_Trip_Table (ConvertTrip_Itr group);
- int Set_Trips (ConvertTrip_Itr group, int org, int des, int trips, int num, int t1, int t2, bool return_flag);
+ double Set_Trips (ConvertTrip_Itr group, int org, int des, double trips, int num, int t1, int t2, bool return_flag);
bool Set_Time (ConvertTrip_Data *group, Dtime &start, Dtime &end, Dtime ttim, int num);
bool Locate_OD (ConvertTrip_Data *group, int &org, int &des, int &stop, int &park, double &dist1, double &dist2);
void Adjust_Trips (void);
Modified: version7/trunk/Transims70/ConvertTrips/ConvertTrips.vcxproj
===================================================================
--- version7/trunk/Transims70/ConvertTrips/ConvertTrips.vcxproj 2018-12-20 02:38:46 UTC (rev 1714)
+++ version7/trunk/Transims70/ConvertTrips/ConvertTrips.vcxproj 2018-12-20 02:43:27 UTC (rev 1715)
@@ -186,6 +186,7 @@
<ClCompile Include="Tour_Map.cpp" />
<ClCompile Include="Tour_Process.cpp" />
<ClCompile Include="Zone_Location.cpp" />
+ <ClCompile Include="Zone_Nodes.cpp" />
<ClCompile Include="Zone_Sum_Report.cpp" />
</ItemGroup>
<ItemGroup>
Modified: version7/trunk/Transims70/ConvertTrips/ConvertTrips.vcxproj.filters
===================================================================
--- version7/trunk/Transims70/ConvertTrips/ConvertTrips.vcxproj.filters 2018-12-20 02:38:46 UTC (rev 1714)
+++ version7/trunk/Transims70/ConvertTrips/ConvertTrips.vcxproj.filters 2018-12-20 02:43:27 UTC (rev 1715)
@@ -97,5 +97,8 @@
<ClCompile Include="Zone_Sum_Report.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="Zone_Nodes.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
Modified: version7/trunk/Transims70/ConvertTrips/Execute.cpp
===================================================================
--- version7/trunk/Transims70/ConvertTrips/Execute.cpp 2018-12-20 02:38:46 UTC (rev 1714)
+++ version7/trunk/Transims70/ConvertTrips/Execute.cpp 2018-12-20 02:43:27 UTC (rev 1715)
@@ -24,6 +24,12 @@
Zone_Location ();
+ //---- map node to zones ----
+
+ if (zone_node_flag) {
+ Zone_Nodes ();
+ }
+
//---- zone summary data ----
if (zone_sum_flag) {
@@ -126,7 +132,7 @@
//---- end the program ----
- Report_Problems (tot_trips);
+ Report_Problems ((int) tot_trips);
Exit_Stat (DONE);
}
Modified: version7/trunk/Transims70/ConvertTrips/Get_Trip_Data.cpp
===================================================================
--- version7/trunk/Transims70/ConvertTrips/Get_Trip_Data.cpp 2018-12-20 02:38:46 UTC (rev 1714)
+++ version7/trunk/Transims70/ConvertTrips/Get_Trip_Data.cpp 2018-12-20 02:43:27 UTC (rev 1715)
@@ -35,7 +35,7 @@
if (!trip_file->Write ()) {
Error ("Writing Trip File");
}
- trip_file->Add_Trip (file.Household (), file.Person (), file.Tour ());
+ trip_file->Add_Trip (file.Household (), file.Person (), file.Tour (), file.Trips ());
trip_copy++;
//---- don't save the record ----
Modified: version7/trunk/Transims70/ConvertTrips/Read_Trip_Table.cpp
===================================================================
--- version7/trunk/Transims70/ConvertTrips/Read_Trip_Table.cpp 2018-12-20 02:38:46 UTC (rev 1714)
+++ version7/trunk/Transims70/ConvertTrips/Read_Trip_Table.cpp 2018-12-20 02:43:27 UTC (rev 1715)
@@ -11,10 +11,10 @@
void ConvertTrips::Read_Trip_Table (ConvertTrip_Itr group)
{
Dtime tod, low, high, start, end;
- int p, p1, p2, num_p, trp, period, current, first_p, last_p, per, num_periods;
- int total, stat, errors, org_zone, des_zone, org, des, o, d, trips, num, num_shares, even_bucket, even;
+ int p, p1, p2, num_p, period, current, first_p, last_p, per, num_periods;
+ int org_zone, des_zone, org, des, o, d, trp, num, num_shares, even_bucket, even;
bool share_flag, factor_flag, time_fac_flag, scale_flag, return_flag, period_flag, forward;
- double trip, factor, added, deleted, bucket;
+ double trip, added, deleted, bucket, trips, total, errors, stat, trip_fac;
Db_Matrix *file;
Factor_Period *period_fac;
@@ -23,7 +23,7 @@
Int_Map_Itr org_itr, des_itr;
Int_Map_RItr des_ritr;
- static string error_msg = "%d Trip%sbetween Zones %d and %d could not be allocated";
+ static string error_msg = "%.3lf Trip%sbetween Zones %d and %d could not be allocated";
//---- read the trip table ----
@@ -38,7 +38,7 @@
return_flag = group->Return_Flag ();
even_bucket = 1;
- bucket = 0.45;
+ bucket = (fraction_flag) ? 0 : 0.45;
factor_flag = group->Factor_Flag ();
time_fac_flag = group->Factor_Periods_Flag ();
@@ -154,13 +154,24 @@
org_in [org] += trip;
des_in [des] += trip;
}
- trip += bucket;
- trips = (int) trip;
- if (trips < 0) trips = 0;
- bucket = trip - trips;
+ if (fraction_flag) {
+ trip += bucket;
- if (trips == 0) continue;
- total += trips;
+ if (trip < min_trips) {
+ bucket = trip;
+ continue;
+ } else {
+ bucket = 0;
+ }
+ } else {
+ trip += bucket;
+ trp = (int) trip;
+ if (trp < 0) trp = 0;
+ bucket = trip - trp;
+ if (trp == 0) continue;
+ trip = trp;
+ }
+ total += trip;
//---- apply the selection script ----
@@ -199,7 +210,7 @@
if (time_fac_flag) {
period = -1;
p1 = p2 = 0;
- trip = 0.0;
+ trip_fac = 0.0;
for (p = first_p; p <= last_p; p++) {
tod = group->Diurnal_Period_Time (p);
@@ -210,50 +221,58 @@
if (period >= 0) {
period_fac = group->Period_Factor (o, d, period);
- factor = trip * period_fac->Factor ();
- if (factor > trip) {
- added += factor - trip;
- } else {
- deleted += trip - factor;
+ trips = trip_fac * period_fac->Factor ();
+
+ if (!fraction_flag) {
+ if (trips > trip) {
+ added += trips - trip_fac;
+ } else {
+ deleted += trip_fac - trips;
+ }
+ trips= period_fac->Bucket_Factor (trip_fac);
}
- trp = period_fac->Bucket_Factor (trip);
- if (trp > 0 && return_flag) {
+ if (trips > 0 && return_flag && !fraction_flag) {
+ trp = (int) trips;
even = (((trp + even_bucket) / 2) * 2);
even_bucket += trp - even;
- trp = even;
+ trips = even;
}
- if (trp > 0) {
- stat = Set_Trips (group, org, des, trp, num, p1, p2, return_flag);
- if (stat > 0) {
+ if (trips > 0) {
+ stat = Set_Trips (group, org, des, trips, num, p1, p2, return_flag);
+
+ if (stat > 0.005) {
errors += stat;
- Print (1, String (error_msg) % stat % ((stat > 1) ? "s " : " ") % org_zone % des_zone);
+ Print (1, String (error_msg) % stat % ((stat != 1) ? "s " : " ") % org_zone % des_zone);
}
}
}
period = current;
p1 = p;
- trip = 0.0;
+ trip_fac = 0.0;
}
- trip += trips * group->Share (p, num);
+ trip_fac += trip * group->Share (p, num);
p2 = p;
}
+ trip = trip_fac;
} else {
p1 = first_p;
p2 = last_p;
- trip = trips;
}
period_fac = group->Period_Factor (o, d, period);
- factor = trip * period_fac->Factor ();
- if (factor > trip) {
- added += factor - trip;
- } else {
- deleted += trip - factor;
+ trips = trip * period_fac->Factor ();
+
+ if (!fraction_flag) {
+ if (trips > trip) {
+ added += trips - trip;
+ } else {
+ deleted += trip - trips;
+ }
+ trips = period_fac->Bucket_Factor (trip);
}
- trp = period_fac->Bucket_Factor (trip);
} else if (period >= 0) {
p1 = p2 = -1;
file->Period_Range (period, start, end);
@@ -269,24 +288,25 @@
}
if (p1 >= 0 && p2 >= 0) break;
}
- trp = trips;
+ trips = trip;
} else {
p1 = first_p;
p2 = last_p;
- trp = trips;
+ trips = trip;
}
- if (trp > 0 && return_flag) {
+ if (trips > 0 && return_flag && !fraction_flag) {
+ trp = (int) trips;
even = (((trp + even_bucket) / 2) * 2);
even_bucket += trp - even;
- trp = even;
+ trips = even;
}
//---- process the trips ----
- if (trp > 0) {
- stat = Set_Trips (group, org, des, trp, num, p1, p2, return_flag);
+ if (trips > 0) {
+ stat = Set_Trips (group, org, des, trips, num, p1, p2, return_flag);
- if (stat > 0) {
+ if (stat > 0.005) {
errors += stat;
Print (1, String (error_msg) % stat % ((stat > 1) ? "s " : " ") % org_zone % des_zone);
}
@@ -298,18 +318,18 @@
file->Close ();
- Print (1, String ("%s has %d Records and %d Trips") % file->File_Type () % Progress_Count () % total);
+ Print (1, String ("%s has %d Records and %.2lf Trips") % file->File_Type () % Progress_Count () % total);
tot_trips += total;
if (errors > 0) {
- Warning (String ("A Total of %d Trip%scould not be allocated") % errors % ((errors > 1) ? "s " : " "));
+ Warning (String ("A Total of %.2lf Trip%scould not be allocated") % errors % ((errors != 1) ? "s " : " "));
Write (1);
tot_errors += errors;
}
if (factor_flag) {
- Print (1, String ("Trip Adjustments: %.0lf trips added, %.0lf trips deleted") % added % deleted);
+ Print (1, String ("Trip Adjustments: %.2lf trips added, %.2lf trips deleted") % added % deleted);
tot_add += added;
tot_del += deleted;
}
Modified: version7/trunk/Transims70/ConvertTrips/Set_Trip.cpp
===================================================================
--- version7/trunk/Transims70/ConvertTrips/Set_Trip.cpp 2018-12-20 02:38:46 UTC (rev 1714)
+++ version7/trunk/Transims70/ConvertTrips/Set_Trip.cpp 2018-12-20 02:43:27 UTC (rev 1715)
@@ -10,21 +10,25 @@
// Set_Trips
//---------------------------------------------------------
-int ConvertTrips::Set_Trips (ConvertTrip_Itr group, int org, int des, int trips, int num, int t1, int t2, bool return_flag)
+double ConvertTrips::Set_Trips (ConvertTrip_Itr group, int org, int des, double trips, int num, int t1, int t2, bool return_flag)
{
- int loc, trp, num_out, org_loc, org_park, des_loc, skim, period, type, org_zone, des_zone;
+ int loc, trp, num_out, org_loc, org_park, des_loc, skim, period, type, org_zone, des_zone, org_node, des_node, max_out;
int last, veh, x, y, mode, ntrips, retry_count, passengers, purpose, constraint, priority, veh_type;
- double org_wt, des_wt, prob, dist, cum_wt, dx, dy, share, share1, total, percent, percent_prob;
- bool org_flag, des_flag, travel_script_flag, skip, split_flag;
+ double org_wt, des_wt, prob, dist, cum_wt, dx, dy, share, share1, total, percent, percent_prob, last_trip, trips_out;
+ bool org_flag, des_flag, travel_script_flag, skip;
Dtime start, arrive, time, time1, ttim, t, duration;
Convert_Location *loc_ptr;
Location_Data *location_ptr;
+ Zone_Data *zone_ptr;
+ Node_Data *node_ptr;
Share_Data *share_ptr;
Int_Itr int_itr;
num_out = skim = 0;
loc_ptr = 0;
+ last_trip = 0;
+ trips_out = 0;
//---- set the vehicle access flags ----
@@ -36,65 +40,135 @@
des_flag = (mode != DRIVE_MODE && mode != PNR_IN_MODE && mode != KNR_IN_MODE &&
mode != HOV2_MODE && mode != HOV3_MODE && mode != HOV4_MODE && mode != TAXI_MODE);
- //---- calculate the origin weight ----
+ org_zone = des_zone = org_loc = des_loc = org_node = des_node = 0;
+ dist = 0;
- org_wt = 0.0;
+ if (od_output_type == ZONE_ID) {
+ org_wt = des_wt = 1.0;
- for (loc = zone_loc [org]; loc >= 0; loc = loc_ptr->Zone_List ()) {
- loc_ptr = &convert_array [loc];
+ org_zone = org;
+ des_zone = des;
- if (org_flag || loc_ptr->Org_Parking () >= 0) {
- org_wt += loc_ptr->Weight (group->Org_Wt ());
+ zone_ptr = &zone_array [org];
+
+ org = zone_ptr->Zone ();
+ x = zone_ptr->X ();
+ y = zone_ptr->Y ();
+
+ zone_ptr = &zone_array [des];
+
+ des = zone_ptr->Zone ();
+
+ dx = zone_ptr->X () - x;
+ dy = zone_ptr->Y () - y;
+
+ dist = sqrt (dx * dx + dy * dy);
+
+ } else if (od_output_type == NODE_ID) {
+
+ //---- calculate the origin weight ----
+
+ org_wt = 0.0;
+
+ for (int_itr = zone_node [org].begin (); int_itr != zone_node [org].end (); int_itr++) {
+ node_ptr = &node_array [*int_itr];
+ org_wt += node_ptr->Control ();
}
- }
- if (org_ptr != 0) {
- for (int_itr = org_ptr->begin (); int_itr != org_ptr->end (); int_itr++) {
- loc_ptr = &convert_array [*int_itr];
+ //---- calculate the destination weight ----
+
+ des_wt = 0.0;
+
+ for (int_itr = zone_node [des].begin (); int_itr != zone_node [des].end (); int_itr++) {
+ node_ptr = &node_array [*int_itr];
+ des_wt += node_ptr->Control ();
+ }
+
+ } else {
+
+ //---- calculate the origin weight ----
+
+ org_wt = 0.0;
+
+ for (loc = zone_loc [org]; loc >= 0; loc = loc_ptr->Zone_List ()) {
+ loc_ptr = &convert_array [loc];
+
if (org_flag || loc_ptr->Org_Parking () >= 0) {
org_wt += loc_ptr->Weight (group->Org_Wt ());
}
}
- }
- if (org_wt == 0.0) return (trips);
+ if (org_ptr != 0) {
+ for (int_itr = org_ptr->begin (); int_itr != org_ptr->end (); int_itr++) {
+ loc_ptr = &convert_array [*int_itr];
- //---- check the destination weight ----
-
- des_wt = 0.0;
+ if (org_flag || loc_ptr->Org_Parking () >= 0) {
+ org_wt += loc_ptr->Weight (group->Org_Wt ());
+ }
+ }
+ }
+ if (org_wt == 0.0) return (trips);
- for (loc = zone_loc [des]; loc >= 0; loc = loc_ptr->Zone_List ()) {
- loc_ptr = &convert_array [loc];
+ //---- check the destination weight ----
- if (des_flag || loc_ptr->Des_Parking () >= 0) {
- des_wt += loc_ptr->Weight (group->Des_Wt ());
- }
- }
- if (des_ptr != 0) {
- for (int_itr = des_ptr->begin (); int_itr != des_ptr->end (); int_itr++) {
- loc_ptr = &convert_array [*int_itr];
+ des_wt = 0.0;
+ for (loc = zone_loc [des]; loc >= 0; loc = loc_ptr->Zone_List ()) {
+ loc_ptr = &convert_array [loc];
+
if (des_flag || loc_ptr->Des_Parking () >= 0) {
des_wt += loc_ptr->Weight (group->Des_Wt ());
}
}
+ if (des_ptr != 0) {
+ for (int_itr = des_ptr->begin (); int_itr != des_ptr->end (); int_itr++) {
+ loc_ptr = &convert_array [*int_itr];
+
+ if (des_flag || loc_ptr->Des_Parking () >= 0) {
+ des_wt += loc_ptr->Weight (group->Des_Wt ());
+ }
+ }
+ }
+ if (des_wt == 0.0) return (trips);
}
- if (des_wt == 0.0) return (trips);
- split_flag = false;
+ //---- number of output records ----
+
percent_prob = 0.0;
+ max_out = (int) trips;
if (return_flag) {
if (group->Return_Percent () == 0 || group->Return_Percent () == 100) {
- ntrips = (trips + 1) / 2;
+ ntrips = (int) (trips / 2);
} else {
- split_flag = true;
percent = (200.0 - group->Return_Percent ()) / 200.0;
percent_prob = group->Return_Percent () / percent;
ntrips = DTOI (trips * percent);
}
+ if (fraction_flag) {
+ if (ntrips <= 1) ntrips = 1;
+
+ max_out = ntrips * 2;
+ last_trip = (trips - (max_out - 2)) / 2;
+ if (trips > 0 && last_trip == 0) last_trip = 1.0;
+ }
+
} else {
- ntrips = trips;
+ ntrips = (int) trips;
+
+ if (fraction_flag) {
+ last_trip = trips - max_out;
+
+ if (ntrips == 0) {
+ if (last_trip > 0) {
+ ntrips = max_out = 1;
+ last_trip = trips;
+ }
+ } else if (trips > 0) {
+ last_trip += 1.0;
+ }
+ }
}
+ if (ntrips == 0) return (trips);
//---- distribute the trips to the time targets ----
@@ -115,96 +189,71 @@
for (trp=0; trp < ntrips; trp++) {
- //---- locate the trip origin ----
+ if (od_output_type == LOCATION_ID) {
- prob = org_wt * random_org.Probability ();
+ //---- locate the trip origin ----
- last = -1;
- cum_wt = 0.0;
+ prob = org_wt * random_org.Probability ();
- for (loc = zone_loc [org]; loc >= 0; loc = loc_ptr->Zone_List ()) {
- loc_ptr = &convert_array [loc];
+ last = -1;
+ cum_wt = 0.0;
- if (org_flag || loc_ptr->Org_Parking () >= 0) {
- share = loc_ptr->Weight (group->Org_Wt ());
+ for (loc = zone_loc [org]; loc >= 0; loc = loc_ptr->Zone_List ()) {
+ loc_ptr = &convert_array [loc];
- if (share != 0.0) {
- cum_wt += share;
- if (prob < cum_wt) break;
- last = loc;
- }
- }
- }
- if (loc < 0 && org_ptr != 0) {
- for (int_itr = org_ptr->begin (); int_itr != org_ptr->end (); int_itr++) {
- loc_ptr = &convert_array [*int_itr];
-
if (org_flag || loc_ptr->Org_Parking () >= 0) {
share = loc_ptr->Weight (group->Org_Wt ());
if (share != 0.0) {
cum_wt += share;
- if (prob < cum_wt) {
- loc = *int_itr;
- break;
+ if (prob < cum_wt) break;
+ last = loc;
+ }
+ }
+ }
+ if (loc < 0 && org_ptr != 0) {
+ for (int_itr = org_ptr->begin (); int_itr != org_ptr->end (); int_itr++) {
+ loc_ptr = &convert_array [*int_itr];
+
+ if (org_flag || loc_ptr->Org_Parking () >= 0) {
+ share = loc_ptr->Weight (group->Org_Wt ());
+
+ if (share != 0.0) {
+ cum_wt += share;
+ if (prob < cum_wt) {
+ loc = *int_itr;
+ break;
+ }
+ last = *int_itr;
}
- last = *int_itr;
}
}
}
- }
- if (loc < 0) {
- if (last < 0) {
- Set_Problem (LOCATION_PROBLEM);
- continue;
+ if (loc < 0) {
+ if (last < 0) {
+ Set_Problem (LOCATION_PROBLEM);
+ continue;
+ }
+ loc = last;
+ loc_ptr = &convert_array [last];
}
- loc = last;
- loc_ptr = &convert_array [last];
- }
- org_park = loc_ptr->Org_Parking ();
+ org_park = loc_ptr->Org_Parking ();
- location_ptr = &location_array [loc];
-
- org_loc = location_ptr->Location ();
- org_zone = location_ptr->Zone ();
- x = location_ptr->X ();
- y = location_ptr->Y ();
-
- //---- calculate the destination weight ----
-
- des_wt = 0.0;
-
- for (loc = zone_loc [des]; loc >= 0; loc = loc_ptr->Zone_List ()) {
- loc_ptr = &convert_array [loc];
location_ptr = &location_array [loc];
- if (location_ptr->Location () != org_loc && (des_flag || loc_ptr->Des_Parking () >= 0)) {
- share = loc_ptr->Weight (group->Des_Wt ());
+ org_loc = location_ptr->Location ();
+ org_zone = location_ptr->Zone ();
+ x = location_ptr->X ();
+ y = location_ptr->Y ();
- if (share != 0.0) {
+ //---- calculate the destination weight ----
- if (group->Dist_Wt ()) {
+ des_wt = 0.0;
- //--- apply the distance weight ----
+ for (loc = zone_loc [des]; loc >= 0; loc = loc_ptr->Zone_List ()) {
+ loc_ptr = &convert_array [loc];
+ location_ptr = &location_array [loc];
- dx = location_ptr->X () - x;
- dy = location_ptr->Y () - y;
-
- dist = sqrt (dx * dx + dy * dy);
- if (dist == 0.0) dist = 0.01;
-
- des_wt += share * dist;
- } else {
- des_wt += share;
- }
- }
- }
- }
- if (des_ptr != 0) {
- for (int_itr = des_ptr->begin (); int_itr != des_ptr->end (); int_itr++) {
- loc_ptr = &convert_array [*int_itr];
- location_ptr = &location_array [*int_itr];
-
if (location_ptr->Location () != org_loc && (des_flag || loc_ptr->Des_Parking () >= 0)) {
share = loc_ptr->Weight (group->Des_Wt ());
@@ -212,7 +261,7 @@
if (group->Dist_Wt ()) {
- //---- apply the distance weight ----
+ //--- apply the distance weight ----
dx = location_ptr->X () - x;
dy = location_ptr->Y () - y;
@@ -227,51 +276,50 @@
}
}
}
- }
- if (des_wt == 0.0) {
- Set_Problem (LOCATION_PROBLEM);
- continue;
- }
+ if (des_ptr != 0) {
+ for (int_itr = des_ptr->begin (); int_itr != des_ptr->end (); int_itr++) {
+ loc_ptr = &convert_array [*int_itr];
+ location_ptr = &location_array [*int_itr];
- //---- locate the destination ----
+ if (location_ptr->Location () != org_loc && (des_flag || loc_ptr->Des_Parking () >= 0)) {
+ share = loc_ptr->Weight (group->Des_Wt ());
- prob = des_wt * random_des.Probability ();
-
- last = -1;
- cum_wt = 0.0;
+ if (share != 0.0) {
- for (loc = zone_loc [des]; loc >= 0; loc = loc_ptr->Zone_List ()) {
- loc_ptr = &convert_array [loc];
- location_ptr = &location_array [loc];
+ if (group->Dist_Wt ()) {
- if (location_ptr->Location () != org_loc && (des_flag || loc_ptr->Des_Parking () >= 0)) {
- share = loc_ptr->Weight (group->Des_Wt ());
+ //---- apply the distance weight ----
- if (share != 0.0) {
- if (group->Dist_Wt ()) {
+ dx = location_ptr->X () - x;
+ dy = location_ptr->Y () - y;
- //--- apply the distance weight ----
+ dist = sqrt (dx * dx + dy * dy);
+ if (dist == 0.0) dist = 0.01;
- dx = location_ptr->X () - x;
- dy = location_ptr->Y () - y;
-
- dist = sqrt (dx * dx + dy * dy);
- if (dist == 0.0) dist = 0.01;
-
- cum_wt += share * dist;
- } else {
- cum_wt += share;
+ des_wt += share * dist;
+ } else {
+ des_wt += share;
+ }
+ }
}
- if (prob < cum_wt) break;
- last = loc;
}
}
- }
- if (loc < 0 && des_ptr != 0) {
- for (int_itr = des_ptr->begin (); int_itr != des_ptr->end (); int_itr++) {
- loc_ptr = &convert_array [*int_itr];
- location_ptr = &location_array [*int_itr];
+ if (des_wt == 0.0) {
+ Set_Problem (LOCATION_PROBLEM);
+ continue;
+ }
+ //---- locate the destination ----
+
+ prob = des_wt * random_des.Probability ();
+
+ last = -1;
+ cum_wt = 0.0;
+
+ for (loc = zone_loc [des]; loc >= 0; loc = loc_ptr->Zone_List ()) {
+ loc_ptr = &convert_array [loc];
+ location_ptr = &location_array [loc];
+
if (location_ptr->Location () != org_loc && (des_flag || loc_ptr->Des_Parking () >= 0)) {
share = loc_ptr->Weight (group->Des_Wt ());
@@ -278,7 +326,7 @@
if (share != 0.0) {
if (group->Dist_Wt ()) {
- //---- apply the distance weight ----
+ //--- apply the distance weight ----
dx = location_ptr->X () - x;
dy = location_ptr->Y () - y;
@@ -290,33 +338,121 @@
} else {
cum_wt += share;
}
- if (prob < cum_wt) {
- loc = *int_itr;
- break;
+ if (prob < cum_wt) break;
+ last = loc;
+ }
+ }
+ }
+ if (loc < 0 && des_ptr != 0) {
+ for (int_itr = des_ptr->begin (); int_itr != des_ptr->end (); int_itr++) {
+ loc_ptr = &convert_array [*int_itr];
+ location_ptr = &location_array [*int_itr];
+
+ if (location_ptr->Location () != org_loc && (des_flag || loc_ptr->Des_Parking () >= 0)) {
+ share = loc_ptr->Weight (group->Des_Wt ());
+
+ if (share != 0.0) {
+ if (group->Dist_Wt ()) {
+
+ //---- apply the distance weight ----
+
+ dx = location_ptr->X () - x;
+ dy = location_ptr->Y () - y;
+
+ dist = sqrt (dx * dx + dy * dy);
+ if (dist == 0.0) dist = 0.01;
+
+ cum_wt += share * dist;
+ } else {
+ cum_wt += share;
+ }
+ if (prob < cum_wt) {
+ loc = *int_itr;
+ break;
+ }
+ last = *int_itr;
}
- last = *int_itr;
}
}
}
- }
- if (loc < 0) {
- if (last < 0) {
+ if (loc < 0) {
+ if (last < 0) {
+ Set_Problem (LOCATION_PROBLEM);
+ continue;
+ }
+ loc = last;
+ loc_ptr = &convert_array [last];
+ }
+ location_ptr = &location_array [loc];
+ des_loc = location_ptr->Location ();
+ des_zone = location_ptr->Zone ();
+
+ dx = location_ptr->X () - x;
+ dy = location_ptr->Y () - y;
+
+ dist = sqrt (dx * dx + dy * dy);
+
+ if (org_loc == des_loc) continue;
+
+ } else if (od_output_type == NODE_ID) {
+
+ //---- locate the trip origin ----
+
+ prob = org_wt * random_org.Probability ();
+
+ org_node = -1;
+ cum_wt = 0.0;
+
+ for (int_itr = zone_node [org].begin (); int_itr != zone_node [org].end (); int_itr++) {
+ node_ptr = &node_array [*int_itr];
+ cum_wt += node_ptr->Control ();
+ if (prob <= cum_wt) {
+ org_node = *int_itr;
+ break;
+ }
+ }
+
+ if (org_node < 0) {
Set_Problem (LOCATION_PROBLEM);
continue;
}
- loc = last;
- loc_ptr = &convert_array [last];
- }
- location_ptr = &location_array [loc];
- des_loc = location_ptr->Location ();
- des_zone = location_ptr->Zone ();
- dx = location_ptr->X () - x;
- dy = location_ptr->Y () - y;
+ node_ptr = &node_array [org_node];
+ x = node_ptr->X ();
+ y = node_ptr->Y ();
- dist = sqrt (dx * dx + dy * dy);
+ //---- locate the trip destination ----
+
+ prob = (des_wt - node_ptr->Control ()) * random_org.Probability ();
- if (org_loc == des_loc) continue;
+ des_node = -1;
+ cum_wt = 0.0;
+
+ for (int_itr = zone_node [des].begin (); int_itr != zone_node [des].end (); int_itr++) {
+ node_ptr = &node_array [*int_itr];
+ if (*int_itr == org_node) continue;
+ cum_wt += node_ptr->Control ();
+ if (prob <= cum_wt) {
+ des_node = *int_itr;
+ break;
+ }
+ }
+ if (des_node < 0) {
+ Set_Problem (LOCATION_PROBLEM);
+ continue;
+ }
+ node_ptr = &node_array [des_node];
+
+ dx = node_ptr->X () - x;
+ dy = node_ptr->Y () - y;
+
+ dist = sqrt (dx * dx + dy * dy);
+
+ if (org_node == des_node) continue;
+
+ des_node = node_ptr->Node ();
+ org_node = node_array [org_node].Node ();
+ }
//---- set the time of day ----
@@ -460,14 +596,35 @@
trip_file->Vehicle (veh);
trip_file->Veh_Type (veh_type);
trip_file->Start (start.Round_Seconds ());
- trip_file->Origin (org_loc);
trip_file->End (arrive.Round_Seconds ());
- trip_file->Destination (des_loc);
+
+ if (od_output_type == ZONE_ID) {
+ trip_file->Origin (org);
+ trip_file->Org_Type (ZONE_ID);
+ trip_file->Destination (des);
+ trip_file->Des_Type (ZONE_ID);
+ } else if (od_output_type == NODE_ID) {
+ trip_file->Origin (org_node);
+ trip_file->Org_Type (NODE_ID);
+ trip_file->Destination (des_node);
+ trip_file->Des_Type (NODE_ID);
+ } else {
+ trip_file->Origin (org_loc);
+ trip_file->Org_Type (LOCATION_ID);
+ trip_file->Destination (des_loc);
+ trip_file->Des_Type (LOCATION_ID);
+ }
trip_file->Duration (duration);
trip_file->Constraint (constraint);
trip_file->Priority (priority);
trip_file->Type (type);
+ if (fraction_flag) {
+ trip_file->Trips (((trp + 1) == ntrips) ? last_trip : 1.0);
+ } else {
+ trip_file->Trips (1);
+ }
+
skip = ((select_start_times && !start_range.In_Range (start)) ||
(select_end_times && !end_range.In_Range (arrive)));
@@ -479,8 +636,9 @@
if (!trip_file->Write ()) {
Error ("Writing Trip File");
}
- trip_file->Add_Trip (hhold_id, 1, 1);
- new_trips++;
+ trip_file->Add_Trip (hhold_id, 1, 1, trip_file->Trips ());
+ trips_out += trip_file->Trips ();
+ new_trips += trip_file->Trips ();
}
//---- household data ----
@@ -518,7 +676,7 @@
//---- check for return trips ----
- if (!return_flag || num_out == trips) continue;
+ if (!return_flag || num_out == max_out) continue;
if (percent_flag) {
if (percent_prob < random_return.Probability ()) continue;
@@ -548,13 +706,28 @@
trip_file->Trip (2);
trip_file->Mode (mode);
trip_file->Start (start.Round_Seconds ());
- trip_file->Origin (des_loc);
trip_file->End (arrive.Round_Seconds ());
- trip_file->Destination (org_loc);
+
+ if (od_output_type == ZONE_ID) {
+ trip_file->Origin (des);
+ trip_file->Destination (org);
+ } else if (od_output_type == NODE_ID) {
+ trip_file->Origin (des_node);
+ trip_file->Destination (org_node);
+ } else {
+ trip_file->Origin (des_loc);
+ trip_file->Destination (org_loc);
+ }
trip_file->Duration (0);
trip_file->Constraint (0);
trip_file->Purpose (purpose);
trip_file->Priority (priority);
+
+ if (fraction_flag) {
+ trip_file->Trips (((trp + 1) == ntrips) ? last_trip : 1.0);
+ } else {
+ trip_file->Trips (1);
+ }
group->Return_Period (start);
@@ -569,10 +742,11 @@
if (!trip_file->Write ()) {
Error ("Writing Trip File");
}
- trip_file->Add_Trip (hhold_id, 1, 1);
- new_trips++;
+ trip_file->Add_Trip (hhold_id, 1, 1, trip_file->Trips ());
+ trips_out += trip_file->Trips ();
+ new_trips += trip_file->Trips ();
}
num_out++;
}
- return (trips - num_out);
+ return (trips - trips_out);
}
Modified: version7/trunk/Transims70/ConvertTrips/Tour_Process.cpp
===================================================================
--- version7/trunk/Transims70/ConvertTrips/Tour_Process.cpp 2018-12-20 02:38:46 UTC (rev 1714)
+++ version7/trunk/Transims70/ConvertTrips/Tour_Process.cpp 2018-12-20 02:43:27 UTC (rev 1715)
@@ -304,7 +304,7 @@
Warning ("Writing ") << problem_file->File_Type ();
problem_flag = false;
}
- problem_file->Add_Trip (last_hhold, person, tour);
+ problem_file->Add_Trip (last_hhold, person, tour, 1);
}
}
@@ -330,9 +330,10 @@
trip_file->Destination (trip_itr->Destination ());
trip_file->Priority (trip_itr->Priority ());
trip_file->Vehicle (trip_itr->Vehicle ());
+ trip_file->Trips (1.0);
if (!trip_file->Write ()) goto trip_error;
- trip_file->Add_Trip (trip_itr->Household (), trip_itr->Person (), trip_itr->Tour ());
+ trip_file->Add_Trip (trip_itr->Household (), trip_itr->Person (), trip_itr->Tour (), trip_itr->Trips ());
new_trips++;
if (zone_sum_flag) {
Copied: version7/trunk/Transims70/ConvertTrips/Zone_Nodes.cpp (from rev 1714, version7/branches/aecom/Transims70/ConvertTrips/Zone_Nodes.cpp)
===================================================================
--- version7/trunk/Transims70/ConvertTrips/Zone_Nodes.cpp (rev 0)
+++ version7/trunk/Transims70/ConvertTrips/Zone_Nodes.cpp 2018-12-20 02:43:27 UTC (rev 1715)
@@ -0,0 +1,107 @@
+//*********************************************************
+// Zone_Nodes.cpp - assign nodes to zones
+//*********************************************************
+
+#include "ConvertTrips.hpp"
+
+//---------------------------------------------------------
+// Zone_Nodes
+//---------------------------------------------------------
+
+void ConvertTrips::Zone_Nodes (void)
+{
+ int zone, node, best, type, skip;
+ double x0, y0, dx, dy, diff;
+
+ Link_Itr link_itr;
+ Node_Data *node_ptr;
+ Node_Itr node_itr;
+ Zone_Itr zone_itr;
+ Zone_Data *zone_ptr;
+ Integers nodes;
+ Ints_Itr itr;
+
+ for (node_itr = node_array.begin (); node_itr != node_array.end (); node_itr++) {
+ node_itr->Control (0);
+ }
+
+ //---- set node weights ----
+
+ for (link_itr = link_array.begin (); link_itr != link_array.end (); link_itr++) {
+ type = link_itr->Type ();
+ if (type > RAMP) continue;
+ if (type > LOCAL) type = 1;
+
+ node_ptr = &node_array [link_itr->Anode ()];
+ if (node_ptr->Control () < type) {
+ node_ptr->Control (type);
+ }
+ node_ptr = &node_array [link_itr->Bnode ()];
+ if (node_ptr->Control () < type) {
+ node_ptr->Control (type);
+ }
+ }
+ zone_node.assign (zone_array.size (), nodes);
+
+ //---- map nodes to zones ----
+
+ for (node = 0, node_itr = node_array.begin (); node_itr != node_array.end (); node_itr++, node++) {
+ if (node_itr->Control () == 0) continue;
+
+ x0 = node_itr->X ();
+ y0 = node_itr->Y ();
+
+ best = 0;
+ diff = MAX_INTEGER;
+
+ for (zone = 0, zone_itr = zone_array.begin (); zone_itr != zone_array.end (); zone_itr++, zone++) {
+ dx = x0 - zone_itr->X ();
+ dy = y0 - zone_itr->Y ();
+
+ dx = dx * dx + dy * dy;
+
+ if (dx < diff) {
+ best = zone;
+ diff = dx;
+ }
+ }
+ zone_node [best].push_back (node);
+ }
+
+ //---- check for missing nodes ----
+
+ for (zone = 0, itr = zone_node.begin (); itr != zone_node.end (); itr++, zone++) {
+retry:
+ if (itr->size () > 1) continue;
+
+ if (itr->size () > 0) {
+ skip = itr->at (0);
+ } else {
+ skip = -1;
+ }
+
+ zone_ptr = &zone_array [zone];
+
+ x0 = zone_itr->X ();
+ y0 = zone_itr->Y ();
+
+ best = 0;
+ diff = -1;
+
+ for (node = 0, node_itr = node_array.begin (); node_itr != node_array.end (); node_itr++, node++) {
+ if (node == skip || node_itr->Control () == 0) continue;
+
+ dx = x0 - node_itr->X ();
+ dy = y0 - node_itr->Y ();
+
+ dx = dx * dx + dy * dy;
+
+ if (dx < diff || diff < 0) {
+ best = node;
+ diff = dx;
+ }
+ }
+ itr->push_back (best);
+ goto retry;
+ }
+}
Modified: version7/trunk/Transims70/Data_Service/Performance_Data.cpp
===================================================================
--- version7/trunk/Transims70/Data_Service/Performance_Data.cpp 2018-12-20 02:38:46 UTC (rev 1714)
+++ version7/trunk/Transims70/Data_Service/Performance_Data.cpp 2018-12-20 02:43:27 UTC (rev 1715)
@@ -878,7 +878,7 @@
// Flow_Time
//---------------------------------------------------------
-Dtime Perf_Period_Array::Flow_Time (int dir_index, Dtime tod, double len_factor, double len, int veh_type, double pce, double occ, bool group_flag, bool forward_flag)
+Dtime Perf_Period_Array::Flow_Time (int dir_index, Dtime tod, double len_factor, double len, double trips, int veh_type, double pce, double occ, bool group_flag, bool forward_flag)
{
int period, num_periods, min_period, max_period, num;
Dtime low, high, end_time, ttime, ttim, increment;
@@ -886,6 +886,10 @@
bool first;
num_periods = periods->Num_Periods ();
+
+ if (trips == 0.0) trips = 1.0;
+ pce *= trips;
+ occ *= trips;
len *= pce;
ttime = 0;
first = true;
@@ -939,11 +943,11 @@
if (end_time <= high) {
ttime += ttim;
perf_ptr->Add_Persons (occ);
- perf_ptr->Add_Vehicles (veh_type);
+ perf_ptr->Add_Vehicles (veh_type, trips);
perf_ptr->Add_Volume (pce);
if (group_flag) perf_ptr->Add_Group_Vol (pce);
if (first) perf_ptr->Add_Enter (pce);
- perf_ptr->Add_Max_Volume (pce);
+ perf_ptr->Add_Max_Volume (pce * trips);
perf_ptr->Add_Veh_Time (tt * pce);
perf_ptr->Add_Veh_Dist (len * len_factor);
perf_ptr->Add_Veh_Delay (delay * pce);
@@ -961,7 +965,7 @@
factor = 0.001;
}
perf_ptr->Add_Persons (occ);
- perf_ptr->Add_Vehicles (veh_type);
+ perf_ptr->Add_Vehicles (veh_type, trips);
perf_ptr->Add_Volume (pce);
if (group_flag) perf_ptr->Add_Group_Vol (pce);
if (first) perf_ptr->Add_Enter (pce);
@@ -980,7 +984,7 @@
if (end_time >= low) {
ttime += ttim;
perf_ptr->Add_Persons (occ);
- perf_ptr->Add_Vehicles (veh_type);
+ perf_ptr->Add_Vehicles (veh_type, trips);
perf_ptr->Add_Volume (pce);
if (group_flag) perf_ptr->Add_Group_Vol (pce);
if (first) perf_ptr->Add_Exit (pce);
@@ -998,7 +1002,7 @@
factor = 0.001;
}
perf_ptr->Add_Persons (occ);
- perf_ptr->Add_Vehicles (veh_type);
+ perf_ptr->Add_Vehicles (veh_type, trips);
perf_ptr->Add_Volume (pce);
if (group_flag) perf_ptr->Add_Group_Vol (pce);
if (first) perf_ptr->Add_Exit (pce);
@@ -1029,7 +1033,7 @@
// Load_Flow
//---------------------------------------------------------
-Dtime Perf_Period_Array::Load_Flow (int dir_index, Dtime tod, Dtime ttime, double len_factor, double len, int veh_type, double pce, double occ, bool group_flag, bool forward_flag)
+Dtime Perf_Period_Array::Load_Flow (int dir_index, Dtime tod, Dtime ttime, double len_factor, double len, double trips, int veh_type, double pce, double occ, bool group_flag, bool forward_flag)
{
int period, num_periods, end_period, num;
Dtime low, high, end_time, ttim, increment, end_tod;
@@ -1037,6 +1041,10 @@
bool first;
num_periods = periods->Num_Periods ();
+
+ if (trips == 0.0) trips = 1.0;
+ occ *= trips;
+ pce *= trips;
len *= pce;
perf_time = 0;
first = true;
@@ -1081,7 +1089,7 @@
perf_time = perf_ptr->Time () * len_factor;
perf_ptr->Add_Persons (occ);
- perf_ptr->Add_Vehicles (veh_type);
+ perf_ptr->Add_Vehicles (veh_type, trips);
perf_ptr->Add_Volume (pce);
if (group_flag) perf_ptr->Add_Group_Vol (pce);
perf_ptr->Add_Enter (pce);
@@ -1117,7 +1125,7 @@
factor = len_factor * (double) (high - tod) / ttime;
perf_ptr->Add_Persons (occ);
- perf_ptr->Add_Vehicles (veh_type);
+ perf_ptr->Add_Vehicles (veh_type, trips);
perf_ptr->Add_Volume (pce);
if (group_flag) perf_ptr->Add_Group_Vol (pce);
if (first) perf_ptr->Add_Enter (pce);
@@ -1139,7 +1147,7 @@
perf_time = perf_ptr->Time () * len_factor;
perf_ptr->Add_Persons (occ);
- perf_ptr->Add_Vehicles (veh_type);
+ perf_ptr->Add_Vehicles (veh_type, trips);
perf_ptr->Add_Volume (pce);
if (group_flag) perf_ptr->Add_Group_Vol (pce);
perf_ptr->Add_Enter (pce);
@@ -1175,7 +1183,7 @@
factor = len_factor * (double) (tod - low) / ttime;
perf_ptr->Add_Persons (occ);
- perf_ptr->Add_Vehicles (veh_type);
+ perf_ptr->Add_Vehicles (veh_type, trips);
perf_ptr->Add_Volume (pce);
if (group_flag) perf_ptr->Add_Group_Vol (pce);
if (first) perf_ptr->Add_Exit (pce);
Modified: version7/trunk/Transims70/Data_Service/Read_Plans.cpp
===================================================================
--- version7/trunk/Transims70/Data_Service/Read_Plans.cpp 2018-12-20 02:38:46 UTC (rev 1714)
+++ version7/trunk/Transims70/Data_Service/Read_Plans.cpp 2018-12-20 02:43:27 UTC (rev 1715)
@@ -72,7 +72,7 @@
plan_time_map.insert (Time_Map_Data (time_index, index));
}
- file.Add_Trip (plan_ptr->Household (), plan_ptr->Person (), plan_ptr->Tour ());
+ file.Add_Trip (plan_ptr->Household (), plan_ptr->Person (), plan_ptr->Tour (), plan_ptr->Trips ());
}
} else {
while (file.Read (false)) {
@@ -128,7 +128,7 @@
}
if (keep_flag) {
num = (int) plan_rec.size ();
- file.Add_Trip (plan_rec.Household (), plan_rec.Person (), plan_rec.Tour ());
+ file.Add_Trip (plan_rec.Household (), plan_rec.Person (), plan_rec.Tour (), plan_rec.Trips ());
file.Add_Leg (num);
plan_array.push_back (plan_rec);
Modified: version7/trunk/Transims70/Data_Service/Read_Problems.cpp
===================================================================
--- version7/trunk/Transims70/Data_Service/Read_Problems.cpp 2018-12-20 02:38:46 UTC (rev 1714)
+++ version7/trunk/Transims70/Data_Service/Read_Problems.cpp 2018-12-20 02:43:27 UTC (rev 1715)
@@ -25,7 +25,7 @@
problem_rec.Clear ();
if (Get_Problem_Data (file, problem_rec)) {
- file.Add_Trip (problem_rec.Household (), problem_rec.Person (), problem_rec.Tour ());
+ file.Add_Trip (problem_rec.Household (), problem_rec.Person (), problem_rec.Tour (), problem_rec.Trips ());
problem_array.push_back (problem_rec);
}
}
Modified: version7/trunk/Transims70/Data_Service/Read_Trips.cpp
===================================================================
--- version7/trunk/Transims70/Data_Service/Read_Trips.cpp 2018-12-20 02:38:46 UTC (rev 1714)
+++ version7/trunk/Transims70/Data_Service/Read_Trips.cpp 2018-12-20 02:43:27 UTC (rev 1715)
@@ -45,7 +45,7 @@
trip_index = trip_itr->Get_Trip_Index ();
trip_map.insert (Trip_Map_Data (trip_index, index));
- file.Add_Trip (trip_index.Household (), trip_index.Person (), trip_index.Tour ());
+ file.Add_Trip (trip_index.Household (), trip_index.Person (), trip_index.Tour (), trip_itr->Trips ());
}
} else {
while (file.Read ()) {
@@ -69,8 +69,7 @@
trip_index.Household () % trip_index.Person () % trip_index.Tour () % trip_index.Trip ());
} else {
trip_array.push_back (trip_rec);
- file.Add_Trip (trip_index.Household (), trip_index.Person (), trip_index.Tour ());
-
+ file.Add_Trip (trip_index.Household (), trip_index.Person (), trip_index.Tour (), trip_rec.Trips ());
}
}
}
Modified: version7/trunk/Transims70/Data_Service/Write_Trips.cpp
===================================================================
--- version7/trunk/Transims70/Data_Service/Write_Trips.cpp 2018-12-20 02:38:46 UTC (rev 1714)
+++ version7/trunk/Transims70/Data_Service/Write_Trips.cpp 2018-12-20 02:43:27 UTC (rev 1715)
@@ -49,6 +49,6 @@
if (!file.Write ()) {
Error (String ("Writing %s") % file.File_Type ());
}
- file.Add_Trip (data.Household (), data.Person (), data.Tour ());
+ file.Add_Trip (data.Household (), data.Person (), data.Tour (), data.Trips ());
return (1);
}
Modified: version7/trunk/Transims70/File_Service/Fare_File.cpp
===================================================================
--- version7/trunk/Transims70/File_Service/Fare_File.cpp 2018-12-20 02:38:46 UTC (rev 1714)
+++ version7/trunk/Transims70/File_Service/Fare_File.cpp 2018-12-20 02:43:27 UTC (rev 1715)
@@ -136,7 +136,7 @@
FILE *fh = f_open...
[truncated message content] |