---
title: "Introduction to 2D Pareto Fronts"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Introduction to 2D Pareto Fronts}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, setup, include = FALSE}
library(leaf)

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

```{r generate-data}
set.seed(42)
df <- data.frame(
  cost = runif(50, 10, 100),
  performance = runif(50, 0, 1)
)

head(df)
```

```{r compute-pareto}
is_optimal <- pareto_2d(
  x = df$cost, 
  y = df$performance, 
  x_bigger_better = FALSE, 
  y_bigger_better = TRUE
)

# How many optimal points did we find?
sum(is_optimal)
```
```{r, plot-front, fig.width=7, fig.height=5, fig.cap="Pareto Front showing Cost vs Performance trade-off."}
result <- plot_pareto(
  df, 
  x_col = "cost", 
  y_col = "performance",
  x_bigger_better = FALSE, 
  y_bigger_better = TRUE,
  show_all_points = TRUE
)

result$plot
```



