Expand description
§macro_traffic_sim
gRPC interface for macroscopic traffic simulation via 4-step demand model.
This crate provides a tonic-based gRPC client and server for interacting with
the macro_traffic_sim_core computation engine. It allows you to:
- Create simulation sessions
- Define transport networks (meso nodes, links, zones)
- Load origin-destination demand matrices
- Configure the 4-step model (trip generation, distribution, mode choice, assignment)
- Run the pipeline and observe progress
- Retrieve results (link volumes, OD matrices, convergence info)
§Architecture
The computation core (macro_traffic_sim_core) implements the classical
4-step traffic demand model (Generation, Distribution, Mode Choice, Assignment).
This crate wraps it with a gRPC API defined in Protocol Buffers, enabling
language-agnostic access from Go, Python, or any gRPC-compatible client.
§Quick Start (Client)
use macro_traffic_sim::pb::macro_service_client::MacroServiceClient;
use macro_traffic_sim::pb::*;
use tonic::transport::Channel;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let channel = Channel::from_static("http://127.0.0.1:50052")
.connect()
.await?;
let mut client = MacroServiceClient::new(channel);
// Create a new session
let response = client.new_session(NewSessionRequest {}).await?;
let session_id = response.into_inner().session_id.unwrap().value;
println!("Session created: {}", session_id);
// Now push network, zones, OD matrix, configure, and run...
Ok(())
}For a complete working example, see
examples/rust_client.
§Running the Server
The server binary is included when built with the server feature:
cargo run --features server --bin macro_traffic_sim§Protocol Buffers
All types are generated from .proto files and exposed under the pb module:
pb::macro_service_client::MacroServiceClient- gRPC client stubpb::macro_service_server::MacroServiceServer- gRPC server trait (withserverfeature)- Session:
pb::NewSessionRequest,pb::NewSessionResponse,pb::InfoSessionResponse - Network:
pb::Node,pb::Link,pb::Zone,pb::NetworkChunk - OD Matrix:
pb::OdMatrixChunk - Config:
pb::ModelConfigRequest,pb::BprConfig,pb::ModeUtility,pb::TimePeriod - Pipeline:
pb::RunPipelineRequest,pb::RunPipelineProgress - Results:
pb::LinkVolumesChunk,pb::LinkVolume,pb::OdResultChunk,pb::AssignmentInfo
§Related Crates
macro_traffic_sim_core- The computation engine (4-step demand model)micro_traffic_sim- gRPC interface for microscopic simulationmicro_traffic_sim_core- Microscopic engine (cellular automata)
§Clients in Other Languages
- Go: clients/go
- Python: clients/python
Re-exports§
pub use pb::*;
Modules§
- pb
- Generated Protocol Buffer types and gRPC service definitions.