├── Code ├── I-75.results │ └── 1.db ├── DriverModel_DLL_HV │ ├── DriverModel.h │ ├── DriverModel.vcxproj.user │ ├── DriverModel_changes.txt │ ├── DriverModel.cpp │ └── DriverModel.vcxproj └── DriverModel_DLL_CAV │ ├── DriverModel.h │ ├── DriverModel.vcxproj.user │ ├── DriverModel_changes.txt │ ├── DriverModel.vcxproj │ └── DriverModel.cpp ├── USF Readme updated.docx ├── CONTRIBUTING.md ├── STOL II TO 22_algorithm description document_CAV Lane Changing Model_Final_v2_clean.pdf ├── README.md └── LICENSE /Code/I-75.results/1.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/STOL-AMS/TO-22-Lane-Changing/HEAD/Code/I-75.results/1.db -------------------------------------------------------------------------------- /USF Readme updated.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/STOL-AMS/TO-22-Lane-Changing/HEAD/USF Readme updated.docx -------------------------------------------------------------------------------- /Code/DriverModel_DLL_HV/DriverModel.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/STOL-AMS/TO-22-Lane-Changing/HEAD/Code/DriverModel_DLL_HV/DriverModel.h -------------------------------------------------------------------------------- /Code/DriverModel_DLL_CAV/DriverModel.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/STOL-AMS/TO-22-Lane-Changing/HEAD/Code/DriverModel_DLL_CAV/DriverModel.h -------------------------------------------------------------------------------- /Code/DriverModel_DLL_CAV/DriverModel.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Code/DriverModel_DLL_HV/DriverModel.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change. -------------------------------------------------------------------------------- /STOL II TO 22_algorithm description document_CAV Lane Changing Model_Final_v2_clean.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/STOL-AMS/TO-22-Lane-Changing/HEAD/STOL II TO 22_algorithm description document_CAV Lane Changing Model_Final_v2_clean.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Summary: 3 | 4 | This repository contains the source code of a mixed traffic simulation model. The mixed traffic simulation model integrates vehicle car-following and lane-changing movements in mixed traffic with connected and automated vehicles of different cooperation behaviors. It is centered at a connected and automated vehicle lane changing model while fully considering the dynamics of surrounding vehicles under different mixed traffic scenarios. The source code was developed to generate two DLL files, which were imported into PTV VISSIM to conduct mixed traffic simulations. One of the DLL files is used for connected and automated vehicle (CAV) control and speed output. Another DLL is used for human-driven vehicle (HV) speed output. The source code was programmed in Microsoft Visual Studio 2017 with C++. 5 | 6 | # Organizational Outline: 7 | * Project Title 8 | * Release Notes 9 | * Getting Started 10 | * Prerequisites 11 | * Installing 12 | * Testing 13 | * Authors 14 | * License 15 | * Acknowledgments 16 | * Code.gov Registration 17 | 18 | # Project Title 19 | 20 | *Developing Analysis, Modeling, and Simulation (AMS) Tools for Connected Automated Vehicle Applications: PATH Model Description and Implementation in the Microscopic Traffic Simulation Platform* 21 | 22 | As road users start to adopt different technologies, the traffic stream might consist of human vehicles (HV), connected vehicles (CV), autonomous vehicles (AV), and connected automated vehicles (CAV) at the same time. The interaction of various types of vehicle fleet may induce complex traffic flow patterns that have never been observed in the existing transportation system. Such complex traffic is difficult to model with existing microscopic simulation and evaluation approaches. To address the challenge, the Federal Highway Administration (FHWA) supported a research project entitled “Developing Analysis, Modeling, and Simulation (AMS) Tools for Connected Automated Vehicle Applications”. 23 | 24 | ## Release Notes 25 | 26 | #### Release 1.0.0 (April 5, 2020) 27 | - Initial release 28 | 29 | ## Getting Started 30 | 31 | *Download the source code file and open it in Microsoft Visual Studio 2017 or higher.* 32 | 33 | ### Prerequisites 34 | 35 | Requires: 36 | - PTV VISSIM 11 37 | - Microsoft Visual Studio 2017 or higher 38 | 39 | ### Installing 40 | 41 | Step 1: Install software tools. 42 | 43 | ``` 44 | - Install Microsoft Visual Studio 2017 45 | - Install Visual Studio 2017 46 | ``` 47 | 48 | Step 2: Generate CAV control and speed output DLL in Microsoft Visual Studio. 49 | 50 | ``` 51 | - Open and run “DriverModel.vcxproj” in Microsoft Visual Studio, which is located at \source code\DriverModel_DLL_CAV 52 | - Note: The generated DLL (DriverModel.dll) is located at \source code \DriverModel_DLL_CAV\x64\Debug 53 | ``` 54 | 55 | Step 3: Generate HV speed output DLL in Microsoft Visual Studio. 56 | 57 | ``` 58 | - Open and run “DriverModel.vcxproj” in Microsoft Visual Studio, which is located at \source code\DriverModel_DLL_HV 59 | - Note: The generated DLL (DriverModel.dll) is located at \source code \DriverModel_DLL_HV\x64\Debug 60 | ``` 61 | 62 | Step 4: Import generated DLLs into PTV VISSIM. 63 | 64 | ``` 65 | - Open I-75.inpx using PTV VISSIM 66 | - Right click on the AV row and then click “Edit” 67 | - Click “External Driver Model” and locate the DLL generated in Step 2 68 | - Right click on the HV row and then click “Edit” 69 | - Click “External Driver Model” and locate the DLL generated in Step 3 70 | ``` 71 | 72 | ## Testing 73 | 74 | ``` 75 | Step 1: Run the simulation in PTV VISSIM. 76 | Step 2: After the simulation (5 minutes), CAV and HV speed information will be generated and saved in data_put_out_AV.txt and data_put_out_HV.txt. 77 | Step 3: In data_put_out_AV.txt every appearance of “630” represents the appearance of a new CAV. Numbers following 630 are the CAV speeds (m/s) measured at each 0.1 second. 78 | Step 4: In data_put_out_HV.txt every appearance of “640” represents the appearance of a new HV. Numbers following 640 are the HV speeds (m/s) measured at each 0.1 second. 79 | ``` 80 | 81 | ## Authors 82 | 83 | Qianwen Li, Ph.D. student, Department of Civil and Environmental Engineering, University of South Florida. 84 | Xiaopeng Li, Ph.D., Department of Civil and Environmental Engineering, University of South Florida. 85 | 86 | ## License 87 | 88 | This project is licensed under the Apache 2.0 License. 89 | 90 | ## Acknowledgments 91 | 92 | This research is supported by Federal Highway Administration (FHWA) Office of Operations Research and Development HRDO program under the project entitled Developing Analysis, Modeling, and Simulation (AMS) Tools for Connected Automated Vehicle Applications (Project Number: DTFH61-16-D-00030-0022). 93 | 94 | ## Code.gov Registration Info 95 | 96 | Agency: DOT 97 | Short Description: Source code of the USF traffic simulation model 98 | Status: Alpha 99 | Tags: Traffic simulation, Vissim, Lane Changing 100 | Labor hours: 0 101 | Contact Name: ?? 102 | Contact Phone: ?? -------------------------------------------------------------------------------- /Code/DriverModel_DLL_HV/DriverModel_changes.txt: -------------------------------------------------------------------------------- 1 | New features and bugfixes in the DriverModel.DLL API (2017-09-15) 2 | ==================================================== 3 | (+ = new features, - = bugs that have been fixed, 4 | * = changes in the usage by VISSIM. 5 | Details about the fixes are in brackets.) 6 | 7 | (2017-09-15) [with VISSIM 10.00-02] 8 | ------------ 9 | + DriverModel.h + .cpp + DriverModelExample.cpp: 10 | Optional transfer of values of user-defined vehicle attributes: 11 | New types DRIVER_DATA_USE_UDA, DRIVER_DATA_VEH_UDA and DRIVER_DATA_NVEH_UDA. 12 | Optional transfer of values for *all* nearby vehicles found according to the 13 | driving behavior parameters. New type DRIVER_DATA_WANTS_ALL_NVEHS. 14 | Option to allow multithreaded simulation runs. 15 | New type DRIVER_DATA_ALLOW_MULTITHREADING. 16 | 17 | (2017-03-21) [with VISSIM 9.00-07 + 10.00] 18 | ------------ 19 | + DriverModel.h + .cpp + DriverModelExample.cpp: 20 | New types DRIVER_DATA_VEH_Z_COORDINATE and DRIVER_DATA_VEH_REAR_Z_COORDINATE. 21 | 22 | (2016-12-14) [with VISSIM 9.00-05 + 10.00] 23 | ------------ 24 | + DriverModel.h + .cpp + DriverModelExample.cpp: 25 | New types DRIVER_DATA_VEH_INTAC_STATE, DRIVER_DATA_VEH_INTAC_TARGET_TYPE, 26 | DRIVER_DATA_VEH_INTAC_TARGET_ID, DRIVER_DATA_VEH_INTAC_HEADWAY, 27 | DRIVER_DATA_NVEH_TYPE, DRIVER_DATA_USE_INTERNAL_MODEL. 28 | + DriverModel.cpp does now cause Vissim to handle the vehicles completely on its 29 | own with the internal models. (Previously, the limitation of the change of 30 | acceleration used in the internal model was not applied even when the driver 31 | model DLL passed back the acceleration suggested by Vissim.) 32 | 33 | (2016-08-23) [with VISSIM 8.00-13 + 9.00-03] 34 | ------------ 35 | + DriverModel.h: 36 | Missing definitions of DRIVER_DATA_VEH_REAR_X_COORDINATE and 37 | DRIVER_DATA_VEH_REAR_Y_COORDINATE added. 38 | (Not added to DriverModel.cpp because these are optional.) 39 | 40 | (2014-07-29) [with VISSIM 6.00-20 + 7.00] 41 | ------------ 42 | + DriverModelExample.cpp: 43 | Alternative version of DriverModel.cpp which contains its own very simple 44 | car following model. 45 | 46 | (2013-08-08) [with VISSIM 6.00-02] 47 | ------------ 48 | + DriverModel.cpp: 49 | Back to default version which simply returns Vissim's suggestion. 50 | * DriverModel.vcproj replaced by DriverModel.vcxproj 51 | Switched project file example to Visual Studio 10. 52 | 53 | (2012-08-28) [with VISSIM 5.40-06] 54 | ------------ 55 | + DriverModel.cpp: 56 | Contains a very simple car following model as an example. 57 | + DriverModel.vxproj: 58 | Updated to Visual Studio 8.0 (2005) 59 | 60 | (2010-07-29) [with VISSIM 5.20-11] 61 | ------------ 62 | + New Interface_Description.pdf replacing DriverModel.txt 63 | (saying VISSIM 5.30 but valid for 5.20-11, too). 64 | + DriverModel.h + .cpp: 65 | New type code: 66 | DRIVER_DATA_PARAMETERFILE. 67 | Some comments improved. 68 | * VISSIM: 69 | All type codes added since 2005-05-24 are treated as optional, so there are 70 | no error messages anymore about values which cannot be set or retrieved. 71 | 72 | (2010-06-16) [released with VISSIM 5.20-10] 73 | ------------ 74 | + DriverModel.h + .cpp (still old format): 75 | New type codes: 76 | DRIVER_DATA_STATUS, DRIVER_DATA_STATUS_DETAILS. 77 | + DriverModel.cpp: 78 | DriverModelSetValue() handles DRIVER_DATA_VEH_ACTIVE_LANE_CHANGE and 79 | DRIVER_DATA_VEH_REL_TARGET_LANE without returning zero. 80 | 81 | (2010-02-17) [since VISSIM 5.20-07] 82 | ------------ 83 | * VISSIM: 84 | DRIVER_DATA_STATUS and DRIVER_DATA_STATUS_DETAILS are treated as optional now. 85 | 86 | (2010-01-14) [since VISSIM 5.20-06] 87 | ------------ 88 | * VISSIM: 89 | DRIVER_DATA_VEH_DESTINATION_LINK, DRIVER_DATA_VEH_REAR_X_COORDINATE and 90 | DRIVER_DATA_VEH_REAR_Y_COORDINATE are treated as optional now. 91 | 92 | (2009-12-11) [since VISSIM 5.20-05] 93 | ------------ 94 | * VISSIM: 95 | DRIVER_DATA_PARAMETERFILE is treated as optional now. 96 | * VISSIM: 97 | DRIVER_DATA_LINK_SEGMENT_UP_RIGHT_X, DRIVER_DATA_LINK_SEGMENT_UP_RIGHT_Y, 98 | DRIVER_DATA_LINK_SEGMENT_UP_LEFT_X, DRIVER_DATA_LINK_SEGMENT_UP_LEFT_Y, 99 | DRIVER_DATA_LINK_SEGMENT_DOWN_RIGHT_X, DRIVER_DATA_LINK_SEGMENT_DOWN_RIGHT_Y, 100 | DRIVER_DATA_LINK_SEGMENT_DOWN_LEFT_X, DRIVER_DATA_LINK_SEGMENT_DOWN_LEFT_Y, 101 | DRIVER_DATA_SIGNAL_HEAD_POS_RIGHT_X, DRIVER_DATA_SIGNAL_HEAD_POS_RIGHT_Y, 102 | DRIVER_DATA_SIGNAL_HEAD_POS_LEFT_X, DRIVER_DATA_SIGNAL_HEAD_POS_LEFT_Y 103 | are not used anymore. 104 | 105 | (2008-12-23) [since VISSIM 5.10-06] 106 | ------------ 107 | * VISSIM: 108 | DRIVER_DATA_USES_PEDESTRIAN_POLYGONS and DRIVER_DATA_VEH_LEAVES_NETWORK 109 | are not used anymore. 110 | 111 | (2007-09-19) [since VISSIM 5.00-00] 112 | ------------ 113 | * VISSIM: 114 | The DriverModel.DLL interface is not used anymore for the Pedestrian Module. 115 | Support for DRIVER_DATA_USES_PEDESTRIAN_POLYGONS has been discontinued. 116 | * VISSIM: 117 | DRIVER_DATA_VEH_Z_COORDINATE, DRIVER_DATA_VEH_HEIGHT, 118 | DRIVER_DATA_VEH_REAR_Z_COORDINATE and DRIVER_DATA_PEDESTRIAN_POLYGON_* 119 | are not used anymore. 120 | 121 | (2007-04-12) [since 4.30-01] 122 | ------------ 123 | * VISSIM: 124 | DRIVER_DATA_VEH_REAR_X_COORDINATE, DRIVER_DATA_VEH_REAR_Y_COORDINATE are 125 | used even if DriverModelGetValue (DRIVER_DATA_USES_PEDESTRIAN_POLYGONS, ...) 126 | set *long_value to 0, i.e. for lane-based driver models. 127 | 128 | (2007-02-06) [not externally released] 129 | ------------ 130 | + DriverModel.h + .cpp: 131 | New type code: 132 | DRIVER_DATA_VEH_REAR_Z_COORDINATE 133 | (only used with DRIVER_DATA_USES_PEDESTRIAN_POLYGONS). 134 | 135 | (2006-11-30) [not externally released] 136 | ------------ 137 | + DriverModel.h + .cpp: 138 | New type codes: 139 | DRIVER_DATA_STATUS, DRIVER_DATA_STATUS_DETAILS. 140 | + DriverModel.cpp: 141 | DriverModelGetValue() and DriverModelSetValue() must return 1 to almost 142 | all calls (even with the new type codes added after 2005-05-24) 143 | to prevent VISSIM from stopping the simulation run with the error message 144 | "Could not send/retrieve ... to/from driver model"! 145 | 146 | (2006-10-20) [not externally released] 147 | ------------ 148 | + DriverModel.h + .cpp: 149 | New type code: 150 | DRIVER_DATA_VEH_HEIGHT 151 | (only used with DRIVER_DATA_USES_PEDESTRIAN_POLYGONS). 152 | 153 | (2006-09-21) [not externally released] 154 | ------------ 155 | + DriverModel.h + .cpp: 156 | New type code: 157 | DRIVER_DATA_VEH_Z_COORDINATE 158 | (only used with DRIVER_DATA_USES_PEDESTRIAN_POLYGONS). 159 | 160 | (2006-09-20) [not externally released] 161 | ------------ 162 | + DriverModel.h + .cpp: 163 | DRIVER_DATA_SETS_XY_COORDINATES replaced by DRIVER_DATA_USES_PEDESTRIAN_POLYGONS. 164 | New type codes: 165 | DRIVER_DATA_PEDESTRIAN_POLYGON_* 166 | (only used with DRIVER_DATA_USES_PEDESTRIAN_POLYGONS). 167 | * VISSIM: 168 | DRIVER_DATA_LINK_SEGMENT_UP_RIGHT_X, DRIVER_DATA_LINK_SEGMENT_UP_RIGHT_Y, 169 | DRIVER_DATA_LINK_SEGMENT_UP_LEFT_X, DRIVER_DATA_LINK_SEGMENT_UP_LEFT_Y, 170 | DRIVER_DATA_LINK_SEGMENT_DOWN_RIGHT_X, DRIVER_DATA_LINK_SEGMENT_DOWN_RIGHT_Y, 171 | DRIVER_DATA_LINK_SEGMENT_DOWN_LEFT_X, DRIVER_DATA_LINK_SEGMENT_DOWN_LEFT_Y, 172 | DRIVER_DATA_SIGNAL_HEAD_POS_RIGHT_X, DRIVER_DATA_SIGNAL_HEAD_POS_RIGHT_Y, 173 | DRIVER_DATA_SIGNAL_HEAD_POS_LEFT_X, DRIVER_DATA_SIGNAL_HEAD_POS_LEFT_Y 174 | are passed to the driver model DLL if DriverModelGetValue 175 | (DRIVER_DATA_USES_PEDESTRIAN_POLYGONS, ...) set *long_value to 0! 176 | 177 | (2006-09-01) [since VISSIM 4.30-00, not externally released] 178 | ------------ 179 | + DriverModel.h + .cpp: 180 | New format (created from an internal database). 181 | + DriverModel.h + .cpp: 182 | New type code: 183 | DRIVER_DATA_PARAMETERFILE. 184 | * VISSIM: The name of the DLL and a parameterfile can be selected for each 185 | vehicle type. 186 | 187 | (2005-11-09) [not externally released] 188 | ------------ 189 | + DriverModel.h + .cpp: 190 | New type codes: 191 | DRIVER_DATA_VEH_DESTINATION_LINK, DRIVER_DATA_SETS_XY_COORDINATES, 192 | DRIVER_DATA_VEH_LEAVES_NETWORK, 193 | DRIVER_DATA_VEH_REAR_X_COORDINATE, DRIVER_DATA_VEH_REAR_Y_COORDINATE, 194 | DRIVER_DATA_LINK_SEGMENT_UP_RIGHT_X, DRIVER_DATA_LINK_SEGMENT_UP_RIGHT_Y, 195 | DRIVER_DATA_LINK_SEGMENT_UP_LEFT_X, DRIVER_DATA_LINK_SEGMENT_UP_LEFT_Y, 196 | DRIVER_DATA_LINK_SEGMENT_DOWN_RIGHT_X, DRIVER_DATA_LINK_SEGMENT_DOWN_RIGHT_Y, 197 | DRIVER_DATA_LINK_SEGMENT_DOWN_LEFT_X, DRIVER_DATA_LINK_SEGMENT_DOWN_LEFT_Y, 198 | DRIVER_DATA_SIGNAL_HEAD_POS_RIGHT_X, DRIVER_DATA_SIGNAL_HEAD_POS_RIGHT_Y, 199 | DRIVER_DATA_SIGNAL_HEAD_POS_LEFT_X, DRIVER_DATA_SIGNAL_HEAD_POS_LEFT_Y. 200 | + DriverModel.h + .cpp: 201 | DRIVER_DATA_VEH_TURNING_INDICATOR is used by DriverModelGetValue(), too. 202 | DRIVER_DATA_VEH_X_COORDINATE and DRIVER_DATA_VEH_Y_COORDINATE are 203 | used by DriverModelGetValue(), too, if DriverModelGetValue 204 | (DRIVER_DATA_SETS_XY_COORDINATES, ...) set *long_value to 1. 205 | 206 | (2005-05-24) 207 | ------------ 208 | + DriverModel.h: 209 | Comments for index values for DRIVER_DATA_NVEH_ values improved. 210 | -------------------------------------------------------------------------------- /Code/DriverModel_DLL_CAV/DriverModel_changes.txt: -------------------------------------------------------------------------------- 1 | New features and bugfixes in the DriverModel.DLL API (2018-09-06) 2 | ==================================================== 3 | (+ = new features, - = bugs that have been fixed, 4 | * = changes in the usage by VISSIM. 5 | Details about the fixes are in brackets.) 6 | 7 | (2018-09-06) [with VISSIM 11.00-01] 8 | ------------ 9 | + DriverModel.h: 10 | New types DRIVER_DATA_PRIO_RULE_DISTANCE and DRIVER_DATA_PRIO_RULE_STATE 11 | which are not yet used by Vissim. 12 | New types DRIVER_DATA_ROUTE_SIGNAL_DISTANCE, DRIVER_DATA_ROUTE_SIGNAL_STATE 13 | and DRIVER_DATA_ROUTE_SIGNAL_SWITCH for information about the next signal 14 | head downstream on the route of the vehicle, including necessary lane changes 15 | required by the route/path of the vehicle. 16 | 17 | (2017-11-02) [with VISSIM 10.00-03*] 18 | ------------ 19 | + DriverModel.h + .cpp + DriverModelExample.cpp: 20 | New types DRIVER_DATA_NVEH_X_COORDINATE, DRIVER_DATA_NVEH_Y_COORDINATE, 21 | DRIVER_DATA_NVEH_Z_COORDINATE, DRIVER_DATA_NVEH_REAR_X_COORDINATE, 22 | DRIVER_DATA_NVEH_REAR_Y_COORDINATE, DRIVER_DATA_NVEH_REAR_Z_COORDINATE, 23 | DRIVER_DATA_CURRENT_LANE_POLY_N, DRIVER_DATA_CURRENT_LANE_POLY_X, 24 | DRIVER_DATA_CURRENT_LANE_POLY_Y, DRIVER_DATA_CURRENT_LANE_POLY_Z. 25 | 26 | (2017-09-15) [with VISSIM 10.00-02] 27 | ------------ 28 | + DriverModel.h + .cpp + DriverModelExample.cpp: 29 | Optional transfer of values of user-defined vehicle attributes: 30 | New types DRIVER_DATA_USE_UDA, DRIVER_DATA_VEH_UDA and DRIVER_DATA_NVEH_UDA. 31 | Optional transfer of values for *all* nearby vehicles found according to the 32 | driving behavior parameters. New type DRIVER_DATA_WANTS_ALL_NVEHS. 33 | Option to allow multithreaded simulation runs. 34 | New type DRIVER_DATA_ALLOW_MULTITHREADING. 35 | 36 | (2017-03-21) [with VISSIM 9.00-07 + 10.00] 37 | ------------ 38 | + DriverModel.h + .cpp + DriverModelExample.cpp: 39 | New types DRIVER_DATA_VEH_Z_COORDINATE and DRIVER_DATA_VEH_REAR_Z_COORDINATE. 40 | 41 | (2016-12-14) [with VISSIM 9.00-05 + 10.00] 42 | ------------ 43 | + DriverModel.h + .cpp + DriverModelExample.cpp: 44 | New types DRIVER_DATA_VEH_INTAC_STATE, DRIVER_DATA_VEH_INTAC_TARGET_TYPE, 45 | DRIVER_DATA_VEH_INTAC_TARGET_ID, DRIVER_DATA_VEH_INTAC_HEADWAY, 46 | DRIVER_DATA_NVEH_TYPE, DRIVER_DATA_USE_INTERNAL_MODEL. 47 | + DriverModel.cpp does now cause Vissim to handle the vehicles completely on its 48 | own with the internal models. (Previously, the limitation of the change of 49 | acceleration used in the internal model was not applied even when the driver 50 | model DLL passed back the acceleration suggested by Vissim.) 51 | 52 | (2016-08-23) [with VISSIM 8.00-13 + 9.00-03] 53 | ------------ 54 | + DriverModel.h: 55 | Missing definitions of DRIVER_DATA_VEH_REAR_X_COORDINATE and 56 | DRIVER_DATA_VEH_REAR_Y_COORDINATE added. 57 | (Not added to DriverModel.cpp because these are optional.) 58 | 59 | (2014-07-29) [with VISSIM 6.00-20 + 7.00] 60 | ------------ 61 | + DriverModelExample.cpp: 62 | Alternative version of DriverModel.cpp which contains its own very simple 63 | car following model. 64 | 65 | (2013-08-08) [with VISSIM 6.00-02] 66 | ------------ 67 | + DriverModel.cpp: 68 | Back to default version which simply returns Vissim's suggestion. 69 | * DriverModel.vcproj replaced by DriverModel.vcxproj 70 | Switched project file example to Visual Studio 10. 71 | 72 | (2012-08-28) [with VISSIM 5.40-06] 73 | ------------ 74 | + DriverModel.cpp: 75 | Contains a very simple car following model as an example. 76 | + DriverModel.vxproj: 77 | Updated to Visual Studio 8.0 (2005) 78 | 79 | (2010-07-29) [with VISSIM 5.20-11] 80 | ------------ 81 | + New Interface_Description.pdf replacing DriverModel.txt 82 | (saying VISSIM 5.30 but valid for 5.20-11, too). 83 | + DriverModel.h + .cpp: 84 | New type code: 85 | DRIVER_DATA_PARAMETERFILE. 86 | Some comments improved. 87 | * VISSIM: 88 | All type codes added since 2005-05-24 are treated as optional, so there are 89 | no error messages anymore about values which cannot be set or retrieved. 90 | 91 | (2010-06-16) [released with VISSIM 5.20-10] 92 | ------------ 93 | + DriverModel.h + .cpp (still old format): 94 | New type codes: 95 | DRIVER_DATA_STATUS, DRIVER_DATA_STATUS_DETAILS. 96 | + DriverModel.cpp: 97 | DriverModelSetValue() handles DRIVER_DATA_VEH_ACTIVE_LANE_CHANGE and 98 | DRIVER_DATA_VEH_REL_TARGET_LANE without returning zero. 99 | 100 | (2010-02-17) [since VISSIM 5.20-07] 101 | ------------ 102 | * VISSIM: 103 | DRIVER_DATA_STATUS and DRIVER_DATA_STATUS_DETAILS are treated as optional now. 104 | 105 | (2010-01-14) [since VISSIM 5.20-06] 106 | ------------ 107 | * VISSIM: 108 | DRIVER_DATA_VEH_DESTINATION_LINK, DRIVER_DATA_VEH_REAR_X_COORDINATE and 109 | DRIVER_DATA_VEH_REAR_Y_COORDINATE are treated as optional now. 110 | 111 | (2009-12-11) [since VISSIM 5.20-05] 112 | ------------ 113 | * VISSIM: 114 | DRIVER_DATA_PARAMETERFILE is treated as optional now. 115 | * VISSIM: 116 | DRIVER_DATA_LINK_SEGMENT_UP_RIGHT_X, DRIVER_DATA_LINK_SEGMENT_UP_RIGHT_Y, 117 | DRIVER_DATA_LINK_SEGMENT_UP_LEFT_X, DRIVER_DATA_LINK_SEGMENT_UP_LEFT_Y, 118 | DRIVER_DATA_LINK_SEGMENT_DOWN_RIGHT_X, DRIVER_DATA_LINK_SEGMENT_DOWN_RIGHT_Y, 119 | DRIVER_DATA_LINK_SEGMENT_DOWN_LEFT_X, DRIVER_DATA_LINK_SEGMENT_DOWN_LEFT_Y, 120 | DRIVER_DATA_SIGNAL_HEAD_POS_RIGHT_X, DRIVER_DATA_SIGNAL_HEAD_POS_RIGHT_Y, 121 | DRIVER_DATA_SIGNAL_HEAD_POS_LEFT_X, DRIVER_DATA_SIGNAL_HEAD_POS_LEFT_Y 122 | are not used anymore. 123 | 124 | (2008-12-23) [since VISSIM 5.10-06] 125 | ------------ 126 | * VISSIM: 127 | DRIVER_DATA_USES_PEDESTRIAN_POLYGONS and DRIVER_DATA_VEH_LEAVES_NETWORK 128 | are not used anymore. 129 | 130 | (2007-09-19) [since VISSIM 5.00-00] 131 | ------------ 132 | * VISSIM: 133 | The DriverModel.DLL interface is not used anymore for the Pedestrian Module. 134 | Support for DRIVER_DATA_USES_PEDESTRIAN_POLYGONS has been discontinued. 135 | * VISSIM: 136 | DRIVER_DATA_VEH_Z_COORDINATE, DRIVER_DATA_VEH_HEIGHT, 137 | DRIVER_DATA_VEH_REAR_Z_COORDINATE and DRIVER_DATA_PEDESTRIAN_POLYGON_* 138 | are not used anymore. 139 | 140 | (2007-04-12) [since 4.30-01] 141 | ------------ 142 | * VISSIM: 143 | DRIVER_DATA_VEH_REAR_X_COORDINATE, DRIVER_DATA_VEH_REAR_Y_COORDINATE are 144 | used even if DriverModelGetValue (DRIVER_DATA_USES_PEDESTRIAN_POLYGONS, ...) 145 | set *long_value to 0, i.e. for lane-based driver models. 146 | 147 | (2007-02-06) [not externally released] 148 | ------------ 149 | + DriverModel.h + .cpp: 150 | New type code: 151 | DRIVER_DATA_VEH_REAR_Z_COORDINATE 152 | (only used with DRIVER_DATA_USES_PEDESTRIAN_POLYGONS). 153 | 154 | (2006-11-30) [not externally released] 155 | ------------ 156 | + DriverModel.h + .cpp: 157 | New type codes: 158 | DRIVER_DATA_STATUS, DRIVER_DATA_STATUS_DETAILS. 159 | + DriverModel.cpp: 160 | DriverModelGetValue() and DriverModelSetValue() must return 1 to almost 161 | all calls (even with the new type codes added after 2005-05-24) 162 | to prevent VISSIM from stopping the simulation run with the error message 163 | "Could not send/retrieve ... to/from driver model"! 164 | 165 | (2006-10-20) [not externally released] 166 | ------------ 167 | + DriverModel.h + .cpp: 168 | New type code: 169 | DRIVER_DATA_VEH_HEIGHT 170 | (only used with DRIVER_DATA_USES_PEDESTRIAN_POLYGONS). 171 | 172 | (2006-09-21) [not externally released] 173 | ------------ 174 | + DriverModel.h + .cpp: 175 | New type code: 176 | DRIVER_DATA_VEH_Z_COORDINATE 177 | (only used with DRIVER_DATA_USES_PEDESTRIAN_POLYGONS). 178 | 179 | (2006-09-20) [not externally released] 180 | ------------ 181 | + DriverModel.h + .cpp: 182 | DRIVER_DATA_SETS_XY_COORDINATES replaced by DRIVER_DATA_USES_PEDESTRIAN_POLYGONS. 183 | New type codes: 184 | DRIVER_DATA_PEDESTRIAN_POLYGON_* 185 | (only used with DRIVER_DATA_USES_PEDESTRIAN_POLYGONS). 186 | * VISSIM: 187 | DRIVER_DATA_LINK_SEGMENT_UP_RIGHT_X, DRIVER_DATA_LINK_SEGMENT_UP_RIGHT_Y, 188 | DRIVER_DATA_LINK_SEGMENT_UP_LEFT_X, DRIVER_DATA_LINK_SEGMENT_UP_LEFT_Y, 189 | DRIVER_DATA_LINK_SEGMENT_DOWN_RIGHT_X, DRIVER_DATA_LINK_SEGMENT_DOWN_RIGHT_Y, 190 | DRIVER_DATA_LINK_SEGMENT_DOWN_LEFT_X, DRIVER_DATA_LINK_SEGMENT_DOWN_LEFT_Y, 191 | DRIVER_DATA_SIGNAL_HEAD_POS_RIGHT_X, DRIVER_DATA_SIGNAL_HEAD_POS_RIGHT_Y, 192 | DRIVER_DATA_SIGNAL_HEAD_POS_LEFT_X, DRIVER_DATA_SIGNAL_HEAD_POS_LEFT_Y 193 | are passed to the driver model DLL if DriverModelGetValue 194 | (DRIVER_DATA_USES_PEDESTRIAN_POLYGONS, ...) set *long_value to 0! 195 | 196 | (2006-09-01) [since VISSIM 4.30-00, not externally released] 197 | ------------ 198 | + DriverModel.h + .cpp: 199 | New format (created from an internal database). 200 | + DriverModel.h + .cpp: 201 | New type code: 202 | DRIVER_DATA_PARAMETERFILE. 203 | * VISSIM: The name of the DLL and a parameterfile can be selected for each 204 | vehicle type. 205 | 206 | (2005-11-09) [not externally released] 207 | ------------ 208 | + DriverModel.h + .cpp: 209 | New type codes: 210 | DRIVER_DATA_VEH_DESTINATION_LINK, DRIVER_DATA_SETS_XY_COORDINATES, 211 | DRIVER_DATA_VEH_LEAVES_NETWORK, 212 | DRIVER_DATA_VEH_REAR_X_COORDINATE, DRIVER_DATA_VEH_REAR_Y_COORDINATE, 213 | DRIVER_DATA_LINK_SEGMENT_UP_RIGHT_X, DRIVER_DATA_LINK_SEGMENT_UP_RIGHT_Y, 214 | DRIVER_DATA_LINK_SEGMENT_UP_LEFT_X, DRIVER_DATA_LINK_SEGMENT_UP_LEFT_Y, 215 | DRIVER_DATA_LINK_SEGMENT_DOWN_RIGHT_X, DRIVER_DATA_LINK_SEGMENT_DOWN_RIGHT_Y, 216 | DRIVER_DATA_LINK_SEGMENT_DOWN_LEFT_X, DRIVER_DATA_LINK_SEGMENT_DOWN_LEFT_Y, 217 | DRIVER_DATA_SIGNAL_HEAD_POS_RIGHT_X, DRIVER_DATA_SIGNAL_HEAD_POS_RIGHT_Y, 218 | DRIVER_DATA_SIGNAL_HEAD_POS_LEFT_X, DRIVER_DATA_SIGNAL_HEAD_POS_LEFT_Y. 219 | + DriverModel.h + .cpp: 220 | DRIVER_DATA_VEH_TURNING_INDICATOR is used by DriverModelGetValue(), too. 221 | DRIVER_DATA_VEH_X_COORDINATE and DRIVER_DATA_VEH_Y_COORDINATE are 222 | used by DriverModelGetValue(), too, if DriverModelGetValue 223 | (DRIVER_DATA_SETS_XY_COORDINATES, ...) set *long_value to 1. 224 | 225 | (2005-05-24) 226 | ------------ 227 | + DriverModel.h: 228 | Comments for index values for DRIVER_DATA_NVEH_ values improved. 229 | -------------------------------------------------------------------------------- /Code/DriverModel_DLL_HV/DriverModel.cpp: -------------------------------------------------------------------------------- 1 | /*==========================================================================*/ 2 | /* DriverModel.cpp DLL Module for VISSIM */ 3 | /* */ 4 | /* Interface module for external driver models. */ 5 | /* Dummy version that does nothing (uses Vissim's internal model). */ 6 | /* export HV trajectory information */ 7 | /*==========================================================================*/ 8 | 9 | #include "DriverModel.h" 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | /*==========================================================================*/ 23 | 24 | 25 | using namespace std; 26 | using std::vector; 27 | vector::iterator iter; 28 | 29 | vector> veh_data(500); 30 | int www = 0; 31 | 32 | 33 | double desired_acceleration = 0.0; 34 | double desired_lane_angle = 0.0; 35 | long active_lane_change = 0; 36 | long rel_target_lane = 0; 37 | double desired_velocity = 0.0; 38 | long turning_indicator = 0; 39 | long vehicle_color = RGB(0,0,0); 40 | long veh_type; 41 | double current_speed = 0.0; 42 | long veh_id; 43 | double time_run; 44 | 45 | ofstream fout; 46 | ifstream fin; 47 | 48 | 49 | 50 | /*==========================================================================*/ 51 | 52 | BOOL APIENTRY DllMain (HANDLE hModule, 53 | DWORD ul_reason_for_call, 54 | LPVOID lpReserved) 55 | { 56 | switch (ul_reason_for_call) { 57 | case DLL_PROCESS_ATTACH: 58 | case DLL_THREAD_ATTACH: 59 | case DLL_THREAD_DETACH: 60 | case DLL_PROCESS_DETACH: 61 | break; 62 | } 63 | return TRUE; 64 | } 65 | 66 | /*==========================================================================*/ 67 | 68 | DRIVERMODEL_API int DriverModelSetValue (long type, 69 | long index1, 70 | long index2, 71 | long long_value, 72 | double double_value, 73 | char *string_value) 74 | { 75 | /* Sets the value of a data object of type , selected by */ 76 | /* and possibly , to , or */ 77 | /* <*string_value> (object and value selection depending on ). */ 78 | /* Return value is 1 on success, otherwise 0. */ 79 | 80 | switch (type) { 81 | case DRIVER_DATA_PATH : 82 | case DRIVER_DATA_TIMESTEP : 83 | case DRIVER_DATA_TIME : 84 | time_run = double_value; 85 | return 1; 86 | case DRIVER_DATA_USE_UDA : 87 | return 0; /* doesn't use any UDAs */ 88 | /* must return 1 for desired values of index1 if UDA values are to be sent from/to Vissim */ 89 | case DRIVER_DATA_VEH_ID : 90 | veh_id = long_value; 91 | return 1; 92 | case DRIVER_DATA_VEH_LANE : 93 | case DRIVER_DATA_VEH_ODOMETER : 94 | case DRIVER_DATA_VEH_LANE_ANGLE : 95 | case DRIVER_DATA_VEH_LATERAL_POSITION : 96 | case DRIVER_DATA_VEH_VELOCITY : 97 | current_speed = double_value; 98 | return 1; 99 | case DRIVER_DATA_VEH_ACCELERATION : 100 | case DRIVER_DATA_VEH_LENGTH : 101 | case DRIVER_DATA_VEH_WIDTH : 102 | case DRIVER_DATA_VEH_WEIGHT : 103 | case DRIVER_DATA_VEH_MAX_ACCELERATION : 104 | return 1; 105 | case DRIVER_DATA_VEH_TURNING_INDICATOR : 106 | turning_indicator = long_value; 107 | return 1; 108 | case DRIVER_DATA_VEH_CATEGORY : 109 | case DRIVER_DATA_VEH_PREFERRED_REL_LANE : 110 | case DRIVER_DATA_VEH_USE_PREFERRED_LANE : 111 | return 1; 112 | case DRIVER_DATA_VEH_DESIRED_VELOCITY : 113 | desired_velocity = double_value; 114 | return 1; 115 | case DRIVER_DATA_VEH_X_COORDINATE : 116 | case DRIVER_DATA_VEH_Y_COORDINATE : 117 | case DRIVER_DATA_VEH_Z_COORDINATE : 118 | case DRIVER_DATA_VEH_REAR_X_COORDINATE : 119 | case DRIVER_DATA_VEH_REAR_Y_COORDINATE : 120 | case DRIVER_DATA_VEH_REAR_Z_COORDINATE : 121 | case DRIVER_DATA_VEH_TYPE : 122 | veh_type = long_value; 123 | return 1; 124 | case DRIVER_DATA_VEH_COLOR : 125 | vehicle_color = long_value; 126 | return 1; 127 | case DRIVER_DATA_VEH_CURRENT_LINK : 128 | return 0; /* (To avoid getting sent lots of DRIVER_DATA_VEH_NEXT_LINKS messages) */ 129 | /* Must return 1 if these messages are to be sent from VISSIM! */ 130 | case DRIVER_DATA_VEH_NEXT_LINKS : 131 | case DRIVER_DATA_VEH_ACTIVE_LANE_CHANGE : 132 | case DRIVER_DATA_VEH_REL_TARGET_LANE : 133 | case DRIVER_DATA_VEH_INTAC_STATE : 134 | case DRIVER_DATA_VEH_INTAC_TARGET_TYPE : 135 | case DRIVER_DATA_VEH_INTAC_TARGET_ID : 136 | case DRIVER_DATA_VEH_INTAC_HEADWAY : 137 | case DRIVER_DATA_VEH_UDA : 138 | case DRIVER_DATA_NVEH_ID : 139 | case DRIVER_DATA_NVEH_LANE_ANGLE : 140 | case DRIVER_DATA_NVEH_LATERAL_POSITION : 141 | case DRIVER_DATA_NVEH_DISTANCE : 142 | case DRIVER_DATA_NVEH_REL_VELOCITY : 143 | case DRIVER_DATA_NVEH_ACCELERATION : 144 | case DRIVER_DATA_NVEH_LENGTH : 145 | case DRIVER_DATA_NVEH_WIDTH : 146 | case DRIVER_DATA_NVEH_WEIGHT : 147 | case DRIVER_DATA_NVEH_TURNING_INDICATOR : 148 | case DRIVER_DATA_NVEH_CATEGORY : 149 | case DRIVER_DATA_NVEH_LANE_CHANGE : 150 | case DRIVER_DATA_NVEH_TYPE : 151 | case DRIVER_DATA_NVEH_UDA : 152 | case DRIVER_DATA_NO_OF_LANES : 153 | case DRIVER_DATA_LANE_WIDTH : 154 | case DRIVER_DATA_LANE_END_DISTANCE : 155 | case DRIVER_DATA_RADIUS : 156 | case DRIVER_DATA_MIN_RADIUS : 157 | case DRIVER_DATA_DIST_TO_MIN_RADIUS : 158 | case DRIVER_DATA_SLOPE : 159 | case DRIVER_DATA_SLOPE_AHEAD : 160 | case DRIVER_DATA_SIGNAL_DISTANCE : 161 | case DRIVER_DATA_SIGNAL_STATE : 162 | case DRIVER_DATA_SIGNAL_STATE_START : 163 | case DRIVER_DATA_SPEED_LIMIT_DISTANCE : 164 | case DRIVER_DATA_SPEED_LIMIT_VALUE : 165 | return 1; 166 | case DRIVER_DATA_DESIRED_ACCELERATION : 167 | desired_acceleration = double_value; 168 | return 1; 169 | case DRIVER_DATA_DESIRED_LANE_ANGLE : 170 | desired_lane_angle = double_value; 171 | return 1; 172 | case DRIVER_DATA_ACTIVE_LANE_CHANGE : 173 | active_lane_change = long_value; 174 | return 1; 175 | case DRIVER_DATA_REL_TARGET_LANE : 176 | rel_target_lane = long_value; 177 | return 1; 178 | default : 179 | return 0; 180 | } 181 | } 182 | 183 | /*--------------------------------------------------------------------------*/ 184 | 185 | DRIVERMODEL_API int DriverModelGetValue (long type, 186 | long index1, 187 | long index2, 188 | long *long_value, 189 | double *double_value, 190 | char **string_value) 191 | { 192 | /* Gets the value of a data object of type , selected by */ 193 | /* and possibly , and writes that value to <*double_value>, */ 194 | /* <*float_value> or <**string_value> (object and value selection */ 195 | /* depending on ). */ 196 | /* Return value is 1 on success, otherwise 0. */ 197 | 198 | switch (type) { 199 | case DRIVER_DATA_STATUS : 200 | *long_value = 0; 201 | return 1; 202 | case DRIVER_DATA_VEH_TURNING_INDICATOR : 203 | *long_value = turning_indicator; 204 | return 1; 205 | case DRIVER_DATA_VEH_DESIRED_VELOCITY : 206 | *double_value = desired_velocity; 207 | return 1; 208 | case DRIVER_DATA_VEH_COLOR : 209 | *long_value = vehicle_color; 210 | return 1; 211 | case DRIVER_DATA_VEH_UDA : 212 | return 0; /* doesn't set any UDA values */ 213 | case DRIVER_DATA_WANTS_SUGGESTION : 214 | *long_value = 1; 215 | return 1; 216 | case DRIVER_DATA_DESIRED_ACCELERATION : 217 | *double_value = desired_acceleration; 218 | return 1; 219 | case DRIVER_DATA_DESIRED_LANE_ANGLE : 220 | *double_value = desired_lane_angle; 221 | return 1; 222 | case DRIVER_DATA_ACTIVE_LANE_CHANGE : 223 | *long_value = active_lane_change; 224 | return 1; 225 | case DRIVER_DATA_REL_TARGET_LANE : 226 | *long_value = rel_target_lane; 227 | return 1; 228 | case DRIVER_DATA_SIMPLE_LANECHANGE : 229 | *long_value = 1; 230 | return 1; 231 | case DRIVER_DATA_USE_INTERNAL_MODEL: 232 | *long_value = 1; /* must be set to 0 if external model is to be applied */ 233 | return 1; 234 | case DRIVER_DATA_WANTS_ALL_NVEHS: 235 | *long_value = 0; /* must be set to 1 if data for more than 2 nearby vehicles per lane and upstream/downstream is to be passed from Vissim */ 236 | return 1; 237 | case DRIVER_DATA_ALLOW_MULTITHREADING: 238 | *long_value = 0; /* must be set to 1 to allow a simulation run to be started with multiple cores used in the simulation parameters */ 239 | return 1; 240 | default: 241 | return 0; 242 | } 243 | } 244 | 245 | /*==========================================================================*/ 246 | 247 | DRIVERMODEL_API int DriverModelExecuteCommand (long number) 248 | { 249 | /* Executes the command if that is available in the driver */ 250 | /* module. Return value is 1 on success, otherwise 0. */ 251 | 252 | switch (number) { 253 | case DRIVER_COMMAND_INIT : 254 | fout.open("data_put_out_HV.txt", std::ios_base::out); 255 | fout.flush(); 256 | for (int i = 0; i < veh_data.size(); i++) 257 | veh_data[i].resize(0); 258 | return 1; 259 | case DRIVER_COMMAND_CREATE_DRIVER : 260 | return 1; 261 | case DRIVER_COMMAND_KILL_DRIVER : 262 | return 1; 263 | case DRIVER_COMMAND_MOVE_DRIVER : 264 | 265 | veh_data[veh_id].push_back(current_speed); 266 | fout.precision(4); 267 | if (time_run == 300 && www == 0) 268 | { 269 | for (int i = 0; i < veh_data.size(); i++) 270 | { 271 | 272 | //fout << "630 "; 273 | if (veh_data[i].empty()) 274 | { 275 | ; 276 | } 277 | else 278 | { 279 | fout << veh_type << " "; 280 | for (int j = 0; j < veh_data[i].size(); j++) 281 | { 282 | fout << veh_data[i][j] << " "; 283 | } 284 | fout << endl; 285 | } 286 | } 287 | 288 | www = 1; 289 | } 290 | return 1; 291 | default : 292 | return 0; 293 | } 294 | } 295 | 296 | /*==========================================================================*/ 297 | /* End of DriverModel.cpp */ 298 | /*==========================================================================*/ 299 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Code/DriverModel_DLL_CAV/DriverModel.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {117A1396-8819-454F-9F6D-C132CED1425F} 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 10.0.17763.0 32 | 33 | 34 | 35 | DynamicLibrary 36 | false 37 | MultiByte 38 | v141 39 | 40 | 41 | DynamicLibrary 42 | false 43 | MultiByte 44 | v141 45 | 46 | 47 | DynamicLibrary 48 | false 49 | MultiByte 50 | v141 51 | 52 | 53 | DynamicLibrary 54 | false 55 | MultiByte 56 | v141 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | <_ProjectFileVersion>10.0.40219.1 76 | $(SolutionDir)Bin\$(Configuration)\ 77 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\ 78 | true 79 | true 80 | $(SolutionDir)Bin\$(Configuration)\ 81 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\ 82 | false 83 | false 84 | 85 | 86 | 87 | /D_WIN32_WINNT=0x0400 /D _WIN32_IE=0x0400 %(AdditionalOptions) 88 | Disabled 89 | WIN32;_DEBUG;_WINDOWS;_USRDLL;DRIVERMODEL_EXPORTS;%(PreprocessorDefinitions) 90 | Default 91 | MultiThreadedDebugDLL 92 | 93 | 94 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName).pch 95 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName) 96 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)/ 97 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName) 98 | Level3 99 | true 100 | ProgramDatabase 101 | 102 | 103 | $(OutDir)$(ProjectName).dll 104 | true 105 | $(SolutionDir)Lib\$(Configuration)\;%(AdditionalLibraryDirectories) 106 | true 107 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName).pdb 108 | $(SolutionDir)Lib\$(Configuration)\$(ProjectName).lib 109 | MachineX86 110 | 111 | 112 | _DEBUG;%(PreprocessorDefinitions) 113 | true 114 | true 115 | Win32 116 | .\Debug/DriverModel.tlb 117 | 118 | 119 | 120 | 121 | _DEBUG;%(PreprocessorDefinitions) 122 | 0x0407 123 | 124 | 125 | 126 | 127 | /D_WIN32_WINNT=0x0400 /D _WIN32_IE=0x0400 %(AdditionalOptions) 128 | Disabled 129 | WIN32;_DEBUG;_WINDOWS;_USRDLL;DRIVERMODEL_EXPORTS;%(PreprocessorDefinitions) 130 | Default 131 | MultiThreadedDebugDLL 132 | 133 | 134 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName).pch 135 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName) 136 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)/ 137 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName) 138 | Level3 139 | true 140 | ProgramDatabase 141 | 142 | 143 | $(OutDir)$(ProjectName).dll 144 | true 145 | $(SolutionDir)Lib\$(Configuration)\;%(AdditionalLibraryDirectories) 146 | true 147 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName).pdb 148 | $(SolutionDir)Lib\$(Configuration)\$(ProjectName).lib 149 | 150 | 151 | _DEBUG;%(PreprocessorDefinitions) 152 | true 153 | true 154 | .\Debug/DriverModel.tlb 155 | 156 | 157 | 158 | 159 | _DEBUG;%(PreprocessorDefinitions) 160 | 0x0407 161 | 162 | 163 | 164 | 165 | /D_WIN32_WINNT=0x0400 /D _WIN32_IE=0x0400 %(AdditionalOptions) 166 | MaxSpeed 167 | OnlyExplicitInline 168 | WIN32;NDEBUG;_WINDOWS;_USRDLL;DRIVERMODEL_EXPORTS;%(PreprocessorDefinitions) 169 | true 170 | Default 171 | MultiThreadedDLL 172 | true 173 | 174 | 175 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName).pch 176 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName) 177 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)/ 178 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName) 179 | Level3 180 | true 181 | 182 | 183 | $(OutDir)$(ProjectName).dll 184 | true 185 | $(SolutionDir)Bin\$(Configuration)\;%(AdditionalLibraryDirectories) 186 | .\Release/DriverModel.pdb 187 | $(SolutionDir)Lib\$(Configuration)\$(ProjectName).lib 188 | MachineX86 189 | 190 | 191 | NDEBUG;%(PreprocessorDefinitions) 192 | true 193 | true 194 | Win32 195 | .\Release/DriverModel.tlb 196 | 197 | 198 | 199 | 200 | NDEBUG;%(PreprocessorDefinitions) 201 | 0x0407 202 | 203 | 204 | 205 | 206 | /D_WIN32_WINNT=0x0400 /D _WIN32_IE=0x0400 %(AdditionalOptions) 207 | MaxSpeed 208 | OnlyExplicitInline 209 | WIN32;NDEBUG;_WINDOWS;_USRDLL;DRIVERMODEL_EXPORTS;%(PreprocessorDefinitions) 210 | true 211 | Default 212 | MultiThreadedDLL 213 | true 214 | 215 | 216 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName).pch 217 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName) 218 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)/ 219 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName) 220 | Level3 221 | true 222 | 223 | 224 | $(OutDir)$(ProjectName).dll 225 | true 226 | $(SolutionDir)Bin\$(Configuration)\;%(AdditionalLibraryDirectories) 227 | .\Release/DriverModel.pdb 228 | $(SolutionDir)Lib\$(Configuration)\$(ProjectName).lib 229 | 230 | 231 | NDEBUG;%(PreprocessorDefinitions) 232 | true 233 | true 234 | .\Release/DriverModel.tlb 235 | 236 | 237 | 238 | 239 | NDEBUG;%(PreprocessorDefinitions) 240 | 0x0407 241 | 242 | 243 | 244 | 245 | Disabled 246 | Disabled 247 | WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DRIVERMODEL_EXPORTS 248 | WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DRIVERMODEL_EXPORTS 249 | EnableFastChecks 250 | EnableFastChecks 251 | MaxSpeed 252 | MaxSpeed 253 | WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DRIVERMODEL_EXPORTS 254 | WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DRIVERMODEL_EXPORTS 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | -------------------------------------------------------------------------------- /Code/DriverModel_DLL_HV/DriverModel.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {117A1396-8819-454F-9F6D-C132CED1425F} 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 10.0.17763.0 32 | 33 | 34 | 35 | DynamicLibrary 36 | false 37 | MultiByte 38 | v141 39 | 40 | 41 | DynamicLibrary 42 | false 43 | MultiByte 44 | v141 45 | 46 | 47 | DynamicLibrary 48 | false 49 | MultiByte 50 | v141 51 | 52 | 53 | DynamicLibrary 54 | false 55 | MultiByte 56 | v141 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | <_ProjectFileVersion>10.0.40219.1 76 | $(SolutionDir)Bin\$(Configuration)\ 77 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\ 78 | true 79 | true 80 | $(SolutionDir)Bin\$(Configuration)\ 81 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\ 82 | false 83 | false 84 | 85 | 86 | 87 | /D_WIN32_WINNT=0x0400 /D _WIN32_IE=0x0400 %(AdditionalOptions) 88 | Disabled 89 | WIN32;_DEBUG;_WINDOWS;_USRDLL;DRIVERMODEL_EXPORTS;%(PreprocessorDefinitions) 90 | Default 91 | MultiThreadedDebugDLL 92 | 93 | 94 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName).pch 95 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName) 96 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)/ 97 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName) 98 | Level3 99 | true 100 | ProgramDatabase 101 | 102 | 103 | $(OutDir)$(ProjectName).dll 104 | true 105 | $(SolutionDir)Lib\$(Configuration)\;%(AdditionalLibraryDirectories) 106 | true 107 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName).pdb 108 | $(SolutionDir)Lib\$(Configuration)\$(ProjectName).lib 109 | MachineX86 110 | 111 | 112 | _DEBUG;%(PreprocessorDefinitions) 113 | true 114 | true 115 | Win32 116 | .\Debug/DriverModel.tlb 117 | 118 | 119 | 120 | 121 | _DEBUG;%(PreprocessorDefinitions) 122 | 0x0407 123 | 124 | 125 | 126 | 127 | /D_WIN32_WINNT=0x0400 /D _WIN32_IE=0x0400 %(AdditionalOptions) 128 | Disabled 129 | WIN32;_DEBUG;_WINDOWS;_USRDLL;DRIVERMODEL_EXPORTS;%(PreprocessorDefinitions) 130 | Default 131 | MultiThreadedDebugDLL 132 | 133 | 134 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName).pch 135 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName) 136 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)/ 137 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName) 138 | Level3 139 | true 140 | ProgramDatabase 141 | 142 | 143 | $(OutDir)$(ProjectName).dll 144 | true 145 | $(SolutionDir)Lib\$(Configuration)\;%(AdditionalLibraryDirectories) 146 | true 147 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName).pdb 148 | $(SolutionDir)Lib\$(Configuration)\$(ProjectName).lib 149 | 150 | 151 | _DEBUG;%(PreprocessorDefinitions) 152 | true 153 | true 154 | .\Debug/DriverModel.tlb 155 | 156 | 157 | 158 | 159 | _DEBUG;%(PreprocessorDefinitions) 160 | 0x0407 161 | 162 | 163 | 164 | 165 | /D_WIN32_WINNT=0x0400 /D _WIN32_IE=0x0400 %(AdditionalOptions) 166 | MaxSpeed 167 | OnlyExplicitInline 168 | WIN32;NDEBUG;_WINDOWS;_USRDLL;DRIVERMODEL_EXPORTS;%(PreprocessorDefinitions) 169 | true 170 | Default 171 | MultiThreadedDLL 172 | true 173 | 174 | 175 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName).pch 176 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName) 177 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)/ 178 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName) 179 | Level3 180 | true 181 | 182 | 183 | $(OutDir)$(ProjectName).dll 184 | true 185 | $(SolutionDir)Bin\$(Configuration)\;%(AdditionalLibraryDirectories) 186 | .\Release/DriverModel.pdb 187 | $(SolutionDir)Lib\$(Configuration)\$(ProjectName).lib 188 | MachineX86 189 | 190 | 191 | NDEBUG;%(PreprocessorDefinitions) 192 | true 193 | true 194 | Win32 195 | .\Release/DriverModel.tlb 196 | 197 | 198 | 199 | 200 | NDEBUG;%(PreprocessorDefinitions) 201 | 0x0407 202 | 203 | 204 | 205 | 206 | /D_WIN32_WINNT=0x0400 /D _WIN32_IE=0x0400 %(AdditionalOptions) 207 | MaxSpeed 208 | OnlyExplicitInline 209 | WIN32;NDEBUG;_WINDOWS;_USRDLL;DRIVERMODEL_EXPORTS;%(PreprocessorDefinitions) 210 | true 211 | Default 212 | MultiThreadedDLL 213 | true 214 | 215 | 216 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName).pch 217 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName) 218 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)/ 219 | $(SolutionDir)Temp\$(Configuration)\$(ProjectName)\$(ProjectName) 220 | Level3 221 | true 222 | 223 | 224 | $(OutDir)$(ProjectName).dll 225 | true 226 | $(SolutionDir)Bin\$(Configuration)\;%(AdditionalLibraryDirectories) 227 | .\Release/DriverModel.pdb 228 | $(SolutionDir)Lib\$(Configuration)\$(ProjectName).lib 229 | 230 | 231 | NDEBUG;%(PreprocessorDefinitions) 232 | true 233 | true 234 | .\Release/DriverModel.tlb 235 | 236 | 237 | 238 | 239 | NDEBUG;%(PreprocessorDefinitions) 240 | 0x0407 241 | 242 | 243 | 244 | 245 | Disabled 246 | Disabled 247 | WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DRIVERMODEL_EXPORTS 248 | WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DRIVERMODEL_EXPORTS 249 | EnableFastChecks 250 | EnableFastChecks 251 | MaxSpeed 252 | MaxSpeed 253 | WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DRIVERMODEL_EXPORTS 254 | WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DRIVERMODEL_EXPORTS 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | -------------------------------------------------------------------------------- /Code/DriverModel_DLL_CAV/DriverModel.cpp: -------------------------------------------------------------------------------- 1 | /*==========================================================================*/ 2 | /* DriverModel.cpp DLL Module for VISSIM */ 3 | /* */ 4 | /* Interface module for external driver models. */ 5 | /* Implement CAV control model and export CAV trajectory information */ 6 | /*==========================================================================*/ 7 | 8 | #include "DriverModel.h" 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #define random(a,b) (rand()%(b-a+1)+a) 22 | 23 | using namespace std; 24 | using std::vector; 25 | vector::iterator iter; 26 | 27 | vector> veh_data(1000); 28 | int www = 0; 29 | 30 | 31 | /*==========================================================================*/ 32 | float k_1 = 0.2; //ACC param1 33 | float k_2 = 0.68; //ACC param2 34 | float react_time = 0.9;//tau 35 | float b_av = 4.5;//CAV max dec 36 | float b_hv = 4.2;//max dec of preceding vehicle 37 | float w_hv = 4.0;//max acc of following vehicle 38 | float s_0 = 4.0;//min following gap 39 | float time_gap=1.3;//time gap 40 | float g_cav = 1.53;// CAV desired time gap 41 | float veh_length = 4.6; //vehicle length for CAV and HV 42 | float b = 0.2;//used for estimate LC duration 43 | float lw = 3.5;//lane width 44 | float av_off_main_rate = 0.2;//mainline CAV diverging rate 45 | float av_off_ramp_rate = 0.2;//on ramp CAV diverging rate 46 | float coop_rate = 0.5;// CAV cooperation rate 47 | float d_a = 0.1;// incentive check threshold 48 | float d_bias = 0.6;//incentive check bias 49 | /*HV diverging rate; CAV penetration rate; Zone A and B length can be customized in PTV VISSIM user interface*/ 50 | 51 | 52 | double current_speed = 0.0; 53 | double desired_acceleration = 0.0; 54 | double desired_lane_angle = 0.0; 55 | long active_lane_change = 0; 56 | long rel_target_lane = 0; 57 | double desired_velocity = 0.0; 58 | long turning_indicator = 0; 59 | long vehicle_color = RGB(0,0,0); 60 | double lead_vehicle_distance = 61; 61 | double lead_vehicle_speed_difference = -9.0; 62 | double lead_vehicle_length = 0.0; 63 | double time_run; 64 | long current_lane; 65 | double lateral_distance; 66 | double net_distance; 67 | double lead_vehicle_speed; 68 | double desired_distance; /* times 1 s */ 69 | double veh_odometer; 70 | long current_link; 71 | long inter_model = 0; 72 | double veh_angle; 73 | 74 | long down_vehicle_type; 75 | long up_vehicle_type; 76 | long down_left_vehicle_type; 77 | long down_right_vehicle_type; 78 | long up_left_vehicle_type; 79 | long up_right_vehicle_type; 80 | long veh_type; 81 | 82 | 83 | long veh_id; 84 | 85 | double down_left_veh_distance; 86 | double down_right_veh_distance; 87 | double up_left_veh_distance; 88 | double up_right_veh_distance; 89 | double up_vehicle_distance; 90 | 91 | long up_vehicle_lane_change; 92 | long down_left_vehicle_lane_change; 93 | long down_right_vehicle_lane_change; 94 | long up_left_vehicle_lane_change; 95 | long up_right_vehicle_lane_change; 96 | 97 | double down_right_veh_sp_diff; 98 | double down_left_veh_sp_diff; 99 | double up_left_veh_sp_diff; 100 | double up_right_veh_sp_diff; 101 | 102 | double down_right_veh_sp; 103 | double down_left_veh_sp; 104 | double up_left_veh_sp; 105 | double up_right_veh_sp; 106 | 107 | double veh_x_po; 108 | double veh_y_po; 109 | 110 | float acc_follow_own_lane; 111 | float acc_follow_nveh_lane; 112 | int change_right_condition = 0; 113 | int change_left_condition = 0; 114 | float angle = 0.05; 115 | map target_lane; 116 | map active_change_time; 117 | map change_lane_period; 118 | map last_link; 119 | map last_angel; 120 | float start_pos_1 = 0; 121 | float dist_adjust = 0; 122 | mapveh_aim; 123 | mapcoop; 124 | 125 | 126 | float right_change_follow; 127 | float left_change_follow; 128 | float suiji; 129 | 130 | float right_future_fol_dist = 88; 131 | float right_future_fol_acc = -10; 132 | float left_future_fol_dist = 88; 133 | float left_future_fol_acc = -10; 134 | 135 | ofstream fout,fav_out; 136 | ifstream fin; 137 | /*==========================================================================*/ 138 | 139 | BOOL APIENTRY DllMain (HANDLE hModule, 140 | DWORD ul_reason_for_call, 141 | LPVOID lpReserved) 142 | { 143 | switch (ul_reason_for_call) { 144 | case DLL_PROCESS_ATTACH: 145 | case DLL_THREAD_ATTACH: 146 | case DLL_THREAD_DETACH: 147 | case DLL_PROCESS_DETACH: 148 | break; 149 | } 150 | return TRUE; 151 | } 152 | 153 | /*==========================================================================*/ 154 | 155 | DRIVERMODEL_API int DriverModelSetValue (long type, 156 | long index1, 157 | long index2, 158 | long long_value, 159 | double double_value, 160 | char *string_value) 161 | { 162 | /* Sets the value of a data object of type , selected by */ 163 | /* and possibly , to , or */ 164 | /* <*string_value> (object and value selection depending on ). */ 165 | /* Return value is 1 on success, otherwise 0. */ 166 | 167 | switch (type) { 168 | case DRIVER_DATA_PATH : 169 | case DRIVER_DATA_TIMESTEP : 170 | case DRIVER_DATA_TIME : 171 | time_run = double_value; 172 | return 1; 173 | case DRIVER_DATA_USE_UDA : 174 | return 0; /* doesn't use any UDAs */ 175 | /* must return 1 for desired values of index1 if UDA values are to be sent from/to Vissim */ 176 | case DRIVER_DATA_VEH_ID: 177 | veh_id = long_value; 178 | lead_vehicle_distance = 70.0; 179 | down_left_veh_distance=70; 180 | down_right_veh_distance=70; 181 | up_left_veh_distance = -70; 182 | up_right_veh_distance = -70; 183 | up_vehicle_distance = -70; 184 | lead_vehicle_speed_difference = 0; 185 | lead_vehicle_speed = 32; 186 | lead_vehicle_length = 4.6; 187 | down_right_veh_sp=32; 188 | down_left_veh_sp = 32; 189 | up_left_veh_sp = 29; 190 | up_right_veh_sp = 29; 191 | return 1; 192 | case DRIVER_DATA_VEH_LANE : 193 | current_lane = long_value; 194 | case DRIVER_DATA_VEH_ODOMETER : 195 | veh_odometer = double_value; 196 | case DRIVER_DATA_VEH_LANE_ANGLE : 197 | veh_angle = double_value; 198 | case DRIVER_DATA_VEH_LATERAL_POSITION : 199 | lateral_distance = double_value; 200 | return 1; 201 | case DRIVER_DATA_VEH_VELOCITY : 202 | current_speed = double_value; 203 | return 1; 204 | case DRIVER_DATA_VEH_ACCELERATION : 205 | case DRIVER_DATA_VEH_LENGTH : 206 | case DRIVER_DATA_VEH_WIDTH : 207 | case DRIVER_DATA_VEH_WEIGHT : 208 | case DRIVER_DATA_VEH_MAX_ACCELERATION : 209 | return 1; 210 | case DRIVER_DATA_VEH_TURNING_INDICATOR : 211 | turning_indicator = long_value; //LC signal 212 | return 1; 213 | case DRIVER_DATA_VEH_CATEGORY : 214 | case DRIVER_DATA_VEH_PREFERRED_REL_LANE : 215 | case DRIVER_DATA_VEH_USE_PREFERRED_LANE : 216 | return 1; 217 | case DRIVER_DATA_VEH_DESIRED_VELOCITY : 218 | desired_velocity = double_value; 219 | return 1; 220 | case DRIVER_DATA_VEH_X_COORDINATE : 221 | veh_x_po = double_value; 222 | return 1; 223 | case DRIVER_DATA_VEH_Y_COORDINATE : 224 | veh_y_po = double_value; 225 | return 1; 226 | case DRIVER_DATA_VEH_Z_COORDINATE : 227 | case DRIVER_DATA_VEH_REAR_X_COORDINATE : 228 | case DRIVER_DATA_VEH_REAR_Y_COORDINATE : 229 | case DRIVER_DATA_VEH_REAR_Z_COORDINATE : 230 | case DRIVER_DATA_VEH_TYPE : 231 | veh_type = long_value; 232 | return 1; 233 | case DRIVER_DATA_VEH_COLOR : 234 | vehicle_color = long_value; 235 | return 1; 236 | case DRIVER_DATA_VEH_CURRENT_LINK : 237 | current_link = long_value; 238 | return 0; /* (To avoid getting sent lots of DRIVER_DATA_VEH_NEXT_LINKS messages) */ 239 | /* Must return 1 if these messages are to be sent from VISSIM! */ 240 | case DRIVER_DATA_VEH_NEXT_LINKS : 241 | case DRIVER_DATA_VEH_ACTIVE_LANE_CHANGE : 242 | case DRIVER_DATA_VEH_REL_TARGET_LANE : 243 | case DRIVER_DATA_VEH_INTAC_STATE : 244 | case DRIVER_DATA_VEH_INTAC_TARGET_TYPE : 245 | case DRIVER_DATA_VEH_INTAC_TARGET_ID : 246 | case DRIVER_DATA_VEH_INTAC_HEADWAY : 247 | case DRIVER_DATA_VEH_UDA : 248 | case DRIVER_DATA_NVEH_ID : 249 | case DRIVER_DATA_NVEH_LANE_ANGLE : 250 | case DRIVER_DATA_NVEH_LATERAL_POSITION : 251 | return 1; 252 | case DRIVER_DATA_NVEH_DISTANCE : 253 | if (index1 == 0 && index2 == 1) { /* leading vehicle on own lane */ 254 | lead_vehicle_distance = double_value; 255 | } 256 | else if (index1 == 0 && index2 == -1) 257 | { 258 | up_vehicle_distance = double_value; 259 | } 260 | else if (index1 == -1 && index2 == 1) { /* right lane leading veh */ 261 | down_right_veh_distance = double_value; 262 | 263 | } 264 | else if (index1 == -1 && index2 == -1) { /* right lane following veh */ 265 | up_right_veh_distance = double_value; 266 | 267 | } 268 | else if (index1 == 1 && index2 == 1) { /* left lane leading veh */ 269 | down_left_veh_distance = double_value; 270 | 271 | } 272 | else if (index1 == 1 && index2 == -1) { /* left lane following veh */ 273 | up_left_veh_distance = double_value; 274 | 275 | } 276 | return 1; 277 | case DRIVER_DATA_NVEH_REL_VELOCITY : 278 | /* double: speed difference [m/s] (veh. speed - nveh. speed) */ 279 | if (index1 == 0 && index2 == 1) { /* leading vehicle on own lane */ 280 | lead_vehicle_speed_difference = double_value; 281 | lead_vehicle_speed = current_speed - lead_vehicle_speed_difference; 282 | } 283 | else if (index1 == -1 && index2 == 1) { /* right lane leading veh */ 284 | down_right_veh_sp_diff = double_value; 285 | down_right_veh_sp = current_speed - down_right_veh_sp_diff; 286 | } 287 | else if (index1 == -1 && index2 == -1) { /* right lane follwoing veh */ 288 | up_right_veh_sp_diff = double_value; 289 | up_right_veh_sp = current_speed - up_right_veh_sp_diff; 290 | } 291 | else if (index1 == 1 && index2 == 1) { /* left lane leading veh */ 292 | down_left_veh_sp_diff = double_value; 293 | down_left_veh_sp = current_speed - down_left_veh_sp_diff; 294 | } 295 | else if (index1 == 1 && index2 == -1) { /* left lane follwoing veh */ 296 | up_left_veh_sp_diff = double_value; 297 | up_left_veh_sp = current_speed - up_left_veh_sp_diff; 298 | } 299 | return 1; 300 | case DRIVER_DATA_NVEH_ACCELERATION : 301 | return 1; 302 | case DRIVER_DATA_NVEH_LENGTH : 303 | if (index1 == 0 && index2 == 1) { /* leading vehicle on own lane */ 304 | lead_vehicle_length = double_value; 305 | } 306 | return 1; 307 | case DRIVER_DATA_NVEH_WIDTH : 308 | case DRIVER_DATA_NVEH_WEIGHT : 309 | case DRIVER_DATA_NVEH_TURNING_INDICATOR : 310 | case DRIVER_DATA_NVEH_CATEGORY : 311 | case DRIVER_DATA_NVEH_LANE_CHANGE : 312 | if (index1 == 0 && index2 == -1) { /* following vehicle on own lane */ 313 | up_vehicle_lane_change = long_value; 314 | } 315 | else if (index1 == -1 && index2 == 1) { /* right lane leading veh */ 316 | down_right_vehicle_lane_change = long_value; 317 | } 318 | else if (index1 == -1 && index2 == -1) { /* right lane following veh */ 319 | up_right_vehicle_lane_change = long_value; 320 | } 321 | else if (index1 == 1 && index2 == 1) { /* left lane leading veh */ 322 | down_left_vehicle_lane_change = long_value; 323 | } 324 | else if (index1 == 1 && index2 == -1) { /* left lane following veh */ 325 | up_left_vehicle_lane_change = long_value; 326 | } 327 | return 1; 328 | case DRIVER_DATA_NVEH_TYPE : 329 | if (index1 == 0 && index2 == 1) { /* leading veh on own lane */ 330 | down_vehicle_type = long_value; 331 | } 332 | else if (index1 == 0 && index2 == -1) { /* following vehicle on own lane */ 333 | up_vehicle_type = long_value; 334 | } 335 | else if (index1 == -1 && index2 == 1) { /* right lane leading veh */ 336 | down_right_vehicle_type = long_value; 337 | } 338 | else if (index1 == -1 && index2 == -1) { /* right lane following veh */ 339 | up_right_vehicle_type = long_value; 340 | } 341 | else if (index1 == 1 && index2 == 1) { /* left lane leading veh */ 342 | down_left_vehicle_type = long_value; 343 | } 344 | else if (index1 == 1 && index2 == -1) { /* left lane following veh */ 345 | up_left_vehicle_type = long_value; 346 | } 347 | return 1; 348 | case DRIVER_DATA_NVEH_UDA : 349 | case DRIVER_DATA_NVEH_X_COORDINATE : 350 | case DRIVER_DATA_NVEH_Y_COORDINATE : 351 | case DRIVER_DATA_NVEH_Z_COORDINATE : 352 | case DRIVER_DATA_NVEH_REAR_X_COORDINATE : 353 | case DRIVER_DATA_NVEH_REAR_Y_COORDINATE : 354 | case DRIVER_DATA_NVEH_REAR_Z_COORDINATE : 355 | case DRIVER_DATA_NO_OF_LANES : 356 | case DRIVER_DATA_LANE_WIDTH : 357 | case DRIVER_DATA_LANE_END_DISTANCE : 358 | case DRIVER_DATA_CURRENT_LANE_POLY_N : 359 | case DRIVER_DATA_CURRENT_LANE_POLY_X : 360 | case DRIVER_DATA_CURRENT_LANE_POLY_Y : 361 | case DRIVER_DATA_CURRENT_LANE_POLY_Z : 362 | case DRIVER_DATA_RADIUS : 363 | case DRIVER_DATA_MIN_RADIUS : 364 | case DRIVER_DATA_DIST_TO_MIN_RADIUS : 365 | case DRIVER_DATA_SLOPE : 366 | case DRIVER_DATA_SLOPE_AHEAD : 367 | case DRIVER_DATA_SIGNAL_DISTANCE : 368 | case DRIVER_DATA_SIGNAL_STATE : 369 | case DRIVER_DATA_SIGNAL_STATE_START : 370 | case DRIVER_DATA_SPEED_LIMIT_DISTANCE : 371 | case DRIVER_DATA_SPEED_LIMIT_VALUE : 372 | return 1; 373 | case DRIVER_DATA_DESIRED_ACCELERATION : 374 | desired_acceleration = double_value; 375 | return 1; 376 | case DRIVER_DATA_DESIRED_LANE_ANGLE : 377 | desired_lane_angle = double_value; 378 | return 1; 379 | case DRIVER_DATA_ACTIVE_LANE_CHANGE : 380 | active_lane_change = long_value; 381 | return 1; 382 | case DRIVER_DATA_REL_TARGET_LANE : 383 | rel_target_lane = long_value; 384 | return 1; 385 | default : 386 | return 0; 387 | } 388 | } 389 | 390 | /*--------------------------------------------------------------------------*/ 391 | 392 | DRIVERMODEL_API int DriverModelGetValue (long type, 393 | long index1, 394 | long index2, 395 | long *long_value, 396 | double *double_value, 397 | char **string_value) 398 | { 399 | /* Gets the value of a data object of type , selected by */ 400 | /* and possibly , and writes that value to <*double_value>, */ 401 | /* <*float_value> or <**string_value> (object and value selection */ 402 | /* depending on ). */ 403 | /* Return value is 1 on success, otherwise 0. */ 404 | 405 | switch (type) { 406 | case DRIVER_DATA_STATUS : 407 | *long_value = 0; 408 | return 1; 409 | case DRIVER_DATA_VEH_TURNING_INDICATOR : 410 | *long_value = turning_indicator; 411 | return 1; 412 | case DRIVER_DATA_VEH_DESIRED_VELOCITY : 413 | desired_velocity = 27; 414 | *double_value = desired_velocity + (rand() % 6 - 3);//-3~3 random number 415 | return 1; 416 | case DRIVER_DATA_VEH_COLOR : 417 | *long_value = vehicle_color; 418 | return 1; 419 | case DRIVER_DATA_VEH_UDA : 420 | return 0; /* doesn't set any UDA values */ 421 | case DRIVER_DATA_WANTS_SUGGESTION : 422 | *long_value = 1; 423 | return 1; 424 | case DRIVER_DATA_DESIRED_ACCELERATION : 425 | *double_value = desired_acceleration; 426 | return 1; 427 | case DRIVER_DATA_DESIRED_LANE_ANGLE : 428 | *double_value = desired_lane_angle; 429 | return 1; 430 | case DRIVER_DATA_ACTIVE_LANE_CHANGE : 431 | *long_value = active_lane_change; 432 | return 1; 433 | case DRIVER_DATA_REL_TARGET_LANE : 434 | if (rel_target_lane*desired_lane_angle < 0) 435 | { 436 | fout << time_run << " " << veh_id << " " << veh_aim[veh_id] << " " << current_link << "----" << current_lane << " " << active_lane_change << "" << desired_lane_angle << " " << change_right_condition << " " << change_left_condition << "??????????999999" << endl; 437 | } 438 | *long_value = rel_target_lane; 439 | return 1; 440 | case DRIVER_DATA_SIMPLE_LANECHANGE : 441 | *long_value = 0; 442 | return 1; 443 | case DRIVER_DATA_USE_INTERNAL_MODEL: 444 | *long_value = 0;/* must be set to 1 if the internal behavior model of Vissim is to be applied */ 445 | case DRIVER_DATA_WANTS_ALL_NVEHS: 446 | *long_value = 0; /* must be set to 1 if data for more than 2 nearby vehicles per lane and upstream/downstream is to be passed from Vissim */ 447 | return 1; 448 | case DRIVER_DATA_ALLOW_MULTITHREADING: 449 | *long_value = 0; /* must be set to 1 to allow a simulation run to be started with multiple cores used in the simulation parameters */ 450 | return 1; 451 | default: 452 | return 0; 453 | } 454 | } 455 | 456 | 457 | 458 | 459 | 460 | void follow_turn() 461 | { 462 | 463 | if (current_speed > (desired_velocity + 0.2)) 464 | { 465 | acc_follow_own_lane = -(current_speed - desired_velocity); 466 | } 467 | else 468 | { 469 | if (lead_vehicle_distance > 69) 470 | { 471 | acc_follow_own_lane = 0.5; 472 | } 473 | else 474 | { 475 | acc_follow_own_lane = k_1 * (lead_vehicle_distance - lead_vehicle_length - dist_adjust - current_speed * g_cav) - k_2 * lead_vehicle_speed_difference; 476 | } 477 | 478 | } 479 | 480 | 481 | //fout << time_run << " " << veh_id << " " << current_link << "--" << current_lane << " " << current_speed << " " << acc_follow_own_lane << " " << desired_acceleration << " " << lead_vehicle_distance << " " << lead_vehicle_speed_difference << " " << active_lane_change << "+++111111" << endl; 482 | //fout << time_run << " " << veh_id << " " << current_link << "--" << current_lane << acc_follow_own_lane << " " << desired_acceleration << " " << lead_vehicle_distance << " " << lead_vehicle_speed_difference << " " << active_lane_change << endl; 483 | 484 | if (active_lane_change == 0) 485 | { 486 | if ((down_right_vehicle_lane_change > 0) && (down_right_vehicle_type == 630) && (coop[veh_id] == 1)) 487 | { 488 | left_change_follow = k_1 * (down_right_veh_distance - lead_vehicle_length - dist_adjust - current_speed * g_cav) - k_2 * down_right_veh_sp_diff; 489 | } 490 | else 491 | { 492 | left_change_follow = 4.5; 493 | } 494 | if ((down_left_vehicle_lane_change < 0) && (down_left_vehicle_type == 630) && (coop[veh_id] == 1)) 495 | { 496 | right_change_follow = k_1 * (down_left_veh_distance - lead_vehicle_length - dist_adjust - current_speed * g_cav) - k_2 * down_left_veh_sp_diff; 497 | } 498 | else 499 | { 500 | right_change_follow = 4.5; 501 | } 502 | 503 | 504 | desired_acceleration = min(min(left_change_follow, right_change_follow), acc_follow_own_lane); 505 | //desired_acceleration = acc_follow_own_lane; 506 | } 507 | else 508 | { 509 | if (current_lane != target_lane[veh_id]) 510 | { 511 | 512 | if (active_lane_change > 0) 513 | { 514 | //acc_follow_nveh_lane = k_1 * (down_left_veh_distance - current_speed * react_time) - k_2 * down_left_veh_sp_diff; 515 | 516 | acc_follow_nveh_lane = k_1 * (down_left_veh_distance - lead_vehicle_length - dist_adjust - current_speed * g_cav) - k_2 * down_left_veh_sp_diff; 517 | 518 | } 519 | else 520 | { 521 | //acc_follow_nveh_lane = k_1 * (down_right_veh_distance - current_speed * react_time) - k_2 * down_right_veh_sp_diff; 522 | 523 | acc_follow_nveh_lane = k_1 * (down_right_veh_distance - lead_vehicle_length - dist_adjust - current_speed * g_cav) - k_2 * down_right_veh_sp_diff; 524 | } 525 | 526 | } 527 | else 528 | { 529 | 530 | if ((active_lane_change > 0) && (lateral_distance < (-1.75 - 1.3*sin(veh_angle)))) 531 | { 532 | //acc_follow_nveh_lane = k_1 * (down_right_veh_distance - current_speed * react_time) - k_2 * down_right_veh_sp_diff; 533 | acc_follow_nveh_lane = k_1 * (down_right_veh_distance - lead_vehicle_length - dist_adjust - current_speed * g_cav) - k_2 * down_right_veh_sp_diff; 534 | 535 | } 536 | else if ((active_lane_change < 0) && (lateral_distance > (1.75 + 1.3*sin(veh_angle)))) 537 | { 538 | //acc_follow_nveh_lane = k_1 * (down_left_veh_distance - current_speed * react_time) - k_2 * down_left_veh_sp_diff; 539 | acc_follow_nveh_lane = k_1 * (down_left_veh_distance - lead_vehicle_length - dist_adjust - current_speed * g_cav) - k_2 * down_left_veh_sp_diff; 540 | 541 | } 542 | else 543 | { 544 | acc_follow_nveh_lane = 9; 545 | } 546 | } 547 | 548 | desired_acceleration = max(min(acc_follow_own_lane, acc_follow_nveh_lane), -b_av); 549 | 550 | } 551 | 552 | //fout << time_run << " " << veh_id << " " << current_link << "----" << current_lane << acc_follow_own_lane << " " << desired_acceleration << " " << lead_vehicle_distance << " " << lead_vehicle_speed_difference << " " << active_lane_change << endl; 553 | //fout << time_run << " " << veh_id << " " << current_link << "--" << current_lane << " " << current_speed << " " << acc_follow_own_lane << " " << desired_acceleration << " " << lead_vehicle_distance << " " << lead_vehicle_speed_difference << " " << active_lane_change << "+++111111" << endl; 554 | } 555 | 556 | void turn_judge() 557 | { 558 | //if ((right_future_fol_dist <= (down_right_veh_distance - veh_length)) && (right_future_fol_acc >= -b_hv) && (up_right_veh_distance < -5) && ((down_right_veh_distance - lead_vehicle_distance) > -1.5) && ((down_right_veh_distance - lead_vehicle_distance) < 1.5)) 559 | //fout << time_run << " " << veh_id << " " << current_link << "----" << current_lane << " " << change_left_condition << " " << left_future_fol_dist << " " << down_left_veh_distance << " " << left_future_fol_acc << " " << down_left_veh_sp << " " << up_left_veh_sp << "====11111" << endl; 560 | //fout << time_run << " " << veh_id << " " << current_link << "----" << current_lane << " " << change_right_condition << " " << right_future_fol_dist << " " << down_right_veh_distance << " " << right_future_fol_acc << " " << down_right_veh_sp << " " << up_right_veh_sp << "====11111" << endl; 561 | 562 | 563 | if (((current_lane > 1) && (current_link != 1) && (current_link != 3) && (current_link != 10002)) || ((current_lane > 3) && ((current_link == 3) || (current_link == 10002))) || ((current_lane > 2) && (current_link ==1 || current_link == 10000))) 564 | { 565 | right_future_fol_dist = current_speed * react_time + current_speed * current_speed*0.5 / b_av - down_right_veh_sp * down_right_veh_sp*0.5 / b_hv; 566 | right_future_fol_acc = w_hv * (1 - pow((up_right_veh_sp / down_right_veh_sp), 4) - pow(((s_0 + max(0, (up_right_veh_sp*time_gap + up_right_veh_sp * (down_right_veh_sp - up_right_veh_sp)*0.5 / sqrt(w_hv*b_hv)))) / right_future_fol_dist), 2)); 567 | if (current_link == 6 && current_lane > 1 && veh_aim[veh_id] == 1) 568 | 569 | { 570 | 571 | 572 | right_future_fol_acc = -3; 573 | } 574 | } 575 | else 576 | { 577 | right_future_fol_dist = 200; 578 | right_future_fol_acc = -20; 579 | } 580 | 581 | 582 | 583 | 584 | if ((((veh_aim[veh_id] != 1) && (current_lane < 3) && (current_link != 2) && (current_link != 10001) && (current_link != 10) && (current_link != 10007))) || ((current_link == 3 || current_link == 10003) && current_lane == 1)) 585 | { 586 | 587 | left_future_fol_dist = current_speed * react_time + current_speed * current_speed*0.5 / b_av - down_left_veh_sp * down_left_veh_sp*0.5 / b_hv; 588 | left_future_fol_acc = w_hv * (1 - pow((up_left_veh_sp / down_left_veh_sp), 4) - pow(((s_0 + max(0, (up_left_veh_sp*time_gap + up_left_veh_sp * (down_left_veh_sp - up_left_veh_sp)*0.5 / sqrt(w_hv*b_hv)))) / left_future_fol_dist), 2)); 589 | 590 | //fout << time_run << " " << veh_id << " " << current_link << "----" << current_lane << " " << change_left_condition << " " << left_future_fol_dist << " " << down_left_veh_distance << " " << left_future_fol_acc << " " << down_left_veh_sp << " " << up_left_veh_sp <<"==333333"<< endl; 591 | } 592 | else 593 | { 594 | left_future_fol_dist = 200; 595 | left_future_fol_acc = -20; 596 | } 597 | 598 | //fout << time_run << " " << veh_id << " " << current_link << "----" << current_lane << " " << change_right_condition << " " << right_future_fol_dist << " " << down_right_veh_distance << " " << right_future_fol_acc << " " << down_right_veh_sp << " " << up_right_veh_sp << "====22222" << endl; 599 | 600 | if (down_left_veh_distance > 69 || down_right_veh_distance > 69) 601 | { 602 | down_left_veh_sp = up_left_veh_sp; 603 | left_future_fol_acc = -3; 604 | down_right_veh_sp = up_right_veh_sp; 605 | right_future_fol_acc = -3; 606 | //left_future_fol_dist = 8; 607 | //right_future_fol_dist = 8; 608 | } 609 | 610 | 611 | 612 | 613 | if ((right_future_fol_dist <= (down_right_veh_distance - veh_length)) && (right_future_fol_acc >= -b_hv)) 614 | { 615 | 616 | if ((current_link == 3 || current_link == 10002) && current_lane == 2) 617 | { 618 | change_right_condition = 0; 619 | 620 | } 621 | else 622 | { 623 | 624 | if (down_right_veh_distance > 6 && up_right_veh_distance < -10) 625 | { 626 | if (current_link == 6 && current_lane > 1) 627 | { 628 | change_right_condition = 1; 629 | } 630 | else 631 | { 632 | //incentive check 633 | acc_follow_nveh_lane = k_1 * (down_right_veh_distance - lead_vehicle_length - dist_adjust - current_speed * react_time) - k_2 * down_right_veh_sp_diff; 634 | if ((acc_follow_nveh_lane - acc_follow_own_lane) > (d_a - d_bias)) 635 | { 636 | change_right_condition = 1; 637 | } 638 | else 639 | { 640 | change_right_condition = 0; 641 | } 642 | } 643 | 644 | } 645 | else 646 | { 647 | change_right_condition = 0; 648 | } 649 | 650 | } 651 | 652 | } 653 | else if ((left_future_fol_dist <= (down_left_veh_distance - veh_length)) && (left_future_fol_acc >= -b_hv)) 654 | { 655 | 656 | if (down_left_veh_distance > 8 && (up_left_veh_distance < -10 || down_left_veh_sp < 1)) 657 | { 658 | if (current_link == 3 && current_lane == 1) 659 | { 660 | change_left_condition = 1; 661 | } 662 | else 663 | { 664 | //incentive check 665 | acc_follow_nveh_lane = k_1 * (down_left_veh_distance - lead_vehicle_length - dist_adjust - current_speed * react_time) - k_2 * down_left_veh_sp_diff; 666 | if ((acc_follow_nveh_lane - acc_follow_own_lane) > (d_a + d_bias)) 667 | { 668 | change_left_condition = 1; 669 | } 670 | else 671 | { 672 | change_left_condition = 0; 673 | } 674 | 675 | } 676 | } 677 | else 678 | { 679 | change_left_condition = 0; 680 | } 681 | 682 | //fout << time_run << " " << veh_id << " " << current_link << "----" << current_lane << " " << change_left_condition << " " << active_lane_change <<" 5555555"<< endl; 683 | } 684 | else 685 | { 686 | change_right_condition = 0; 687 | change_left_condition = 0; 688 | } 689 | 690 | //fout << time_run << " " << veh_id << " " << current_link << "----" << current_lane << " " << change_left_condition << " " << left_future_fol_dist << " " << down_left_veh_distance << " " << left_future_fol_acc << " " << down_left_veh_sp << " " << up_left_veh_sp << "====666666"<" << desired_lane_angle << " " << change_right_condition << " " << change_left_condition << "????????????111111" << endl; 700 | } 701 | 702 | 703 | 704 | //fout << time_run << " " << veh_id << " " << current_link << "--" << current_lane << " " << active_lane_change << " " << change_left_condition << " " << desired_lane_angle << " " << lateral_distance << endl; 705 | //fout << time_run << " " << veh_id << " " << current_lane << " " << active_lane_change << " " << desired_lane_angle << " " << veh_angle << " " << "3333333" << endl; 706 | //fout << time_run << " " << veh_id << " " << veh_aim[veh_id] << " " << current_link << "----" << current_lane << " " << active_lane_change << "" << desired_lane_angle << " " << change_right_condition << " " << change_left_condition << "===1111111" << endl; 707 | if (active_lane_change == 0) 708 | { 709 | //if ((change_right_condition == 1) && (right_hv_con == 1)) 710 | if (change_right_condition == 1) 711 | { 712 | 713 | active_lane_change = -1; 714 | rel_target_lane = -1; 715 | 716 | target_lane[veh_id] = current_lane + rel_target_lane; 717 | desired_lane_angle = active_lane_change * 0.05; 718 | active_change_time[veh_id] = time_run; 719 | change_lane_period[veh_id] = b * current_speed; 720 | 721 | 722 | } 723 | //else if ((change_left_condition == 1) && (left_hv_con == 1)) 724 | else if (change_left_condition == 1) 725 | { 726 | active_lane_change = 1; 727 | rel_target_lane = 1; 728 | //change_left_condition = 0; 729 | 730 | target_lane[veh_id] = current_lane + rel_target_lane; 731 | desired_lane_angle = active_lane_change * 0.05; 732 | active_change_time[veh_id] = time_run; 733 | change_lane_period[veh_id] = b * current_speed; 734 | 735 | } 736 | else 737 | { 738 | active_lane_change = 0; 739 | rel_target_lane = 0; 740 | target_lane[veh_id] = 0; 741 | desired_lane_angle = 0; 742 | } 743 | 744 | } 745 | else 746 | { 747 | 748 | if ((active_lane_change == -1) && (target_lane[veh_id] == current_lane) && (lateral_distance < 0.03)) 749 | { 750 | //LC to right ends 751 | active_lane_change = 0; 752 | rel_target_lane = 0; 753 | target_lane[veh_id] = 0; 754 | 755 | } 756 | else if ((active_lane_change == 1) && (target_lane[veh_id] == current_lane) && (lateral_distance > -0.03)) 757 | { 758 | //LC to left ends 759 | active_lane_change = 0; 760 | rel_target_lane = 0; 761 | target_lane[veh_id] = 0; 762 | 763 | } 764 | else if ((active_lane_change != 0) && (target_lane[veh_id] == 0)) 765 | { 766 | 767 | active_lane_change = 0; 768 | rel_target_lane = 0; 769 | desired_lane_angle = 0; 770 | } 771 | 772 | else if ((target_lane[veh_id] < current_lane) && (active_lane_change == -1)) 773 | { 774 | if (change_right_condition == 0) 775 | { 776 | active_lane_change = 0; 777 | rel_target_lane = 0; 778 | target_lane[veh_id] = 0; 779 | desired_lane_angle = 0; 780 | } 781 | else 782 | { 783 | //angle = (lw + lateral_distance) / ((change_lane_period[veh_id] - time_run)*current_speed + 0.5*desired_acceleration*(change_lane_period[veh_id] - time_run)*(change_lane_period[veh_id] - time_run)); 784 | angle = (lw + lateral_distance) / (down_right_veh_distance - right_future_fol_dist + down_right_veh_sp * (change_lane_period[veh_id] - time_run + active_change_time[veh_id])); 785 | desired_lane_angle = active_lane_change * atan(angle); 786 | //historical angle value 787 | if (active_lane_change*desired_lane_angle < 0) 788 | { 789 | desired_lane_angle = last_angel[veh_id]; 790 | } 791 | } 792 | } 793 | else if ((target_lane[veh_id] > current_lane) && (active_lane_change == 1)) 794 | { 795 | if (change_left_condition == 0) 796 | { 797 | active_lane_change = 0; 798 | rel_target_lane = 0; 799 | target_lane[veh_id] = 0; 800 | desired_lane_angle = -0.03; 801 | //vehicle_color = RGB(128, 128, 128) + 255 * 16777216; 802 | } 803 | else 804 | { 805 | angle = (lw - lateral_distance) / (down_left_veh_distance - left_future_fol_dist + down_left_veh_sp * (change_lane_period[veh_id] - time_run + active_change_time[veh_id])); 806 | desired_lane_angle = active_lane_change * atan(angle); 807 | //historical angle value 808 | if (active_lane_change*desired_lane_angle < 0) 809 | { 810 | desired_lane_angle = last_angel[veh_id]; 811 | } 812 | 813 | } 814 | } 815 | else if (target_lane[veh_id] == current_lane) 816 | { 817 | if ((active_lane_change == -1) && (lateral_distance > (1.75 + 1.3*sin(veh_angle)))) 818 | { 819 | // LC to right 820 | right_future_fol_dist = current_speed * react_time + current_speed * current_speed*0.5 / b_av - lead_vehicle_speed * lead_vehicle_speed*0.5 / b_hv; 821 | angle = lateral_distance / (lead_vehicle_distance - right_future_fol_dist + lead_vehicle_speed * (change_lane_period[veh_id] - time_run + active_change_time[veh_id])); 822 | desired_lane_angle = active_lane_change * atan(angle); 823 | 824 | //historical angle value 825 | if (active_lane_change*desired_lane_angle < 0) 826 | { 827 | desired_lane_angle = last_angel[veh_id]; 828 | } 829 | 830 | } 831 | else if ((active_lane_change == 1) && (lateral_distance < (-1.75 - 1.3*sin(veh_angle)))) 832 | { 833 | //LC to left 834 | left_future_fol_dist = current_speed * react_time + current_speed * current_speed*0.5 / b_av - lead_vehicle_speed * lead_vehicle_speed*0.5 / b_hv; 835 | angle = -lateral_distance / (lead_vehicle_distance - left_future_fol_dist + lead_vehicle_speed * (change_lane_period[veh_id] - time_run + active_change_time[veh_id])); 836 | desired_lane_angle = active_lane_change * atan(angle); 837 | 838 | //historical angle value 839 | if (active_lane_change*desired_lane_angle < 0) 840 | { 841 | desired_lane_angle = last_angel[veh_id]; 842 | } 843 | } 844 | } 845 | else 846 | { 847 | active_lane_change = 0; 848 | rel_target_lane = 0; 849 | target_lane[veh_id] = 0; 850 | desired_lane_angle = 0; 851 | 852 | } 853 | 854 | } 855 | 856 | last_angel[veh_id] = desired_lane_angle; 857 | 858 | //fout << time_run << " " << veh_id << " " << current_link << "--" << current_lane << " " << active_lane_change << " " << change_left_condition << " " << desired_lane_angle << " " << lateral_distance << endl; 859 | //fout << time_run << " " << veh_id << " " << active_lane_change << "" << desired_lane_angle << " " << down_left_veh_distance << " " << left_future_fol_dist << " " << down_left_veh_sp << " " << lead_vehicle_speed << "===222222" << endl; 860 | 861 | //fout << right_future_fol_dist << " " << current_speed << " " << lead_vehicle_speed << " " << lateral_distance << " " << lead_vehicle_distance << " " << change_lane_period[veh_id] << " " << active_change_time[veh_id] << " " << angle << endl; 862 | //fout << time_run << " " << veh_id << " " << veh_aim[veh_id] << " " << current_link << "----" << current_lane << " " << active_lane_change << "" << desired_lane_angle << " " << change_right_condition << " " << change_left_condition <<"===3333333"<" << desired_lane_angle << " " << change_right_condition << " " << change_left_condition << "????????????555555" << endl; 867 | } 868 | 869 | } 870 | 871 | 872 | //=====================================correct the LC angle 873 | void correction_angle() 874 | { 875 | 876 | if (active_lane_change == 0) 877 | { 878 | if (lateral_distance > 0.5) 879 | { 880 | desired_lane_angle = -0.1; 881 | //rel_target_lane = 0; 882 | target_lane[veh_id] = current_lane; 883 | } 884 | else if (lateral_distance < -0.5) 885 | { 886 | desired_lane_angle = 0.1; 887 | //rel_target_lane = 0; 888 | target_lane[veh_id] = current_lane; 889 | } 890 | else 891 | { 892 | desired_lane_angle = 0; 893 | } 894 | } 895 | } 896 | 897 | 898 | 899 | 900 | 901 | 902 | 903 | /*==========================================================================*/ 904 | 905 | DRIVERMODEL_API int DriverModelExecuteCommand (long number) 906 | { 907 | /* Executes the command if that is available in the driver */ 908 | /* module. Return value is 1 on success, otherwise 0. */ 909 | 910 | switch (number) { 911 | case DRIVER_COMMAND_INIT: 912 | fout.open("data_put_out_AV.txt", std::ios_base::out); 913 | fout.flush(); 914 | for (int i = 0; i < veh_data.size(); i++) 915 | veh_data[i].resize(0); 916 | return 1; 917 | case DRIVER_COMMAND_CREATE_DRIVER: 918 | target_lane[veh_id] = 0; 919 | active_change_time[veh_id] = 0; 920 | change_lane_period[veh_id] = 0; 921 | 922 | veh_aim[veh_id] = 0; 923 | last_link[veh_id] = 0; 924 | last_angel[veh_id] = 0; 925 | coop[veh_id] = 0; 926 | return 1; 927 | case DRIVER_COMMAND_KILL_DRIVER: 928 | target_lane.erase(veh_id); 929 | active_change_time.erase(veh_id); 930 | change_lane_period.erase(veh_id); 931 | 932 | veh_aim.erase(veh_id); 933 | last_link.erase(veh_id); 934 | last_angel.erase(veh_id); 935 | coop.erase(veh_id); 936 | return 1; 937 | case DRIVER_COMMAND_MOVE_DRIVER: 938 | 939 | net_distance = lead_vehicle_distance - lead_vehicle_length; 940 | desired_distance = 15 + lead_vehicle_length; /* times 1 s */ 941 | change_left_condition = 0; 942 | change_right_condition = 0; 943 | 944 | //right_future_fol_dist = 999; 945 | //right_future_fol_acc = -8; 946 | //left_future_fol_dist = 999; 947 | //left_future_fol_acc = -8; 948 | 949 | 950 | //for checking states========================================================================== 951 | if (active_lane_change*desired_lane_angle < 0) 952 | { 953 | fout << time_run << " " << veh_id << " " << veh_aim[veh_id] << " " << current_link << "----" << current_lane << " " << active_lane_change << "" << desired_lane_angle << " " << change_right_condition << " " << change_left_condition << "??????????888888" << endl; 954 | } 955 | 956 | 957 | 958 | if (current_link == 1 && veh_y_po < -250 && veh_aim[veh_id] == 0) 959 | { 960 | if ((time_run - floor(time_run)) < av_off_main_rate) 961 | { 962 | veh_aim[veh_id] = 1;//diverge 963 | vehicle_color = RGB(0, 255, 255) + 255 * 16777216; 964 | 965 | } 966 | else 967 | { 968 | veh_aim[veh_id] = 2;//through 969 | vehicle_color = RGB(0, 180, 255) + 255 * 16777216; 970 | } 971 | 972 | 973 | suiji = random(0, 100); 974 | if (suiji < coop_rate *100) 975 | { 976 | coop[veh_id] = 1; 977 | } 978 | else 979 | { 980 | coop[veh_id] = 2; 981 | } 982 | 983 | 984 | } 985 | else if (current_link == 2 && veh_y_po < 460 && veh_aim[veh_id] == 0) 986 | { 987 | if ((time_run - floor(time_run)) < av_off_ramp_rate) 988 | { 989 | veh_aim[veh_id] = 1; 990 | vehicle_color = RGB(0, 255, 255) + 255 * 16777216; 991 | } 992 | else 993 | { 994 | veh_aim[veh_id] = 2; 995 | vehicle_color = RGB(0, 180, 255) + 255 * 16777216; 996 | } 997 | suiji = random(0, 100); 998 | if (suiji < coop_rate * 100) 999 | { 1000 | coop[veh_id] = 1; 1001 | } 1002 | else 1003 | { 1004 | coop[veh_id] = 2; 1005 | } 1006 | } 1007 | 1008 | 1009 | 1010 | 1011 | if (active_lane_change != 0) 1012 | { 1013 | if ((current_link != last_link[veh_id]) && (current_link == 3 || current_link == 7) && (active_change_time[veh_id] 4700) 1059 | else if ((current_link == 7 || current_link == 10005) && current_lane == 2 && veh_y_po > 4420) 1060 | { 1061 | //diverging 1062 | if (down_right_veh_distance > 6 && veh_aim[veh_id] == 1) 1063 | { 1064 | 1065 | change_right_condition = 1; 1066 | //vehicle_color = RGB(255, 188, 0) + 255 * 16777216; 1067 | follow_turn(); 1068 | //turn_judge(); 1069 | right_future_fol_dist = 7; 1070 | right_future_fol_acc = -3; 1071 | acc_angle(); 1072 | //active_lane_change = -1; 1073 | //rel_target_lane = -1; 1074 | //target_lane[veh_id] = 1; 1075 | //desired_lane_angle = -0.1; 1076 | 1077 | } 1078 | else 1079 | { 1080 | follow_turn(); 1081 | turn_judge(); 1082 | acc_angle(); 1083 | } 1084 | 1085 | } 1086 | else 1087 | { 1088 | follow_turn(); 1089 | turn_judge(); 1090 | acc_angle(); 1091 | } 1092 | 1093 | 1094 | correction_angle(); 1095 | 1096 | 1097 | 1098 | 1099 | //for checking========================================================================== 1100 | if (active_lane_change*desired_lane_angle < 0) 1101 | { 1102 | fout << time_run << " " << veh_id << " " << veh_aim[veh_id] << " " << current_link << "----" << current_lane << " " << active_lane_change << "" << desired_lane_angle << " " << change_right_condition << " " << change_left_condition << "??????????999999" << endl; 1103 | } 1104 | 1105 | 1106 | 1107 | 1108 | 1109 | last_link[veh_id] = current_link; 1110 | 1111 | 1112 | veh_data[veh_id].push_back(current_speed); 1113 | fout.precision(4); 1114 | if (time_run == 300 && www == 0) 1115 | { 1116 | for (int i = 0; i < veh_data.size(); i++) 1117 | { 1118 | 1119 | //fout << "630 "; 1120 | if (veh_data[i].empty()) 1121 | { 1122 | ; 1123 | } 1124 | else 1125 | { 1126 | fout << veh_type << " "; 1127 | for (int j = 0; j < veh_data[i].size(); j++) 1128 | { 1129 | fout << veh_data[i][j] << " "; 1130 | } 1131 | fout << endl; 1132 | } 1133 | } 1134 | 1135 | www = 1; 1136 | } 1137 | 1138 | 1139 | 1140 | return 1; 1141 | default : 1142 | return 0; 1143 | } 1144 | } 1145 | 1146 | /*==========================================================================*/ 1147 | /* End of DriverModel.cpp */ 1148 | /*==========================================================================*/ --------------------------------------------------------------------------------