From 1bb77b7ec1c46ee27b18bb289a177ade1b9b2496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laure=CE=B7t?= Date: Thu, 9 Dec 2021 15:53:39 +0100 Subject: [PATCH] fix: broken notebook ;( --- notebook.ipynb | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/notebook.ipynb b/notebook.ipynb index a21fd59..df61f18 100644 --- a/notebook.ipynb +++ b/notebook.ipynb @@ -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", - " \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"