Skip to content

Commit

Permalink
Update VRP notebook with iterations
Browse files Browse the repository at this point in the history
  • Loading branch information
leonlan committed Oct 21, 2024
1 parent 6df8d96 commit 4f1d300
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 13 additions & 7 deletions examples/capacitated_vehicle_routing_problem.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"from alns import ALNS\n",
"from alns.accept import RecordToRecordTravel\n",
"from alns.select import RouletteWheel\n",
"from alns.stop import MaxRuntime"
"from alns.stop import MaxIterations"
]
},
{
Expand Down Expand Up @@ -472,10 +472,13 @@
},
"outputs": [],
"source": [
"num_iterations = 3000\n",
"init = nearest_neighbor()\n",
"select = RouletteWheel([25, 5, 1, 0], 0.8, 1, 1)\n",
"accept = RecordToRecordTravel.autofit(init.objective(), 0.02, 0, 9000)\n",
"stop = MaxRuntime(60)\n",
"accept = RecordToRecordTravel.autofit(\n",
" init.objective(), 0.02, 0, num_iterations\n",
")\n",
"stop = MaxIterations(num_iterations)\n",
"\n",
"result = alns.iterate(init, select, accept, stop)"
]
Expand Down Expand Up @@ -632,10 +635,13 @@
},
"outputs": [],
"source": [
"num_iterations = 3000\n",
"init = nearest_neighbor()\n",
"select = RouletteWheel([25, 5, 1, 0], 0.8, 1, 1)\n",
"accept = RecordToRecordTravel.autofit(init.objective(), 0.02, 0, 6000)\n",
"stop = MaxRuntime(60)\n",
"accept = RecordToRecordTravel.autofit(\n",
" init.objective(), 0.02, 0, num_iterations\n",
")\n",
"stop = MaxIterations(num_iterations)\n",
"\n",
"result = alns.iterate(init, select, accept, stop)"
]
Expand Down Expand Up @@ -696,7 +702,7 @@
"id": "7424ca3f-b4e7-459d-a307-be2d26426cdc",
"metadata": {},
"source": [
"In this notebook we implemented two heuristics for the CVRP, using the ALNS meta-heuristic framework. The first heuristic used a random customer destroy operator and we obtained a solution which is 6% worse than the best known solution. The second heuristic used a destroy operator which removes strings arround a randomly selected customer and we obtained a solution that is only 3% worse than the best known solution. \n",
"In this notebook we implemented two heuristics for the CVRP, using the ALNS meta-heuristic framework. The first heuristic used a random customer destroy operator and we obtained a solution which is 10% worse than the best known solution. The second heuristic used a destroy operator which removes strings arround a randomly selected customer and we obtained a solution that is only 3% worse than the best known solution. \n",
"\n",
"This example shows that by constructing problem-specific operators, one can create even more powerful ALNS heuristics."
]
Expand All @@ -710,7 +716,7 @@
"provenance": []
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": ".venv",
"language": "python",
"name": "python3"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/permutation_flow_shop_problem.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@
"metadata": {},
"source": [
"## Conclusions\n",
"In this notebook, we implemented several variants of adaptive large neighborhood search heuristic to solve the permutation flow shop problem. We obtained a solution that is only 1.5% worse than the best known solution. Furthermore, we showed several advanced features in ALNS, including:\n",
"In this notebook, we implemented several variants of adaptive large neighborhood search heuristic to solve the permutation flow shop problem. We obtained a solution that is only 1-2% worse than the best known solution. Furthermore, we showed several advanced features in ALNS, including:\n",
"\n",
"* Autofitting acceptance criteria\n",
"* Adding local search to repair operators\n",
Expand Down

0 comments on commit 4f1d300

Please sign in to comment.