Skip to content

Commit

Permalink
Update Readme for new CSP example
Browse files Browse the repository at this point in the history
  • Loading branch information
N-Wouda committed Jul 29, 2019
1 parent 563b3c6 commit eb30c39
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ how the ALNS library may be used. Of particular interest are,
instance of 131 cities to within 2.1% of optimality, using simple
destroy and repair heuristics with a post-processing step.
- The cutting-stock problem (CSP), [here][4]. We solve an instance with
180 orders, over 165 distinct beam sizes. The total stock available
amounts to 165 beams of length 1000. We solve the instance to within
1.35% of optimality in only a very limited number of iterations.
180 beams over 165 distinct sizes to within 1.35% of optimality in
only a very limited number of iterations.

## References
- Pisinger, D., and Ropke, S. (2010). Large Neighborhood Search. In M.
Expand Down
23 changes: 9 additions & 14 deletions examples/cutting_stock_problem.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@
" Solution state for the CSP problem. It has two members, assignments and \n",
" unassigned. Assignments is a list of lists, one for each beam in use.\n",
" Each entry is another list, containing the ordered beams cut from this \n",
" beam. Each such sublist must sum to less than or equal to BEAM_LENGTH.\n",
" Unassigned is a list of ordered beams that are not currently assigned\n",
" to one of the available beams.\n",
" beam. Each such sublist must sum to at most BEAM_LENGTH. Unassigned is \n",
" a list of ordered beams that are not currently assigned to one of the\n",
" available beams.\n",
" \"\"\"\n",
" \n",
"\n",
" def __init__(self, assignments, unassigned=None):\n",
" self.assignments = assignments\n",
" self.unassigned = []\n",
Expand All @@ -136,21 +136,16 @@
" \"\"\"\n",
" Computes the total number of beams in use.\n",
" \"\"\"\n",
" return sum(1\n",
" for assignment in self.assignments\n",
" if len(assignment) != 0)\n",
" return len(self.assignments)\n",
"\n",
" def plot(self):\n",
" \"\"\"\n",
" Helper method to plot a solution.\n",
" \"\"\"\n",
" lengths = [sum(assignment)\n",
" for assignment in self.assignments]\n",
" \n",
" _, ax = plt.subplots(figsize=(12, 6))\n",
" \n",
"\n",
" ax.barh(np.arange(len(self.assignments)), \n",
" lengths, \n",
" [sum(assignment) for assignment in self.assignments], \n",
" height=1)\n",
"\n",
" ax.set_xlim(right=BEAM_LENGTH)\n",
Expand Down Expand Up @@ -218,10 +213,10 @@
" poorest assignments are removed first.\n",
" \"\"\"\n",
" state = state.copy()\n",
" \n",
"\n",
" def value(assignment): # helper method for sorting\n",
" return BEAM_LENGTH - sum(assignment) if len(assignment) != 0 else 0\n",
" \n",
"\n",
" # Sort assignments by wastage, worst first\n",
" worst_assignments = sorted(state.assignments, key=value, reverse=True)\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

MAJOR = 1
MINOR = 0
MAINTENANCE = 3
MAINTENANCE = 4
MODIFIER = ""

VERSION = "{0}.{1}.{2}{3}".format(MAJOR, MINOR, MAINTENANCE, MODIFIER)
Expand Down

0 comments on commit eb30c39

Please sign in to comment.