private void UpdateVolume(List <int> VolInput, List <int> Vol) { int p = 0; foreach (int val in VolInput) { VissimTools.SetVol(val, "Volume(1)", Vol[p]); //vehicle input point [VolInput], volume of 1st interval //VissimTools.SetVol(val, "Volume(2)", Vol); //vehicle input point [VolInput], volume of 2nd interval p++; } }
private void RunCACCSimSingle(string fn, string fnini, int SimTime, int simresol, int rseed, List <int> MainVolInput, List <int> OnRampVolInput, List <int> OutGoingLinks, List <int> InComingLinks, List <int> MainVol, List <int> OnRampVol, string MPCacc, string MPAcc, string MPHov) { int outci = 0; //initialized the counter for traffic on on-ramp int inci = 0; //initialized the time coutner for traffic on off-ramp int ininterval = 2 * simresol; // In the on-ramp (shorter length) collect data at twice of the simulation interval int outinterval = 4 * simresol; // In the off-ramp (longer length) collect data at four times of the simulation interval int vid = 0; int type = 0; object VTYPE = null; object VIDs = null; //invoking the initiallizatio of the Vssim network based on the pararmeter defined above VissimTools.InitVissim(fn, fnini, SimTime, simresol, rseed); //seting the vehicle input volumes UpdateVolume(MainVolInput, MainVol); // Update Mainline Volume UpdateVolume(OnRampVolInput, OnRampVol); // Update On-Ramp Volume //Setting the relative flow rate of CACC in the main input point and 1st on-ramp //VissimTools.SetRelFlow(2, "Relflow(100,1)", 1.0-Convert.ToDouble(MPCacc)); //vehicle compisiton row 2 (input #2), subatribute (100 vehicle type) //VissimTools.SetRelFlow(2, "Relflow(102,1)", Convert.ToDouble(MPCacc)); //vehicle compisiton row 2 (input #2), subatribute (102 vehicle type) //VissimTools.SetRelFlow(4, "Relflow(100,1)", 1.0-Convert.ToDouble(MPCacc)); //vehicle compisiton row 4 (input #4), subatribute (100 type and 101 type) //VissimTools.SetRelFlow(4, "Relflow(101,1)", Convert.ToDouble(MPCacc)); //vehicle compisiton row 4 (input #4), subatribute (101 vehicle type) // TO DO : We need to add ACC mode Market Penetration Rates; Traffic Composition ID must be obatined through the GUI. for (int i = 1; i <= simresol * SimTime; i++) { VissimTools.vissim.Simulation.RunSingleStep(); if (i == 845) { Console.Write("!"); } inci++; outci++; if (inci == ininterval) { foreach (int val in InComingLinks) { VIDs = VissimTools.GetLinkVehiclesbyNumber(val); VTYPE = VissimTools.GetLinkVehiclesByType(val); for (int k = 0; k < ((object[, ])(VIDs)).Length / 2; k++) { type = Convert.ToInt32(((object[, ])(VTYPE))[k, 1]); if (type == 102) { vid = Convert.ToInt32(((object[, ])(VIDs))[k, 1]); if (VissimTools.Get_Lane(vid) > 1) { VissimTools.Set_VehType(vid, 101); } } } inci = 0; } } if (outci == outinterval) { foreach (int val in OutGoingLinks) { VIDs = VissimTools.GetLinkVehiclesbyNumber(val); VTYPE = VissimTools.GetLinkVehiclesByType(val); for (int k = 0; k < ((object[, ])(VIDs)).Length / 2; k++) { type = Convert.ToInt32(((object[, ])(VTYPE))[k, 1]); if (type == 101) { vid = Convert.ToInt32(((object[, ])(VIDs))[k, 1]); if (VissimTools.GetRoute(vid) == 2) { VissimTools.Set_VehType(vid, 100); } } } outci = 0; } } } }