Skip to content

Commit 10f5997

Browse files
Fix: properly render P-Median model formulation in docs (#466) (#483)
1 parent 0205260 commit 10f5997

File tree

1 file changed

+63
-42
lines changed

1 file changed

+63
-42
lines changed

notebooks/p-median.ipynb

+63-42
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,38 @@
1717
"\n",
1818
"**P-Median can be written as:**\n",
1919
"\n",
20-
"$\\begin{array} \\displaystyle \\textbf{Minimize} & \\displaystyle \\sum_{i \\in I}\\sum_{j \\in J}{a_i d_{ij} X_{ij}} &&& (1) \\\\\n",
21-
"\\displaystyle \\textbf{Subject to:} & \\displaystyle \\sum_{j \\in J}{X_{ij} = 1} & \\forall i \\in I && (2) \\\\\n",
22-
" & \\displaystyle \\sum_{j \\in J}{Y_{j} = p} &&& (3) \\\\\n",
23-
" & X_{ij} \\leq Y_{j} & \\forall i \\in I & \\forall j \\in J & (4) \\\\\n",
24-
" & X_{ij} \\in \\{0,1\\} & \\forall i \\in I & \\forall j \\in J & (5) \\\\\n",
25-
" & Y_{j} \\in \\{0,1\\} & \\forall j \\in J && (6) \\\\ \\end{array}$\n",
20+
"$$\n",
21+
"\\begin{array}{lllll}\n",
22+
"\\textbf{Minimize} & \\displaystyle \\sum_{i \\in I} \\sum_{j \\in J} a_i d_{ij} X_{ij} &&& (1) \\\\\n",
23+
"\\textbf{Subject to:} & \\sum_{j \\in J} X_{ij} = 1 & \\forall i \\in I && (2) \\\\\n",
24+
"& \\sum_{j \\in J} Y_j = p &&& (3) \\\\\n",
25+
"& X_{ij} \\leq Y_j & \\forall i \\in I, j \\in J && (4) \\\\\n",
26+
"& X_{ij} \\in \\{0, 1\\} & \\forall i \\in I, j \\in J && (5) \\\\\n",
27+
"& Y_j \\in \\{0, 1\\} & \\forall j \\in J && (6) \\\\\n",
28+
"\\end{array}\n",
29+
"$$\n",
30+
"\n",
31+
"$$\n",
32+
"\\begin{array}{lllll}\n",
33+
"\\textbf{Where:} \\\\\n",
34+
"& i & = & \\text{index referencing demand nodes} \\\\\n",
35+
"& j & = & \\text{index referencing potential facility sites} \\\\\n",
36+
"& d_{ij} & = & \\text{distance or travel time between node } i \\text{ and } j \\\\\n",
37+
"& p & = & \\text{number of facilities to locate} \\\\\n",
38+
"& a_i & = & \\text{demand at node } i \\\\\n",
39+
"& X_{ij} & = &\n",
40+
" \\begin{cases}\n",
41+
" 1, & \\text{if demand } i \\text{ is assigned to facility } j \\\\\n",
42+
" 0, & \\text{otherwise}\n",
43+
" \\end{cases} \\\\\n",
44+
"& Y_j & = &\n",
45+
" \\begin{cases}\n",
46+
" 1, & \\text{if facility is located at node } j \\\\\n",
47+
" 0, & \\text{otherwise}\n",
48+
" \\end{cases}\n",
49+
"\\end{array}\n",
50+
"$$\n",
2651
"\n",
27-
"$\\begin{array} \\displaystyle \\textbf{Where:}\\\\ & & \\displaystyle i & \\small = & \\textrm{index referencing nodes of the network as demand} \\\\\n",
28-
"& & j & \\small = & \\textrm{index referencing nodes of the network as potential facility sites} \\\\\n",
29-
"& & d_{ij} & \\small = & \\textrm{shortest distance or travel time between nodes } i \\textrm{ and } j \\\\\n",
30-
"& & p & \\small = & \\textrm{number of facilities to be located} \\\\\n",
31-
"& & a_i & \\small = & \\textrm{service load or population demand at } i \\\\\n",
32-
"& & X_{ij} & \\small = & \\begin{cases}\n",
33-
" 1, \\textrm{if demand } i \\textrm{ is assigned to facility } j \\\\\n",
34-
" 0, \\textrm{otherwise}\n",
35-
" \\end{cases} \\\\\n",
36-
"& & Y_{j} & \\small = & \\begin{cases}\n",
37-
" 1, \\textrm{if node } j \\textrm{ has been selected for a facility} \\\\\n",
38-
" 0, \\textrm{otherwise} \\\\\n",
39-
" \\end{cases} \\\\ \n",
40-
"\\end{array}$\n",
4152
"\n",
4253
"_The formulation above is adapted from Church and Murray (2018)_\n",
4354
"\n",
@@ -1696,29 +1707,39 @@
16961707
"\n",
16971708
"**Capacitated P-Median can be written as:**\n",
16981709
"\n",
1699-
"$\\begin{array} \\displaystyle \\textbf{Minimize} & \\displaystyle \\sum_{i \\in I}\\sum_{j \\in J}{a_i d_{ij} X_{ij}} &&& (1) \\\\\n",
1700-
"\\displaystyle \\textbf{Subject to:} & \\displaystyle \\sum_{j \\in J}{X_{ij} = 1} & \\forall i \\in I && (2) \\\\\n",
1701-
" & \\displaystyle \\sum_{j \\in J}{Y_{j} = p} &&& (3) \\\\\n",
1702-
" & \\displaystyle \\sum_{i \\in I}{a_i X_{ij} \\leq {c_j Y_{j}}}& \\forall j \\in J && (4) \\\\\n",
1703-
" & X_{ij} \\leq Y_{j} & \\forall i \\in I & \\forall j \\in J & (5) \\\\\n",
1704-
" & X_{ij} \\in \\{0,1\\} & \\forall i \\in I & \\forall j \\in J & (6) \\\\\n",
1705-
" & Y_{j} \\in \\{0,1\\} & \\forall j \\in J && (7) \\\\ \\end{array}$\n",
1710+
"$$\n",
1711+
"\\begin{array}{lllll}\n",
1712+
"\\textbf{Minimize} & \\displaystyle \\sum_{i \\in I} \\sum_{j \\in J} a_i d_{ij} X_{ij} &&& (1) \\\\\n",
1713+
"\\textbf{Subject to:} & \\sum_{j \\in J} X_{ij} = 1 & \\forall i \\in I && (2) \\\\\n",
1714+
"& \\sum_{j \\in J} Y_j = p &&& (3) \\\\\n",
1715+
"& \\sum_{i \\in I} a_i X_{ij} \\leq c_j Y_j & \\forall j \\in J && (4) \\\\\n",
1716+
"& X_{ij} \\leq Y_j & \\forall i \\in I, j \\in J && (5) \\\\\n",
1717+
"& X_{ij} \\in \\{0, 1\\} & \\forall i \\in I, j \\in J && (6) \\\\\n",
1718+
"& Y_j \\in \\{0, 1\\} & \\forall j \\in J && (7) \\\\\n",
1719+
"\\end{array}\n",
1720+
"$$\n",
17061721
"\n",
1707-
"$\\begin{array} \\displaystyle \\textbf{Where:}\\\\ & & \\displaystyle i & \\small = & \\textrm{index referencing nodes of the network as demand} \\\\\n",
1708-
"& & j & \\small = & \\textrm{index referencing nodes of the network as potential facility sites} \\\\\n",
1709-
"& & d_{ij} & \\small = & \\textrm{shortest distance or travel time between nodes } i \\textrm{ and } j \\\\\n",
1710-
"& & p & \\small = & \\textrm{number of facilities to be located} \\\\\n",
1711-
"& & a_i & \\small = & \\textrm{service load or population demand at } i \\\\\n",
1712-
"& & c_j & \\small = & \\textrm{capacity of facility} j \\\\\n",
1713-
"& & X_{ij} & \\small = & \\begin{cases}\n",
1714-
" 1, \\textrm{if demand } i \\textrm{ is assigned to facility } j \\\\\n",
1715-
" 0, \\textrm{otherwise}\n",
1716-
" \\end{cases} \\\\\n",
1717-
"& & Y_{j} & \\small = & \\begin{cases}\n",
1718-
" 1, \\textrm{if node } j \\textrm{ has been selected for a facility} \\\\\n",
1719-
" 0, \\textrm{otherwise} \\\\\n",
1720-
" \\end{cases} \\\\ \n",
1721-
"\\end{array}$\n",
1722+
"$$\n",
1723+
"\\begin{array}{lllll}\n",
1724+
"\\textbf{Where:} \\\\\n",
1725+
"& i & = & \\text{index referencing demand nodes} \\\\\n",
1726+
"& j & = & \\text{index referencing potential facility sites} \\\\\n",
1727+
"& d_{ij} & = & \\text{distance or travel time between nodes } i \\text{ and } j \\\\\n",
1728+
"& p & = & \\text{number of facilities to locate} \\\\\n",
1729+
"& a_i & = & \\text{demand at node } i \\\\\n",
1730+
"& c_j & = & \\text{capacity of facility at node } j \\\\\n",
1731+
"& X_{ij} & = &\n",
1732+
" \\begin{cases}\n",
1733+
" 1, & \\text{if demand } i \\text{ is assigned to facility } j \\\\\n",
1734+
" 0, & \\text{otherwise}\n",
1735+
" \\end{cases} \\\\\n",
1736+
"& Y_j & = &\n",
1737+
" \\begin{cases}\n",
1738+
" 1, & \\text{if facility is located at node } j \\\\\n",
1739+
" 0, & \\text{otherwise}\n",
1740+
" \\end{cases}\n",
1741+
"\\end{array}\n",
1742+
"$$\n",
17221743
"\n",
17231744
"_The formulation above is adapted from Church and Murray (2009)_"
17241745
]

0 commit comments

Comments
 (0)