diff --git a/Notebooks/Tutorial - Handling polytopes.ipynb b/Notebooks/Tutorial - Handling polytopes.ipynb
index 1d1d79c9c861dac35d89720950189b817d5ef02a..984fe7f517d04884a7f5acf1f46eff3c8bc86d02 100644
--- a/Notebooks/Tutorial - Handling polytopes.ipynb	
+++ b/Notebooks/Tutorial - Handling polytopes.ipynb	
@@ -27,7 +27,7 @@
     "\n",
     "Then you should put all this in a folder, at a given path (noted /path/to/package).\n",
     "\n",
-    "Finally, you should open a bash shell (on Linux distribution) or an anaconda prompt (on Windows) and type: `pip install -e /path/to/package`."
+    "Finally, you should open a console (on Linux distribution) or an anaconda prompt (on Windows) and type: `pip install -e /path/to/package`."
    ]
   },
   {
@@ -56,8 +56,8 @@
    "execution_count": 1,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:57.792955Z",
-     "start_time": "2021-02-05T13:32:56.530489Z"
+     "end_time": "2021-02-16T19:47:46.056333Z",
+     "start_time": "2021-02-16T19:47:44.670040Z"
     }
    },
    "outputs": [],
@@ -70,7 +70,7 @@
    "metadata": {},
    "source": [
     "We define two types of patterns: \n",
-    "- \"patterns of ones\", which act as the skeleton of the polytope: every vertex/element in the neseted lists is 1, and represent a genereic element. It is useful to consider the pattern as a whole and when differntiating elements isn't necesseray (for example, evaluating each nested pattern for its shape and not its content).\n",
+    "- \"patterns of ones\", which act as the skeleton of the polytope: every vertex/element in the nested lists is 1, and represent a generic element. It is useful for considering the pattern as a whole, when differentiating elements isn't necessary (for example, evaluating each nested pattern for its shape and not its content).\n",
     "    - The dimension 1 pattern of ones is [1,1],\n",
     "    - The dimension 2 pattern of ones is the nesting of 2 dim-1 patterns, so [[1,1],[1,1]],\n",
     "    - The dimension 3 pattern of ones is [[[1,1],[1,1]],[[1,1],[1,1]]],\n",
@@ -89,7 +89,7 @@
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "For example, to generate a dim-3 pattern of ones, you can use the code below:"
+    "In the code, generating a dim-3 pattern of ones can be made with the function `make_regular_polytope_pattern`, as presented below:"
    ]
   },
   {
@@ -97,8 +97,8 @@
    "execution_count": 2,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:57.803409Z",
-     "start_time": "2021-02-05T13:32:57.794924Z"
+     "end_time": "2021-02-16T19:47:46.079273Z",
+     "start_time": "2021-02-16T19:47:46.060332Z"
     }
    },
    "outputs": [
@@ -123,11 +123,11 @@
    "metadata": {},
    "source": [
     "## Irregular polytopes and patterns\n",
-    "In the previous part, we presented regular polytopes and patterns, *i.e.* n-dimensional hypercubes. In our model, they represent the core of polytopes, but not the entire story. Indeed, as presented by C. Guichaoua in [1], polytopes are extended by adding and/or deleting some vertices to a n-dimensional hypercubes. The alteration (both addition and deletion) follow the vertices of a m-dimensional polytope, with $m < n - 1$. In that sense, every polytope is a n-dimensional polytope on which some vertices may be deleted, and some other may be added, following the shape of another hypercube. In the case of both addition and deletion, the dimensions of their respective polytopic shape can be of different dimensions. When some vertices are involved with both an addition and a deletion, the deletion has higher priority.\n",
+    "In the previous part, we presented regular polytopes and patterns, *i.e.* n-dimensional hypercubes. In our model, they represent the core of polytopes, but not the entire story. Indeed, as introduced by C. Guichaoua in [1], polytopes are extended by adding and/or deleting some vertices to a n-dimensional hypercubes. The alteration (both addition and deletion) follow the vertices of a m-dimensional polytope, with $m < n - 1$. In that sense, every polytope is a n-dimensional polytope on which some vertices may be deleted, and some other may be added, following the shape of another hypercube. In the case of both addition and deletion, the dimensions of their respective polytopic shape can be of different dimensions. When some vertices are involved with both an addition and a deletion, the deletion has higher priority.\n",
     "\n",
     "To represent a deletion in a pattern, we simply delete the involved elements. For example, the pattern associated with the deletion of an element in a dimension 1 polytope is \"[1]\" (not to confuse with references), and the deletion of the last dim-1 polytope in a dim-3 polytope would be: [[[1,1],[1,1]],[[1,1]]]. (NB: a void dim-1 polytope ([]) will not be displayed).\n",
     "\n",
-    "An addition will be represented by the tuple at the position of the addition, where the first element of the tuple will be the element originally present in the polytope, and the second one will be the added element. In that sense, the pattern associated with the addition of an element in a dimension 1 polytope is \"[1, (1,1)]\", and the addition of a dim-1 polytope in a dim-3 polytope would be: [[[1,1],[1,1]],[[1,1],[(1,1),(1,1)]]]."
+    "An addition will be represented by a tuple at the position of the addition, where the first element of the tuple will be the element originally present in the polytope, and the second one will be the added element. In that sense, the pattern associated with the addition of an element in a dimension 1 polytope is \"[1, (1,1)]\", and the addition of a dim-1 polytope in a dim-3 polytope would be: [[[1,1],[1,1]],[[1,1],[(1,1),(1,1)]]]."
    ]
   },
   {
@@ -135,9 +135,9 @@
    "metadata": {},
    "source": [
     "### Irregularities in practice\n",
-    "In practice, we need to define a modus operandis to construct the irregularities. This is made by encoding the location of additions or deletions in the pattern. This encoding is in fact two lists of booleans (0 or 1) which we call codes.\n",
+    "In practice, we need a procedure to construct the irregularities. This is made by encoding the location of additions or deletions in the pattern. This encoding is in fact two lists of booleans (0 or 1) which we call codes.\n",
     "\n",
-    "Codes are constructed to indicate where and how many positions need to be altered. Even though each element in the polytope can be specified by dichotomy (by construction, by concatenating two polytopes when increasing the dimension, see part \"Antecedents\"), **the goal of codes here is not to indicate individually each position which need to be altered**. \n",
+    "Codes are constructed to indicate where and how many positions need to be altered. Even though each element in the polytope can be specified by dichotomy (dim-n polytope are recursively constructed as the concatenation of two dim-(n-1) polytopes, see part \"Antecedents\"), **the goal of codes here is not to indicate individually each position which need to be altered**. They rather follow a procedure, defined below:\n",
     "\n",
     "- Codes are related to the notion of dimensions in the nesting:\n",
     "     - The first element of the code (left element, the first in the list) will encode information about the 2 polytopes of dimension n-1\n",
@@ -145,32 +145,85 @@
     "     - The third element of the code will encode information about polytopes at the n-3 dimension\n",
     "     - And so on until the last one, which represent information at the last nesting dimension (so directly on elements)\n",
     "     \n",
-    "- As a dichotomy principle, the alteration will be propagated with binary rules at each dimension:\n",
+    "- At each dimension, the boolean indicates the propagation of the alteration, as a binary rule:\n",
     "     - If the current boolean is a 1, this alteration will affect both nested polytopes.\n",
     "     - If the current boolean is a 0, this alteration will only affect the second nested polytope, the one \"on the right\" (geometrically).\n",
     "\n",
-    "- In that sense, at every dimension, if the current boolean is 0, the code will only be propagated to the 2nd nested polytope, and the 1st nested polytope will be left without alteration. Otherwise, if it's a 1, the rest of the code will be copied to both polytopes of lower dimension.\n",
+    "     In that sense, at every dimension, if the current boolean is 0, the code will only be propagated to the 2nd nested polytope, and the 1st nested polytope will be left without alteration. Otherwise, if it's a 1, the rest of the code will be copied to both polytopes of lower dimension.\n",
     "\n",
-    "- At the last level, a 0 will indicate to alter only the 2nd polytope (so the element on the right), and a 1 will indicate to alter both. Hence, a code composed of zeroes ([0,0,...,0]) will still alter the last element! To specify \"no alteration at all\", code must be an empty list.\n",
     "\n",
-    "In that sense, by dichotomy, we specify, for each dimension, to which part of the nesting alteration should be propagated (both or only the second part). As it is a dichotomy principle, codes have to be of the same length than the dimension of the polytope.\n",
+    "- At the last level, a 0 will indicate to alter only the 2nd polytope (so the element on the right), and a 1 will indicate to alter both, as presented before.\n",
+    "> A consequence of that rule is that a code composed of zeroes ([0,0,...,0]) will still alter the last element! To specify \"no alteration at all\", code must be an empty list.\n",
     "\n",
-    "In addition, the number of \"1\" in the code define the dimension of the alteration polytope.\n",
+    "Finally, we specify, for each dimension, to which part of the nesting alteration should be propagated (both or only the second part). Hence, codes are of the same length as the dimension of the polytope.\n",
     "\n",
-    "Here is an illustration on a dim-3 polytope.\n",
+    "In addition, the number of \"1\" in the code is exactly the dimension of the alteration polytope."
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "#### Illustration on a dim-3 polytope\n",
+    "\n",
+    "Let's illustrate this procedure with an example: a dim-3 polytope with code [0,1,0].\n",
+    "\n",
+    "<img src=\"imgs/code_first_presentation.png\" width=\"500\"/>\n",
     "\n",
-    "<img src=\"imgs/code_gif.gif\" width=\"700\"/>\n"
+    "At this level, the boolean being a 0, we will propagate the alteration code to the 2nd dim-(n-1) polytope *only*, so the first dim-(n-1) polytope will remain unaltered.\n",
+    "\n",
+    "<img src=\"imgs/code_2.png\" width=\"700\"/>"
    ]
   },
   {
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "Let's play with codes a little bit. For example, let's consider a polytope of dimension 3, with an addition and no deletion. The additional polytope is of dimension 1 (so 2 elements, and a unique 1 in the code), and should occur on the last elements of both nested dimension 2 polytopes. It corresponds to the following polytope:\n",
+    "Hence, the only polytope to alter will be the polytope $(a_4, a_5, a_6, a_7)$, with the code [1,0] (the remaining part of the original code, the first boolean (0) being used at the previous level). It is a recursive process.\n",
+    "\n",
+    "<img src=\"imgs/code_second_level.png\" width=\"500\"/>\n",
+    "\n",
+    "The boolean being 1 at this level, we will propagate alteration in both nested polytopes, as presented below:\n",
+    "\n",
+    "<img src=\"imgs/code_4.png\" width=\"700\"/>"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "This will propagate the remaining part of the code ([0]) on both polytopes, as presented below:\n",
+    "\n",
+    "<img src=\"imgs/code_last_level.png\" width=\"500\"/>\n",
+    "\n",
+    "In this case, the boolean 0 indicates to only alter the second dim-0 elements, but on both dim-1 polytopes ($(a_4, a_5)$ and $(a_6, a_7)$) as the code was propagated to both of them in the previous stage.\n",
+    "\n",
+    "<img src=\"imgs/code_6.png\" width=\"700\"/>\n",
+    "\n",
+    "Hence, the code [0,1,0] on a dim-3 polytope will alter elements $a_5$ and $a_7$."
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "Finally, an important point is that codes remain the same for addition and deletion, as they only impact position. Then, depending on the chosen alteration, the previous code can result in two polytopes, presented below:\n",
+    "\n",
+    "<img src=\"imgs/code_7.png\" width=\"700\"/>\n",
+    "\n",
+    "NB: elements in green are elements with new indexes, as addition/deletion changes their order."
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "#### Some examples, along with the code\n",
+    "Let's play with codes a little bit. For example, let's consider a polytope of dimension 3, with an addition and no deletion. The additional polytope is of dimension 1 (so 2 elements, and a unique 1 in the code), and should occur on the last elements of both nested dim-2 polytopes. It corresponds to the following polytope:\n",
     "\n",
     "<img src=\"imgs/dim_3_add_100_del_.png\" width=\"200\"/>\n",
     "\n",
-    "To represent the addition, we shall propagate addition in both dimension-2 polytopes, but in no other level. The code is hence a 1 for the dimension 2 level of nesting (so the first boolean element), and 0 for all the others, so: [1,0,0].\n",
+    "To represent the addition, we shall propagate addition in both dim-2 polytopes, but in no other level. The code is hence a 1 for the dimension 2 level of nesting (so the first boolean element), and 0 for all the others, so: [1,0,0].\n",
     "\n",
     "As there is no deletion, the code should be null, so the deleting code will be an empty list: []."
    ]
@@ -180,8 +233,8 @@
    "execution_count": 3,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:57.811387Z",
-     "start_time": "2021-02-05T13:32:57.805403Z"
+     "end_time": "2021-02-16T19:47:46.103213Z",
+     "start_time": "2021-02-16T19:47:46.085262Z"
     }
    },
    "outputs": [
@@ -212,8 +265,8 @@
    "execution_count": 4,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:57.818369Z",
-     "start_time": "2021-02-05T13:32:57.813382Z"
+     "end_time": "2021-02-16T19:47:46.120163Z",
+     "start_time": "2021-02-16T19:47:46.109200Z"
     }
    },
    "outputs": [
@@ -236,11 +289,11 @@
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "Let's now consider the polytope of dimension 3, where the last 2 elements are deleted. The alteration polytope is of dimension 1 (so 2 elements, and a unique 1 in the code), and should occur on the last elements of both nested dimension 0 polytopes (last two elements). It corresponds to the following polytope:\n",
+    "Let's now consider the polytope of dimension 3, where the last 2 elements are deleted. The alteration polytope is of dimension 1 (so 2 elements, and a unique 1 in the code), and should occur on the last elements of both nested dim-0 polytopes (last two elements). It corresponds to the following polytope:\n",
     "\n",
     "<img src=\"imgs/dim_3_add_del_001.png\" width=\"200\"/>\n",
     "\n",
-    "To represent the deletion, we shall only propagate addition in the last dimension-0 polytopes, but in no other level. The code is hence a 1 for the dimension 0 level of nesting (so the last boolean element), and 0 for all the others, so: [0,0,1].\n",
+    "To represent the deletion, we shall only propagate addition in the last dim-0 polytopes, but in no other level. The code is hence a 1 for the dimension 0 level of nesting (so the last boolean element), and 0 for all the others, so: [0,0,1].\n",
     "\n",
     "As there is no addition, the code should be null, so the addition code will be an empty list: []."
    ]
@@ -250,8 +303,8 @@
    "execution_count": 5,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:57.825368Z",
-     "start_time": "2021-02-05T13:32:57.820363Z"
+     "end_time": "2021-02-16T19:47:46.138115Z",
+     "start_time": "2021-02-16T19:47:46.123157Z"
     }
    },
    "outputs": [
@@ -275,7 +328,7 @@
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "Mixing both previous codes result in a polytope where the first dimension-2 polytope has an addition, and the second has its last two elements deleted (because deletion has higher priority than addition, by construction). It corresponds to the following polytope:\n",
+    "Mixing both previous codes result in a polytope where the first dim-2 polytope has an addition, and the second has its last two elements deleted (because deletion has higher priority than addition, by construction). It corresponds to the following polytope:\n",
     "\n",
     "<img src=\"imgs/dim_3_add_100_del_001.png\" width=\"200\"/>"
    ]
@@ -285,8 +338,8 @@
    "execution_count": 6,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:57.835326Z",
-     "start_time": "2021-02-05T13:32:57.828342Z"
+     "end_time": "2021-02-16T19:47:46.156067Z",
+     "start_time": "2021-02-16T19:47:46.148091Z"
     }
    },
    "outputs": [
@@ -310,7 +363,7 @@
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "Finally, an example of a dimension-4 polytope, with a dimension 2 deletion and no addition is given below: \n",
+    "Finally, an example of a dim-4 polytope, with a dimension 2 deletion and no addition is given below: \n",
     "\n",
     "<img src=\"imgs/dim_4_add_del_0110.png\" width=\"600\"/>\n",
     "\n",
@@ -322,8 +375,8 @@
    "execution_count": 7,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:57.844300Z",
-     "start_time": "2021-02-05T13:32:57.838316Z"
+     "end_time": "2021-02-16T19:47:46.176020Z",
+     "start_time": "2021-02-16T19:47:46.165045Z"
     }
    },
    "outputs": [
@@ -359,8 +412,8 @@
    "execution_count": 8,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:57.851280Z",
-     "start_time": "2021-02-05T13:32:57.845296Z"
+     "end_time": "2021-02-16T19:47:46.191975Z",
+     "start_time": "2021-02-16T19:47:46.181998Z"
     }
    },
    "outputs": [
@@ -391,8 +444,8 @@
    "execution_count": 9,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:57.860258Z",
-     "start_time": "2021-02-05T13:32:57.854275Z"
+     "end_time": "2021-02-16T19:47:46.214909Z",
+     "start_time": "2021-02-16T19:47:46.200948Z"
     }
    },
    "outputs": [
@@ -423,7 +476,7 @@
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "Nonetheless, it can happen that different couples of codes generate the same pattern. In that sense, we developed an additional function, which should be the generic one:"
+    "Nonetheless, it can happen that different couples of codes generate the same pattern. In that sense, the function `get_unique_codes` generates codes resulting in unique patterns. It should be the generic one:"
    ]
   },
   {
@@ -431,8 +484,8 @@
    "execution_count": 10,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:57.868241Z",
-     "start_time": "2021-02-05T13:32:57.861254Z"
+     "end_time": "2021-02-16T19:47:46.232864Z",
+     "start_time": "2021-02-16T19:47:46.219897Z"
     }
    },
    "outputs": [
@@ -476,8 +529,8 @@
    "execution_count": 11,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:57.881202Z",
-     "start_time": "2021-02-05T13:32:57.871227Z"
+     "end_time": "2021-02-16T19:47:46.256799Z",
+     "start_time": "2021-02-16T19:47:46.236851Z"
     }
    },
    "outputs": [
@@ -519,8 +572,8 @@
    "execution_count": 12,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:57.895155Z",
-     "start_time": "2021-02-05T13:32:57.883188Z"
+     "end_time": "2021-02-16T19:47:46.275747Z",
+     "start_time": "2021-02-16T19:47:46.264777Z"
     }
    },
    "outputs": [
@@ -561,8 +614,8 @@
    "execution_count": 13,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:57.905129Z",
-     "start_time": "2021-02-05T13:32:57.897150Z"
+     "end_time": "2021-02-16T19:47:46.292703Z",
+     "start_time": "2021-02-16T19:47:46.281731Z"
     }
    },
    "outputs": [
@@ -586,7 +639,7 @@
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "Two important informations about a pattern are its dimension and its size. Both can be accessed with these functions:"
+    "Two important informations about a pattern are its dimension and its size. Both can be accessed with `get_pattern_dimension` and `get_pattern_size` functions respectively:"
    ]
   },
   {
@@ -594,8 +647,8 @@
    "execution_count": 14,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:57.913107Z",
-     "start_time": "2021-02-05T13:32:57.907124Z"
+     "end_time": "2021-02-16T19:47:46.309656Z",
+     "start_time": "2021-02-16T19:47:46.297689Z"
     }
    },
    "outputs": [
@@ -619,8 +672,8 @@
    "execution_count": 15,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:57.922095Z",
-     "start_time": "2021-02-05T13:32:57.915103Z"
+     "end_time": "2021-02-16T19:47:46.322624Z",
+     "start_time": "2021-02-16T19:47:46.313645Z"
     }
    },
    "outputs": [
@@ -654,8 +707,8 @@
    "execution_count": 16,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:57.932057Z",
-     "start_time": "2021-02-05T13:32:57.926074Z"
+     "end_time": "2021-02-16T19:47:46.350552Z",
+     "start_time": "2021-02-16T19:47:46.333593Z"
     }
    },
    "outputs": [
@@ -686,8 +739,8 @@
    "execution_count": 17,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:57.943028Z",
-     "start_time": "2021-02-05T13:32:57.934052Z"
+     "end_time": "2021-02-16T19:47:46.369497Z",
+     "start_time": "2021-02-16T19:47:46.355534Z"
     }
    },
    "outputs": [
@@ -726,8 +779,8 @@
    "execution_count": 18,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:57.962974Z",
-     "start_time": "2021-02-05T13:32:57.948014Z"
+     "end_time": "2021-02-16T19:47:46.410399Z",
+     "start_time": "2021-02-16T19:47:46.380475Z"
     }
    },
    "outputs": [
@@ -768,7 +821,7 @@
    "metadata": {},
    "source": [
     "# Indexing elements, antecedents and successors\n",
-    "In this part, we will focus on linking and accessing elements in the pattern. More particularily, we will focus on the paradigm developed by C. Guichaoua [1]. In this paradigm, elements are studied in comparison with the previous ones. In that sense, we need to know the position of each element, and to be able to compare this position with others.\n",
+    "In this part, we will focus on linking and accessing elements in the pattern. More particularly, we will focus on the paradigm developed by C. Guichaoua [1]. In this paradigm, elements are studied in comparison with the previous ones. In that sense, we need to know the position of each element, and to be able to compare this position with others.\n",
     "\n",
     "**Disclaimer: as we need to access to particular elements, all patterns will have to be indexed ones.**\n",
     "\n",
@@ -780,8 +833,8 @@
    "execution_count": 19,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:57.971954Z",
-     "start_time": "2021-02-05T13:32:57.966963Z"
+     "end_time": "2021-02-16T19:47:46.434327Z",
+     "start_time": "2021-02-16T19:47:46.428347Z"
     }
    },
    "outputs": [],
@@ -809,11 +862,11 @@
    "source": [
     "A special case appears for additions in the polytope, because we need to specify which element on the added edge we are studying. Similarly to addition in patterns, we use tuples to indicate which element we are looking at. To remain consistent with the dichotomy principle, the tuple contains two booleans, the first one indicating the position of the edge in the last dimension (as for any other element), and the second representing the position of the element on the edge (0 for left, *i.e.* the original element, and 1 for the right, *i.e.* the added element).\n",
     "\n",
-    "Using a tuple has the advantage of specifying that we're dealing with an addition, and not another dimension. In addition, indexes still contains $d$ elements (with $d$ the dimension), with the last element being a tuple with two booleans rather than a unique boolean.\n",
+    "Using a tuple has the advantage of specifying that we're dealing with an addition, and not another dimension. Furthermore, indexes still contains $d$ elements (with $d$ the dimension), with the last element being a tuple with two booleans rather than a unique boolean.\n",
     "\n",
     "<img src=\"imgs/indexes_examples.png\" width=\"700\"/>\n",
     "\n",
-    "In both cases, one should use function ``get_index_of_element``, as shown below"
+    "In both cases, one should use function ``get_index_from_element``, as shown below:"
    ]
   },
   {
@@ -821,8 +874,8 @@
    "execution_count": 20,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:57.983919Z",
-     "start_time": "2021-02-05T13:32:57.976938Z"
+     "end_time": "2021-02-16T19:47:46.453271Z",
+     "start_time": "2021-02-16T19:47:46.437314Z"
     }
    },
    "outputs": [
@@ -830,6 +883,7 @@
      "name": "stdout",
      "output_type": "stream",
      "text": [
+      "Pattern: [[[0, 1], [2, 3]], [[4, (5, 6)], [7, (8, 9)]]] (the same as the right one on the previous figure)\n",
       "a_3 has index: [0, 1, 1]\n",
       "a_5 has index: [1, 0, (1, 0)]\n",
       "a_6 has index: [1, 0, (1, 1)]\n"
@@ -838,13 +892,15 @@
    ],
    "source": [
     "pattern = pf.make_indexed_pattern(dimension = 3, adding_code = [0,1,0], deleting_code = [])\n",
-    "ind_three = pm.get_index_of_element(3, pattern)\n",
+    "print(\"Pattern: {} (the same as the right one on the previous figure)\".format(pattern))\n",
+    "\n",
+    "ind_three = pm.get_index_from_element(3, pattern)\n",
     "print(\"a_3 has index: {}\".format(ind_three))\n",
     "\n",
-    "ind_five = pm.get_index_of_element(5, pattern)\n",
+    "ind_five = pm.get_index_from_element(5, pattern)\n",
     "print(\"a_5 has index: {}\".format(ind_five))\n",
     "\n",
-    "ind_six = pm.get_index_of_element(6, pattern)\n",
+    "ind_six = pm.get_index_from_element(6, pattern)\n",
     "print(\"a_6 has index: {}\".format(ind_six))"
    ]
   },
@@ -852,7 +908,7 @@
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "The inverse operation also exists, with the function ``get_element_with_index``:"
+    "The inverse operation also exists, with the function ``get_element_from_index``:"
    ]
   },
   {
@@ -860,8 +916,8 @@
    "execution_count": 21,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:57.997883Z",
-     "start_time": "2021-02-05T13:32:57.988905Z"
+     "end_time": "2021-02-16T19:47:46.481198Z",
+     "start_time": "2021-02-16T19:47:46.462249Z"
     }
    },
    "outputs": [
@@ -869,6 +925,7 @@
      "name": "stdout",
      "output_type": "stream",
      "text": [
+      "Pattern: [[[0, 1], [2, 3]], [[4, (5, 6)], [7, (8, 9)]]] (the same as before)\n",
       "[0,1,1] is the element: 3\n",
       "[1, 0, (1, 0)] is the element: 5\n",
       "[1, 0, (1, 0)] is the element: 6\n",
@@ -878,16 +935,18 @@
    ],
    "source": [
     "pattern = pf.make_indexed_pattern(dimension = 3, adding_code = [0,1,0], deleting_code = [])\n",
-    "element = pm.get_element_with_index([0,1,1], pattern)\n",
+    "print(\"Pattern: {} (the same as before)\".format(pattern))\n",
+    "\n",
+    "element = pm.get_element_from_index([0,1,1], pattern)\n",
     "print(\"[0,1,1] is the element: {}\".format(element))\n",
     "\n",
-    "element = pm.get_element_with_index([1, 0, (1, 0)], pattern)\n",
+    "element = pm.get_element_from_index([1, 0, (1, 0)], pattern)\n",
     "print(\"[1, 0, (1, 0)] is the element: {}\".format(element))\n",
     "\n",
-    "element = pm.get_element_with_index([1, 0, (1, 1)], pattern)\n",
+    "element = pm.get_element_from_index([1, 0, (1, 1)], pattern)\n",
     "print(\"[1, 0, (1, 0)] is the element: {}\".format(element))\n",
     "\n",
-    "element = pm.get_element_with_index([0, 0, (1, 1)], pattern)\n",
+    "element = pm.get_element_from_index([0, 0, (1, 1)], pattern)\n",
     "print(\"[0, 0, (1, 0)] is the element: {} (should be None, as there is no such element added)\".format(element))"
    ]
   },
@@ -913,7 +972,7 @@
     "\n",
     "> NB: the definition of antecedents in [1] is wider, including every element originating an oriented *path* to the current one. In that definition, $a_0$ would be antecedent of every element. We didn't followed this definition and restricted ourselves with \"direct\" antecedents, *i.e.* element spawning a direct arrow with the current element.\n",
     "\n",
-    "Antecedents of an elements can be computed using the functions ``get_antecedents_from_element`` or ``get_antecedents_from_idx`` depending or whether the studied element is in the form of an element (element 1, 2, 3, etc) or as an index."
+    "Antecedents of an elements can be computed using the functions ``get_antecedents_from_element`` or ``get_antecedents_from_index`` depending or whether the studied element is in the form of an element (element 1, 2, 3, etc) or as an index."
    ]
   },
   {
@@ -921,8 +980,8 @@
    "execution_count": 22,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:58.006856Z",
-     "start_time": "2021-02-05T13:32:57.999876Z"
+     "end_time": "2021-02-16T19:47:46.504136Z",
+     "start_time": "2021-02-16T19:47:46.487183Z"
     }
    },
    "outputs": [
@@ -941,7 +1000,7 @@
     "ant_elt = pm.get_antecedents_from_element(3, pattern)\n",
     "print(\"Antecedents of the element 3: {}\".format(ant_elt))\n",
     "\n",
-    "ant_idx = pm.get_antecedents_from_idx([0,1,1], pattern)\n",
+    "ant_idx = pm.get_antecedents_from_index([0,1,1], pattern)\n",
     "print(\"Antecedents of the element [0,1,1]: {}\".format(ant_idx))"
    ]
   },
@@ -949,7 +1008,7 @@
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "One can also retreive the index of the antecedent from the index of the element, with the function ``get_antecedents_idx_from_idx``:"
+    "One can also retreive the index of the antecedent from the index of the element, with the function ``get_antecedents_index_from_index``:"
    ]
   },
   {
@@ -957,8 +1016,8 @@
    "execution_count": 23,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:58.014836Z",
-     "start_time": "2021-02-05T13:32:58.008851Z"
+     "end_time": "2021-02-16T19:47:46.523085Z",
+     "start_time": "2021-02-16T19:47:46.511117Z"
     }
    },
    "outputs": [
@@ -974,7 +1033,7 @@
     }
    ],
    "source": [
-    "pm.get_antecedents_idx_from_idx([0,1,1])\n",
+    "pm.get_antecedents_index_from_index([0,1,1])\n",
     "# This function does not need the pattern, but some of its outputs may not exist in every pattern"
    ]
   },
@@ -984,7 +1043,7 @@
    "source": [
     "In the paradigm of [1], each antecedent is associated with a \"pivot\" element, in order to construct a square system (implication system of 4 elements) with the primer ($a_0$, the first element of the polytope). In our example above, if we consider the antecedent $a_5$ of $a_6$, its pivot is $a_1$, because it defines a square system $(a_0, a_1, a_5, a_6)$. For further details, the reader should refer to [1] or [TODO: Add My Own Reference].\n",
     "\n",
-    "In the code, this is made with the function ``get_pivot_from_idx`` (NB: the antecedent needs to be under its index form, and it returns the pivot as element, not index):"
+    "In the code, this is made with the function ``get_pivot_from_index`` (NB: the antecedent needs to be under its index form, and it returns the pivot as element, not index):"
    ]
   },
   {
@@ -992,8 +1051,8 @@
    "execution_count": 24,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:58.027800Z",
-     "start_time": "2021-02-05T13:32:58.017836Z"
+     "end_time": "2021-02-16T19:47:46.540041Z",
+     "start_time": "2021-02-16T19:47:46.528075Z"
     }
    },
    "outputs": [
@@ -1009,17 +1068,17 @@
     "pattern = pf.make_indexed_pattern(dimension = 3, adding_code = [1,0,0], deleting_code = [0,0,1])\n",
     "\n",
     "element = 6\n",
-    "elt_idx = pm.get_index_of_element(element, pattern)\n",
-    "ant_idx = pm.get_antecedents_idx_from_idx(elt_idx)[0]\n",
-    "pivot = pm.get_pivot_from_idx(elt_idx, ant_idx, pattern)\n",
-    "print(\"Element: {}, antecedent: {}, pivot: {}\".format(element, pm.get_element_with_index(ant_idx, pattern), pivot))"
+    "elt_idx = pm.get_index_from_element(element, pattern)\n",
+    "ant_idx = pm.get_antecedents_index_from_index(elt_idx)[0]\n",
+    "pivot = pm.get_pivot_from_index(elt_idx, ant_idx, pattern)\n",
+    "print(\"Element: {}, antecedent: {}, pivot: {}\".format(element, pm.get_element_from_index(ant_idx, pattern), pivot))"
    ]
   },
   {
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "Finally, the function ``get_antecedents_with_pivots_from_idx`` returns couples (as tuples) of antecedents and their pivot from the index of an element:"
+    "Finally, the function ``get_antecedents_with_pivots_from_index`` returns couples (as tuples) of antecedents and their pivot from the index of an element:"
    ]
   },
   {
@@ -1027,8 +1086,8 @@
    "execution_count": 25,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:58.034782Z",
-     "start_time": "2021-02-05T13:32:58.029795Z"
+     "end_time": "2021-02-16T19:47:46.552008Z",
+     "start_time": "2021-02-16T19:47:46.544030Z"
     }
    },
    "outputs": [
@@ -1044,14 +1103,14 @@
     }
    ],
    "source": [
-    "pm.get_antecedents_with_pivots_from_idx(elt_idx, pattern)"
+    "pm.get_antecedents_with_pivots_from_index(elt_idx, pattern)"
    ]
   },
   {
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "The same functions exist for successors of an element, *i.e.* ``get_successors_from_element``, ``get_successors_from_idx``, which returns the successors of an element (under its element form) when, respectively, it's as an element and as an index, and the function `get_successors_idx_from_idx`, which returns the successors of an element under its index form, from the element as an index.\n",
+    "The same functions exist for successors of an element, *i.e.* ``get_successors_from_element``, ``get_successors_from_index``, which returns the successors of an element (under its element form) when, respectively, it's an element and as an index, and the function `get_successors_index_from_index`, which returns the successors of an element under its index form, from the element as an index.\n",
     "\n",
     "For example, to find the successors of $a_1$ (which are $a_3$ and $a_6$), one can use the functions:"
    ]
@@ -1061,8 +1120,8 @@
    "execution_count": 26,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:58.048745Z",
-     "start_time": "2021-02-05T13:32:58.039770Z"
+     "end_time": "2021-02-16T19:47:46.586915Z",
+     "start_time": "2021-02-16T19:47:46.561982Z"
     }
    },
    "outputs": [
@@ -1070,9 +1129,9 @@
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "Successors of 1, as an element: [6, 3]\n",
-      "Successors of 1, as an index: [6, 3]\n",
-      "Successors of [0, 0, 1], as an index: [[1, 0, 1], [0, 1, 1]]\n"
+      "Successors of 1: [6, 3]\n",
+      "Successors of [0, 0, 1]: [6, 3]\n",
+      "Successors of [0, 0, 1]: [[1, 0, 1], [0, 1, 1]]\n"
      ]
     }
    ],
@@ -1081,14 +1140,14 @@
     "\n",
     "element = 1\n",
     "suc_elt_from_elt = pm.get_successors_from_element(element, pattern)\n",
-    "print(\"Successors of {}, as an element: {}\".format(element, suc_elt_from_elt))\n",
+    "print(\"Successors of {}: {}\".format(element, suc_elt_from_elt))\n",
     "\n",
-    "elt_idx = pm.get_index_of_element(element, pattern)\n",
-    "suc_elt_from_idx = pm.get_successors_from_idx(elt_idx, pattern)\n",
-    "print(\"Successors of {}, as an index: {}\".format(element, suc_elt_from_idx))\n",
+    "elt_idx = pm.get_index_from_element(element, pattern)\n",
+    "suc_elt_from_idx = pm.get_successors_from_index(elt_idx, pattern)\n",
+    "print(\"Successors of {}: {}\".format(elt_idx, suc_elt_from_idx))\n",
     "\n",
-    "suc_idx_from_idx = pm.get_successors_idx_from_idx(elt_idx)\n",
-    "print(\"Successors of {}, as an index: {}\".format(elt_idx, suc_idx_from_idx))"
+    "suc_idx_from_idx = pm.get_successors_index_from_index(elt_idx)\n",
+    "print(\"Successors of {}: {}\".format(elt_idx, suc_idx_from_idx))"
    ]
   },
   {
@@ -1096,7 +1155,7 @@
    "metadata": {},
    "source": [
     "# PPP\n",
-    "An interesting paradigm developed in [2] by C. Louboutin is the PPP, for Primer Preserving Permutation. The idea is to look at relation in a non-sequential way, and try to find implication systems which explain a music sequence in a different logic, and with different functions between elements (looking at the first beats of all bars between them, then second beats between them, etc).\n",
+    "An interesting paradigm developed in [2] by C. Louboutin is the PPP, for Primer Preserving Permutation. The idea is to look at relation in a non-sequential way, and try to find implication systems which explain a music sequence in a different logic, and with different functions between elements (for example, looking at the first beats of all bars between them, then second beats between them, etc).\n",
     "\n",
     "In this seminal work, PPP were only defined for regular polytopes, *i.e.* polytopes without alteration, with $2^n$ element ($n$ being the dimension). An illustration example is shown below:\n",
     "\n",
@@ -1109,7 +1168,7 @@
    "source": [
     "This work has been extended to irregular polytopes, and can be used with the function `generate_ppp`, starting from an indexed pattern.\n",
     "\n",
-    "> This extension is not explained here, but is in [TODO: Add My Own Reference] (not released yet, so this document should be updated with the reference when available). In a nutshell, the idea is to define the interesting faces with different couples of edges (seen as vectors), and compute polytope through these faces. In that sense, alteration does not change the paradigm, and are permuted too.\n",
+    "> This extension is not explained here, but is in [TODO: Add My Own Reference]. In a nutshell, the idea is to define the interesting faces with different couples of edges (seen as vectors), and interpret the polytope through these faces. In that sense, alteration does not change the paradigm, and are permuted too.\n",
     "\n",
     "An example of PPP on an irregular polytope is presented in the figure below:\n",
     "\n",
@@ -1123,8 +1182,8 @@
    "execution_count": 27,
    "metadata": {
     "ExecuteTime": {
-     "end_time": "2021-02-05T13:32:58.061711Z",
-     "start_time": "2021-02-05T13:32:58.050739Z"
+     "end_time": "2021-02-16T19:47:46.632796Z",
+     "start_time": "2021-02-16T19:47:46.594893Z"
     }
    },
    "outputs": [
@@ -1164,6 +1223,288 @@
     "for idx, a_ppp in enumerate(all_ppps):\n",
     "    print(\"PPP {} of this pattern:\\n{}\\n\".format(idx, a_ppp))"
    ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Polytopical costs\n",
+    "The goal of this paradigm is to compute costs for musical sequences. This costs are then fed to dynamic programming algorithm, computing a segmentation of the whole music piece.\n",
+    "\n",
+    "Costs are explained in [TODO: Add Own Reference].\n",
+    "\n",
+    "One important notion in these costs is the relation between the musical elements. Indeed, as an edge links two musical elements, it should model a relation between them. Hence, a relation space between the musical elements must be defined.\n",
+    "\n",
+    "In addition, in both paradigms [1] and [2], some elements need to be anticipated from the context. Concretley, this means that some relations of the past of an element are composed to form a new \"virutal\" (anticipated) element. Hence, the aformentioned relation space needs to be ***stable par composition*** (need help here, I only found \"internal binary operation\" in english to say what I want, is this correct?).\n",
+    "\n",
+    "Finally, the relation space needs to be commutative, to simplify the model of implication.\n",
+    "\n",
+    "In this work, we chose to represent musical elements as major or minor chords, and relation between them in the \"circle of triads\". This circle represents every major and minor chords, ordered following the circle of fifths. Minor and major chords are alternated, following the order of relative fifths. It is presented below (from [1]):\n",
+    "\n",
+    "<img src=\"imgs/triad_circle.png\" width=\"400\"/>\n",
+    "\n",
+    "Hence, a relation between two elements wil be the signed rotation (in number of steps) between these two chords.\n",
+    "\n",
+    "It is to be noted that this relation space is limited, and more work should be made on this topic to accurately evaluate the potential of polytopes.\n",
+    "\n",
+    "The file containing the code for computing the costs is the file `polytopical_costs.py`."
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 28,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2021-02-16T19:47:46.647755Z",
+     "start_time": "2021-02-16T19:47:46.639774Z"
+    }
+   },
+   "outputs": [],
+   "source": [
+    "from polytopes import polytopical_costs as pc"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "## Cost defined by C. Guichaoua [1]\n",
+    "The first cost is the one defined by C. Guichaoua in [1], also explained in [TODO: Add Own reference]. In a nutshell, in consists in anticipating elements with their antecedents, and increase the cost by 1 if the element is different than the anticipated one.\n",
+    "\n",
+    "To find the best polytope according to this cost, one can use the function `best_guichaoua_cost_segment`, returning the optimal polytope according to this cost function, along with the resulting cost."
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 29,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2021-02-16T19:47:47.259117Z",
+     "start_time": "2021-02-16T19:47:46.652739Z"
+    }
+   },
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "List of chords:\n",
+      "['Eb', 'Eb', 'Eb', 'Eb', 'Abm', 'Abm', 'Abm', 'Abm', 'E', 'E', 'E', 'E', 'F#', 'F#', 'Eb', 'Eb', 'Abm', 'Abm', 'Abm', 'Abm', 'Abm', 'Abm', 'E', 'Eb', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ab', 'Ebm', 'Ebm', 'Ebm', 'Ebm']\n",
+      "\n",
+      "Optimal pattern:\n",
+      "[[[[[0, 1], [2, 3]], [[4, 5], [6, 7]]], [[[8, 9], [10, 11]], [[12, 13], [14, 15]]]], [[[[16, 17], [18, 19]], [[20, 21], [22, 23]]], [[[(24, 25), (26, 27)], [(28, 29), (30, 31)]], [[(32, 33), (34, 35)]]]]]\n",
+      "Resulting in cost: 12\n",
+      "The optimal pattern, with chords as elements:\n",
+      "[[[[['Eb', 'Eb'], ['Eb', 'Eb']], [['Abm', 'Abm'], ['Abm', 'Abm']]], [[['E', 'E'], ['E', 'E']], [['F#', 'F#'], ['Eb', 'Eb']]]], [[[['Abm', 'Abm'], ['Abm', 'Abm']], [['Abm', 'Abm'], ['E', 'Eb']]], [[[('Ebm', 'Ebm'), ('Ebm', 'Ebm')], [('Ebm', 'Ebm'), ('Ebm', 'Ab')]], [[('Ebm', 'Ebm'), ('Ebm', 'Ebm')]]]]]\n",
+      "\n"
+     ]
+    }
+   ],
+   "source": [
+    "segment = ['Eb', 'Eb', 'Eb', 'Eb', 'Abm', 'Abm', 'Abm', 'Abm', 'E', 'E', 'E', 'E', 'F#', 'F#', 'Eb', 'Eb', 'Abm', 'Abm', 'Abm', 'Abm', 'Abm', 'Abm', 'E', 'Eb', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ab', 'Ebm', 'Ebm', 'Ebm', 'Ebm']\n",
+    "print(\"List of chords:\\n{}\\n\".format(segment))\n",
+    "\n",
+    "cost, pattern = pc.best_guichaoua_cost_segment(segment)\n",
+    "print(\"Optimal pattern:\\n{}\\nResulting in cost: {}\".format(pattern, cost))\n",
+    "\n",
+    "chords_on_pattern = pf.apply_chords_on_pattern(pattern, segment)\n",
+    "print(\"The optimal pattern, with chords as elements:\\n{}\\n\".format(chords_on_pattern))"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "NB: this function can also compute the score with penalties, but they are not presented here. You should refer to [1] and the documentation of this function in order to use them."
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "**Note pour moi-même: check le code.**"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "## Cost of C. Louboutin [2], extended to irregular polytopes\n",
+    "A second cost is the one used in C. Louboutin's paradigm, presented in [2]. The idea of his model is to increase the score according to the \"harmonic\" distance between elements (*i.e.* the distance between chords in the circle of triads). His cost is based on the System and Contrast model, and each cost depends on a PPP.\n",
+    "\n",
+    "As presented before, PPP have been expanded to irregular polytopes, so this cost have been expanded to all irregular polytopes. This new cost, called \"Louboutin cost\", is presented in [TODO: Add Own reference].\n",
+    "\n",
+    "To find the best polytope according to this cost, one can use the function `best_louboutin_cost_segment`, returning the optimal polytope according to this cost function, along with the resulting cost."
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 30,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2021-02-16T19:47:47.960241Z",
+     "start_time": "2021-02-16T19:47:47.261111Z"
+    }
+   },
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "List of chords:\n",
+      "['Eb', 'Eb', 'Eb', 'Eb', 'Abm', 'Abm', 'Abm', 'Abm', 'E', 'E', 'E', 'E', 'F#', 'F#', 'Eb', 'Eb', 'Abm', 'Abm', 'Abm', 'Abm', 'Abm', 'Abm', 'E', 'Eb', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ab', 'Ebm', 'Ebm', 'Ebm', 'Ebm']\n",
+      "\n",
+      "Optimal pattern:\n",
+      "[[[[[0, 1], [2, 3]], [[4, 5], [6, 7]]], [[[8, 9], [10, 11]], [[12, 13], [14, 15]]]], [[[[16, 17], [18, 19]], [[20, 21], [22, 23]]], [[[24, 25], [26, 27]], [[(28, 29), (30, 31)], [(32, 33), (34, 35)]]]]]\n",
+      "Resulting in cost: 63\n",
+      "\n",
+      "The optimal pattern, with chords as elements:\n",
+      "[[[[['Eb', 'Eb'], ['Eb', 'Eb']], [['Abm', 'Abm'], ['Abm', 'Abm']]], [[['E', 'E'], ['E', 'E']], [['F#', 'F#'], ['Eb', 'Eb']]]], [[[['Abm', 'Abm'], ['Abm', 'Abm']], [['Abm', 'Abm'], ['E', 'Eb']]], [[['Ebm', 'Ebm'], ['Ebm', 'Ebm']], [[('Ebm', 'Ebm'), ('Ebm', 'Ab')], [('Ebm', 'Ebm'), ('Ebm', 'Ebm')]]]]]\n",
+      "\n"
+     ]
+    }
+   ],
+   "source": [
+    "segment = ['Eb', 'Eb', 'Eb', 'Eb', 'Abm', 'Abm', 'Abm', 'Abm', 'E', 'E', 'E', 'E', 'F#', 'F#', 'Eb', 'Eb', 'Abm', 'Abm', 'Abm', 'Abm', 'Abm', 'Abm', 'E', 'Eb', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ab', 'Ebm', 'Ebm', 'Ebm', 'Ebm']\n",
+    "print(\"List of chords:\\n{}\\n\".format(segment))\n",
+    "\n",
+    "cost, pattern = pc.best_louboutin_cost_segment(segment)\n",
+    "print(\"Optimal pattern:\\n{}\\nResulting in cost: {}\\n\".format(pattern, cost))\n",
+    "\n",
+    "chords_on_pattern = pf.apply_chords_on_pattern(pattern, segment)\n",
+    "print(\"The optimal pattern, with chords as elements:\\n{}\\n\".format(chords_on_pattern))"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "**Note pour moi-même: check le code (surtout celui-là).**"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Dynamic minimization\n",
+    "Finally, to compute the dynamic minimization on a song, one should use the module `segmentation_algorithms.py`."
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 31,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2021-02-16T19:47:47.965228Z",
+     "start_time": "2021-02-16T19:47:47.961239Z"
+    }
+   },
+   "outputs": [],
+   "source": [
+    "from polytopes import segmentation_algorithms as sa"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "Functions corresponding to the previous models are respectively `dynamic_minimization_guichaoua` and `dynamic_minimization_louboutin`.\n",
+    "\n",
+    "NB: a good practice would be to have only one dynamic minimization function, with costs specified as an argument. This should be made in future versions."
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 32,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2021-02-16T19:47:47.992156Z",
+     "start_time": "2021-02-16T19:47:47.967223Z"
+    }
+   },
+   "outputs": [],
+   "source": [
+    "# 001.manual.simple.seq, from RWC POP\n",
+    "song = ['Abm', 'Abm', 'Abm', 'Abm', 'F#', 'F#', 'F#', 'F#', 'E', 'E', 'E', 'E', 'F#', 'F#', 'F#', 'F#', 'F#', 'F#', 'F#', 'F#', 'Eb', 'Eb', 'Eb', 'Eb', 'Abm', 'Abm', 'Abm', 'Abm', 'E', 'E', 'E', 'E', 'B', 'B', 'B', 'B', 'Eb', 'Eb', 'Eb', 'Eb', 'Abm', 'Abm', 'Abm', 'Abm', 'E', 'E', 'E', 'E', 'F#', 'F#', 'Eb', 'Eb', 'Abm', 'Abm', 'Abm', 'Abm', 'F#', 'F#', 'F#', 'F#', 'C#', 'C#', 'C#', 'C#', 'E', 'E', 'F#', 'F#', 'Abm', 'Abm', 'Abm', 'Abm', 'F#', 'F#', 'F#', 'F#', 'C#', 'C#', 'C#', 'C#', 'E', 'E', 'F#', 'F#', 'Cm', 'Cm', 'Cm', 'Cm', 'Cm', 'Cm', 'Cm', 'F', 'Cm', 'Cm', 'Cm', 'Cm', 'Cm', 'Cm', 'Cm', 'Bb', 'Cm', 'Cm', 'Cm', 'Cm', 'Cm', 'Cm', 'Cm', 'F', 'Ab', 'Ab', 'Bb', 'Bb', 'Cm', 'Cm', 'Cm', 'Cm', 'Ab', 'Ab', 'Ab', 'Ab', 'Eb', 'Eb', 'Eb', 'Eb', 'G', 'G', 'G', 'G', 'Cm', 'Cm', 'Cm', 'Cm', 'Ab', 'Ab', 'Ab', 'Ab', 'Eb', 'Eb', 'Eb', 'Eb', 'G', 'G', 'G', 'G', 'Eb', 'Eb', 'Eb', 'Eb', 'Abm', 'Abm', 'Abm', 'Abm', 'E', 'E', 'E', 'E', 'B', 'B', 'B', 'B', 'Eb', 'Eb', 'Eb', 'Eb', 'Abm', 'Abm', 'Abm', 'Abm', 'E', 'E', 'E', 'E', 'F#', 'F#', 'Eb', 'Eb', 'Abm', 'Abm', 'Abm', 'Abm', 'F#', 'F#', 'F#', 'F#', 'C#', 'C#', 'C#', 'C#', 'E', 'E', 'F#', 'F#', 'Cm', 'Cm', 'Cm', 'Cm', 'Cm', 'Cm', 'Cm', 'F', 'Cm', 'Cm', 'Cm', 'Cm', 'Cm', 'Cm', 'Cm', 'Bb', 'Cm', 'Cm', 'Cm', 'Cm', 'Cm', 'Cm', 'Cm', 'F', 'Ab', 'Ab', 'Bb', 'Bb', 'Cm', 'Cm', 'Cm', 'Cm', 'Ab', 'Ab', 'Ab', 'Ab', 'Eb', 'Eb', 'Eb', 'Eb', 'G', 'G', 'G', 'G', 'Cm', 'Cm', 'Cm', 'Cm', 'Ab', 'Ab', 'Ab', 'Ab', 'Eb', 'Eb', 'Eb', 'Eb', 'G', 'G', 'G', 'G', 'Eb', 'Eb', 'Eb', 'Eb', 'Abm', 'Abm', 'Abm', 'Abm', 'E', 'E', 'E', 'E', 'B', 'B', 'B', 'B', 'Eb', 'Eb', 'Eb', 'Eb', 'Abm', 'Abm', 'Abm', 'Abm', 'E', 'E', 'E', 'E', 'F#', 'F#', 'Eb', 'Eb', 'Abm', 'Abm', 'Abm', 'Abm', 'Abm', 'Abm', 'E', 'Eb', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ab', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'C#', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ebm', 'Ab', 'C#', 'C#', 'F#', 'F#', 'B', 'B', 'E', 'E', 'A', 'A', 'D', 'D', 'Eb', 'Eb', 'Eb', 'Eb', 'Eb', 'Eb', 'Eb', 'Eb', 'Ab', 'Ab', 'Ab', 'Ab', 'Eb', 'Eb', 'Eb', 'Eb', 'G', 'G', 'G', 'G', 'Cm', 'Cm', 'Cm', 'Cm', 'Ab', 'Ab', 'Ab', 'Ab', 'Eb', 'Eb', 'Eb', 'Eb', 'G', 'G', 'G', 'G', 'Eb', 'Eb', 'Eb', 'Eb', 'Abm', 'Abm', 'Abm', 'Abm', 'E', 'E', 'E', 'E', 'B', 'B', 'B', 'B', 'Eb', 'Eb', 'Eb', 'Eb', 'Abm', 'Abm', 'Abm', 'Abm', 'E', 'E', 'E', 'E', 'F#', 'F#', 'Eb', 'Eb', 'Abm', 'Abm', 'Abm', 'Abm', 'E', 'E', 'E', 'E', 'B', 'B', 'B', 'B', 'Eb', 'Eb', 'Eb', 'Eb', 'Abm', 'Abm', 'Abm', 'Abm', 'E', 'E', 'E', 'E', 'F#', 'F#', 'Eb', 'Eb', 'Abm', 'Abm', 'Abm', 'Abm', 'F#', 'F#', 'F#', 'F#', 'C#', 'C#', 'C#', 'C#', 'E', 'E', 'F#', 'F#', 'Abm', 'Abm', 'Abm', 'Abm', 'F#', 'F#', 'F#', 'F#', 'C#', 'C#', 'C#', 'C#', 'E', 'E', 'F#', 'F#', 'F#', 'F#', 'Abm', 'Abm', 'Abm', 'Abm']"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 33,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2021-02-16T19:49:55.034936Z",
+     "start_time": "2021-02-16T19:47:47.994151Z"
+    }
+   },
+   "outputs": [
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "c:\\users\\amarmore\\desktop\\projects\\phd main projects\\on git\\code\\polytopes and relation\\polytopes\\segmentation_algorithms.py:487: UserWarning: No Polytope is available for this size of segment. Trying sequential cost instead.\n",
+      "  warnings.warn(\"No Polytope is available for this size of segment. Trying sequential cost instead.\")\n"
+     ]
+    },
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Frontiers of this algorithm:\n",
+      "[0, 20, 52, 84, 112, 144, 176, 192, 220, 252, 284, 292, 332, 364, 396, 428, 462]\n",
+      "With cost:113.25\n"
+     ]
+    }
+   ],
+   "source": [
+    "# Guichaoua\n",
+    "frontiers, cost = sa.dynamic_minimization_guichaoua(song)\n",
+    "print(\"Frontiers of this algorithm:\\n{}\\nWith cost: {}\".format(frontiers, cost))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 34,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2021-02-16T19:58:12.753991Z",
+     "start_time": "2021-02-16T19:49:55.036933Z"
+    }
+   },
+   "outputs": [
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "c:\\users\\amarmore\\desktop\\projects\\phd main projects\\on git\\code\\polytopes and relation\\polytopes\\segmentation_algorithms.py:616: UserWarning: No Polytope is available for this size of segment. Trying sequential cost instead.\n",
+      "  warnings.warn(\"No Polytope is available for this size of segment. Trying sequential cost instead.\")\n"
+     ]
+    },
+    {
+     "ename": "KeyboardInterrupt",
+     "evalue": "",
+     "output_type": "error",
+     "traceback": [
+      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
+      "\u001b[1;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
+      "\u001b[1;32m<ipython-input-34-49ee1c4a990d>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[1;31m# Louboutin\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mfrontiers\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcost\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0msa\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdynamic_minimization_louboutin\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msong\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      3\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Frontiers of this algorithm:\\n{}\\nWith cost:{}\"\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfrontiers\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcost\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
+      "\u001b[1;32mc:\\users\\amarmore\\desktop\\projects\\phd main projects\\on git\\code\\polytopes and relation\\polytopes\\segmentation_algorithms.py\u001b[0m in \u001b[0;36mdynamic_minimization_louboutin\u001b[1;34m(chord_sequence, min_size, max_size, segment_size_penalty, irregularity_penalty, target_size, persist_patterns)\u001b[0m\n\u001b[0;32m    604\u001b[0m                     \u001b[0mthis_polytope_cost\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0minf\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    605\u001b[0m                     \u001b[1;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ma_pattern\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 606\u001b[1;33m                         \u001b[0mthis_ppp_cost\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpc\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlouboutin_cost_for_a_ppp\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msegment\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0ma_pattern\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0ma_pattern\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m3\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0ma_pattern\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m4\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcurrent_min\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mthis_segment_cost\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    607\u001b[0m                         \u001b[1;32mif\u001b[0m \u001b[0mthis_ppp_cost\u001b[0m \u001b[1;33m<\u001b[0m \u001b[0mthis_polytope_cost\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    608\u001b[0m                             \u001b[0mthis_polytope_cost\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mthis_ppp_cost\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
+      "\u001b[1;32mc:\\users\\amarmore\\desktop\\projects\\phd main projects\\on git\\code\\polytopes and relation\\polytopes\\polytopical_costs.py\u001b[0m in \u001b[0;36mlouboutin_cost_for_a_ppp\u001b[1;34m(segment, a_ppp, pattern_of_ones, reindex, current_min)\u001b[0m\n\u001b[0;32m     54\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     55\u001b[0m     \u001b[0mnew_segment\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpm\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mswap_chord_sequence\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msegment\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mreindex\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 56\u001b[1;33m     \u001b[1;32mreturn\u001b[0m \u001b[0mpolytopic_scale_s_and_c_cost_computation\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnew_segment\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mpattern_of_ones\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcurrent_min\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mcurrent_min\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     57\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     58\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mpolytopic_scale_s_and_c_cost_computation\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msymbol_flow\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mpolytope_pattern\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mextended_s_and_c\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mFalse\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcurrent_min\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0minf\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
+      "\u001b[1;32mc:\\users\\amarmore\\desktop\\projects\\phd main projects\\on git\\code\\polytopes and relation\\polytopes\\polytopical_costs.py\u001b[0m in \u001b[0;36mpolytopic_scale_s_and_c_cost_computation\u001b[1;34m(symbol_flow, polytope_pattern, extended_s_and_c, current_min)\u001b[0m\n\u001b[0;32m     87\u001b[0m         \u001b[1;32mreturn\u001b[0m \u001b[0mrecursive_low_level_splitter_for_s_and_c_cost\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msymbol_flow\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mpolytope_pattern\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mextended_s_and_c\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mextended_s_and_c\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     88\u001b[0m     \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 89\u001b[1;33m         \u001b[0minner_systems_cost\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mrecursive_low_level_splitter_for_s_and_c_cost\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msymbol_flow\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mpolytope_pattern\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mextended_s_and_c\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mextended_s_and_c\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     90\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[0minner_systems_cost\u001b[0m \u001b[1;33m>\u001b[0m \u001b[0mcurrent_min\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     91\u001b[0m             \u001b[1;31m# Cost is already higher than current min, so avoid further computation.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
+      "\u001b[1;32mc:\\users\\amarmore\\desktop\\projects\\phd main projects\\on git\\code\\polytopes and relation\\polytopes\\polytopical_costs.py\u001b[0m in \u001b[0;36mrecursive_low_level_splitter_for_s_and_c_cost\u001b[1;34m(symbol_flow, polytope_pattern, extended_s_and_c)\u001b[0m\n\u001b[0;32m    143\u001b[0m             \u001b[0mcost_first_nested_pattern\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mrecursive_low_level_splitter_for_s_and_c_cost\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msymbol_flow\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[0mpf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_pattern_size\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfirst_nested_pattern\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mfirst_nested_pattern\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mextended_s_and_c\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mextended_s_and_c\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    144\u001b[0m             \u001b[0msecond_nested_pattern\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpolytope_pattern\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 145\u001b[1;33m             \u001b[0mcost_second_nested_pattern\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mrecursive_low_level_splitter_for_s_and_c_cost\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msymbol_flow\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mpf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_pattern_size\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfirst_nested_pattern\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0msecond_nested_pattern\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mextended_s_and_c\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mextended_s_and_c\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    146\u001b[0m             \u001b[1;32mreturn\u001b[0m \u001b[0mcost_first_nested_pattern\u001b[0m \u001b[1;33m+\u001b[0m \u001b[0mcost_second_nested_pattern\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    147\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
+      "\u001b[1;32mc:\\users\\amarmore\\desktop\\projects\\phd main projects\\on git\\code\\polytopes and relation\\polytopes\\polytopical_costs.py\u001b[0m in \u001b[0;36mrecursive_low_level_splitter_for_s_and_c_cost\u001b[1;34m(symbol_flow, polytope_pattern, extended_s_and_c)\u001b[0m\n\u001b[0;32m    141\u001b[0m         \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    142\u001b[0m             \u001b[0mfirst_nested_pattern\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpolytope_pattern\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 143\u001b[1;33m             \u001b[0mcost_first_nested_pattern\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mrecursive_low_level_splitter_for_s_and_c_cost\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msymbol_flow\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[0mpf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_pattern_size\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfirst_nested_pattern\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mfirst_nested_pattern\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mextended_s_and_c\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mextended_s_and_c\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    144\u001b[0m             \u001b[0msecond_nested_pattern\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpolytope_pattern\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    145\u001b[0m             \u001b[0mcost_second_nested_pattern\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mrecursive_low_level_splitter_for_s_and_c_cost\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msymbol_flow\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mpf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_pattern_size\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfirst_nested_pattern\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0msecond_nested_pattern\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mextended_s_and_c\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mextended_s_and_c\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
+      "\u001b[1;32mc:\\users\\amarmore\\desktop\\projects\\phd main projects\\on git\\code\\polytopes and relation\\polytopes\\polytopical_costs.py\u001b[0m in \u001b[0;36mrecursive_low_level_splitter_for_s_and_c_cost\u001b[1;34m(symbol_flow, polytope_pattern, extended_s_and_c)\u001b[0m\n\u001b[0;32m    141\u001b[0m         \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    142\u001b[0m             \u001b[0mfirst_nested_pattern\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpolytope_pattern\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 143\u001b[1;33m             \u001b[0mcost_first_nested_pattern\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mrecursive_low_level_splitter_for_s_and_c_cost\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msymbol_flow\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[0mpf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_pattern_size\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfirst_nested_pattern\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mfirst_nested_pattern\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mextended_s_and_c\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mextended_s_and_c\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    144\u001b[0m             \u001b[0msecond_nested_pattern\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpolytope_pattern\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    145\u001b[0m             \u001b[0mcost_second_nested_pattern\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mrecursive_low_level_splitter_for_s_and_c_cost\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msymbol_flow\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mpf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_pattern_size\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfirst_nested_pattern\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0msecond_nested_pattern\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mextended_s_and_c\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mextended_s_and_c\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
+      "\u001b[1;32mc:\\users\\amarmore\\desktop\\projects\\phd main projects\\on git\\code\\polytopes and relation\\polytopes\\polytopical_costs.py\u001b[0m in \u001b[0;36mrecursive_low_level_splitter_for_s_and_c_cost\u001b[1;34m(symbol_flow, polytope_pattern, extended_s_and_c)\u001b[0m\n\u001b[0;32m    126\u001b[0m     \"\"\"\n\u001b[0;32m    127\u001b[0m     \u001b[1;31m# Computing the cost of elements as the sum of all dim 2 polytopes (excluding primers).\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 128\u001b[1;33m     \u001b[1;32mif\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msymbol_flow\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m!=\u001b[0m \u001b[0mpf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_pattern_size\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mpolytope_pattern\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    129\u001b[0m         \u001b[1;32mraise\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mPatternAndSequenceIncompatible\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Chord sequence and pattern are of different lengths.\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    130\u001b[0m     \u001b[1;32mif\u001b[0m \u001b[0mpf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_pattern_dimension\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mpolytope_pattern\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m<=\u001b[0m \u001b[1;36m2\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
+      "\u001b[1;32mc:\\users\\amarmore\\desktop\\projects\\phd main projects\\on git\\code\\polytopes and relation\\polytopes\\pattern_factory.py\u001b[0m in \u001b[0;36mget_pattern_size\u001b[1;34m(pattern)\u001b[0m\n\u001b[0;32m    654\u001b[0m             \u001b[0msize\u001b[0m \u001b[1;33m+=\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    655\u001b[0m         \u001b[1;32melif\u001b[0m \u001b[0mtype\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mis\u001b[0m \u001b[0mlist\u001b[0m \u001b[1;32mor\u001b[0m \u001b[0mtype\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mis\u001b[0m \u001b[0mtuple\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 656\u001b[1;33m             \u001b[0msize\u001b[0m \u001b[1;33m+=\u001b[0m \u001b[0mget_pattern_size\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    657\u001b[0m     \u001b[1;32mreturn\u001b[0m \u001b[0msize\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    658\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
+      "\u001b[1;31mKeyboardInterrupt\u001b[0m: "
+     ]
+    }
+   ],
+   "source": [
+    "# Louboutin\n",
+    "frontiers, cost = sa.dynamic_minimization_louboutin(song)\n",
+    "print(\"Frontiers of this algorithm:\\n{}\\nWith cost: {}\".format(frontiers, cost))"
+   ]
   }
  ],
  "metadata": {