I have the following "logic puzzle" (I think this is considered as a "scheduling problem"):
In this problem, there are 5 basketball players - provided some clues about their nicknames and heights, you are required to find the correct combinations of players-nicknames-heights.
In a previous post (https://stackoverflow.com/questions/70527987/solving-logic-puzzles-using-r), I learned how to solve this problem with "brute force" using the R programming language:
library(dplyr)
dt <- purrr::cross_df(list(
name = list(c("Bill", "Ernie", "Oscar", "Sammy", "Tony")),
nickname = combinat::permn(c("Slats", "Stretch", "Tiny", "Tower", "Tree")),
height = combinat::permn(c(6.6, 6.5, 6.3, 6.1, 6))
))
dt %>%
group_by(id = (seq_len(n()) - 1L) %/% 5L) %>%
filter(
height[name == "Oscar"] > height[nickname == "Tree"],
height[nickname == "Tree"] > height[name == "Tony"],
height[name == "Bill"] > height[name == "Sammy"],
height[name == "Bill"] < height[nickname == "Slats"],
nickname[name == "Tony"] != "Tiny",
height[nickname == "Stretch"] > height[name == "Oscar"],
height[nickname == "Stretch"] < 6.6
)
#output
# A tibble: 5 x 4
# Groups: id [1]
name nickname height id
<chr> <chr> <dbl> <int>
1 Bill Stretch 6.5 14398
2 Ernie Slats 6.6 14398
3 Oscar Tiny 6.3 14398
4 Sammy Tree 6.1 14398
5 Tony Tower 6 14398
However, I am curious to know if this problem can be solved using modern optimization algorithms. For instance, if there were 100,000 basketball players in this problem, it would simply be impossible to solve using brute force - to create a list containing combinations of every player-nickname-height would unlikely be storable within a computer.
I have read that there modern optimization algorithms can be used instead (e.g. particle swarm optimization, simulated annealing, nelder-meade, genetic algorithm, etc.) for such problems. I have spent some time reading about the math behind these optimization algorithms and think I understand the general ideas - however, I am not sure how to define the "optimization functions" for these problems, and which "metric" should be used as a target.
For example, in this problem, perhaps the "fraction of the optimization constraints satisfied" by each combination of player-height-nickname can be used as a metric?
If (not factually correct, just sketching a quick example)
Combinations 1 : Bill = Slats, Ernie = Stretch, Oscar = Tiny, Sammy = Tiny and Tony = Tree. Bill is 6'6, Ernie is 6'5, Oscar is 6'3, Sammy is 6'1 and Tony is 6'. satisfies 3/4th's of the optimization constraints
Combinations 53 : Bill = Stretch, Ernie = Slats, Oscar = Tiny, Sammy = Tiny and Tony = Tree. Bill is 6'6, Ernie is 6'5, Oscar is 6'3, Sammy is 6 and Tony is 6'1. satisfies only 2/4th's of the optimization constraints
Perhaps we might be able to say that Combination 1 had a higher "performance metric" than Combination 53, and as a result, it might be more advantageous to consider combinations that are "closer" to Combination 1 compared to Combination 53.
Can someone please show me how this basketball problem can be using modern optimization algorithms in the R programming language?