An objective function is the function an optimization procedure seeks to minimize or maximize. Constraints limit which solutions the procedure may choose. section 4.1 section 4.8
For an NBA roster decision, the objective is total win shares. The optimization must still satisfy roster, salary, and age requirements. section 4.8 section 4.0
co_object <-
lp(const.mat = constraint_matrix,
objective = free_agents_sort$win_shares,
direction = "max",
const.rhs = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 90000000, 150),
const.dir = c("<=", ">=","<=", ">=", "<=", ">=",
"<=", ">=", "<=", ">=", "<=", "<=", "<="),
int.vec = 1:24, all.bin = TRUE)
Set the objective to free-agent win shares and maximize it while passing the roster constraints to lp(). section 4.8
Selecting the five free agents
The solution selects five players with one player at each position, 25.5 expected win shares, $89.5 million in salaries, and an average age of 28.4.





























