fix: broken notebook ;(

This commit is contained in:
Laureηt 2021-12-09 15:53:39 +01:00
parent a74b1027f1
commit 1bb77b7ec1

View file

@ -110,12 +110,34 @@
"metadata": {},
"outputs": [],
"source": [
"# on convert tous les .opb et .lp\n",
"# on convert tous les .opb en .lp pour les utiliser dans glpk\n",
"for (root, dirs, files) in walkdir(\"data\")\n",
" for file in files\n",
" if endswith(file, \".opb\")\n",
" price, weight, capacity = readKnapInstance(root * \"/\" * file)\n",
" filename = splitext(file)[1]\n",
" f = open(root * \"/\" * filename * \".lp\", \"w\");\n",
" write(f, \"Maximize\\n\")\n",
" write(f, \" Knap: \")\n",
" for (i, p) in enumerate(price)\n",
" write(f, \"+ \" * string(p) * \" obj\" * string(i) * \" \")\n",
" end\n",
" write(f, \"\\n\")\n",
"\n",
" write(f, \"\\nSubject To\\n\")\n",
" write(f, \" MaxKnap: \")\n",
" for (i, w) in enumerate(weight)\n",
" write(f, \"+ \" * string(w) * \" obj\" * string(i) * \" \")\n",
" end\n",
" write(f, \"\\n\")\n",
"\n",
" write(f, \"\\nBinary\\n\")\n",
" for (i, p) in enumerate(price)\n",
" write(f, \" obj\" * string(i) * \"\\n\")\n",
" end\n",
"\n",
" write(f, \"\\nEnd\\n\")\n",
" close(f)\n",
" end\n",
" end\n",
"end"