diff --git a/optimierung_pymoo.ipynb b/optimierung_pymoo.ipynb
index 5e580f8874e6c30a46d9a088c57df6134facba76..75a729ced42fbac37c34c9b93e67f999ee1a3b7c 100644
--- a/optimierung_pymoo.ipynb
+++ b/optimierung_pymoo.ipynb
@@ -27,17 +27,16 @@
     "\n",
     "$\\Delta p_{\\mathrm{loss}} = - \\frac{1}{2} \\varrho \\zeta \\left(\\frac{Q}{A}\\right)^2 = -l Q^2 :l\\in [l_{\\mathrm{min}}:\\infty )$\n",
     "\n",
-    "\n",
     "nun soll für einen Gegebenen Volumenstrom $Q$ eine Optimale Drehzahl bestimmt werden, welche die Pumpenlesitung minimiert.\n",
     "\n",
     "$$\n",
     "\\begin{align*}\n",
     "\\mathrm{min} \\sum_{p \\in \\mathcal{P}} Po_{p}  \\\\\n",
-    "Q_p = Q_{\\mathrm{target}, i} \\\\\n",
-    "Q_p \n",
-    ", n\\epsilon [n_{min},n_{max}] \\\\\n",
+    "Q_{p,i} \\geq \\sum_{strang} Q_v + \\sum_{strang} Q_p \\\\\n",
+    "Q_p , n\\epsilon [n_{min},n_{max}] \\\\\n",
     "\\overrightarrow{n} = (1,n,n^2,n^3)^T \\\\\n",
     "min P = A \\overrightarrow{n} \\\\\n",
+    "\n",
     "-n\\leq n_{min} \\\\\n",
     "n\\leq n_{max}\n",
     "\\end{align*}\n",
@@ -156,33 +155,7 @@
    "cell_type": "code",
    "execution_count": 4,
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "<Compressed Sparse Column sparse array of dtype 'float64'\n",
-      "\twith 16 stored elements and shape (6, 8)>\n",
-      "  Coords\tValues\n",
-      "  (0, 0)\t-1.0\n",
-      "  (1, 0)\t1.0\n",
-      "  (1, 1)\t-1.0\n",
-      "  (2, 1)\t1.0\n",
-      "  (1, 2)\t-1.0\n",
-      "  (5, 2)\t1.0\n",
-      "  (2, 3)\t-1.0\n",
-      "  (3, 3)\t1.0\n",
-      "  (2, 4)\t-1.0\n",
-      "  (4, 4)\t1.0\n",
-      "  (0, 5)\t1.0\n",
-      "  (3, 5)\t-1.0\n",
-      "  (0, 6)\t1.0\n",
-      "  (4, 6)\t-1.0\n",
-      "  (0, 7)\t1.0\n",
-      "  (5, 7)\t-1.0\n"
-     ]
-    }
-   ],
+   "outputs": [],
    "source": [
     "import networkx as nx\n",
     "Mtrx= nx.incidence_matrix(graph,nodes,oriented=True)"
@@ -220,19 +193,21 @@
     "\n",
     "Zeilen = knoten \n",
     "Spalten = kanten\n",
-    "Summe pro knoten = 0"
+    "Summe pro knoten = 0\n",
+    "\n",
+    "Q pump muss größer gleich sein als alle nachfolgenden durchflüsse"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 6,
+   "execution_count": 18,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "{None: {'nodes': ['source', 'pump1', 'pump2', 'valveA', 'valveB', 'valveC'], 'pumps': ['pump1', 'pump2'], 'valves': ['valveA', 'valveB', 'valveC']}}\n"
+      "{None: {'Q_valve': {'valveA': 4.0, 'valveB': 4.0, 'valveC': 4.0}, 'nodes': ['source', 'pump1', 'pump2', 'valveA', 'valveB', 'valveC'], 'pumps': ['pump1', 'pump2'], 'valves': ['valveA', 'valveB', 'valveC']}}\n"
      ]
     }
    ],
@@ -243,28 +218,36 @@
     "import numpy as np\n",
     "from sklearn.linear_model import LinearRegression\n",
     "\n",
+    "\n",
+    "\n",
     "modell =  pyo.AbstractModel()\n",
     "#notwendige Mengen zur Berechnung der Constraints\n",
     "modell.nodes = pyo.Set()\n",
     "modell.pumps = pyo.Set()\n",
     "modell.valves = pyo.Set()\n",
     "\n",
+    "modell.Q_valve=pyo.Param(modell.valves)\n",
+    "\n",
     "#Optimierungsvariable\n",
-    "modell.n = pyo.Var(modell.pumps,bounds=(0,1))\n",
-    "modell.Q = pyo.Var(modell.nodes)\n",
+    "modell.n = pyo.Var(modell.pumps,bounds=(750/3600,1))\n",
+    "modell.Q_pump = pyo.Var(modell.pumps)\n",
     "\n",
     "#Objective\n",
     "def PumpPower(modell):\n",
     "    return sum(np.dot(\n",
     "        np.array(\n",
-    "            [modell.Q[i]**3,(modell.Q[i]**2)*modell.n[i],modell.Q[i]*modell.n[i]**2,modell.n[i]**3]\n",
+    "            [modell.Q_pump[i]**3,(modell.Q_pump[i]**2)*modell.n[i],modell.Q_pump[i]*modell.n[i]**2,modell.n[i]**3]\n",
     "            ),LR_P.coef_\n",
     "            ) for i in modell.pumps)\n",
     "modell.Power_Objective = pyo.Objective(rule=PumpPower,sense=pyo.minimize)\n",
+    "def PumpFlow(modell,pump):\n",
+    "    pump=np.dot(np.array([modell.Q_pump[pump]**2,modell.n[pump]*modell.Q_pump[pump],modell.n[pump]**2]),LR_H.coef_)\n",
+    "    return pump>=sum(modell.Q_valve[node] for node in graph.successors(pump) if node in modell.valves)+sum(modell.Q_pump[n] for n in graph.successors(node) if node in modell.pumps)\n",
+    "modell.Flow_Objective = pyo.Objective(rule=PumpFlow,sense=pyo.as_boolean)\n",
     "\n",
     "#Constaints\n",
     "def continuityRule(modell,node):\n",
-    "    return sum(modell.Q[i] for i in graph.predecessors(node))==sum(modell.Q[j] for j in graph.successors(node))\n",
+    "    return sum(modell.Q_pump[i] for i in graph.predecessors(node))==sum(modell.Q_pump[j] for j in graph.successors(node))\n",
     "#alternative\n",
     "def continuityRule2(modell,node):\n",
     "    return 0.==sum(graph[node][i][0]['weight'] for i in graph[node])\n",
@@ -272,9 +255,10 @@
     "#construction of test Data dictionairy missing\n",
     "TestData={\n",
     "    None:{\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_valve':{'valveA':4.,'valveB':4.,'valveC':4.},\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",
     "    }\n",
     "}\n",
     "print(TestData)\n",
@@ -283,7 +267,7 @@
     "#Optimierungsgleichung\n",
     "#modell.pump_constraint = pyo.Constraint(expr=sum(modell.nodes[k] for k in modell.nodes)==0,rule=continuityRule)\n",
     "#instance=modell.create_instance(graph,LR_H)\n",
-    "#instance.obj = pyo.Objective(expr=sum(PumpPower(modell.Q[i],modell.n[i],LR_P) for i in modell.pumps),sense=min)\n"
+    "#instance.obj = pyo.Objective(expr=sum(PumpPower(modell.Q_pump[i],modell.n[i],LR_P) for i in modell.pumps),sense=min)\n"
    ]
   },
   {
@@ -299,54 +283,39 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 11,
+   "execution_count": 19,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "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\\tmptn91lkdj.pyomo.nl>\n",
-      "============\n",
-      "\n",
-      "original problem has 5 variables (0 bin, 0 int, 0 impl, 5 cont) and 1 constraints\n",
-      "\n",
-      "solve problem\n",
-      "=============\n",
-      "\n",
-      "feasible solution found by trivial heuristic after 0.0 seconds, objective value 0.000000e+00\n",
-      "presolving:\n",
-      "   (0.0s) symmetry computation started: requiring (bin +, int +, cont +), (fixed: bin -, int -, cont -)\n",
-      "   (0.0s) symmetry computation finished: 1 generators found (max: 1500, log10 of symmetry group size: 0.0) (symcode time: 0.00)\n",
-      "dynamic symmetry handling statistics:\n",
-      "   orbitopal reduction:       no components\n",
-      "   orbital reduction:         no components\n",
-      "   lexicographic reduction:    1 permutations with support sizes 4\n",
-      "handled 1 out of 1 symmetry components\n",
-      "presolving (1 rounds: 1 fast, 1 medium, 1 exhaustive):\n",
-      " 0 deleted vars, 0 deleted constraints, 0 added constraints, 0 tightened bounds, 0 added holes, 0 changed sides, 0 changed coefficients\n",
-      " 0 implications, 0 cliques\n",
-      "presolved problem has 5 variables (0 bin, 0 int, 0 impl, 5 cont) and 1 constraints\n",
-      "      1 constraints of type <nonlinear>\n",
-      "Presolving Time: 0.00\n",
-      "transformed 3/3 original solutions to the transformed problem space\n",
-      "\n"
+      "ERROR: Rule failed when generating expression for Objective Flow_Objective\n",
+      "with index None: KeyError: \"Index 'None' is not valid for indexed component\n",
+      "'Q_pump'\"\n",
+      "ERROR: Constructing component 'Flow_Objective' from data=None failed:\n",
+      "        KeyError: \"Index 'None' is not valid for indexed component 'Q_pump'\"\n"
+     ]
+    },
+    {
+     "ename": "KeyError",
+     "evalue": "\"Index 'None' is not valid for indexed component 'Q_pump'\"",
+     "output_type": "error",
+     "traceback": [
+      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
+      "\u001b[1;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
+      "Cell \u001b[1;32mIn[19], line 4\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mpyomo\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mopt\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m SolverFactory\n\u001b[0;32m      3\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.0\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----> 4\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      6\u001b[0m result\u001b[38;5;241m=\u001b[39mopt\u001b[38;5;241m.\u001b[39msolve(instance, tee\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: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\\objective.py:335\u001b[0m, in \u001b[0;36mObjective.construct\u001b[1;34m(self, data)\u001b[0m\n\u001b[0;32m    333\u001b[0m \u001b[38;5;66;03m# Bypass the index validation and create the member directly\u001b[39;00m\n\u001b[0;32m    334\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m index \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mindex_set():\n\u001b[1;32m--> 335\u001b[0m     ans \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_setitem_when_not_present(index, \u001b[43mrule\u001b[49m\u001b[43m(\u001b[49m\u001b[43mblock\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mindex\u001b[49m\u001b[43m)\u001b[49m)\n\u001b[0;32m    336\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m ans \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m    337\u001b[0m         ans\u001b[38;5;241m.\u001b[39mset_sense(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_init_sense(block, index))\n",
+      "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python312\\site-packages\\pyomo\\core\\base\\initializer.py:349\u001b[0m, in \u001b[0;36mIndexedCallInitializer.__call__\u001b[1;34m(self, parent, idx)\u001b[0m\n\u001b[0;32m    347\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_fcn(parent, \u001b[38;5;241m*\u001b[39midx)\n\u001b[0;32m    348\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m--> 349\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_fcn\u001b[49m\u001b[43m(\u001b[49m\u001b[43mparent\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43midx\u001b[49m\u001b[43m)\u001b[49m\n",
+      "Cell \u001b[1;32mIn[18], line 30\u001b[0m, in \u001b[0;36mPumpFlow\u001b[1;34m(modell, pump)\u001b[0m\n\u001b[0;32m     29\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mPumpFlow\u001b[39m(modell,pump):\n\u001b[1;32m---> 30\u001b[0m     pump\u001b[38;5;241m=\u001b[39mnp\u001b[38;5;241m.\u001b[39mdot(np\u001b[38;5;241m.\u001b[39marray([\u001b[43mmodell\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mQ_pump\u001b[49m\u001b[43m[\u001b[49m\u001b[43mpump\u001b[49m\u001b[43m]\u001b[49m\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m2\u001b[39m,modell\u001b[38;5;241m.\u001b[39mn[pump]\u001b[38;5;241m*\u001b[39mmodell\u001b[38;5;241m.\u001b[39mQ_pump[pump],modell\u001b[38;5;241m.\u001b[39mn[pump]\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m2\u001b[39m]),LR_H\u001b[38;5;241m.\u001b[39mcoef_)\n\u001b[0;32m     31\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m pump\u001b[38;5;241m>\u001b[39m\u001b[38;5;241m=\u001b[39m\u001b[38;5;28msum\u001b[39m(modell\u001b[38;5;241m.\u001b[39mQ_valve[node] \u001b[38;5;28;01mfor\u001b[39;00m node \u001b[38;5;129;01min\u001b[39;00m graph\u001b[38;5;241m.\u001b[39msuccessors(pump) \u001b[38;5;28;01mif\u001b[39;00m node \u001b[38;5;129;01min\u001b[39;00m modell\u001b[38;5;241m.\u001b[39mvalves)\u001b[38;5;241m+\u001b[39m\u001b[38;5;28msum\u001b[39m(modell\u001b[38;5;241m.\u001b[39mQ_pump[n] \u001b[38;5;28;01mfor\u001b[39;00m n \u001b[38;5;129;01min\u001b[39;00m graph\u001b[38;5;241m.\u001b[39msuccessors(node) \u001b[38;5;28;01mif\u001b[39;00m node \u001b[38;5;129;01min\u001b[39;00m modell\u001b[38;5;241m.\u001b[39mpumps)\n",
+      "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python312\\site-packages\\pyomo\\core\\base\\var.py:999\u001b[0m, in \u001b[0;36mIndexedVar.__getitem__\u001b[1;34m(self, args)\u001b[0m\n\u001b[0;32m    997\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m__getitem__\u001b[39m(\u001b[38;5;28mself\u001b[39m, args) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m VarData:\n\u001b[0;32m    998\u001b[0m     \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 999\u001b[0m         \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43msuper\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[38;5;21;43m__getitem__\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43margs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m   1000\u001b[0m     \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mRuntimeError\u001b[39;00m:\n\u001b[0;32m   1001\u001b[0m         tmp \u001b[38;5;241m=\u001b[39m args \u001b[38;5;28;01mif\u001b[39;00m args\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__class__\u001b[39m \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28mtuple\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m (args,)\n",
+      "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python312\\site-packages\\pyomo\\core\\base\\indexed_component.py:648\u001b[0m, in \u001b[0;36mIndexedComponent.__getitem__\u001b[1;34m(self, index)\u001b[0m\n\u001b[0;32m    646\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(index, EXPR\u001b[38;5;241m.\u001b[39mGetItemExpression):\n\u001b[0;32m    647\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m index\n\u001b[1;32m--> 648\u001b[0m validated_index \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_validate_index\u001b[49m\u001b[43m(\u001b[49m\u001b[43mindex\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m    649\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m validated_index \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m index:\n\u001b[0;32m    650\u001b[0m     index \u001b[38;5;241m=\u001b[39m validated_index\n",
+      "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python312\\site-packages\\pyomo\\core\\base\\indexed_component.py:870\u001b[0m, in \u001b[0;36mIndexedComponent._validate_index\u001b[1;34m(self, idx)\u001b[0m\n\u001b[0;32m    863\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m(\n\u001b[0;32m    864\u001b[0m         \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCannot treat the scalar component \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\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m    865\u001b[0m         \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mas an indexed component\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    866\u001b[0m     )\n\u001b[0;32m    867\u001b[0m \u001b[38;5;66;03m#\u001b[39;00m\n\u001b[0;32m    868\u001b[0m \u001b[38;5;66;03m# Raise an exception\u001b[39;00m\n\u001b[0;32m    869\u001b[0m \u001b[38;5;66;03m#\u001b[39;00m\n\u001b[1;32m--> 870\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m(\n\u001b[0;32m    871\u001b[0m     \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mIndex \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 is not valid for indexed component \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    872\u001b[0m     \u001b[38;5;241m%\u001b[39m (normalized_idx, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mname)\n\u001b[0;32m    873\u001b[0m )\n",
+      "\u001b[1;31mKeyError\u001b[0m: \"Index 'None' is not valid for indexed component 'Q_pump'\""
      ]
     }
    ],
@@ -355,24 +324,9 @@
     "\n",
     "opt = pyo.SolverFactory('scipampl', executable=r'C:\\Program Files\\SCIPOptSuite 9.2.0\\bin\\scip.exe')\n",
     "instance = modell.create_instance(TestData)\n",
+    "\n",
     "result=opt.solve(instance, tee=True)\n"
    ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "opt"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": []
   }
  ],
  "metadata": {