The RESPOND model can be used in multiple ways:
- As a C++ library - Integrate into your own C++ projects
- Via Python package - Use the higher-level respondpy interface
- Standalone executable - Legacy support for direct command-line execution
For C++ developers, RESPOND can be integrated directly into projects. See the C++ API Guide for:
- Complete API reference
- Usage examples
- Memory management details
- Design patterns and best practices
#include <respond/simulation.hpp>
#include <respond/model.hpp>
#include <respond/timestep.hpp>
#include <respond/transition.hpp>
int main() {
// Create a simulation
respond::Simulation sim("my_logger");
// Create and configure a model
auto model = respond::Model::Create("markov", "my_logger");
// Set initial state
Eigen::VectorXd initial_state(50);
initial_state.setZero();
initial_state(0) = 1000; // 1000 individuals in state 0
model->SetState(initial_state);
// Build one timestep and attach transitions
respond::Timestep step("my_logger");
auto &behavior = step.CreateTransition("behavior");
// behavior->AddMatrix(...);
auto migration = respond::Transition::Create("migration");
step.AddTransition(migration);
// Mutable slot access to transitions owned by this timestep
// step[0]->AddMatrix(...);
// Add timesteps to the model
for (int t = 0; t < 52; ++t) {
model->AddTimestep(step);
}
// Add model to simulation
sim.AddModel(model);
// Run simulation for 52 timesteps
sim.Run(52);
// Extract results
auto histories = sim.GetModelHistory(0);
return 0;
}For complete examples and API documentation, see the C++ API Guide.
Legacy support for standalone execution is available in release v0.3.0.
To run the executable (requires legacy release):
./respond_exe /path/to/input/folders 1 1The executable takes 3 positional arguments:
- Input folder path: Directory containing simulation configuration and data
- Start folder index: First input folder number (e.g., 1 for
input1) - End folder index: Last input folder number (inclusive)
# Run single input folder
./respond_exe /home/user/data 1 1
# Run folders input1, input2, input3
./respond_exe /home/user/data 1 3
# Run folders input5 through input10
./respond_exe /home/user/data 5 10The executable produces output files in the same directory as the input data.
For a higher-level interface, use the respondpy Python package:
import respondpy as respond
# Configure and run simulations
sim = respond.Simulation(config_path)
results = sim.run()See the respondpy documentation for details.
Previous: Data
Next: Under the Hood