diff --git a/Notebooks/Tutorial - Handling polytopes.ipynb b/Notebooks/Tutorial - Handling polytopes.ipynb index 838eaabaca4f049bff7f60b0398a5ad1377dd0ed..cc362882dcf0dbe298ee92bfeb60f297f5d79c5e 100644 --- a/Notebooks/Tutorial - Handling polytopes.ipynb +++ b/Notebooks/Tutorial - Handling polytopes.ipynb @@ -7,15 +7,15 @@ "# Hi!\n", "Hello and welcome in this tutorial for polytope reconfiguration of music.\n", "\n", - "This work presents a geometrical view for analyzing music, allowing to consider relations between musical elements which don't follow the sequential order.\n", + "This work presents a geometrical view for analyzing music, allowing to consider relations between musical elements which don't follow the sequential order. See [1] for more details.\n", "\n", - "It was developped by C. Guichaoua [1] and C. Louboutin [2], both under the supervision of F. Bimbot.\n", + "It was developped by C. Guichaoua [2] and C. Louboutin [3], both under the supervision of F. Bimbot.\n", "\n", - "[TODO: Add My Own Reference]: In the near future, I will upload a reference (probably on ArXiv) summing up both of their work, detailing their similarities, and presenting some new models, which could help understanding the rest of this notebook. In the meantime, you should refer to the PhD thesis previously referenced.\n", + "[1] Marmoret, A., Cohen, J. E., & Bibmot, F. (2022). Polytopic Analysis of Music. arXiv preprint arXiv:2212.11054.\n", "\n", - "[1] C. Guichaoua, Modèles de compression et critères de complexité pour la description et l’inférence de structure musicale. PhD thesis, 2017.\n", + "[2] Guichaoua, C., Modèles de compression et critères de complexité pour la description et l’inférence de structure musicale. PhD thesis, 2017.\n", "\n", - "[2] C. Louboutin, Modélisation multi-échelle et multi-dimensionnelle de la structure musicale par graphes polytopiques. PhD thesis, Rennes 1, 2019." + "[3] Louboutin, C., Modélisation multi-échelle et multi-dimensionnelle de la structure musicale par graphes polytopiques. PhD thesis, Rennes 1, 2019." ] }, { @@ -56,25 +56,13 @@ "execution_count": 1, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.275357Z", - "start_time": "2022-12-23T23:51:28.165741Z" + "end_time": "2021-02-16T19:47:46.056333Z", + "start_time": "2021-02-16T19:47:44.670040Z" } }, - "outputs": [ - { - "ename": "ModuleNotFoundError", - "evalue": "No module named 'polytopes'", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m<ipython-input-1-1061df01e14a>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mfrom\u001b[0m \u001b[0mpolytopes\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mpattern_factory\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0mpf\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'polytopes'" - ] - } - ], + "outputs": [], "source": [ - "from MusicOnPolytopes import pattern_factory as pf" + "from polytopes import pattern_factory as pf" ] }, { @@ -106,14 +94,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.279347Z", - "start_time": "2022-12-23T23:51:28.170Z" + "end_time": "2021-02-16T19:47:46.079273Z", + "start_time": "2021-02-16T19:47:46.060332Z" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[[[1, 1], [1, 1]], [[1, 1], [1, 1]]]" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Feel free to play with the dimension\n", "pf.make_regular_polytope_pattern(dimension = 3)" @@ -231,14 +230,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.280352Z", - "start_time": "2022-12-23T23:51:28.179Z" + "end_time": "2021-02-16T19:47:46.103213Z", + "start_time": "2021-02-16T19:47:46.085262Z" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[[[1, 1], [1, (1, 1)]], [[1, 1], [1, (1, 1)]]]" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "pf.make_polytope_pattern(dimension = 3, adding_code = [1,0,0], deleting_code = [])" ] @@ -252,14 +262,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.282339Z", - "start_time": "2022-12-23T23:51:28.183Z" + "end_time": "2021-02-16T19:47:46.120163Z", + "start_time": "2021-02-16T19:47:46.109200Z" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[[[0, 1], [2, (3, 4)]], [[5, 6], [7, (8, 9)]]]" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "pf.make_indexed_pattern(dimension = 3, adding_code = [1,0,0], deleting_code = [])" ] @@ -279,14 +300,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.284334Z", - "start_time": "2022-12-23T23:51:28.188Z" + "end_time": "2021-02-16T19:47:46.138115Z", + "start_time": "2021-02-16T19:47:46.123157Z" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[[[0, 1], [2, 3]], [[4, 5]]]" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "#pf.make_polytope_pattern(dimension = 3, adding_code = [], deleting_code = [0,0,1])\n", "pf.make_indexed_pattern(dimension = 3, adding_code = [], deleting_code = [0,0,1])" @@ -303,14 +335,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.286331Z", - "start_time": "2022-12-23T23:51:28.192Z" + "end_time": "2021-02-16T19:47:46.156067Z", + "start_time": "2021-02-16T19:47:46.148091Z" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[[[0, 1], [2, (3, 4)]], [[5, 6]]]" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "#pf.make_polytope_pattern(dimension = 3, adding_code = [1,0,0], deleting_code = [0,0,1])\n", "pf.make_indexed_pattern(dimension = 3, adding_code = [1,0,0], deleting_code = [0,0,1])" @@ -329,14 +372,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.288323Z", - "start_time": "2022-12-23T23:51:28.196Z" + "end_time": "2021-02-16T19:47:46.176020Z", + "start_time": "2021-02-16T19:47:46.165045Z" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[[[[0, 1], [2, 3]], [[4, 5], [6, 7]]],\n", + " [[[8, 9], [10, 11]], [[12, 13], [14, 15]]]]" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "adding_code = [] ### Change values here if needed\n", "deleting_code = [] ### Change values here if needed\n", @@ -354,14 +409,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.289325Z", - "start_time": "2022-12-23T23:51:28.200Z" + "end_time": "2021-02-16T19:47:46.191975Z", + "start_time": "2021-02-16T19:47:46.181998Z" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "30" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "pf.get_final_pattern_size(dimension = 5, adding_code = [1,0,0,1,0], deleting_code = [0,1,0,1,0])" ] @@ -375,14 +441,32 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.290317Z", - "start_time": "2022-12-23T23:51:28.207Z" + "end_time": "2021-02-16T19:47:46.214909Z", + "start_time": "2021-02-16T19:47:46.200948Z" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[([], [0, 0, 0]),\n", + " ([0, 0, 0], [0, 0, 0]),\n", + " ([0, 0, 1], [0, 1, 0]),\n", + " ([0, 0, 1], [1, 0, 0]),\n", + " ([0, 1, 0], [0, 0, 1]),\n", + " ([0, 1, 0], [1, 0, 0]),\n", + " ([1, 0, 0], [0, 0, 1]),\n", + " ([1, 0, 0], [0, 1, 0])]" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# The first element of each tuple is the addition code, the second is the deletion one.\n", "pf.get_codes(7)" @@ -397,14 +481,31 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.291314Z", - "start_time": "2022-12-23T23:51:28.213Z" + "end_time": "2021-02-16T19:47:46.232864Z", + "start_time": "2021-02-16T19:47:46.219897Z" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[([], [0, 0, 0]),\n", + " ([0, 0, 1], [0, 1, 0]),\n", + " ([0, 0, 1], [1, 0, 0]),\n", + " ([0, 1, 0], [0, 0, 1]),\n", + " ([0, 1, 0], [1, 0, 0]),\n", + " ([1, 0, 0], [0, 0, 1]),\n", + " ([1, 0, 0], [0, 1, 0])]" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "pf.get_unique_codes(7)" ] @@ -425,14 +526,29 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.293309Z", - "start_time": "2022-12-23T23:51:28.219Z" + "end_time": "2021-02-16T19:47:46.256799Z", + "start_time": "2021-02-16T19:47:46.236851Z" } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Pattern of ones:\n", + "[[[[1, 1], [1, 1]], [[1, 1], [1, 1]]], [[[1, 1], [1, 1]], [[1, 1], [1, 1]]]]\n", + "\n", + "Previous pattern, indexed:\n", + "[[[[0, 1], [2, 3]], [[4, 5], [6, 7]]], [[[8, 9], [10, 11]], [[12, 13], [14, 15]]]]\n", + "\n", + "Going back to pattern of ones pattern, indexed:\n", + "[[[[1, 1], [1, 1]], [[1, 1], [1, 1]]], [[[1, 1], [1, 1]], [[1, 1], [1, 1]]]]\n" + ] + } + ], "source": [ "pattern_of_ones = pf.make_polytope_pattern(dimension = 4, adding_code = [], deleting_code = [])\n", "print(\"Pattern of ones:\\n{}\\n\".format(pattern_of_ones))\n", @@ -453,14 +569,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.294307Z", - "start_time": "2022-12-23T23:51:28.226Z" + "end_time": "2021-02-16T19:47:46.275747Z", + "start_time": "2021-02-16T19:47:46.264777Z" } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Is [[[[1, 1], [1, 1]], [[1, 1], [1, 1]]], [[[1, 1], [1, 1]], [[1, 1], [1, 1]]]] an indexed pattern?\n", + "False\n", + "\n", + "Is [[[[0, 1], [2, 3]], [[4, 5], [6, 7]]], [[[8, 9], [10, 11]], [[12, 13], [14, 15]]]] an indexed pattern?\n", + "True\n" + ] + } + ], "source": [ "pattern_of_ones = pf.make_polytope_pattern(dimension = 4, adding_code = [], deleting_code = [])\n", "boolean = pf.is_indexed_pattern(pattern_of_ones)\n", @@ -483,14 +611,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.295304Z", - "start_time": "2022-12-23T23:51:28.231Z" + "end_time": "2021-02-16T19:47:46.292703Z", + "start_time": "2021-02-16T19:47:46.281731Z" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[[[[0, 1], [2, 3]], [[4, 5], [6, (7, 8)]]], [[[9, 10]], [[11, 12]]]]" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "pattern = pf.make_indexed_pattern(dimension = 4, adding_code = [1,0,0,0], deleting_code = [0,1,0,1])\n", "pattern" @@ -505,28 +644,50 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.297300Z", - "start_time": "2022-12-23T23:51:28.238Z" + "end_time": "2021-02-16T19:47:46.309656Z", + "start_time": "2021-02-16T19:47:46.297689Z" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "4" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "pf.get_pattern_dimension(pattern)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.299294Z", - "start_time": "2022-12-23T23:51:28.242Z" + "end_time": "2021-02-16T19:47:46.322624Z", + "start_time": "2021-02-16T19:47:46.313645Z" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "13" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "pf.get_pattern_size(pattern)" ] @@ -543,14 +704,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.301288Z", - "start_time": "2022-12-23T23:51:28.248Z" + "end_time": "2021-02-16T19:47:46.350552Z", + "start_time": "2021-02-16T19:47:46.333593Z" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "pf.flatten_pattern(pattern)" ] @@ -564,14 +736,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.302285Z", - "start_time": "2022-12-23T23:51:28.255Z" + "end_time": "2021-02-16T19:47:46.369497Z", + "start_time": "2021-02-16T19:47:46.355534Z" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[0, 1, 2, 3, 4, 5, 6, (7, 8), 9, 10, 11, 12]" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "pf.flatten_nested_list(pattern)" ] @@ -593,14 +776,30 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.304281Z", - "start_time": "2022-12-23T23:51:28.260Z" + "end_time": "2021-02-16T19:47:46.410399Z", + "start_time": "2021-02-16T19:47:46.380475Z" } }, - "outputs": [], + "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", + "The 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", + "\n", + "The 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", @@ -631,11 +830,11 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.305277Z", - "start_time": "2022-12-23T23:51:28.264Z" + "end_time": "2021-02-16T19:47:46.434327Z", + "start_time": "2021-02-16T19:47:46.428347Z" } }, "outputs": [], @@ -672,14 +871,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.308269Z", - "start_time": "2022-12-23T23:51:28.268Z" + "end_time": "2021-02-16T19:47:46.453271Z", + "start_time": "2021-02-16T19:47:46.437314Z" } }, - "outputs": [], + "outputs": [ + { + "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" + ] + } + ], "source": [ "pattern = pf.make_indexed_pattern(dimension = 3, adding_code = [0,1,0], deleting_code = [])\n", "print(\"Pattern: {} (the same as the right one on the previous figure)\".format(pattern))\n", @@ -703,14 +913,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 21, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.309267Z", - "start_time": "2022-12-23T23:51:28.272Z" + "end_time": "2021-02-16T19:47:46.481198Z", + "start_time": "2021-02-16T19:47:46.462249Z" } }, - "outputs": [], + "outputs": [ + { + "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", + "[0, 0, (1, 0)] is the element: None (should be None, as there is no such element added)\n" + ] + } + ], "source": [ "pattern = pf.make_indexed_pattern(dimension = 3, adding_code = [0,1,0], deleting_code = [])\n", "print(\"Pattern: {} (the same as before)\".format(pattern))\n", @@ -755,23 +977,20 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 22, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.449519Z", - "start_time": "2022-12-23T23:51:28.418601Z" + "end_time": "2021-02-16T19:47:46.504136Z", + "start_time": "2021-02-16T19:47:46.487183Z" } }, "outputs": [ { - "ename": "NameError", - "evalue": "name 'pf' is not defined", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m<ipython-input-2-aad02dca8042>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mpattern\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmake_indexed_pattern\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdimension\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;36m3\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0madding_code\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdeleting_code\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m0\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[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[0mant_elt\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpm\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_antecedents_from_element\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m3\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mpattern\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Antecedents of the element 3: {}\"\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mant_elt\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[0;32m 5\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;31mNameError\u001b[0m: name 'pf' is not defined" + "name": "stdout", + "output_type": "stream", + "text": [ + "Antecedents of the element 3: [1, 2]\n", + "Antecedents of the element [0,1,1]: [1, 2]\n" ] } ], @@ -794,14 +1013,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.453508Z", - "start_time": "2022-12-23T23:51:28.283Z" + "end_time": "2021-02-16T19:47:46.523085Z", + "start_time": "2021-02-16T19:47:46.511117Z" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[[0, 0, 1], [0, 1, 0]]" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "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" @@ -818,14 +1048,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 24, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.456502Z", - "start_time": "2022-12-23T23:51:28.289Z" + "end_time": "2021-02-16T19:47:46.540041Z", + "start_time": "2021-02-16T19:47:46.528075Z" } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Element: 6, antecedent: 1, pivot: 5\n" + ] + } + ], "source": [ "pattern = pf.make_indexed_pattern(dimension = 3, adding_code = [1,0,0], deleting_code = [0,0,1])\n", "\n", @@ -845,14 +1083,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 25, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.458500Z", - "start_time": "2022-12-23T23:51:28.293Z" + "end_time": "2021-02-16T19:47:46.552008Z", + "start_time": "2021-02-16T19:47:46.544030Z" } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[(1, 5), (5, 1)]" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "pm.get_antecedents_with_pivots_from_index(elt_idx, pattern)" ] @@ -868,14 +1117,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 26, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.461491Z", - "start_time": "2022-12-23T23:51:28.298Z" + "end_time": "2021-02-16T19:47:46.586915Z", + "start_time": "2021-02-16T19:47:46.561982Z" } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "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" + ] + } + ], "source": [ "pattern = pf.make_indexed_pattern(dimension = 3, adding_code = [1,0,0], deleting_code = [0,0,1])\n", "\n", @@ -920,14 +1179,41 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.463480Z", - "start_time": "2022-12-23T23:51:28.305Z" + "end_time": "2021-02-16T19:47:46.632796Z", + "start_time": "2021-02-16T19:47:46.594893Z" } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Pattern: [[[[0, 1], [2, 3]], [[4, 5], [(6, 7), (8, 9)]]], [[[10, 11], [12, 13]], [[14, 15]]]]\n", + "\n", + "PPP 0 of this pattern:\n", + "[[[[0, 1], [2, 3]], [[4, 5], [(6, 7), (8, 9)]]], [[[10, 11], [12, 13]], [[14, 15]]]]\n", + "\n", + "PPP 1 of this pattern:\n", + "[[[[0, 1], [4, 5]], [[2, 3], [(6, 7), (8, 9)]]], [[[10, 11], [14, 15]], [[12, 13]]]]\n", + "\n", + "PPP 2 of this pattern:\n", + "[[[[0, 1], [10, 11]], [[2, 3], [12, 13]]], [[[4, 5], [14, 15]], [[(6, 7), (8, 9)]]]]\n", + "\n", + "PPP 3 of this pattern:\n", + "[[[[0, 2], [4, (6, 7)]], [[1, 3], [5, (8, 9)]]], [[[10, 12], [14]], [[11, 13], [15]]]]\n", + "\n", + "PPP 4 of this pattern:\n", + "[[[[0, 2], [10, 12]], [[1, 3], [11, 13]]], [[[4, (6, 7)], [14]], [[5, (8, 9)], [15]]]]\n", + "\n", + "PPP 5 of this pattern:\n", + "[[[[0, 4], [10, 14]], [[1, 5], [11, 15]]], [[[2, (6, 7)], [12]], [[3, (8, 9)], [13]]]]\n", + "\n" + ] + } + ], "source": [ "pattern = pf.make_indexed_pattern(dimension = 4, adding_code = [1,0,0,1], deleting_code = [0,0,0,1])\n", "print(\"Pattern: {}\\n\".format(pattern))\n", @@ -966,11 +1252,11 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 28, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.465478Z", - "start_time": "2022-12-23T23:51:28.312Z" + "end_time": "2021-02-16T19:47:46.647755Z", + "start_time": "2021-02-16T19:47:46.639774Z" } }, "outputs": [], @@ -990,14 +1276,30 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 29, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.467470Z", - "start_time": "2022-12-23T23:51:28.315Z" + "end_time": "2021-02-16T19:47:47.259117Z", + "start_time": "2021-02-16T19:47:46.652739Z" } }, - "outputs": [], + "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", @@ -1037,14 +1339,31 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 30, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.469465Z", - "start_time": "2022-12-23T23:51:28.320Z" + "end_time": "2021-02-16T19:47:47.960241Z", + "start_time": "2021-02-16T19:47:47.261111Z" } }, - "outputs": [], + "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", @@ -1073,11 +1392,11 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 31, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.471461Z", - "start_time": "2022-12-23T23:51:28.324Z" + "end_time": "2021-02-16T19:47:47.965228Z", + "start_time": "2021-02-16T19:47:47.961239Z" } }, "outputs": [], @@ -1096,11 +1415,11 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 32, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.473454Z", - "start_time": "2022-12-23T23:51:28.329Z" + "end_time": "2021-02-16T19:47:47.992156Z", + "start_time": "2021-02-16T19:47:47.967223Z" } }, "outputs": [], @@ -1111,14 +1430,32 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 33, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.475449Z", - "start_time": "2022-12-23T23:51:28.333Z" + "end_time": "2021-02-16T19:49:55.034936Z", + "start_time": "2021-02-16T19:47:47.994151Z" } }, - "outputs": [], + "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", @@ -1127,14 +1464,42 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 34, "metadata": { "ExecuteTime": { - "end_time": "2022-12-23T23:51:28.476446Z", - "start_time": "2022-12-23T23:51:28.337Z" + "end_time": "2021-02-16T19:58:12.753991Z", + "start_time": "2021-02-16T19:49:55.036933Z" } }, - "outputs": [], + "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", diff --git a/Notebooks/Tutorial - model classes.ipynb b/Notebooks/Tutorial - model classes (deprecated, not used in practice).ipynb similarity index 99% rename from Notebooks/Tutorial - model classes.ipynb rename to Notebooks/Tutorial - model classes (deprecated, not used in practice).ipynb index c8fc8565cc2fb698645f3a5fcabe60046bc7201e..8d801bed20b3255307502b8a9ee03fa45f2f37eb 100644 --- a/Notebooks/Tutorial - model classes.ipynb +++ b/Notebooks/Tutorial - model classes (deprecated, not used in practice).ipynb @@ -2109,13 +2109,6 @@ "source": [ "polytope.get_list_of_numbers()" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": {