## ----setup, include = FALSE---------------------------------------------------
library(leaf)

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----generate-data------------------------------------------------------------
set.seed(42)
df <- data.frame(
  cost = runif(50, 10, 100),
  performance = runif(50, 0, 1)
)

head(df)

## ----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)

## ----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

