mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-08 18:38:51 -06:00
Make lazy constr component compatible with Pyomo+Gurobi
This commit is contained in:
@@ -38,9 +38,13 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 1,
|
||||
"id": "f906fe9c",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-01-30T22:19:30.826123021Z",
|
||||
"start_time": "2024-01-30T22:19:30.766066926Z"
|
||||
},
|
||||
"collapsed": false,
|
||||
"jupyter": {
|
||||
"outputs_hidden": false
|
||||
@@ -57,18 +61,18 @@
|
||||
"x4 = [[0.37454012 0.9507143 0.7319939 ]\n",
|
||||
" [0.5986585 0.15601864 0.15599452]\n",
|
||||
" [0.05808361 0.8661761 0.601115 ]]\n",
|
||||
"x5 = (2, 3)\t0.68030757\n",
|
||||
" (3, 2)\t0.45049927\n",
|
||||
" (4, 0)\t0.013264962\n",
|
||||
" (0, 2)\t0.94220173\n",
|
||||
" (4, 2)\t0.5632882\n",
|
||||
" (2, 1)\t0.3854165\n",
|
||||
" (1, 1)\t0.015966251\n",
|
||||
" (3, 0)\t0.23089382\n",
|
||||
" (4, 4)\t0.24102546\n",
|
||||
" (1, 3)\t0.68326354\n",
|
||||
" (3, 1)\t0.6099967\n",
|
||||
" (0, 3)\t0.8331949\n"
|
||||
"x5 = (3, 2)\t0.6803075671195984\n",
|
||||
" (2, 3)\t0.4504992663860321\n",
|
||||
" (0, 4)\t0.013264961540699005\n",
|
||||
" (2, 0)\t0.9422017335891724\n",
|
||||
" (2, 4)\t0.5632882118225098\n",
|
||||
" (1, 2)\t0.38541650772094727\n",
|
||||
" (1, 1)\t0.015966251492500305\n",
|
||||
" (0, 3)\t0.2308938205242157\n",
|
||||
" (4, 4)\t0.24102546274662018\n",
|
||||
" (3, 1)\t0.6832635402679443\n",
|
||||
" (1, 3)\t0.6099966764450073\n",
|
||||
" (3, 0)\t0.83319491147995\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -182,6 +186,10 @@
|
||||
"execution_count": 4,
|
||||
"id": "ac6f8c6f",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-01-30T22:19:30.826707866Z",
|
||||
"start_time": "2024-01-30T22:19:30.825940503Z"
|
||||
},
|
||||
"collapsed": false,
|
||||
"jupyter": {
|
||||
"outputs_hidden": false
|
||||
@@ -205,7 +213,7 @@
|
||||
"\n",
|
||||
"from miplearn.problems.tsp import (\n",
|
||||
" TravelingSalesmanGenerator,\n",
|
||||
" build_tsp_model,\n",
|
||||
" build_tsp_model_gurobipy,\n",
|
||||
")\n",
|
||||
"from miplearn.io import write_pkl_gz\n",
|
||||
"from miplearn.h5 import H5File\n",
|
||||
@@ -231,7 +239,7 @@
|
||||
"# Solve all instances and collect basic solution information.\n",
|
||||
"# Process at most four instances in parallel.\n",
|
||||
"bc = BasicCollector()\n",
|
||||
"bc.collect(glob(\"data/tsp/*.pkl.gz\"), build_tsp_model, n_jobs=4)\n",
|
||||
"bc.collect(glob(\"data/tsp/*.pkl.gz\"), build_tsp_model_gurobipy, n_jobs=4)\n",
|
||||
"\n",
|
||||
"# Read and print some training data for the first instance.\n",
|
||||
"with H5File(\"data/tsp/00000.h5\", \"r\") as h5:\n",
|
||||
@@ -244,6 +252,9 @@
|
||||
"execution_count": null,
|
||||
"id": "78f0b07a",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"start_time": "2024-01-30T22:19:30.826179789Z"
|
||||
},
|
||||
"collapsed": false,
|
||||
"jupyter": {
|
||||
"outputs_hidden": false
|
||||
@@ -269,7 +280,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.16"
|
||||
"version": "3.11.7"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
Reference in New Issue
Block a user