Quickstart#

This guide shows how to get started with the invode package.

Installation#

Install the latest published version from PyPI:

pip install invode

To upgrade:

pip install --upgrade invode

Example Usage#

Here’s a minimal working example using ODEOptimizer:

from invode.optimizer import ODEOptimizer

def my_ode(params):
    # Example model output
    return [1.0, 2.0]  # Replace with actual simulation output

def my_error(sim_output):
    # Example error function
    return sum((x - y)**2 for x, y in zip(sim_output, [1.1, 2.1]))

bounds = {'k1': (0.1, 1.0), 'k2': (0.01, 0.5)}

optimizer = ODEOptimizer(
    ode_func=my_ode,
    error_func=my_error,
    param_bounds=bounds,
    n_samples=50,
    num_iter=5,
    verbose=True
)

best_params, best_error = optimizer.fit()

print("Best Parameters:", best_params)
print("Best Error:", best_error)

Summary and Plots#

You can view a summary and plot of the error history:

optimizer.summary()
optimizer.plot_error_history()