Skip to content

Commit 9a49a2e

Browse files
committed
Minor updates
1 parent 44ffe57 commit 9a49a2e

File tree

2 files changed

+28
-19
lines changed

2 files changed

+28
-19
lines changed

notebooks/contrib/Sudoku_Solver.ipynb

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
"source": [
99
"# Sudoku Solver\n",
1010
"\n",
11-
"**Prepared by:** William Bartel ([email protected], 2024) and Andrew Brooks ([email protected], 2024)\n",
12-
"\n",
13-
"Adapted from material by Prof. Alexander Dowling and Elvis Eugene at the University of Notre Dame\n",
14-
"\n",
15-
"Nonlinear and Stochastic Optimization - Project 2"
11+
"**Prepared by:** William Bartel ([email protected], 2024) and Andrew Brooks ([email protected], 2024). Adapted from material by Prof. Alexander Dowling and Elvis Eugene at the University of Notre Dame"
1612
]
1713
},
1814
{
@@ -137,29 +133,33 @@
137133
"id": "RIoCdk4T8BP1"
138134
},
139135
"source": [
140-
"**Sets:** \\\\\n",
141-
"Rows $R=\\{0,1, ...,n\\}$ \\\\\n",
142-
"Columns $C=\\{0,1, ...,n\\}$ \\\\\n",
143-
"Values $V=\\{0,1, ...,n\\}$ \\\\\n",
144-
"Subgrids $K=\\{0,1, ...,n\\}$\n",
136+
"**Sets:**\n",
137+
"* Rows $R=\\{0,1, ...,n\\}$ \\\\\n",
138+
"* Columns $C=\\{0,1, ...,n\\}$ \\\\\n",
139+
"* Values $V=\\{0,1, ...,n\\}$ \\\\\n",
140+
"* Subgrids $K=\\{0,1, ...,n\\}$\n",
145141
"\n",
146-
"**Parameters:** \\\\\n",
147-
"$s_{v,i,j} = $ is value $v$ present in box located at $(i,j)$ from unsolved puzzle for $i\\in R, j\\in C, v \\in V$. (Binary) \\\\\n",
148-
"$SG_{i} = $ coordinate pairs for the boxes in each subgrid for $i\\in K$ \\\\\n",
142+
"**Parameters:**\n",
143+
"* $s_{v,i,j} = $ is value $v$ present in box located at $(i,j)$ from unsolved puzzle for $i\\in R, j\\in C, v \\in V$. (Binary) \\\\\n",
144+
"* $SG_{i} = $ coordinate pairs for the boxes in each subgrid for $i\\in K$ \\\\\n",
149145
"\n",
150-
"**Variables:** \\\\\n",
151-
"$y_{v,i,j} = $ is value $v$ present in box located at $(i,j)$ when creating solved puzzle for $i\\in R, j\\in C, v \\in V$. (Binary)\n",
146+
"**Variables:**\n",
147+
"* $y_{v,i,j} = $ is value $v$ present in box located at $(i,j)$ when creating solved puzzle for $i\\in R, j\\in C, v \\in V$. (Binary)\n",
152148
"\n",
153149
"\n",
154-
"**Objective:** \\\\\n",
155-
"$\\min0$\n",
150+
"**Objective:**\n",
151+
"* $\\min0$\n",
156152
"\n",
157153
"**Constraints:**\n",
158154
"\n",
159155
"$$\\sum_{i\\in R}y_{v,i,j}=1, \\forall j\\in C, v\\in V$$\n",
156+
"\n",
160157
"$$\\sum_{j\\in C}y_{i,j,k}=1, \\forall i\\in R, v\\in V$$\n",
158+
"\n",
161159
"$$\\sum_{(i,j)\\in SG[\\ l \\ ]}y_{v,i,j}=1, \\forall l\\in K$$\n",
160+
"\n",
162161
"$$\\sum_{v\\in V}y_{v,i,j}=1, \\forall i\\in R, j\\in C$$\n",
162+
"\n",
163163
"$$y_{v,i,j} * s_{v,i,j} = s_{v,i,j}, \\forall i\\in R, j\\in C, v\\in V$$\n",
164164
"\n",
165165
"Because the problem is a feasibility problem and there is only one possible answer, no objective is needed and thus the objective is a constant, in this case 0.\n",
@@ -1008,7 +1008,9 @@
10081008
"id": "1dijjD3G-gqv"
10091009
},
10101010
"source": [
1011-
"The results show glpk and cbc are relatively the same for solving puzzles with $n=4,9,16,25,36$. After testing the solvers on multiple datasets, glpk seems slightly faster than cbc, especially on smaller puzzles. For $n=4,9,16$, the sudoku problems are relatively simple and solve time is in fractions of a second. When reasoning about these results, it is important to note that glpk is specifically designed for smaller, simpler problems while cbc is for larger and more complex problems."
1011+
"The results show glpk and cbc are relatively the same for solving puzzles with $n=4,9,16,25,36$. After testing the solvers on multiple datasets, glpk seems slightly faster than cbc, especially on smaller puzzles. For $n=4,9,16$, the sudoku problems are relatively simple and solve time is in fractions of a second. When reasoning about these results, it is important to note that glpk is specifically designed for smaller, simpler problems while cbc is for larger and more complex problems.\n",
1012+
"\n",
1013+
"Future work: remake the above figure as a log-log plot. Is the slope 3? The problem size (number of integer decisions) is proporational to $n^3$."
10121014
]
10131015
},
10141016
{
@@ -1036,6 +1038,11 @@
10361038
"\n",
10371039
"In this project, we were able to create an effective sudoku puzzle generator and solver that prints solutions. Furthermore, we tested to show there is a superlinear relationship between problem size and solver time, meaning time grows at a rate faster than the problem size."
10381040
]
1041+
},
1042+
{
1043+
"cell_type": "markdown",
1044+
"metadata": {},
1045+
"source": []
10391046
}
10401047
],
10411048
"metadata": {

notebooks/contrib/more_circle_packing.ipynb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,9 @@
13011301
"source": [
13021302
"## Conclusion\n",
13031303
"\n",
1304-
"In this project, we aimed to solve the circle packing problem by deriving the radius and coordinates of circles within a given rectangular boundary to maximize the packing density. Initially, we attempted to model the problem using Pyomo, but encountered challenges due to the discontinuous and nonconvex nature of the problem, which often prevented the model from finding an optimal solution. After considering the problem's complexity, we introduced an arbitrary initial starting point, leading to the discovery of different optimal solutions for the same number of circles depending on the starting conditions. To address this issue, we developed an iterative algorithm that refines the solution in each iteration, using the previous iteration's optimal solution as the starting point. This approach allowed us to significantly improve convergence, with most cases converging to a single optimal solution, while a few starting points still did not yield solutions due to the discontinuity of our problem. Overall, our iterative approach provided a more reliable method for solving the circle packing problem, demonstrating the importance of considering the problem's nature and refining the solution process."
1304+
"In this project, we aimed to solve the circle packing problem by deriving the radius and coordinates of circles within a given rectangular boundary to maximize the packing density. Initially, we attempted to model the problem using Pyomo, but encountered challenges due to the discontinuous and nonconvex nature of the problem, which often prevented the model from finding an optimal solution. After considering the problem's complexity, we introduced an arbitrary initial starting point, leading to the discovery of different optimal solutions for the same number of circles depending on the starting conditions. To address this issue, we developed an iterative algorithm that refines the solution in each iteration, using the previous iteration's optimal solution as the starting point. This approach allowed us to significantly improve convergence, with most cases converging to a single optimal solution, while a few starting points still did not yield solutions due to the discontinuity of our problem. Overall, our iterative approach provided a more reliable method for solving the circle packing problem, demonstrating the importance of considering the problem's nature and refining the solution process.\n",
1305+
"\n",
1306+
"Future work: Try using a [global optimization solver](../contrib/Deterministic_Global_Optimization.ipynb)."
13051307
]
13061308
},
13071309
{

0 commit comments

Comments
 (0)