Skip to content

Latest commit

 

History

History
123 lines (83 loc) · 3.16 KB

File metadata and controls

123 lines (83 loc) · 3.16 KB

Running the Model

The RESPOND model can be used in multiple ways:

  1. As a C++ library - Integrate into your own C++ projects
  2. Via Python package - Use the higher-level respondpy interface
  3. Standalone executable - Legacy support for direct command-line execution

Using RESPOND as a C++ Library

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

Basic Example

#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.

Using the Standalone Executable

Legacy support for standalone execution is available in release v0.3.0.

Command-Line Usage

To run the executable (requires legacy release):

./respond_exe /path/to/input/folders 1 1

Arguments

The executable takes 3 positional arguments:

  1. Input folder path: Directory containing simulation configuration and data
  2. Start folder index: First input folder number (e.g., 1 for input1)
  3. End folder index: Last input folder number (inclusive)

Examples

# 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 10

Output

The executable produces output files in the same directory as the input data.

Python Integration

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