Metadata-Version: 2.4
Name: simuci
Version: 0.1.5
Summary: ICU discrete-event simulation engine — distribution sampling, patient clustering, and statistical validation.
Project-URL: Repository, https://github.com/coslatte/simuci
Author: SimUCI Team
License: MIT License
        
        Copyright (c) 2026 SimUCI Team
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: discrete-event,healthcare,icu,simpy,simulation
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
Classifier: Typing :: Typed
Requires-Python: <=3.14,>=3.9
Requires-Dist: numpy>=1.26
Requires-Dist: pandas>=2.0
Requires-Dist: scikit-learn>=1.3
Requires-Dist: scipy>=1.11
Requires-Dist: simpy>=4.0
Provides-Extra: dev
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Description-Content-Type: text/markdown

# simuci

ICU discrete-event simulation engine — distribution sampling, patient clustering, and statistical validation.

## Installation

```bash
pip install simuci
```

For development:

```bash
git clone https://github.com/coslatte/simuci.git
cd simuci
pip install -e ".[dev]"
```

## Quick Start

```python
from simuci import Experiment, single_run, multiple_replication

# Create an experiment with patient parameters
exp = Experiment(
    age=55,
    diagnosis_admission1=11,
    diagnosis_admission2=0,
    diagnosis_admission3=0,
    diagnosis_admission4=0,
    apache=20,
    respiratory_insufficiency=5,
    artificial_ventilation=1,
    uti_stay=100,
    vam_time=50,
    preuti_stay_time=10,
    percent=3,
)

# Single replication (requires centroids CSV)
result = single_run(exp, centroids_path="path/to/centroids.csv")
print(result)
# {'Tiempo Pre VAM': 5, 'Tiempo VAM': 89, 'Tiempo Post VAM': 168, 'Estadia UCI': 262, 'Estadia Post UCI': 45}

# Multiple replications → DataFrame
df = multiple_replication(exp, n_reps=200, centroids_path="path/to/centroids.csv")
print(df.describe())
```

## Using Your Own Centroid Data

You must pass the path to your centroid CSV explicitly:

```python
from simuci import single_run, Experiment

exp = Experiment(age=55, ..., validate=False)

# Point to your centroids CSV
result = single_run(exp, centroids_path="path/to/real_centroids.csv")
```

The centroids CSV must have:

- An index column (cluster IDs: 0, 1, 2)
- At least 11 numeric columns (features used for nearest-centroid classification)

You can also use the loader directly:

```python
from simuci.loaders import CentroidLoader

loader = CentroidLoader()
centroids = loader.load("path/to/centroids.csv")  # returns numpy array
```

## Statistical Validation

```python
import numpy as np
from simuci import SimulationMetrics, Wilcoxon, Friedman

# Compare simulation output to real data
metrics = SimulationMetrics(
    true_data=np.array(...),       # (n_patients, n_variables)
    simulation_data=np.array(...), # (n_patients, n_replicates, n_variables)
)
metrics.evaluate(confidence_level=0.95, result_as_dict=True)

print(metrics.coverage_percentage)
print(metrics.error_margin)
print(metrics.kolmogorov_smirnov_result)
print(metrics.anderson_darling_result)
```

## Input Validation

All `Experiment` inputs are validated on construction by default:

```python
from simuci import Experiment

# This raises ValueError: age must be between 14 and 100
Experiment(age=200, ...)
```

Skip validation with `validate=False` if you've already validated externally.

## API Reference

| Symbol | Description |
|--------|-------------|
| `Experiment` | Patient parameters + result container |
| `single_run(exp)` | One simulation replication |
| `multiple_replication(exp, n_reps)` | N replications → DataFrame |
| `clustering(edad, ...)` | Nearest-centroid patient classifier |
| `Wilcoxon` | Paired Wilcoxon signed-rank test |
| `Friedman` | Friedman chi-square test |
| `SimulationMetrics` | Full evaluation suite (coverage, RMSE, KS, AD) |
| `StatsUtils` | Static CI helper |
| `CentroidLoader` | CSV loader with schema validation |
| `validate_experiment_inputs()` | Parameter range checking |

## License

MIT
