Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions benchmark/Dynamics/BenchDynamics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

using Graph = dsm::Graph;
using Itinerary = dsm::Itinerary;
using Dynamics = dsm::FirstOrderDynamics<uint32_t>;
using Dynamics = dsm::FirstOrderDynamics;

using Bench = sb::Bench<long long int>;

Expand All @@ -28,8 +28,6 @@ int main() {
dynamics.addItinerary(it2);
dynamics.addItinerary(it3);
dynamics.addItinerary(it4);
dynamics.setErrorProbability(0.3);
dynamics.setMinSpeedRateo(0.95);

const int n_rep{100};
Bench b1(n_rep);
Expand Down
4 changes: 2 additions & 2 deletions examples/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
slow_charge_tl:
./slow_charge_tl.out 69 0.3 ./sctl 0
./slow_charge_tl.out 69 0.3 ./sctl 0 450
slow_charge_rb:
./slow_charge_rb.out 69 0.3 ./scrb/
./slow_charge_rb.out 69 0.3 ./scrb/ 450
stalingrado:
./stalingrado.out
8 changes: 4 additions & 4 deletions examples/slow_charge_rb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace fs = std::filesystem;

std::atomic<unsigned int> progress{0};
std::atomic<bool> bExitFlag{false};
uint nAgents{450};

// uncomment these lines to print densities, flows and speeds
#define PRINT_DENSITIES
Expand All @@ -30,7 +29,7 @@ using Unit = unsigned int;
using Delay = uint8_t;

using Graph = dsm::Graph;
using Dynamics = dsm::FirstOrderDynamics<Delay>;
using Dynamics = dsm::FirstOrderDynamics;
using Street = dsm::Street;
using SpireStreet = dsm::SpireStreet;
using Roundabout = dsm::Roundabout;
Expand All @@ -42,15 +41,16 @@ void printLoadingBar(int const i, int const n) {
}

int main(int argc, char** argv) {
if (argc != 4) {
if (argc != 5) {
std::cerr << "Usage: " << argv[0]
<< " <SEED> <ERROR_PROBABILITY> <OUT_FOLDER_BASE>\n";
<< " <SEED> <ERROR_PROBABILITY> <OUT_FOLDER_BASE> <INIT_NAGENTS>\n";
return 1;
}

const int SEED = std::stoi(argv[1]); // seed for random number generator
const double ERROR_PROBABILITY{std::stod(argv[2])};
const std::string BASE_OUT_FOLDER{argv[3]};
auto nAgents{std::stoul(argv[4])};

std::cout << "-------------------------------------------------\n";
std::cout << "Input parameters:\n";
Expand Down
15 changes: 8 additions & 7 deletions examples/slow_charge_tl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace fs = std::filesystem;

std::atomic<unsigned int> progress{0};
std::atomic<bool> bExitFlag{false};
uint nAgents{315}; // 315 for error probability 0.3, 450 for error probability 0.05

// uncomment these lines to print densities, flows and speeds
#define PRINT_DENSITIES
Expand All @@ -31,7 +30,7 @@ using Unit = unsigned int;
using Delay = uint8_t;

using Graph = dsm::Graph;
using Dynamics = dsm::FirstOrderDynamics<Delay>;
using Dynamics = dsm::FirstOrderDynamics;
using Street = dsm::Street;
using SpireStreet = dsm::SpireStreet;
using TrafficLight = dsm::TrafficLight;
Expand All @@ -43,9 +42,10 @@ void printLoadingBar(int const i, int const n) {
}

int main(int argc, char** argv) {
if (argc != 5) {
std::cerr << "Usage: " << argv[0]
<< " <SEED> <ERROR_PROBABILITY> <OUT_FOLDER_BASE> <OPTIMIZE>\n";
if (argc != 6) {
std::cerr
<< "Usage: " << argv[0]
<< " <SEED> <ERROR_PROBABILITY> <OUT_FOLDER_BASE> <OPTIMIZE> <INIT_NAGENTS>\n";
return 1;
}

Expand All @@ -54,6 +54,7 @@ int main(int argc, char** argv) {
std::string BASE_OUT_FOLDER{argv[3]};
const bool OPTIMIZE{std::string(argv[4]) != std::string("0")};
BASE_OUT_FOLDER += OPTIMIZE ? "_op/" : "/";
auto nAgents{std::stoul(argv[5])};

const std::string IN_MATRIX{"./data/matrix.dat"}; // input matrix file
const std::string IN_COORDS{"./data/coordinates.dsm"}; // input coords file
Expand All @@ -68,6 +69,7 @@ int main(int argc, char** argv) {
std::cout << "Seed: " << SEED << '\n';
std::cout << "Error probability: " << ERROR_PROBABILITY << '\n';
std::cout << "Base output folder: " << BASE_OUT_FOLDER << '\n';
std::cout << "Initial number of agents: " << nAgents << '\n';
if (OPTIMIZE) {
std::cout << "Traffic light optimization ENABLED.\n";
}
Expand All @@ -89,12 +91,11 @@ int main(int argc, char** argv) {
graph.importCoordinates(IN_COORDS);
std::cout << "Setting street parameters..." << '\n';
for (const auto& [streetId, street] : graph.streetSet()) {
street->setLength(2e3);
street->setCapacity(225);
street->setTransportCapacity(1);
street->setMaxSpeed(13.9);
}
graph.buildAdj();
graph.normalizeStreetCapacities();
const auto dv = graph.adjMatrix().getDegreeVector();

// graph.addStreet(Street(100002, std::make_pair(0, 108)));
Expand Down
2 changes: 1 addition & 1 deletion examples/stalingrado.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ using Delay = uint8_t;

using Graph = dsm::Graph;
using Itinerary = dsm::Itinerary;
using Dynamics = dsm::FirstOrderDynamics<Delay>;
using Dynamics = dsm::FirstOrderDynamics;
using Street = dsm::Street;
using SpireStreet = dsm::SpireStreet;
using TrafficLight = dsm::TrafficLight;
Expand Down
5 changes: 2 additions & 3 deletions profiling/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using unit = uint32_t;

using Graph = dsm::Graph;
using Itinerary = dsm::Itinerary;
using Dynamics = dsm::FirstOrderDynamics<unit>;
using Dynamics = dsm::FirstOrderDynamics;

int main() {
Graph graph{};
Expand All @@ -36,13 +36,12 @@ int main() {

std::cout << "Creating dynamics...\n";

Dynamics dynamics{graph};
Dynamics dynamics{graph, std::nullopt, 0.95};
dynamics.addItinerary(it1);
dynamics.addItinerary(it2);
dynamics.addItinerary(it3);
dynamics.addItinerary(it4);
dynamics.setErrorProbability(0.3);
dynamics.setMinSpeedRateo(0.95);
dynamics.updatePaths();

std::cout << "Done.\n"
Expand Down
2 changes: 1 addition & 1 deletion src/dsm/dsm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

static constexpr uint8_t DSM_VERSION_MAJOR = 2;
static constexpr uint8_t DSM_VERSION_MINOR = 2;
static constexpr uint8_t DSM_VERSION_PATCH = 4;
static constexpr uint8_t DSM_VERSION_PATCH = 5;

static auto const DSM_VERSION =
std::format("{}.{}.{}", DSM_VERSION_MAJOR, DSM_VERSION_MINOR, DSM_VERSION_PATCH);
Expand Down
Loading
Loading