---
title: "Discrete optimization"
author:
  - name: "Fan Wang"
    affiliation: "Department of Economics, University of Houston"
    url: "https://fanwangecon.github.io/"
date: "2026-11-30"
---

**Part of [Math Camp: An Introduction to Mathematics and Statistics with Applications in Economics](https://fanwangecon.github.io/Stam4Econ/).**  
[Main Stam4Econ site](https://fanwangecon.github.io/Stam4Econ/) | [View this section in the book](https://fanwangecon.github.io/Stam4Econ/optimization_discrete/overview.html#discrete-optimization) | [Author: Fan Wang](https://fanwangecon.github.io/) | [DOI: 10.5281/zenodo.24696926](https://doi.org/10.5281/zenodo.24696926)  
Date: 2026-11-30 | [HTML](https://fanwangecon.github.io/Stam4Econ/htmlpdfq/optimization_discrete/discrete_optimization_integer.html) | [PDF](https://fanwangecon.github.io/Stam4Econ/htmlpdfq/optimization_discrete/discrete_optimization_integer.pdf) | [QMD](https://fanwangecon.github.io/Stam4Econ/htmlpdfq/optimization_discrete/discrete_optimization_integer.qmd)

## Discrete optimization 

### Integer programming problem

An integer programming problem is a type of optimization problem where some or all of the variables are required to take on integer values. This is particularly useful in scenarios where the decision variables represent discrete choices, such as the number of items to produce, the number of workers to assign, or the number of vehicles to dispatch.

### Labor choices for firms

Suppose we have a firm's profit maximization problem with a CES production function, where the firm chooses the number of college educated and non-college educated workers to maximize profit. The firm's profit function can be expressed as:

$$
\pi = p \cdot f(L_c, L_n) - w_c \cdot L_c - w_n \cdot L_n
$$

where:

- $\pi$ is the profit,
- $p$ is the price of the output,
- $f(L_c, L_n)$ is the production function,
- $L_c$ is the number of college educated workers,
- $L_n$ is the number of non-college educated workers,
- $w_c$ is the wage for college educated workers, and
- $w_n$ is the wage for non-college educated workers.

The production function $f$ is a constant elasticity of substitution (CES) function, which can be expressed as:

$$
f(L_c, L_n) = A \left( \alpha L_c^{\rho} + (1 - \alpha) L_n^{\rho} \right)^{\frac{\phi}{\rho}}
$$

where: 

- $A$ is a scaling factor, the total factor productivity,
- $\alpha$ is the "share" parameter that helps to capture the relative productivity of college educated workers,
- $\rho$ is the substitution parameter, the elasticity of substitution between the two types of labor is given by $\sigma = \frac{1}{1 - \rho}$, which means that $\rho$ is equal to $\frac{\sigma -1 }{\sigma}$.
- $\phi$ is a parameter that determines the overall returns to scale.

In dealing with large firms and economic aggregates, generally we think about $L_c$ and $L_n$ as continuous variables. But suppose we are analyzing the choices of small firms, and there are policies that are based on specific firm size thresholds (e.g., registration thresholds, insurance thresholds, etc.). In this case, we may want to restrict the choices of $L_c$ and $L_n$ to be integers, to study how policies impact firms. 

The discrete choice profit maximization problem can be formulated as follows:

\begin{align}
\max_{L_c, L_n} & \quad p \cdot f(L_c, L_n) - w_c \cdot L_c - w_n \cdot L_n \\
\text{subject to} & \quad L_c, L_n \in \mathbb{Z}^+ \\
\end{align}

where $\mathbb{Z}^+$ denotes the set of positive integers.

How do we solve for this problem? We can explore all possible combinations of positive integers. We could also explore properties of the production function and the cost function.

First, solve the problem holding $Lc + Ln = L$ constant, and only vary $L_c$. Specifically, we can rewrite the profit function as:

$$
\pi = p \cdot f(L_c, L - L_c) - w_c \cdot L_c - w_n \cdot (L - L_c)
$$

The integer programming problem is is over just the $L_c$ choices:

\begin{align}
\pi^{\ast}\left(L\right) = \max_{L_c} & \quad p \cdot f(L_c, L - L_c) - w_c \cdot L_c - w_n \cdot (L - L_c) \\
\text{subject to} & \quad L_c \in \mathbb{Z}^+ \text{ and } L_c \le L \\
\end{align}

If $\phi<1$, the set $\left\{\pi^{\ast}\left(L\right) \mid L \in \mathbb{Z}, L \ge 2 \right\}$ has a single peak point. So we incrementally solve at higher $L$ until the optimal profit begins to decrease.

### The number of optimal withdraws

Given a constant consumption function over time $c(t)=c$, we make a decision about how many times to withdraw cash from the bank to support this consumption flow. Keeping money at the bank earns interest (that infinitely compounds) given interest rate $r$, and each withdraw has a fixed cost $\psi$. Withdrawing more frequently generates higher interests earnings, but incurs more fixed costs of withdraw. 

During time period $t=0$ to $t=1$, what is the optimal number of withdraws?

We want to use the cost minimization problem where by choosing the number of withdraws, we minimize the amount of resources needed at $t=0$ to support consumption flow between time $t=0$ and time $t=1$.

Let the cost function be $COST(r, \psi, c, n)$, where $n$ is the number of withdraws. The cost minimization problem is:

\begin{align}
\min_{n} & \quad COST(r, \psi, c, n) \\
\text{subject to} & \quad n \in \mathbb{Z}^+
\end{align}

Suppose we only withdraw at the start once, then in terms of present value at time $t=0$, we need to have:

\begin{align}
COST(r, \psi, c, n=1) = \psi + c
\end{align}

If we withdraw twice, or three times, for future withdraws, if $r>0$, we do need less money then what will be withdrawn (along with fixed cost) at time $t=0$. Furthermore, when we withdraw more frequently, the amount of withdraw is divided by the number of withdraws, although the fixed cost of withdraw is incurred for each withdraw. 

\begin{align}
COST(r, \psi, c, n=2) &= \left(\psi + \frac{c}{2}\right) + \left(\psi + \frac{c}{2}\right) e^{-\frac{r}{2}} \\
COST(r, \psi, c, n=3) &= \left(\psi + \frac{c}{3}\right) + \left(\psi + \frac{c}{3}\right) e^{-\frac{r}{3}} +  \left(\psi + \frac{c}{3}\right) e^{-\frac{2r}{3}}\\
\end{align}

How do we solve this problem? We can solve continue this cost function calculation and compare among all alternatives $n$ values to find the one that provides the lowest cost. 

This is cumbersome. The problem actually has an analytical solution. Consider the COST functions above as a linear function of $c$. Note that as $n$ increase (at decreasing rate), the y-intercept increases, and the slope decreases (but remains positive), if $r>0$. Drawing a figure where the x-axis is $c$ and the y-axis is $COST(r, \psi, c, n)$, we can form the lower envelope of all the intersecting lines. Solving for consecutive intersections of lines between $n$ and $n+1$ provides the thresholds where the optimal number of withdraws switches from making $n$ to making $n+1$ withdraws. 

We have shown that a continuous time problem with discrete choice can have analytical solutions. 

### The number of optimal withdraws and optimal initial deposit, joint continuous and discrete optimization

We modify the prior problem in the following way:

- At the start of the period, you earn income $W$, this income is eared as cash-in-pocket
- We choose how much of the cash-in-pocket to deposit into the bank, $\alpha W$, where $\alpha \in \left[0, 1\right]$.

Between time $t=0$ and $t=\widehat{t}$, consumption flow is supported by initial cash-in-pocket that was not deposited, the $(1-\alpha) W$ units of cash. Between $t=\widehat{t}$ to $T$, consumption is supported by withdraws from the bank. 

The individuals chooses $\widehat{t}$ (there is a one-to-one mapping between chooseing $\widehat{t}$ and $\alpha$) and chooses $N$, the number of withdraws to make between $widehat{t}$ and $T$.

Now we have a joint continuous and discrete choice problem. The overall optimization problem is:

\begin{align}
\begin{gathered}
\max_{N \in \mathbb{N}, \widehat{t} \in [0, T]}
C\\
\text{s.t.}\, 
w = 
\Lambda^{depositwithdraw}\left(\widehat{t}, N \mathrel{;} C\right) + 
\Lambda^{initpocket}\left(\widehat{t} \mathrel{;} C\right)
\end{gathered}
\end{align}

$\Lambda^{depositwithdraw}\left(\widehat{t}, N \mathrel{;} C\right)$ is resources needed at $t=0$ to support all the $N$ withdraws from $t=\widehat{t}$ to $T$. $\Lambda^{initpocket}\left(\widehat{t} \mathrel{;} C\right)$ is resources needed at $t=0$ to support consumption from the initial cash-in-pocket until $t=\widehat{t}$. These two functions are constructed following our discussion in the last section.

We can further divide the problem to solve for the optimal $N$ given $\widehat{t}$ by minimizing the 
$\Lambda^{depositwithdraw}\left(\widehat{t}, N \mathrel{;} C\right)$ with respect to $N$. Specifically, we solve:

$$
\min_{N \in \mathbb{N}} \Lambda^{depositwithdraw}\left(\widehat{t}, N \mathrel{;} C\right)
$$

Once the optimal $N^{\ast}\left(C, \widehat{t}\right)$ is determined as a function of $\widehat{t}$, we can then optimize over $\widehat{t}$ to find the overall optimal solution that maximizes $C$, given the solution found from minimization earlier:


\begin{align}
\begin{gathered}
\max_{\widehat{t} \in [0, T]} C\\
\text{s.t.}\, 
w = 
\Lambda^{depositwithdraw}\left(\widehat{t}, N^{\ast}\left(C, \widehat{t}\right) \mathrel{;} C\right) + 
\Lambda^{initpocket}\left(\widehat{t} \mathrel{;} C\right)
\end{gathered}
\end{align}

