Comb Opt 1: Brute-Force Optimization

Packages Used: Functions from the following packages are used in this notebook for the first time:

Combinatorial optimization refers to procedures used to find solutions from a collection of finite objects that characterize possible solution instances. These procedures fall into three broad categories:

  1. Brute-Force Optimization: Generate all possible solutions to find the global optimum.
  2. Heuristics: Look at a small fraction of possible solutions to find a local optimum that may not be the global optimum.
  3. Optimal Procedures: Look at a small fraction of possible solutions to find the global optimum solution.

Brute-Force Optimization
Heuristics and optimal procedures efficiently look at a small fraction of the possible solution instances to find a locally or globally optimal solution, but it is possible in many cases if the number of solutions is not too big to brute-force generate all possible solutions to find the global optimum. The ability to generate solution instances is useful for many reasons:

  1. Brute-force optimization: If "small enough," can be used to find the global optimum by searching through all instances.
  2. Heuristic validation: Test heuristics on small instances where the global optimum can be determined in order to validate before using the heuristic for larger instances where it is not feasible to generate all instances.
  3. Monte Carlo: Randomly generated instances can be used as part of a Monte Carlo approach for problems where other types of heuristics are not available.

The Combinatorics package has several functions that generate combinatorial objects that can be used to represent instances of many different types of problems:

1. Permutations

A permutation is listing of the indices from 1 to n where the order does matter. The number of permutations is n factorial:

$ \quad n! = n \cdot (n - 1) \cdot (n - 2) \dotsb 2 \cdot 1 \implies 3! = 6 $

Need to use collect to generate all permutations because permutations only iterates one permutation at a time:

The function randperm returns a random ordering the indices 1 to n:

Often used to randomly reorder the elements in an n-element array:

The function shuffle(v) is equavilent to v[randperm(length(v))], which is both more concise and does not require that the array v first be created:

The number of permutations, $n!$, for $n = 12$ and $n = 50$:

Ex 1: Unter's Passenger-to-Car Assignment (Ex 1 in Net Mod 1)

image.png

2. Combinations

A combination is a selection of items from a collection where the order does not matter. The number of combinations of n items taken k at a time without repetition (also referred to as "n choose k" and the binomial coefficient) is:

$ \quad \dbinom{n}{k} = \dfrac{n!}{(n - k)!\,k!} \implies \dbinom{4}{3} = 4 $

Pairwise Interchanges

Given an array of length $n$, the number of pairwise interchanges of its elements is

$ \quad \dbinom{n}{2} = \dfrac{n(n - 1)}{2} \implies \dbinom{4}{2} = 6 $

When the array represents a permutation, it is often computationally infeasible to generate all of the permutations; instead, just looking at the pairwise interchanges of the array allows it to be altered in an efficient manner.

Ex 2: Shortest Path in Undirected Network (Ex 3 in Net Mod 2)

image.png

The number of possible paths in an undirected network is:

$ \begin{eqnarray} \quad \sum_{k=0}^{n-2} \dbinom{n-2}{k} k! &\implies& \sum_{k=0}^{6-2} \dbinom{6-2}{k} k! = 65, \mbox{ for } n = 6 \end{eqnarray}$

3. Subsets

Ex 3: Brute-Force Capital Budgeting

Instead of solving Ex 1 in MIP 2 as a MILP, all non-empty subsets of the investment opportunities could be considered the fine the subset that maximizes profit while statisfying all of the constraints: