diff --git a/notebooks/p-median.ipynb b/notebooks/p-median.ipynb index 277d21bb..ffd626ce 100644 --- a/notebooks/p-median.ipynb +++ b/notebooks/p-median.ipynb @@ -17,27 +17,38 @@ "\n", "**P-Median can be written as:**\n", "\n", - "$\\begin{array} \\displaystyle \\textbf{Minimize} & \\displaystyle \\sum_{i \\in I}\\sum_{j \\in J}{a_i d_{ij} X_{ij}} &&& (1) \\\\\n", - "\\displaystyle \\textbf{Subject to:} & \\displaystyle \\sum_{j \\in J}{X_{ij} = 1} & \\forall i \\in I && (2) \\\\\n", - " & \\displaystyle \\sum_{j \\in J}{Y_{j} = p} &&& (3) \\\\\n", - " & X_{ij} \\leq Y_{j} & \\forall i \\in I & \\forall j \\in J & (4) \\\\\n", - " & X_{ij} \\in \\{0,1\\} & \\forall i \\in I & \\forall j \\in J & (5) \\\\\n", - " & Y_{j} \\in \\{0,1\\} & \\forall j \\in J && (6) \\\\ \\end{array}$\n", + "$$\n", + "\\begin{array}{lllll}\n", + "\\textbf{Minimize} & \\displaystyle \\sum_{i \\in I} \\sum_{j \\in J} a_i d_{ij} X_{ij} &&& (1) \\\\\n", + "\\textbf{Subject to:} & \\sum_{j \\in J} X_{ij} = 1 & \\forall i \\in I && (2) \\\\\n", + "& \\sum_{j \\in J} Y_j = p &&& (3) \\\\\n", + "& X_{ij} \\leq Y_j & \\forall i \\in I, j \\in J && (4) \\\\\n", + "& X_{ij} \\in \\{0, 1\\} & \\forall i \\in I, j \\in J && (5) \\\\\n", + "& Y_j \\in \\{0, 1\\} & \\forall j \\in J && (6) \\\\\n", + "\\end{array}\n", + "$$\n", + "\n", + "$$\n", + "\\begin{array}{lllll}\n", + "\\textbf{Where:} \\\\\n", + "& i & = & \\text{index referencing demand nodes} \\\\\n", + "& j & = & \\text{index referencing potential facility sites} \\\\\n", + "& d_{ij} & = & \\text{distance or travel time between node } i \\text{ and } j \\\\\n", + "& p & = & \\text{number of facilities to locate} \\\\\n", + "& a_i & = & \\text{demand at node } i \\\\\n", + "& X_{ij} & = &\n", + " \\begin{cases}\n", + " 1, & \\text{if demand } i \\text{ is assigned to facility } j \\\\\n", + " 0, & \\text{otherwise}\n", + " \\end{cases} \\\\\n", + "& Y_j & = &\n", + " \\begin{cases}\n", + " 1, & \\text{if facility is located at node } j \\\\\n", + " 0, & \\text{otherwise}\n", + " \\end{cases}\n", + "\\end{array}\n", + "$$\n", "\n", - "$\\begin{array} \\displaystyle \\textbf{Where:}\\\\ & & \\displaystyle i & \\small = & \\textrm{index referencing nodes of the network as demand} \\\\\n", - "& & j & \\small = & \\textrm{index referencing nodes of the network as potential facility sites} \\\\\n", - "& & d_{ij} & \\small = & \\textrm{shortest distance or travel time between nodes } i \\textrm{ and } j \\\\\n", - "& & p & \\small = & \\textrm{number of facilities to be located} \\\\\n", - "& & a_i & \\small = & \\textrm{service load or population demand at } i \\\\\n", - "& & X_{ij} & \\small = & \\begin{cases}\n", - " 1, \\textrm{if demand } i \\textrm{ is assigned to facility } j \\\\\n", - " 0, \\textrm{otherwise}\n", - " \\end{cases} \\\\\n", - "& & Y_{j} & \\small = & \\begin{cases}\n", - " 1, \\textrm{if node } j \\textrm{ has been selected for a facility} \\\\\n", - " 0, \\textrm{otherwise} \\\\\n", - " \\end{cases} \\\\ \n", - "\\end{array}$\n", "\n", "_The formulation above is adapted from Church and Murray (2018)_\n", "\n", @@ -1696,29 +1707,39 @@ "\n", "**Capacitated P-Median can be written as:**\n", "\n", - "$\\begin{array} \\displaystyle \\textbf{Minimize} & \\displaystyle \\sum_{i \\in I}\\sum_{j \\in J}{a_i d_{ij} X_{ij}} &&& (1) \\\\\n", - "\\displaystyle \\textbf{Subject to:} & \\displaystyle \\sum_{j \\in J}{X_{ij} = 1} & \\forall i \\in I && (2) \\\\\n", - " & \\displaystyle \\sum_{j \\in J}{Y_{j} = p} &&& (3) \\\\\n", - " & \\displaystyle \\sum_{i \\in I}{a_i X_{ij} \\leq {c_j Y_{j}}}& \\forall j \\in J && (4) \\\\\n", - " & X_{ij} \\leq Y_{j} & \\forall i \\in I & \\forall j \\in J & (5) \\\\\n", - " & X_{ij} \\in \\{0,1\\} & \\forall i \\in I & \\forall j \\in J & (6) \\\\\n", - " & Y_{j} \\in \\{0,1\\} & \\forall j \\in J && (7) \\\\ \\end{array}$\n", + "$$\n", + "\\begin{array}{lllll}\n", + "\\textbf{Minimize} & \\displaystyle \\sum_{i \\in I} \\sum_{j \\in J} a_i d_{ij} X_{ij} &&& (1) \\\\\n", + "\\textbf{Subject to:} & \\sum_{j \\in J} X_{ij} = 1 & \\forall i \\in I && (2) \\\\\n", + "& \\sum_{j \\in J} Y_j = p &&& (3) \\\\\n", + "& \\sum_{i \\in I} a_i X_{ij} \\leq c_j Y_j & \\forall j \\in J && (4) \\\\\n", + "& X_{ij} \\leq Y_j & \\forall i \\in I, j \\in J && (5) \\\\\n", + "& X_{ij} \\in \\{0, 1\\} & \\forall i \\in I, j \\in J && (6) \\\\\n", + "& Y_j \\in \\{0, 1\\} & \\forall j \\in J && (7) \\\\\n", + "\\end{array}\n", + "$$\n", "\n", - "$\\begin{array} \\displaystyle \\textbf{Where:}\\\\ & & \\displaystyle i & \\small = & \\textrm{index referencing nodes of the network as demand} \\\\\n", - "& & j & \\small = & \\textrm{index referencing nodes of the network as potential facility sites} \\\\\n", - "& & d_{ij} & \\small = & \\textrm{shortest distance or travel time between nodes } i \\textrm{ and } j \\\\\n", - "& & p & \\small = & \\textrm{number of facilities to be located} \\\\\n", - "& & a_i & \\small = & \\textrm{service load or population demand at } i \\\\\n", - "& & c_j & \\small = & \\textrm{capacity of facility} j \\\\\n", - "& & X_{ij} & \\small = & \\begin{cases}\n", - " 1, \\textrm{if demand } i \\textrm{ is assigned to facility } j \\\\\n", - " 0, \\textrm{otherwise}\n", - " \\end{cases} \\\\\n", - "& & Y_{j} & \\small = & \\begin{cases}\n", - " 1, \\textrm{if node } j \\textrm{ has been selected for a facility} \\\\\n", - " 0, \\textrm{otherwise} \\\\\n", - " \\end{cases} \\\\ \n", - "\\end{array}$\n", + "$$\n", + "\\begin{array}{lllll}\n", + "\\textbf{Where:} \\\\\n", + "& i & = & \\text{index referencing demand nodes} \\\\\n", + "& j & = & \\text{index referencing potential facility sites} \\\\\n", + "& d_{ij} & = & \\text{distance or travel time between nodes } i \\text{ and } j \\\\\n", + "& p & = & \\text{number of facilities to locate} \\\\\n", + "& a_i & = & \\text{demand at node } i \\\\\n", + "& c_j & = & \\text{capacity of facility at node } j \\\\\n", + "& X_{ij} & = &\n", + " \\begin{cases}\n", + " 1, & \\text{if demand } i \\text{ is assigned to facility } j \\\\\n", + " 0, & \\text{otherwise}\n", + " \\end{cases} \\\\\n", + "& Y_j & = &\n", + " \\begin{cases}\n", + " 1, & \\text{if facility is located at node } j \\\\\n", + " 0, & \\text{otherwise}\n", + " \\end{cases}\n", + "\\end{array}\n", + "$$\n", "\n", "_The formulation above is adapted from Church and Murray (2009)_" ]