diff --git a/optimierung_pymoo.ipynb b/optimierung_pymoo.ipynb index 6907b174e62d97307d21b9994a4023fe9db1f99f..8cb41c62fd9265a082a021b334fcc77369d7a9eb 100644 --- a/optimierung_pymoo.ipynb +++ b/optimierung_pymoo.ipynb @@ -58,17 +58,8 @@ "output_type": "stream", "text": [ "Defaulting to user installation because normal site-packages is not writeable\n", - "Collecting pyomo\n", - " Downloading Pyomo-6.8.2-py3-none-any.whl.metadata (8.0 kB)\n", - "Collecting ply (from pyomo)\n", - " Downloading ply-3.11-py2.py3-none-any.whl.metadata (844 bytes)\n", - "Downloading Pyomo-6.8.2-py3-none-any.whl (3.7 MB)\n", - " ---------------------------------------- 0.0/3.7 MB ? eta -:--:--\n", - " ---------------------------- ----------- 2.6/3.7 MB 12.6 MB/s eta 0:00:01\n", - " ---------------------------------------- 3.7/3.7 MB 11.6 MB/s eta 0:00:00\n", - "Downloading ply-3.11-py2.py3-none-any.whl (49 kB)\n", - "Installing collected packages: ply, pyomo\n", - "Successfully installed ply-3.11 pyomo-6.8.2\n" + "Requirement already satisfied: pyomo in c:\\users\\steinmann\\appdata\\roaming\\python\\python312\\site-packages (6.8.2)\n", + "Requirement already satisfied: ply in c:\\users\\steinmann\\appdata\\roaming\\python\\python312\\site-packages (from pyomo) (3.11)\n" ] }, { @@ -76,8 +67,8 @@ "output_type": "stream", "text": [ "\n", - "[notice] A new release of pip is available: 24.3.1 -> 25.0\n", - "[notice] To update, run: C:\\Users\\Victor\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\\python.exe -m pip install --upgrade pip\n" + "[notice] A new release of pip is available: 24.2 -> 25.0\n", + "[notice] To update, run: C:\\Program Files\\Python312\\python.exe -m pip install --upgrade pip\n" ] } ], @@ -87,7 +78,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -117,7 +108,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 28, "metadata": {}, "outputs": [ { @@ -137,7 +128,7 @@ "import multiDiGraph as gr\n", "nodes =['source','pump1','pump2','valveA','valveB','valveC']\n", "graph = gr.construct_graph('source',('source','pump1',0.),('pump1','pump2',0.),('pump2','valveA',0.),('pump2','valveB',0.),\n", - " ('pump1','valveC',0.),('valveA','source',4.),('valveB','source',4.),('valveC','source',4.))\n", + " ('pump1','valveC',0.),('valveA','source',2.),('valveB','source',2.),('valveC','source',2.))\n", "\n", "#ist das notwendig?!?\n", "for node in graph.nodes:\n", @@ -173,7 +164,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -183,7 +174,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -216,7 +207,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 29, "metadata": {}, "outputs": [], "source": [ @@ -233,18 +224,18 @@ "modell.pumps = pyo.Set()\n", "modell.valves = pyo.Set()\n", "\n", - "modell.Q_valve=pyo.Param(modell.valves)\n", + "#modell.Q_valve=pyo.Param(modell.valves)\n", "modell.Q = pyo.Param(modell.nodes)\n", "\n", "#Optimierungsvariable\n", - "modell.n = pyo.Var(modell.pumps,bounds=(750/3600,1))\n", + "modell.n = pyo.Var(modell.pumps,bounds=(750/3600,10))\n", "\n", "\n", "#expressions for constraints:\n", "def PumpFlow(modell,pump):\n", " return pyo.summation(np.array([modell.Q[pump]**2, modell.n[pump]*modell.Q[pump], modell.n[pump]**2]),LR_H.coef_,index=[0,1,2])\n", "def Pump_delivery_req(modell,pump):\n", - " return PumpFlow(modell,pump) ==modell.Q[pump]\n", + " return PumpFlow(modell,pump) >=modell.Q[pump]\n", "def valve_req_rule(modell,valve):\n", " return modell.Q[valve]>=modell.Q_valve[valve]\n", "\n", @@ -254,11 +245,12 @@ " return modell.Q[node]==pyo.summation(modell.Q,index=graph.predecessors(node))\n", "\n", "#Objective\n", - "def PumpPower(modell,pump):\n", - " return pyo.summation(\n", - " np.array([modell.Q[pump]**3, (modell.Q[pump]**2)*modell.n[pump], modell.Q[pump]*modell.n[pump]**2, modell.n[pump]**3, 1.]),\n", - " LR_P.coef_, index=[0,1,2,3,4])\n", - "modell.Power_Objective = pyo.Objective(modell.pumps,rule=PumpPower,sense=pyo.minimize)" + "def PumpPower(modell):\n", + " return sum(pyo.summation(\n", + " np.array([modell.Q[pump]**3, (modell.Q[pump]**2)*modell.n[pump], modell.Q[pump]*modell.n[pump]**2, modell.n[pump]**3]),\n", + " LR_P.coef_, index=[0,1,2,3])\n", + " for pump in modell.pumps )\n", + "modell.Power_Objective = pyo.Objective(rule=PumpPower,sense=pyo.minimize)" ] }, { @@ -274,67 +266,111 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 30, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "{None: {'nodes': ['source', 'pump1', 'pump2', 'valveA', 'valveB', 'valveC'], 'pumps': ['pump1', 'pump2'], 'valves': ['valveA', 'valveB', 'valveC'], 'Q': [12.0, 12.0, 8.0, 4.0, 4.0, 4.0]}}\n", - "WARNING: Failed to create solver with name 'scipampl': Failed to set\n", - "executable for solver asl. File with name=C:\\Program Files\\SCIPOptSuite\n", - "9.2.1\\bin\\scip.exe either does not exist or it is not executable. To skip this\n", - "validation, call set_executable with validate=False.\n", - "Traceback (most recent call last):\n", - " File \"C:\\Users\\Steinmann\\AppData\\Roaming\\Python\\Python312\\site-packages\\pyomo\\opt\\base\\solvers.py\", line 162, in __call__\n", - " opt = self._cls[_implicit_solvers[mode]](**kwds)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"C:\\Users\\Steinmann\\AppData\\Roaming\\Python\\Python312\\site-packages\\pyomo\\solvers\\plugins\\solvers\\ASL.py\", line 46, in __init__\n", - " SystemCallSolver.__init__(self, **kwds)\n", - " File \"C:\\Users\\Steinmann\\AppData\\Roaming\\Python\\Python312\\site-packages\\pyomo\\opt\\solver\\shellcmd.py\", line 66, in __init__\n", - " self.set_executable(name=executable, validate=validate)\n", - " File \"C:\\Users\\Steinmann\\AppData\\Roaming\\Python\\Python312\\site-packages\\pyomo\\opt\\solver\\shellcmd.py\", line 115, in set_executable\n", - " raise ValueError(\n", - "ValueError: Failed to set executable for solver asl. File with name=C:\\Program Files\\SCIPOptSuite 9.2.1\\bin\\scip.exe either does not exist or it is not executable. To skip this validation, call set_executable with validate=False.\n", - "ERROR: Rule failed when initializing variable for Var Q with index None:\n", - "AssertionError:\n", - "ERROR: Constructing component 'Q' from data=[12.0, 12.0, 8.0, 4.0, 4.0, 4.0]\n", - "failed:\n", - " AssertionError:\n" - ] - }, - { - "ename": "AssertionError", - "evalue": "", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mAssertionError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[1;32mIn[21], line 14\u001b[0m\n\u001b[0;32m 12\u001b[0m \u001b[38;5;28mprint\u001b[39m(TestData)\n\u001b[0;32m 13\u001b[0m opt \u001b[38;5;241m=\u001b[39m pyo\u001b[38;5;241m.\u001b[39mSolverFactory(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mscipampl\u001b[39m\u001b[38;5;124m'\u001b[39m, executable\u001b[38;5;241m=\u001b[39m\u001b[38;5;124mr\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mC:\u001b[39m\u001b[38;5;124m\\\u001b[39m\u001b[38;5;124mProgram Files\u001b[39m\u001b[38;5;124m\\\u001b[39m\u001b[38;5;124mSCIPOptSuite 9.2.1\u001b[39m\u001b[38;5;124m\\\u001b[39m\u001b[38;5;124mbin\u001b[39m\u001b[38;5;124m\\\u001b[39m\u001b[38;5;124mscip.exe\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m---> 14\u001b[0m instance \u001b[38;5;241m=\u001b[39m \u001b[43mmodell\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcreate_instance\u001b[49m\u001b[43m(\u001b[49m\u001b[43mTestData\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 15\u001b[0m instance\u001b[38;5;241m.\u001b[39mFlow_constraint\u001b[38;5;241m=\u001b[39mpyo\u001b[38;5;241m.\u001b[39mConstraint(instance\u001b[38;5;241m.\u001b[39mvalves,rule\u001b[38;5;241m=\u001b[39mvalve_req_rule)\n\u001b[0;32m 16\u001b[0m instance\u001b[38;5;241m.\u001b[39mpump_Flow_constraint\u001b[38;5;241m=\u001b[39mpyo\u001b[38;5;241m.\u001b[39mConstraint(instance\u001b[38;5;241m.\u001b[39mpumps,rule\u001b[38;5;241m=\u001b[39mPump_delivery_req)\n", - "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python312\\site-packages\\pyomo\\core\\base\\PyomoModel.py:734\u001b[0m, in \u001b[0;36mModel.create_instance\u001b[1;34m(self, filename, data, name, namespace, namespaces, profile_memory, report_timing, **kwds)\u001b[0m\n\u001b[0;32m 731\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m _namespaces:\n\u001b[0;32m 732\u001b[0m _namespaces\u001b[38;5;241m.\u001b[39mappend(\u001b[38;5;28;01mNone\u001b[39;00m)\n\u001b[1;32m--> 734\u001b[0m \u001b[43minstance\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mload\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdata\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mnamespaces\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m_namespaces\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mprofile_memory\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mprofile_memory\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 736\u001b[0m \u001b[38;5;66;03m#\u001b[39;00m\n\u001b[0;32m 737\u001b[0m \u001b[38;5;66;03m# Indicate that the model is concrete/constructed\u001b[39;00m\n\u001b[0;32m 738\u001b[0m \u001b[38;5;66;03m#\u001b[39;00m\n\u001b[0;32m 739\u001b[0m instance\u001b[38;5;241m.\u001b[39m_constructed \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mTrue\u001b[39;00m\n", - "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python312\\site-packages\\pyomo\\core\\base\\PyomoModel.py:771\u001b[0m, in \u001b[0;36mModel.load\u001b[1;34m(self, arg, namespaces, profile_memory)\u001b[0m\n\u001b[0;32m 769\u001b[0m msg \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCannot load model model data from with object of type \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;132;01m%s\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 770\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(msg \u001b[38;5;241m%\u001b[39m \u001b[38;5;28mstr\u001b[39m(\u001b[38;5;28mtype\u001b[39m(arg)))\n\u001b[1;32m--> 771\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_load_model_data\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdp\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mnamespaces\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mprofile_memory\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mprofile_memory\u001b[49m\u001b[43m)\u001b[49m\n", - "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python312\\site-packages\\pyomo\\core\\base\\PyomoModel.py:823\u001b[0m, in \u001b[0;36mModel._load_model_data\u001b[1;34m(self, modeldata, namespaces, **kwds)\u001b[0m\n\u001b[0;32m 820\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m component\u001b[38;5;241m.\u001b[39mctype \u001b[38;5;129;01mis\u001b[39;00m Model:\n\u001b[0;32m 821\u001b[0m \u001b[38;5;28;01mcontinue\u001b[39;00m\n\u001b[1;32m--> 823\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_initialize_component\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 824\u001b[0m \u001b[43m \u001b[49m\u001b[43mmodeldata\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mnamespaces\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcomponent_name\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mprofile_memory\u001b[49m\n\u001b[0;32m 825\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 827\u001b[0m \u001b[38;5;66;03m# Note: As is, connectors are expanded when using command-line pyomo but not calling model.create(...) in a Python script.\u001b[39;00m\n\u001b[0;32m 828\u001b[0m \u001b[38;5;66;03m# John says this has to do with extension points which are called from commandline but not when writing scripts.\u001b[39;00m\n\u001b[0;32m 829\u001b[0m \u001b[38;5;66;03m# Uncommenting the next two lines switches this (command-line fails because it tries to expand connectors twice)\u001b[39;00m\n\u001b[0;32m 830\u001b[0m \u001b[38;5;66;03m# connector_expander = ConnectorExpander()\u001b[39;00m\n\u001b[0;32m 831\u001b[0m \u001b[38;5;66;03m# connector_expander.apply(instance=self)\u001b[39;00m\n\u001b[0;32m 833\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m profile_memory \u001b[38;5;241m>\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;241m2\u001b[39m \u001b[38;5;129;01mand\u001b[39;00m pympler_available:\n", - "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python312\\site-packages\\pyomo\\core\\base\\PyomoModel.py:871\u001b[0m, in \u001b[0;36mModel._initialize_component\u001b[1;34m(self, modeldata, namespaces, component_name, profile_memory)\u001b[0m\n\u001b[0;32m 863\u001b[0m logger\u001b[38;5;241m.\u001b[39mdebug(\n\u001b[0;32m 864\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mConstructing \u001b[39m\u001b[38;5;132;01m%s\u001b[39;00m\u001b[38;5;124m \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;132;01m%s\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m on \u001b[39m\u001b[38;5;132;01m%s\u001b[39;00m\u001b[38;5;124m from data=\u001b[39m\u001b[38;5;132;01m%s\u001b[39;00m\u001b[38;5;124m\"\u001b[39m,\n\u001b[0;32m 865\u001b[0m declaration\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__class__\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m,\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 868\u001b[0m \u001b[38;5;28mstr\u001b[39m(data),\n\u001b[0;32m 869\u001b[0m )\n\u001b[0;32m 870\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 871\u001b[0m \u001b[43mdeclaration\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mconstruct\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdata\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 872\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m:\n\u001b[0;32m 873\u001b[0m err \u001b[38;5;241m=\u001b[39m sys\u001b[38;5;241m.\u001b[39mexc_info()[\u001b[38;5;241m1\u001b[39m]\n", - "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python312\\site-packages\\pyomo\\core\\base\\var.py:735\u001b[0m, in \u001b[0;36mVar.construct\u001b[1;34m(self, data)\u001b[0m\n\u001b[0;32m 732\u001b[0m index \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m 733\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m 734\u001b[0m \u001b[38;5;66;03m# We do not (currently) accept data for constructing Variables\u001b[39;00m\n\u001b[1;32m--> 735\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m data \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m 737\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mindex_set()\u001b[38;5;241m.\u001b[39misfinite() \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_dense:\n\u001b[0;32m 738\u001b[0m \u001b[38;5;66;03m# Note: if the index is not finite, then we cannot\u001b[39;00m\n\u001b[0;32m 739\u001b[0m \u001b[38;5;66;03m# iterate over it. This used to be fatal; now we\u001b[39;00m\n\u001b[0;32m 740\u001b[0m \u001b[38;5;66;03m# just warn\u001b[39;00m\n\u001b[0;32m 741\u001b[0m logger\u001b[38;5;241m.\u001b[39mwarning(\n\u001b[0;32m 742\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mVar \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;132;01m%s\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m indexed by a non-finite set, but declared \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 743\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mwith \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mdense=True\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m. Reverting to \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mdense=False\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m as \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 746\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mdense=False\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;241m%\u001b[39m (\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mname,)\n\u001b[0;32m 747\u001b[0m )\n", - "\u001b[1;31mAssertionError\u001b[0m: " + "{None: {'nodes': ['source', 'pump1', 'pump2', 'valveA', 'valveB', 'valveC'], 'pumps': ['pump1', 'pump2'], 'valves': ['valveA', 'valveB', 'valveC'], 'Q': {'source': 6.0, 'pump1': 6.0, 'pump2': 4.0, 'valveA': 2.0, 'valveB': 2.0, 'valveC': 2.0}}}\n", + "SCIP version 9.2.0 [precision: 8 byte] [memory: block] [mode: optimized] [LP solver: Soplex 7.1.2] [GitHash: 74cea9222e]\n", + "Copyright (c) 2002-2024 Zuse Institute Berlin (ZIB)\n", + "\n", + "External libraries: \n", + " Soplex 7.1.2 Linear Programming Solver developed at Zuse Institute Berlin (soplex.zib.de) [GitHash: b040369c]\n", + " CppAD 20180000.0 Algorithmic Differentiation of C++ algorithms developed by B. Bell (github.com/coin-or/CppAD)\n", + " TinyCThread 1.2 small portable implementation of the C11 threads API (tinycthread.github.io)\n", + " MPIR 3.0.0 Multiple Precision Integers and Rationals Library developed by W. Hart (mpir.org)\n", + " ZIMPL 3.6.2 Zuse Institute Mathematical Programming Language developed by T. Koch (zimpl.zib.de)\n", + " AMPL/MP 690e9e7 AMPL .nl file reader library (github.com/ampl/mp)\n", + " PaPILO 2.4.0 parallel presolve for integer and linear optimization (github.com/scipopt/papilo) (built with TBB) [GitHash: 2d9fe29f]\n", + " Nauty 2.8.8 Computing Graph Automorphism Groups by Brendan D. McKay (users.cecs.anu.edu.au/~bdm/nauty)\n", + " sassy 1.1 Symmetry preprocessor by Markus Anders (github.com/markusa4/sassy)\n", + " Ipopt 3.14.16 Interior Point Optimizer developed by A. Waechter et.al. (github.com/coin-or/Ipopt)\n", + "\n", + "user parameter file <scip.set> not found - using default parameters\n", + "read problem <C:\\Users\\STEINM~1\\AppData\\Local\\Temp\\tmpexzfzskj.pyomo.nl>\n", + "============\n", + "\n", + "original problem has 3 variables (0 bin, 0 int, 0 impl, 3 cont) and 3 constraints\n", + "\n", + "solve problem\n", + "=============\n", + "\n", + "feasible solution found by trivial heuristic after 0.0 seconds, objective value 1.002020e+05\n", + "presolving:\n", + "(round 1, fast) 0 del vars, 0 del conss, 0 add conss, 4 chg bounds, 0 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs\n", + "(round 2, fast) 0 del vars, 0 del conss, 0 add conss, 5 chg bounds, 0 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs\n", + " (0.0s) symmetry computation started: requiring (bin +, int +, cont +), (fixed: bin -, int -, cont -)\n", + " (0.0s) no symmetry present (symcode time: 0.00)\n", + "presolving (3 rounds: 3 fast, 1 medium, 1 exhaustive):\n", + " 0 deleted vars, 0 deleted constraints, 0 added constraints, 5 tightened bounds, 0 added holes, 0 changed sides, 0 changed coefficients\n", + " 0 implications, 0 cliques\n", + "presolved problem has 3 variables (0 bin, 0 int, 0 impl, 3 cont) and 3 constraints\n", + " 3 constraints of type <nonlinear>\n", + "Presolving Time: 0.00\n", + "transformed 1/1 original solutions to the transformed problem space\n", + "\n", + " time | node | left |LP iter|LP it/n|mem/heur|mdpt |vars |cons |rows |cuts |sepa|confs|strbr| dualbound | primalbound | gap | compl. \n", + "t 0.0s| 1 | 0 | 0 | - | trivial| 0 | 3 | 3 | 0 | 0 | 0 | 0 | 0 | 2.420756e+02 | 2.420756e+02 | 0.00%| unknown\n", + "\n", + "SCIP Status : problem is solved [optimal solution found]\n", + "Solving Time (sec) : 0.00\n", + "Solving Nodes : 1\n", + "Primal Bound : +2.42075610615326e+02 (3 solutions)\n", + "Dual Bound : +2.42075610615326e+02\n", + "Gap : 0.00 %\n", + "\n", + "Problem: \n", + "- Lower bound: -inf\n", + " Upper bound: inf\n", + " Number of objectives: 1\n", + " Number of constraints: 0\n", + " Number of variables: 2\n", + " Sense: unknown\n", + "Solver: \n", + "- Status: ok\n", + " Message: optimal solution found\n", + " Termination condition: optimal\n", + " Id: 0\n", + " Error rc: 0\n", + " Time: 0.06373882293701172\n", + "Solution: \n", + "- number of solutions: 0\n", + " number of solutions displayed: 0\n", + "\n", + "n : Size=2, Index=pumps\n", + " Key : Lower : Value : Upper : Fixed : Stale : Domain\n", + " pump1 : 0.20833333333333334 : 0.8693804045842674 : 10 : False : False : Reals\n", + " pump2 : 0.20833333333333334 : 0.6940981161554753 : 10 : False : False : Reals\n", + "Q : Size=6, Index=nodes, Domain=Any, Default=None, Mutable=False\n", + " Key : Value\n", + " pump1 : 6.0\n", + " pump2 : 4.0\n", + " source : 6.0\n", + " valveA : 2.0\n", + " valveB : 2.0\n", + " valveC : 2.0\n" ] } ], "source": [ "from pyomo.opt import SolverFactory\n", - "\n", + "dict={}\n", + "for key in graph.nodes.keys():\n", + " dict[key]=graph.nodes[key]['flow']\n", "TestData={\n", " None:{\n", " \n", " 'nodes':[key for key in graph.nodes.keys()],\n", " 'pumps':[key for key in graph.nodes.keys() if 'pump' in key],\n", " 'valves':[key for key in graph.nodes.keys() if 'valve' in key],\n", - " 'Q':[graph.nodes[key]['flow']for key in graph.nodes.keys()]\n", + " 'Q':dict\n", " }\n", "}\n", "print(TestData)\n", - "opt = pyo.SolverFactory('scipampl', executable=r'C:\\Program Files\\SCIPOptSuite 9.2.1\\bin\\scip.exe')\n", + "opt = pyo.SolverFactory('scipampl', executable=r'c:\\Program Files\\SCIPOptSuite 9.2.0\\bin\\scip.exe')\n", "instance = modell.create_instance(TestData)\n", "#instance.Flow_constraint=pyo.Constraint(instance.valves,rule=valve_req_rule)\n", "instance.pump_Flow_constraint=pyo.Constraint(instance.pumps,rule=Pump_delivery_req)\n", @@ -363,7 +399,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.8" + "version": "3.12.5" } }, "nbformat": 4,