---
title: "ModelSize"
description: "Notes how big each model is, to relate solving times to model size."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.cpbenchy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ModelSize

## What it does

Counts the variables (and how many are Boolean) and the constraints of every model, as loaded, so you
can relate solving times to model size.

## Use it

```python
import cpbenchy
from cpbenchy import observers

results = cpbenchy.run("instances/", solvers=["ortools"], time_limit=60, plugins=[observers.ModelSize()])
results.to_pandas().groupby(["solver", "status"])["extra.n_variables"].describe()
```

```sh
cpbenchy run instances/ -s ortools -t 60 -p cpbenchy.observers:ModelSize
cpbenchy show --by solver,status
```

## What it records

| | |
|---|---|
| `extra["n_variables"]` | the model's decision variables |
| `extra["n_boolvars"]` | of which Boolean |
| `extra["n_constraints"]` | the model's top-level constraints |

## Implementation

Source: https://docs.cpbenchy.com/library/model-size/index.mdx
