{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
},
"colab": {
"name": "notebook_1.ipynb",
"provenance": [],
"include_colab_link": true
},
"accelerator": "GPU"
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"
"
]
},
{
"cell_type": "code",
"metadata": {
"id": "LNzvcQYRncpd",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "2db93048-bf8d-44a0-da61-fcdb3eda475d"
},
"source": [
"!git clone https://github.com/abdalazizrashid/AI-Feynman.git"
],
"execution_count": 57,
"outputs": [
{
"output_type": "stream",
"text": [
"fatal: destination path 'AI-Feynman' already exists and is not an empty directory.\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "wY7fcIORnmzR",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 309
},
"outputId": "6548409e-dd85-4bfb-d633-a2747812ce5f"
},
"source": [
"!pip install -r AI-Feynman/requirements.txt"
],
"execution_count": 58,
"outputs": [
{
"output_type": "stream",
"text": [
"Requirement already satisfied: torch in /usr/local/lib/python3.6/dist-packages (from -r AI-Feynman/requirements.txt (line 1)) (1.6.0+cu101)\n",
"Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from -r AI-Feynman/requirements.txt (line 2)) (1.18.5)\n",
"Requirement already satisfied: matplotlib in /usr/local/lib/python3.6/dist-packages (from -r AI-Feynman/requirements.txt (line 3)) (3.2.2)\n",
"Requirement already satisfied: sympy in /usr/local/lib/python3.6/dist-packages (from -r AI-Feynman/requirements.txt (line 4)) (1.1.1)\n",
"Requirement already satisfied: pandas in /usr/local/lib/python3.6/dist-packages (from -r AI-Feynman/requirements.txt (line 5)) (1.0.5)\n",
"Requirement already satisfied: scipy in /usr/local/lib/python3.6/dist-packages (from -r AI-Feynman/requirements.txt (line 6)) (1.4.1)\n",
"Requirement already satisfied: sortedcontainers in /usr/local/lib/python3.6/dist-packages (from -r AI-Feynman/requirements.txt (line 7)) (2.2.2)\n",
"Requirement already satisfied: tabulate in /usr/local/lib/python3.6/dist-packages (from -r AI-Feynman/requirements.txt (line 8)) (0.8.7)\n",
"Requirement already satisfied: future in /usr/local/lib/python3.6/dist-packages (from torch->-r AI-Feynman/requirements.txt (line 1)) (0.16.0)\n",
"Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib->-r AI-Feynman/requirements.txt (line 3)) (2.8.1)\n",
"Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib->-r AI-Feynman/requirements.txt (line 3)) (1.2.0)\n",
"Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.6/dist-packages (from matplotlib->-r AI-Feynman/requirements.txt (line 3)) (0.10.0)\n",
"Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib->-r AI-Feynman/requirements.txt (line 3)) (2.4.7)\n",
"Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.6/dist-packages (from sympy->-r AI-Feynman/requirements.txt (line 4)) (1.1.0)\n",
"Requirement already satisfied: pytz>=2017.2 in /usr/local/lib/python3.6/dist-packages (from pandas->-r AI-Feynman/requirements.txt (line 5)) (2018.9)\n",
"Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.6/dist-packages (from python-dateutil>=2.1->matplotlib->-r AI-Feynman/requirements.txt (line 3)) (1.15.0)\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "Y0gbIW5HnuQl",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 153
},
"outputId": "97fe04fc-c404-47b8-bec3-11d5cf321d19"
},
"source": [
"!cd /content/AI-Feynman/Code/ && ./compile.sh && apt install -y parallel\n"
],
"execution_count": 59,
"outputs": [
{
"output_type": "stream",
"text": [
"Reading package lists... Done\n",
"Building dependency tree \n",
"Reading state information... Done\n",
"parallel is already the newest version (20161222-1).\n",
"The following package was automatically installed and is no longer required:\n",
" libnvidia-common-440\n",
"Use 'apt autoremove' to remove it.\n",
"0 upgraded, 0 newly installed, 0 to remove and 35 not upgraded.\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "Kf05DiVfn1H9",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "ae513c97-4dfd-4528-edc5-c592ecc7caf0"
},
"source": [
"import os\n",
"os.chdir(\"/content/AI-Feynman/Code/\")\n",
"print(os.getcwd())"
],
"execution_count": 8,
"outputs": [
{
"output_type": "stream",
"text": [
"/content/AI-Feynman/Code\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "FuenJ6qWnSa9",
"colab_type": "code",
"colab": {}
},
"source": [
"from S_run_aifeynman import run_aifeynman\n"
],
"execution_count": 61,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "_KzP-ygVOq5s",
"colab_type": "text"
},
"source": [
"## Original Code Example"
]
},
{
"cell_type": "code",
"metadata": {
"id": "rxKF50gnnSbE",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 1000
},
"outputId": "66121f32-cddf-4609-df6e-9be120d0e8e7"
},
"source": [
"%%time\n",
"run_aifeynman(\"../example_data/\",\"example1.txt\",30,\"14ops.txt\", polyfit_deg=3, NN_epochs=400)"
],
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"text": [
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 30.834454019627426, '0']\n",
"[36.83243537730492, 29.12634010089305, cos(x0) + cos(x2 + x3) + 2.333740234375]\n",
"[55.42220420859321, 29.09077077952536, cos(x2 + x3) + 1.88584470748901]\n",
"[63.97127597744305, 28.649814958454094, '1.808310192134*(cos(((x3-x2)/pi)))**(-1)']\n",
"[73.2730466728654, 26.754024113174246, '0.2*x0**2 - 0.444444444444444*x0*x1 + 0.111111111111111*x0 + 0.2*x1**2 + 0.125*x1 + 0.2*x2**2 - 0.444444444444444*x2*x3 + 0.166666666666667*x2 + 0.2*x3**2 + 0.166666666666667*x3 + 0.2']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 30.834454019627426, '0']\n",
"[36.83243537730492, 29.12634010089305, cos(x0) + cos(x2 + x3) + 2.333740234375]\n",
"[46.5605178945111, 27.13368508267342, 1.03779721260071]\n",
"[46.56056711257602, 27.133459108345154, 1.03783261803319]\n",
"[46.56057649641146, 27.13342067603215, 1.03783936851191]\n",
"[46.560576570214884, 27.133420535207133, 1.03783942160429]\n",
"[48.48784302438703, 26.85871313046377, 'tan(0.036548656722*exp(pi))']\n",
"[48.613819620546025, 26.858713124630636, 'tan(0.269214177330*pi)']\n",
"[73.2730466728654, 26.754024113174246, '0.2*x0**2 - 0.444444444444444*x0*x1 + 0.111111111111111*x0 + 0.2*x1**2 + 0.125*x1 + 0.2*x2**2 - 0.444444444444444*x2*x3 + 0.166666666666667*x2 + 0.2*x3**2 + 0.166666666666667*x3 + 0.2']\n",
"[206.23011212397856, 26.70884811651698, tan(0.694796025753021*log(-0.642380475997925*cos(x2 - 1.00466322898865*x3) + 3.26658010482788))]\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 30.834454019627426, '0']\n",
"[36.83243537730492, 29.12634010089305, cos(x0) + cos(x2 + x3) + 2.333740234375]\n",
"[44.620081767607, 28.75693944878952, -0.270385265350342]\n",
"[46.5605178945111, 27.13368508267342, 1.03779721260071]\n",
"[46.56056711257602, 27.133459108345154, 1.03783261803319]\n",
"[46.56057649641146, 27.13342067603215, 1.03783936851191]\n",
"[46.560576570214884, 27.133420535207133, 1.03783942160429]\n",
"[48.48784302438703, 26.85871313046377, 'tan(0.036548656722*exp(pi))']\n",
"[48.613819620546025, 26.858713124630636, 'tan(0.269214177330*pi)']\n",
"[73.2730466728654, 26.754024113174246, '0.2*x0**2 - 0.444444444444444*x0*x1 + 0.111111111111111*x0 + 0.2*x1**2 + 0.125*x1 + 0.2*x2**2 - 0.444444444444444*x2*x3 + 0.166666666666667*x2 + 0.2*x3**2 + 0.166666666666667*x3 + 0.2']\n",
"[206.23011212397856, 26.70884811651698, tan(0.694796025753021*log(-0.642380475997925*cos(x2 - 1.00466322898865*x3) + 3.26658010482788))]\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 30.834454019627426, '0']\n",
"[36.83243537730492, 29.12634010089305, cos(x0) + cos(x2 + x3) + 2.333740234375]\n",
"[44.620081767607, 28.75693944878952, -0.270385265350342]\n",
"[46.5605178945111, 27.13368508267342, 1.03779721260071]\n",
"[46.56056711257602, 27.133459108345154, 1.03783261803319]\n",
"[46.56057649641146, 27.13342067603215, 1.03783936851191]\n",
"[46.560576570214884, 27.133420535207133, 1.03783942160429]\n",
"[48.48784302438703, 26.85871313046377, 'tan(0.036548656722*exp(pi))']\n",
"[48.613819620546025, 26.858713124630636, 'tan(0.269214177330*pi)']\n",
"[73.2730466728654, 26.754024113174246, '0.2*x0**2 - 0.444444444444444*x0*x1 + 0.111111111111111*x0 + 0.2*x1**2 + 0.125*x1 + 0.2*x2**2 - 0.444444444444444*x2*x3 + 0.166666666666667*x2 + 0.2*x3**2 + 0.166666666666667*x3 + 0.2']\n",
"[206.23011212397856, 26.70884811651698, tan(0.694796025753021*log(-0.642380475997925*cos(x2 - 1.00466322898865*x3) + 3.26658010482788))]\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 30.834454019627426, '0']\n",
"[2.584962500721156, 30.42456896678888, '0.333333333333333']\n",
"[32.00876552846736, 28.13821400441772, '1/(-0.934925954011+x1)']\n",
"[46.070972708611805, 28.114455148352643, 0.739170650917556]\n",
"[46.5605178945111, 27.13368508267342, 1.03779721260071]\n",
"[46.56056711257602, 27.133459108345154, 1.03783261803319]\n",
"[46.56057649641146, 27.13342067603215, 1.03783936851191]\n",
"[46.560576570214884, 27.133420535207133, 1.03783942160429]\n",
"[48.48784302438703, 26.85871313046377, 'tan(0.036548656722*exp(pi))']\n",
"[48.613819620546025, 26.858713124630636, 'tan(0.269214177330*pi)']\n",
"[73.2730466728654, 26.754024113174246, '0.2*x0**2 - 0.444444444444444*x0*x1 + 0.111111111111111*x0 + 0.2*x1**2 + 0.125*x1 + 0.2*x2**2 - 0.444444444444444*x2*x3 + 0.166666666666667*x2 + 0.2*x3**2 + 0.166666666666667*x3 + 0.2']\n",
"[206.23011212397856, 26.70884811651698, tan(0.694796025753021*log(-0.642380475997925*cos(x2 - 1.00466322898865*x3) + 3.26658010482788))]\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 30.834454019627426, '0']\n",
"[2.584962500721156, 30.42456896678888, '0.333333333333333']\n",
"[28.865610660795387, 29.201384954099407, -4.89119133556296e-6]\n",
"[32.00876552846736, 28.13821400441772, '1/(-0.934925954011+x1)']\n",
"[46.070972708611805, 28.114455148352643, 0.739170650917556]\n",
"[46.5605178945111, 27.13368508267342, 1.03779721260071]\n",
"[46.56056711257602, 27.133459108345154, 1.03783261803319]\n",
"[46.56057649641146, 27.13342067603215, 1.03783936851191]\n",
"[46.560576570214884, 27.133420535207133, 1.03783942160429]\n",
"[48.48784302438703, 26.85871313046377, 'tan(0.036548656722*exp(pi))']\n",
"[48.613819620546025, 26.858713124630636, 'tan(0.269214177330*pi)']\n",
"[73.2730466728654, 26.754024113174246, '0.2*x0**2 - 0.444444444444444*x0*x1 + 0.111111111111111*x0 + 0.2*x1**2 + 0.125*x1 + 0.2*x2**2 - 0.444444444444444*x2*x3 + 0.166666666666667*x2 + 0.2*x3**2 + 0.166666666666667*x3 + 0.2']\n",
"[206.23011212397856, 26.70884811651698, tan(0.694796025753021*log(-0.642380475997925*cos(x2 - 1.00466322898865*x3) + 3.26658010482788))]\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 30.834454019627426, '0']\n",
"[2.584962500721156, 30.42456896678888, '0.333333333333333']\n",
"[28.865610660795387, 29.201384954099407, -4.89119133556296e-6]\n",
"[28.88485156251213, 29.114959286627403, 'asin(-0.000004956861+(x1*sin(pi)))']\n",
"[29.02302728370149, 29.114941148276046, 'asin(-3.141598108678+pi)']\n",
"[32.00876552846736, 28.13821400441772, '1/(-0.934925954011+x1)']\n",
"[46.070972708611805, 28.114455148352643, 0.739170650917556]\n",
"[46.5605178945111, 27.13368508267342, 1.03779721260071]\n",
"[46.56056711257602, 27.133459108345154, 1.03783261803319]\n",
"[46.56057649641146, 27.13342067603215, 1.03783936851191]\n",
"[46.560576570214884, 27.133420535207133, 1.03783942160429]\n",
"[48.48784302438703, 26.85871313046377, 'tan(0.036548656722*exp(pi))']\n",
"[48.613819620546025, 26.858713124630636, 'tan(0.269214177330*pi)']\n",
"[73.2730466728654, 26.754024113174246, '0.2*x0**2 - 0.444444444444444*x0*x1 + 0.111111111111111*x0 + 0.2*x1**2 + 0.125*x1 + 0.2*x2**2 - 0.444444444444444*x2*x3 + 0.166666666666667*x2 + 0.2*x3**2 + 0.166666666666667*x3 + 0.2']\n",
"[206.23011212397856, 26.70884811651698, tan(0.694796025753021*log(-0.642380475997925*cos(x2 - 1.00466322898865*x3) + 3.26658010482788))]\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 30.834454019627426, '0']\n",
"[2.584962500721156, 30.42456896678888, '0.333333333333333']\n",
"[28.865610660795387, 29.201384954099407, -4.89119133556296e-6]\n",
"[28.88485156251213, 29.114959286627403, 'asin(-0.000004956861+(x1*sin(pi)))']\n",
"[29.02302728370149, 29.114941148276046, 'asin(-3.141598108678+pi)']\n",
"[32.00876552846736, 28.13821400441772, '1/(-0.934925954011+x1)']\n",
"[46.070972708611805, 28.114455148352643, 0.739170650917556]\n",
"[46.5605178945111, 27.13368508267342, 1.03779721260071]\n",
"[46.56056711257602, 27.133459108345154, 1.03783261803319]\n",
"[46.56057649641146, 27.13342067603215, 1.03783936851191]\n",
"[46.560576570214884, 27.133420535207133, 1.03783942160429]\n",
"[48.48784302438703, 26.85871313046377, 'tan(0.036548656722*exp(pi))']\n",
"[48.613819620546025, 26.858713124630636, 'tan(0.269214177330*pi)']\n",
"[73.2730466728654, 26.754024113174246, '0.2*x0**2 - 0.444444444444444*x0*x1 + 0.111111111111111*x0 + 0.2*x1**2 + 0.125*x1 + 0.2*x2**2 - 0.444444444444444*x2*x3 + 0.166666666666667*x2 + 0.2*x3**2 + 0.166666666666667*x3 + 0.2']\n",
"[206.23011212397856, 26.70884811651698, tan(0.694796025753021*log(-0.642380475997925*cos(x2 - 1.00466322898865*x3) + 3.26658010482788))]\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 30.834454019627426, '0']\n",
"[1.0, 29.661717905473818, '1']\n",
"[28.865610660795387, 29.201384954099407, -4.89119133556296e-6]\n",
"[28.88485156251213, 29.114959286627403, 'asin(-0.000004956861+(x1*sin(pi)))']\n",
"[29.02302728370149, 29.114941148276046, 'asin(-3.141598108678+pi)']\n",
"[32.00876552846736, 28.13821400441772, '1/(-0.934925954011+x1)']\n",
"[35.50977500432694, 1.6280023074285465e-06, '(x0**2 - 2*x0*x1 + x1**2 + x2**2 - 2*x2*x3 + x3**2)**0.5']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 30.834454019627426, '0']\n",
"[1.0, 29.661717905473818, '1']\n",
"[28.865610660795387, 29.201384954099407, -4.89119133556296e-6]\n",
"[28.88485156251213, 29.114959286627403, 'asin(-0.000004956861+(x1*sin(pi)))']\n",
"[29.02302728370149, 29.114941148276046, 'asin(-3.141598108678+pi)']\n",
"[32.00876552846736, 28.13821400441772, '1/(-0.934925954011+x1)']\n",
"[35.50977500432694, 1.6280023074285465e-06, '(x0**2 - 2*x0*x1 + x1**2 + x2**2 - 2*x2*x3 + x3**2)**0.5']\n",
"Checking for symmetry \n",
" example1.txt_train\n",
"Training a NN on the data... \n",
"\n",
"tensor(0.0404, device='cuda:0', grad_fn=)\n",
"tensor(0.0282, device='cuda:0', grad_fn=)\n",
"tensor(0.0354, device='cuda:0', grad_fn=)\n",
"tensor(0.0265, device='cuda:0', grad_fn=)\n",
"NN loss: tensor(0.0029, device='cuda:0', grad_fn=) \n",
"\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[47.56309550289244, 29.20117684355327, 2.07930612564087]\n",
"[50.5090504796962, 28.162061596052734, '0.005215765238+sqrt((x2*x2))']\n",
"[53.788821841164236, 27.623981263190988, '0.2*x0**2 - 0.444444444444444*x0*x1 + 0.111111111111111*x0 + 0.2*x1**2 + 0.111111111111111*x1 + 0.2*x2**2 + 0.625']\n",
"[118.35791391022252, 27.41497824744871, -0.971029222011566*cos(x2) + cos(x0 + sin(x1)) + 2.61414766311646]\n",
"[174.23364071878729, 27.411232030672863, '0.2*x0**2 - 0.444444444444444*x0*x1 + 0.117043664748057*x0 + 0.2*x1**2 + 0.111111111111111*x1 + 0.215954831506172*x2**2 + 0.618452302296974']\n",
"[202.75973089793666, 26.4718092017765, -0.971062898635864*cos(x2) - 0.97521698474884*cos(x0 - 0.988607943058014*x1) + 2.4916136264801]\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[26.416665599935456, 31.151831594084907, '-tan(0.1*x0*x1 - 0.625)']\n",
"[40.392864438595524, 29.960782005496213, 'tan(-23.126257072703+exp(pi))']\n",
"[40.393057897115405, 29.960777143296564, 'tan(-3.127155157913+pi)']\n",
"[46.0166311684591, 29.95909299612648, '0.711846380458438']\n",
"[46.5605178945111, 27.13368508267342, 1.03779721260071]\n",
"[46.56056711257602, 27.133459108345154, 1.03783261803319]\n",
"[46.56057649641146, 27.13342067603215, 1.03783936851191]\n",
"[46.560576570214884, 27.133420535207133, 1.03783942160429]\n",
"[46.56058152917947, 27.13339217046357, 1.03784298896790]\n",
"[46.68158917359681, 26.85871306245941, 'tan(-0.845761305278*(x1-(x1+1)))']\n",
"[151.3842928046349, 26.449089073084824, -0.889655292034149*tan(0.102245159447193*cos(x2) - 0.877891777343642)]\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 30.834454019627426, '0']\n",
"[4.0, 30.771263892512106, 'acos(-666.000000000000*(x1-((x1+1)-1)))']\n",
"[13.60964047443681, 30.24841398745967, 'acos(0.000000000038*(x0+exp(exp(pi))))']\n",
"[40.392864438595524, 29.960782005496213, 'tan(-23.126257072703+exp(pi))']\n",
"[40.393057897115405, 29.960777143296564, 'tan(-3.127155157913+pi)']\n",
"[44.620081767607, 28.75693944878952, -0.270385265350342]\n",
"[46.5605178945111, 27.13368508267342, 1.03779721260071]\n",
"[46.56056711257602, 27.133459108345154, 1.03783261803319]\n",
"[46.56057649641146, 27.13342067603215, 1.03783936851191]\n",
"[46.560576570214884, 27.133420535207133, 1.03783942160429]\n",
"[46.56058152917947, 27.13339217046357, 1.03784298896790]\n",
"[46.68158917359681, 26.85871306245941, 'tan(-0.845761305278*(x1-(x1+1)))']\n",
"[151.3842928046349, 26.449089073084824, -0.889655292034149*tan(0.102245159447193*cos(x2) - 0.877891777343642)]\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 30.834454019627426, '0']\n",
"[4.0, 30.771263892512106, 'acos(-666.000000000000*(x1-((x1+1)-1)))']\n",
"[13.60964047443681, 30.24841398745967, 'acos(0.000000000038*(x0+exp(exp(pi))))']\n",
"[39.56224242422107, 27.05989455935905, 'log(3*x0**2 - 6*x0*x1 - x0 + 3*x1**2 - x1 + 3*x2**2)']\n",
"[46.68158917359681, 26.85871306245941, 'tan(-0.845761305278*(x1-(x1+1)))']\n",
"[151.3842928046349, 26.449089073084824, -0.889655292034149*tan(0.102245159447193*cos(x2) - 0.877891777343642)]\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 30.834454019627426, '0']\n",
"[2.0, 30.21233279612709, '0.500000000000000']\n",
"[32.00876552846736, 28.13821400441772, '1/(-0.934925954011+x1)']\n",
"[39.56224242422107, 27.05989455935905, 'log(3*x0**2 - 6*x0*x1 - x0 + 3*x1**2 - x1 + 3*x2**2)']\n",
"[46.68158917359681, 26.85871306245941, 'tan(-0.845761305278*(x1-(x1+1)))']\n",
"[151.3842928046349, 26.449089073084824, -0.889655292034149*tan(0.102245159447193*cos(x2) - 0.877891777343642)]\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 30.834454019627426, '0']\n",
"[2.0, 30.21233279612709, '0.500000000000000']\n",
"[26.736183635149136, 28.02326246238811, exp(-0.119926199316978*exp(exp(cos(x2))))]\n",
"[39.56224242422107, 27.05989455935905, 'log(3*x0**2 - 6*x0*x1 - x0 + 3*x1**2 - x1 + 3*x2**2)']\n",
"[46.68158917359681, 26.85871306245941, 'tan(-0.845761305278*(x1-(x1+1)))']\n",
"[151.3842928046349, 26.449089073084824, -0.889655292034149*tan(0.102245159447193*cos(x2) - 0.877891777343642)]\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 30.834454019627426, '0']\n",
"[2.0, 30.21233279612709, '0.500000000000000']\n",
"[26.736183635149136, 28.02326246238811, exp(-0.119926199316978*exp(exp(cos(x2))))]\n",
"[39.56224242422107, 27.05989455935905, 'log(3*x0**2 - 6*x0*x1 - x0 + 3*x1**2 - x1 + 3*x2**2)']\n",
"[46.68158917359681, 26.85871306245941, 'tan(-0.845761305278*(x1-(x1+1)))']\n",
"[151.3842928046349, 26.449089073084824, -0.889655292034149*tan(0.102245159447193*cos(x2) - 0.877891777343642)]\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 30.834454019627426, '0']\n",
"[2.0, 30.21233279612709, '0.500000000000000']\n",
"[26.736183635149136, 28.02326246238811, exp(-0.119926199316978*exp(exp(cos(x2))))]\n",
"[39.56224242422107, 27.05989455935905, 'log(3*x0**2 - 6*x0*x1 - x0 + 3*x1**2 - x1 + 3*x2**2)']\n",
"[46.68158917359681, 26.85871306245941, 'tan(-0.845761305278*(x1-(x1+1)))']\n",
"[151.3842928046349, 26.449089073084824, -0.889655292034149*tan(0.102245159447193*cos(x2) - 0.877891777343642)]\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 30.834454019627426, '0']\n",
"[1.0, 29.661717905473818, '1']\n",
"[26.736183635149136, 28.02326246238811, exp(-0.119926199316978*exp(exp(cos(x2))))]\n",
"[27.991334457287852, 8.839887073688955e-07, '(x0**2 - 2*x0*x1 + x1**2 + x2**2)**0.5']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 30.834454019627426, '0']\n",
"[1.0, 29.661717905473818, '1']\n",
"[26.736183635149136, 28.02326246238811, exp(-0.119926199316978*exp(exp(cos(x2))))]\n",
"[27.991334457287852, 8.839887073688955e-07, '(x0**2 - 2*x0*x1 + x1**2 + x2**2)**0.5']\n",
"Checking for symmetry \n",
" example1.txt_train-translated_minus\n",
"Found pretrained NN \n",
"\n",
"tensor(0.0134, device='cuda:0', grad_fn=)\n",
"tensor(0.0198, device='cuda:0', grad_fn=)\n",
"tensor(0.0220, device='cuda:0', grad_fn=)\n",
"NN loss after training: tensor(0.0051, device='cuda:0', grad_fn=) \n",
"\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[16.779565475879124, 0.0, '0.000000000000+sqrt(((x1*x1)+(x0*x0)))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[16.779565475879124, 0.0, '0.000000000000+sqrt(((x1*x1)+(x0*x0)))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[4.0, 29.274727392929375, 'pi/2']\n",
"[16.779565475879124, 0.0, '0.000000000000+sqrt(((x1*x1)+(x0*x0)))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[4.0, 29.274727392929375, 'pi/2']\n",
"[16.779565475879124, 0.0, '0.000000000000+sqrt(((x1*x1)+(x0*x0)))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[4.0, 29.274727392929375, 'pi/2']\n",
"[16.779565475879124, 0.0, '0.000000000000+sqrt(((x1*x1)+(x0*x0)))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[4.0, 29.274727392929375, 'pi/2']\n",
"[16.779565475879124, 0.0, '0.000000000000+sqrt(((x1*x1)+(x0*x0)))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[4.0, 29.274727392929375, 'pi/2']\n",
"[16.779565475879124, 0.0, '0.000000000000+sqrt(((x1*x1)+(x0*x0)))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[4.0, 29.274727392929375, 'pi/2']\n",
"[16.779565475879124, 0.0, '0.000000000000+sqrt(((x1*x1)+(x0*x0)))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[1.0, 29.661717905473818, '1']\n",
"[4.0, 29.274727392929375, 'pi/2']\n",
"[13.169925001442312, 0.0, '(x0**2 + x1**2)**0.5']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[1.0, 29.661717905473818, '1']\n",
"[4.0, 29.274727392929375, 'pi/2']\n",
"[13.169925001442312, 0.0, '(x0**2 + x1**2)**0.5']\n",
"Checking for symmetry \n",
" example1.txt_train-translated_minus-translated_minus\n",
"Found pretrained NN \n",
"\n",
"tensor(0.0258, device='cuda:0', grad_fn=)\n",
"tensor(0.0227, device='cuda:0', grad_fn=)\n",
"tensor(0.0499, device='cuda:0', grad_fn=)\n",
"NN loss after training: tensor(0.0171, device='cuda:0', grad_fn=) \n",
"\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[12.1357092861044, 29.214205611514426, '1.78000000000000']\n",
"[27.36452797660028, 28.767880375411565, '0.04*x0**2 + 1.78']\n",
"[61.704892355813804, 27.90519712519376, '1.002287261112*log((pi+(x0*x0)))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[12.1357092861044, 29.214205611514426, '1.78000000000000']\n",
"[27.36452797660028, 28.767880375411565, '0.04*x0**2 + 1.78']\n",
"[46.5605178945111, 27.13368508267342, 1.03779721260071]\n",
"[46.560609037047406, 27.133341532987984, 1.03786277770996]\n",
"[46.56082212240015, 27.132627863336616, 1.03801608085632]\n",
"[159.48362903293216, 26.68961200174967, tan(1.36156690120697*cos(exp(exp(x0 - 1.45150196552277*exp(x0))))**0.627788364887238)]\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[4.0, 29.274727392929375, 'pi/2']\n",
"[12.1357092861044, 29.214205611514426, '1.78000000000000']\n",
"[27.36452797660028, 28.767880375411565, '0.04*x0**2 + 1.78']\n",
"[44.619738251519436, 28.75697271359565, -0.270320892333984]\n",
"[44.620081767607, 28.75693944878952, -0.270385265350342]\n",
"[46.5605178945111, 27.13368508267342, 1.03779721260071]\n",
"[46.560609037047406, 27.133341532987984, 1.03786277770996]\n",
"[46.56082212240015, 27.132627863336616, 1.03801608085632]\n",
"[159.48362903293216, 26.68961200174967, tan(1.36156690120697*cos(exp(exp(x0 - 1.45150196552277*exp(x0))))**0.627788364887238)]\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[4.0, 29.274727392929375, 'pi/2']\n",
"[12.1357092861044, 29.214205611514426, '1.78000000000000']\n",
"[12.584962500721156, 28.563725251344263, 'log(x0**2 + 7)']\n",
"[22.53445297804259, 28.460572241792615, 'log(0.888888888888889*x0**2 + 7)']\n",
"[35.60876171948284, 28.441523309583, 'log(0.888888888888889*x0**2 + 6.89)']\n",
"[46.5605178945111, 27.13368508267342, 1.03779721260071]\n",
"[46.560609037047406, 27.133341532987984, 1.03786277770996]\n",
"[46.56082212240015, 27.132627863336616, 1.03801608085632]\n",
"[159.48362903293216, 26.68961200174967, tan(1.36156690120697*cos(exp(exp(x0 - 1.45150196552277*exp(x0))))**0.627788364887238)]\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[4.0, 29.274727392929375, 'pi/2']\n",
"[12.1357092861044, 29.214205611514426, '1.78000000000000']\n",
"[12.584962500721156, 28.563725251344263, 'log(x0**2 + 7)']\n",
"[22.53445297804259, 28.460572241792615, 'log(0.888888888888889*x0**2 + 7)']\n",
"[35.60876171948284, 28.441523309583, 'log(0.888888888888889*x0**2 + 6.89)']\n",
"[46.070972708611805, 28.114455148352643, 0.739170650917556]\n",
"[46.5605178945111, 27.13368508267342, 1.03779721260071]\n",
"[46.560609037047406, 27.133341532987984, 1.03786277770996]\n",
"[46.56082212240015, 27.132627863336616, 1.03801608085632]\n",
"[159.48362903293216, 26.68961200174967, tan(1.36156690120697*cos(exp(exp(x0 - 1.45150196552277*exp(x0))))**0.627788364887238)]\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[3.0, 29.304496932666545, '1.50000000000000']\n",
"[4.0, 28.26178092441696, 'exp(-23.140666108580+exp(pi))']\n",
"[42.736802128832295, 28.259201258812894, 'exp(0.000000392728*(sin((pi-(cos(x0)-1))))**(-1))']\n",
"[46.070972708611805, 28.114455148352643, 0.739170650917556]\n",
"[46.5605178945111, 27.13368508267342, 1.03779721260071]\n",
"[46.560609037047406, 27.133341532987984, 1.03786277770996]\n",
"[46.56082212240015, 27.132627863336616, 1.03801608085632]\n",
"[159.48362903293216, 26.68961200174967, tan(1.36156690120697*cos(exp(exp(x0 - 1.45150196552277*exp(x0))))**0.627788364887238)]\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[3.0, 29.304496932666545, '1.50000000000000']\n",
"[4.0, 28.26178092441696, 'exp(-23.140666108580+exp(pi))']\n",
"[23.550746785383243, 27.481599263478095, 'asin(-0.02*x0**2 + 0.7)']\n",
"[46.5605178945111, 27.13368508267342, 1.03779721260071]\n",
"[46.560609037047406, 27.133341532987984, 1.03786277770996]\n",
"[46.56082212240015, 27.132627863336616, 1.03801608085632]\n",
"[159.48362903293216, 26.68961200174967, tan(1.36156690120697*cos(exp(exp(x0 - 1.45150196552277*exp(x0))))**0.627788364887238)]\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[3.0, 29.304496932666545, '1.50000000000000']\n",
"[4.0, 28.26178092441696, 'exp(-23.140666108580+exp(pi))']\n",
"[23.550746785383243, 27.481599263478095, 'asin(-0.02*x0**2 + 0.7)']\n",
"[46.5605178945111, 27.13368508267342, 1.03779721260071]\n",
"[46.560609037047406, 27.133341532987984, 1.03786277770996]\n",
"[46.56082212240015, 27.132627863336616, 1.03801608085632]\n",
"[159.48362903293216, 26.68961200174967, tan(1.36156690120697*cos(exp(exp(x0 - 1.45150196552277*exp(x0))))**0.627788364887238)]\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[3.0, 29.304496932666545, '1.50000000000000']\n",
"[4.0, 28.26178092441696, 'exp(-23.140666108580+exp(pi))']\n",
"[23.550746785383243, 27.481599263478095, 'asin(-0.02*x0**2 + 0.7)']\n",
"[46.5605178945111, 27.13368508267342, 1.03779721260071]\n",
"[46.560609037047406, 27.133341532987984, 1.03786277770996]\n",
"[46.56082212240015, 27.132627863336616, 1.03801608085632]\n",
"[159.48362903293216, 26.68961200174967, tan(1.36156690120697*cos(exp(exp(x0 - 1.45150196552277*exp(x0))))**0.627788364887238)]\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[3.0, 29.304496932666545, '1.50000000000000']\n",
"[4.0, 28.26178092441696, 'exp(-23.140666108580+exp(pi))']\n",
"[23.550746785383243, 27.481599263478095, 'asin(-0.02*x0**2 + 0.7)']\n",
"[46.5605178945111, 27.13368508267342, 1.03779721260071]\n",
"[46.560609037047406, 27.133341532987984, 1.03786277770996]\n",
"[46.56082212240015, 27.132627863336616, 1.03801608085632]\n",
"[159.48362903293216, 26.68961200174967, tan(1.36156690120697*cos(exp(exp(x0 - 1.45150196552277*exp(x0))))**0.627788364887238)]\n",
"Checking for symmetry \n",
" example1.txt_train-translated_minus-translated_minus-translated_multiply\n",
"Just one variable!\n",
"example1.txt_train-translated_minus-translated_minus-translated_multiply just one variable for ADD \n",
"\n",
"example1.txt_train-translated_minus-translated_minus-translated_multiply just one variable for ADD \n",
"\n",
"example1.txt_train-translated_minus-translated_minus-translated_multiply just one variable for ADD \n",
"\n",
"example1.txt_train-translated_minus-translated_minus-translated_multiply just one variable for ADD \n",
"\n",
"example1.txt_train-translated_minus-translated_minus-translated_multiply just one variable for ADD\n",
"example1.txt_train-translated_minus-translated_minus-translated_multiply just one variable for ADD\n",
"CPU times: user 31min 53s, sys: 1min 6s, total: 33min\n",
"Wall time: 1h 11min\n"
],
"name": "stdout"
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"array([['30.834454019627426', '4.946471395876568', '593576.5675051882',\n",
" '0.0', '30.834454019627426', '0'],\n",
" ['29.661717905473818', '4.890530251072885', '586863.6301287463',\n",
" '1.0', '29.661717905473818', '1'],\n",
" ['29.304496932666545', '4.873050165836775', '584766.019900413',\n",
" '3.0', '29.304496932666545', '1.50000000000000'],\n",
" ['29.66164889019033', '4.820780475275042', '578493.657033005',\n",
" '4.0', '28.26178092441696', 'exp(-23.140666108580+exp(pi))'],\n",
" ['0.0', '-inf', '-inf', '13.169925001442312', '0.0',\n",
" '((x0-x1)**2 + (x2-x3)**2)**0.5']], dtype=' with_units.gz"
],
"execution_count": 6,
"outputs": [
{
"output_type": "stream",
"text": [
" % Total % Received % Xferd Average Speed Time Time Time Current\n",
" Dload Upload Total Spent Left Speed\n",
"100 1661M 100 1661M 0 0 17.0M 0 0:01:37 0:01:37 --:--:-- 17.6M\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "_ncr6YDy5OuX",
"colab_type": "code",
"colab": {}
},
"source": [
"!cd /content && tar -xzf with_units.gz && cd /content/AI-Feynman/Code"
],
"execution_count": 7,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "pXAAM7-F7B47",
"colab_type": "text"
},
"source": [
"## Solver configurations "
]
},
{
"cell_type": "code",
"metadata": {
"id": "uTi8DWUB6mOZ",
"colab_type": "code",
"colab": {}
},
"source": [
"_CFG = {\n",
" \"dataset_path\" : \"/content/Feynman_with_units\",\n",
" \"operations_file\" : \"./14ops.txt\",\n",
" \"polynomial_degree\" : 3,\n",
" \"number_of_epochs\" : 500,\n",
" \"bruteforce_time\" : 20,\n",
" \"test_percentage\" : 0,\n",
"}"
],
"execution_count": 3,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "day8oRZd584P",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 368
},
"outputId": "4652fd09-8150-420e-c46f-b628a3b395be"
},
"source": [
"import logging\n",
"import argparse\n",
"import pathlib\n",
"import os\n",
"\n",
"\n",
"\n",
"from threading import active_count\n",
"from multiprocessing import Pool\n",
"from multiprocessing.pool import ThreadPool\n",
"from random import shuffle\n",
"from tabulate import tabulate\n",
"from pathlib import Path\n",
"from functools import partial\n",
"\n",
"\n",
"from S_run_aifeynman import run_aifeynman\n",
"\n",
"_CFG = {\n",
" \"dataset_path\" : \"../../Feynman_without_units/\",\n",
" \"operations_file\" : \"./14ops.txt\",\n",
" \"polynomial_degree\" : 3,\n",
" \"number_of_epochs\" : 500,\n",
" \"bruteforce_time\" : 60,\n",
" \"test_percentage\" : 0,\n",
"}\n",
"\n",
"class RunAll:\n",
" \"\"\"\n",
" Run the solver on the whole dataset\n",
" \"\"\"\n",
"\n",
" def __init__(self, *, cfg=_CFG):\n",
" logging.basicConfig(filename=\"output_no_units_parallel.log\", level=logging.DEBUG)\n",
" self.cfg = cfg\n",
" self.results = {}\n",
"\n",
" \n",
" def print_results(self):\n",
" table = []\n",
" for file, sol in self.results.items():\n",
" table.append(sol[-1])\n",
" print(tabulate(\n",
" table,\n",
" headers=[\n",
" \"Average error\",\n",
" \"Cumulative error\",\n",
" \"Error\",\n",
" \"Symbolic expression\",\n",
" ],\n",
" )\n",
" )\n",
" \n",
" def run_solver(self, dirs=None):\n",
" if not dirs:\n",
" path = Path(self.cfg[\"dataset_path\"])\n",
" dirs = list(path.iterdir())\n",
" shuffle(dirs) # Shuffle to sample a different file each time\n",
" \n",
" else:\n",
" path=Path(self.cfg[\"dataset_path\"])\n",
" child = dirs\n",
" \n",
" \n",
"\n",
" print(f\"Process PID: {os.getpid()} ---------------- Number of threads: {active_count()}\" )\n",
" self.results[str(child).split(\"/\")[-1]] = run_aifeynman(\n",
" pathdir=str(path.resolve()) + \"/\",\n",
" filename=str(child).split(\"/\")[-1],\n",
" BF_try_time=int(self.cfg[\"bruteforce_time\"]),\n",
" BF_ops_file_type=Path(self.cfg[\"operations_file\"]),\n",
" polyfit_deg=int(self.cfg[\"polynomial_degree\"]),\n",
" NN_epochs=int(self.cfg[\"number_of_epochs\"]),\n",
" vars_name=[],\n",
" test_percentage=int(self.cfg[\"test_percentage\"]),\n",
" )\n",
"\n",
" logging.info(self.results)\n",
" print(\"@\"*120)\n",
" print(\"@\"*120)\n",
"\n",
" self.print_results()\n",
"\n"
],
"execution_count": 4,
"outputs": [
{
"output_type": "error",
"ename": "ModuleNotFoundError",
"evalue": "ignored",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 15\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 16\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 17\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mS_run_aifeynman\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mrun_aifeynman\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 18\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 19\u001b[0m _CFG = {\n",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'S_run_aifeynman'",
"",
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0;32m\nNOTE: If your import is failing due to a missing package, you can\nmanually install dependencies using either !pip or !apt.\n\nTo view examples of installing some common dependencies, click the\n\"Open Examples\" button below.\n\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n"
]
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "GRh1Ld01UknX",
"colab_type": "code",
"colab": {}
},
"source": [
"def get_files(path: str, chunks=None):\n",
" dirs = list(Path(path).iterdir())\n",
" dirs = [file.name for file in dirs if not (str(file).endswith(\"test\") or str(file).endswith(\"train\"))]\n",
" if chunks:\n",
" for i in range(0, len(dirs), chunks):\n",
" yield dirs[i : i + chunks]\n",
" yield dirs\n",
"\n",
"files = list(get_files(Path(\"/content/Feynman_without_units\")))\n",
"\n",
"\n",
"with open(\"files.txt\", \"w\") as F:\n",
" for line in files[-1]:\n",
" F.write(f\"{line}\\n\")"
],
"execution_count": 5,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "XAHCWx4BUWd1",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 579
},
"outputId": "ba32a0e8-467c-4872-f2d9-2789b51e77ad"
},
"source": [
"%%time\n",
"\n",
"solver = RunAll().run_solver\n",
"path = Path(_CFG[\"dataset_path\"])\n",
"#dirs = list(path.iterdir())\n",
"#chunked_dirs = list(get_files(dirs, chunks=24))\n",
"# print(chunked_dirs[0], len(chunked_dirs[0]))\n",
"# for dd in chunked_dirs:\n",
"# pool = Pool(len(dd))\n",
"# print(dd, len(dd))\n",
"# pool.map(print, dd)\n",
"# pool.map(solver, dd)\n",
"# pool.close()\n",
"\n",
"solver(files[-1][-1])\n"
],
"execution_count": 48,
"outputs": [
{
"output_type": "stream",
"text": [
"Process PID: 119 ---------------- Number of threads: 4\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"Checking for symmetry \n",
" III.7.38_train\n"
],
"name": "stdout"
},
{
"output_type": "error",
"ename": "TypeError",
"evalue": "ignored",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mget_ipython\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrun_cell_magic\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'time'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m''\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'\\nsolver = RunAll().run_solver\\npath = Path(_CFG[\"dataset_path\"])\\n#dirs = list(path.iterdir())\\n#chunked_dirs = list(get_files(dirs, chunks=24))\\n# print(chunked_dirs[0], len(chunked_dirs[0]))\\n# for dd in chunked_dirs:\\n# pool = Pool(len(dd))\\n# print(dd, len(dd))\\n# pool.map(print, dd)\\n# pool.map(solver, dd)\\n# pool.close()\\n\\nsolver(files[-1][-1])'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py\u001b[0m in \u001b[0;36mrun_cell_magic\u001b[0;34m(self, magic_name, line, cell)\u001b[0m\n\u001b[1;32m 2115\u001b[0m \u001b[0mmagic_arg_s\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvar_expand\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mline\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstack_depth\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2116\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbuiltin_trap\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2117\u001b[0;31m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfn\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmagic_arg_s\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcell\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2118\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mresult\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2119\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m\u001b[0m in \u001b[0;36mtime\u001b[0;34m(self, line, cell, local_ns)\u001b[0m\n",
"\u001b[0;32m/usr/local/lib/python3.6/dist-packages/IPython/core/magic.py\u001b[0m in \u001b[0;36m\u001b[0;34m(f, *a, **k)\u001b[0m\n\u001b[1;32m 186\u001b[0m \u001b[0;31m# but it's overkill for just that one bit of state.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 187\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mmagic_deco\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0marg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 188\u001b[0;31m \u001b[0mcall\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mlambda\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 189\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 190\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mcallable\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0marg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/local/lib/python3.6/dist-packages/IPython/core/magics/execution.py\u001b[0m in \u001b[0;36mtime\u001b[0;34m(self, line, cell, local_ns)\u001b[0m\n\u001b[1;32m 1191\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1192\u001b[0m \u001b[0mst\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mclock2\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1193\u001b[0;31m \u001b[0mexec\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcode\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mglob\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlocal_ns\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1194\u001b[0m \u001b[0mend\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mclock2\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1195\u001b[0m \u001b[0mout\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n",
"\u001b[0;32m\u001b[0m in \u001b[0;36mrun_solver\u001b[0;34m(self, dirs)\u001b[0m\n\u001b[1;32m 73\u001b[0m \u001b[0mNN_epochs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcfg\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"number_of_epochs\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 74\u001b[0m \u001b[0mvars_name\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 75\u001b[0;31m \u001b[0mtest_percentage\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcfg\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"test_percentage\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 76\u001b[0m )\n\u001b[1;32m 77\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/content/AI-Feynman/Code/S_run_aifeynman.py\u001b[0m in \u001b[0;36mrun_aifeynman\u001b[0;34m(pathdir, filename, BF_try_time, BF_ops_file_type, polyfit_deg, NN_epochs, vars_name, test_percentage)\u001b[0m\n\u001b[1;32m 163\u001b[0m \u001b[0mPA\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mParetoSet\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 164\u001b[0m \u001b[0;31m# Run the code on the train data\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 165\u001b[0;31m \u001b[0mPA\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mrun_AI_all\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpathdir\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mfilename\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0;34m\"_train\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mBF_try_time\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mBF_ops_file_type\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpolyfit_deg\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mNN_epochs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mPA\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mPA\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 166\u001b[0m \u001b[0mPA_list\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mPA\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_pareto_points\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 167\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/content/AI-Feynman/Code/S_run_aifeynman.py\u001b[0m in \u001b[0;36mrun_AI_all\u001b[0;34m(pathdir, filename, BF_try_time, BF_ops_file_type, polyfit_deg, NN_epochs, PA)\u001b[0m\n\u001b[1;32m 53\u001b[0m \u001b[0;31m# check if the NN is trained. If it is not, train it on the data.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 54\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Checking for symmetry \\n\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfilename\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 55\u001b[0;31m \u001b[0;32mif\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m<\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 56\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Just one variable!\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 57\u001b[0m \u001b[0;32mpass\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mTypeError\u001b[0m: object of type 'numpy.float64' has no len()"
]
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "RGCB0c4Y60SN",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 1000
},
"outputId": "99cd020a-2852-4ab6-9d2e-d31bd714fe5f"
},
"source": [
"%%time\n",
"RunAll(cfg=_CFG)\n",
" "
],
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"text": [
"/content/Feynman_with_units/I.34.8\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[17.509775004326936, 0.0, '1.000000000000*(x2*(x1*(x0/x3)))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[17.509775004326936, 0.0, '1.000000000000*(x2*(x1*(x0/x3)))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[16.194602975157967, nan, 'acos(-x0 - x1 - x2 + 2)']\n",
"[17.509775004326936, 0.0, '1.000000000000*(x2*(x1*(x0/x3)))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[16.194602975157967, nan, 'acos(-x0 - x1 - x2 + 2)']\n",
"[17.509775004326936, 0.0, '1.000000000000*(x2*(x1*(x0/x3)))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[16.194602975157967, nan, 'acos(-x0 - x1 - x2 + 2)']\n",
"[17.509775004326936, 0.0, '1.000000000000*(x2*(x1*(x0/x3)))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[16.194602975157967, nan, 'acos(-x0 - x1 - x2 + 2)']\n",
"[17.509775004326936, 0.0, '1.000000000000*(x2*(x1*(x0/x3)))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 29.021163959047044, 'asin(666.000000000000*(x2-((x2+1)-1)))']\n",
"[16.194602975157967, nan, 'acos(-x0 - x1 - x2 + 2)']\n",
"[17.509775004326936, 0.0, '1.000000000000*(x2*(x1*(x0/x3)))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 29.021163959047044, 'asin(666.000000000000*(x2-((x2+1)-1)))']\n",
"[16.194602975157967, nan, 'acos(-x0 - x1 - x2 + 2)']\n",
"[17.509775004326936, 0.0, '1.000000000000*(x2*(x1*(x0/x3)))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 29.021163959047044, 'asin(666.000000000000*(x2-((x2+1)-1)))']\n",
"[16.194602975157967, nan, 'acos(-x0 - x1 - x2 + 2)']\n",
"[17.509775004326936, 0.0, '1.000000000000*(x2*(x1*(x0/x3)))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 29.021163959047044, 'asin(666.000000000000*(x2-((x2+1)-1)))']\n",
"[16.194602975157967, nan, 'acos(-x0 - x1 - x2 + 2)']\n",
"[17.509775004326936, 0.0, '1.000000000000*(x2*(x1*(x0/x3)))']\n",
"Checking for symmetry \n",
" I.34.8_train\n",
"Training a NN on the data... \n",
"\n",
"tensor(0.0918, device='cuda:0', grad_fn=)\n",
"tensor(0.0656, device='cuda:0', grad_fn=)\n",
"tensor(0.0516, device='cuda:0', grad_fn=)\n",
"tensor(0.0221, device='cuda:0', grad_fn=)\n",
"NN loss: tensor(0.0038, device='cuda:0', grad_fn=) \n",
"\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[12.60964047443681, 9.234604872781642e-07, '0.000000000000+(x1*(x0/x2))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[12.60964047443681, 9.234604872781642e-07, '0.000000000000+(x1*(x0/x2))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[4.0, 32.33086112527217, 'pi/2']\n",
"[12.60964047443681, 9.234604872781642e-07, '0.000000000000+(x1*(x0/x2))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[4.0, 32.33086112527217, 'pi/2']\n",
"[12.60964047443681, 9.234604872781642e-07, '0.000000000000+(x1*(x0/x2))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[4.0, 32.33086112527217, 'pi/2']\n",
"[12.60964047443681, 9.234604872781642e-07, '0.000000000000+(x1*(x0/x2))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[4.0, 32.33086112527217, 'pi/2']\n",
"[12.60964047443681, 9.234604872781642e-07, '0.000000000000+(x1*(x0/x2))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[4.0, 32.33086112527217, 'pi/2']\n",
"[12.60964047443681, 9.234604872781642e-07, '0.000000000000+(x1*(x0/x2))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[4.0, 32.33086112527217, 'pi/2']\n",
"[12.60964047443681, 9.234604872781642e-07, '0.000000000000+(x1*(x0/x2))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[1.0, 32.555376461840865, '1']\n",
"[4.0, 32.33086112527217, 'pi/2']\n",
"[12.60964047443681, 9.234604872781642e-07, '0.000000000000+(x1*(x0/x2))']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[1.0, 32.555376461840865, '1']\n",
"[4.0, 32.33086112527217, 'pi/2']\n",
"[12.60964047443681, 9.234604872781642e-07, '0.000000000000+(x1*(x0/x2))']\n",
"Checking for symmetry \n",
" I.34.8_train-translated_multiply\n",
"Found pretrained NN \n",
"\n",
"tensor(0.0416, device='cuda:0', grad_fn=)\n",
"tensor(0.0176, device='cuda:0', grad_fn=)\n",
"tensor(0.0303, device='cuda:0', grad_fn=)\n",
"NN loss after training: tensor(0.0040, device='cuda:0', grad_fn=) \n",
"\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[5.754887502163468, 9.234604872781642e-07, '0.000000000000+(x0/x1)']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[5.754887502163468, 9.234604872781642e-07, '0.000000000000+(x0/x1)']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[4.0, 32.33086112527217, 'pi/2']\n",
"[5.754887502163468, 9.234604872781642e-07, '0.000000000000+(x0/x1)']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[4.0, 32.33086112527217, 'pi/2']\n",
"[5.754887502163468, 9.234604872781642e-07, '0.000000000000+(x0/x1)']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[4.0, 32.33086112527217, 'pi/2']\n",
"[5.754887502163468, 9.234604872781642e-07, '0.000000000000+(x0/x1)']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[4.0, 32.33086112527217, 'pi/2']\n",
"[5.754887502163468, 9.234604872781642e-07, '0.000000000000+(x0/x1)']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 32.919359912499495, '0']\n",
"[4.0, 32.33086112527217, 'pi/2']\n",
"[5.754887502163468, 9.234604872781642e-07, '0.000000000000+(x0/x1)']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 32.919359912499495, '0']\n",
"[4.0, 32.33086112527217, 'pi/2']\n",
"[5.754887502163468, 9.234604872781642e-07, '0.000000000000+(x0/x1)']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 32.919359912499495, '0']\n",
"[1.0, 32.555376461840865, '1']\n",
"[4.0, 32.33086112527217, 'pi/2']\n",
"[5.754887502163468, 9.234604872781642e-07, '0.000000000000+(x0/x1)']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 32.919359912499495, '0']\n",
"[1.0, 32.555376461840865, '1']\n",
"[4.0, 32.33086112527217, 'pi/2']\n",
"[5.754887502163468, 9.234604872781642e-07, '0.000000000000+(x0/x1)']\n",
"Checking for symmetry \n",
" I.34.8_train-translated_multiply-translated_multiply\n",
"Found pretrained NN \n",
"\n",
"tensor(0.0311, device='cuda:0', grad_fn=)\n",
"tensor(0.0333, device='cuda:0', grad_fn=)\n",
"tensor(0.0225, device='cuda:0', grad_fn=)\n",
"NN loss after training: tensor(0.0062, device='cuda:0', grad_fn=) \n",
"\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 9.234604872781642e-07, '0.000000000000+x0']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 9.234604872781642e-07, '0.000000000000+x0']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 9.234604872781642e-07, '0.000000000000+x0']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 9.234604872781642e-07, '0.000000000000+x0']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 9.234604872781642e-07, '0.000000000000+x0']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 9.234604872781642e-07, '0.000000000000+x0']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 9.234604872781642e-07, '0.000000000000+x0']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 9.234604872781642e-07, '0.000000000000+x0']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 9.234604872781642e-07, '0.000000000000+x0']\n",
"Checking for brute force + \n",
"\n",
"Checking for brute force * \n",
"\n",
"Checking polyfit \n",
"\n",
"Complexity RMSE Expression\n",
"[0.0, 9.234604872781642e-07, '0.000000000000+x0']\n",
"Checking for symmetry \n",
" I.34.8_train-translated_multiply-translated_multiply-translated_divide\n",
"Just one variable!\n",
"I.34.8_train-translated_multiply-translated_multiply-translated_divide just one variable for ADD \n",
"\n",
"I.34.8_train-translated_multiply-translated_multiply-translated_divide just one variable for ADD \n",
"\n",
"I.34.8_train-translated_multiply-translated_multiply-translated_divide just one variable for ADD \n",
"\n",
"I.34.8_train-translated_multiply-translated_multiply-translated_divide just one variable for ADD \n",
"\n",
"I.34.8_train-translated_multiply-translated_multiply-translated_divide just one variable for ADD\n",
"I.34.8_train-translated_multiply-translated_multiply-translated_divide just one variable for ADD\n",
"########################################################################################################################\n",
"{'I.34.8': array([['0.0', '-20.046446431241375', '-20046446.431241374', '0.0',\n",
" '9.234604872781642e-07', '0.000000000000+((x0*(x1*x2))/x3)'],\n",
" ['nan', 'nan', 'nan', '16.194602975157967', 'nan',\n",
" 'acos(-x0 - x1 - x2 + 2)'],\n",
" ['0.0', '-inf', '-inf', '16.509775004326936', '0.0',\n",
" 'x0*x1*x2/x3']], dtype='"
]
},
"metadata": {
"tags": []
},
"execution_count": 26
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "DlQ6ydH8vVtU",
"colab_type": "text"
},
"source": [
"## Problem: **I.34.8**\n",
"Took 4 hours and 35 minute to come up with the correct result:\n",
"$$\n",
"\\omega = \\dfrac{x_0 x_1 x_2}{x_3}\n",
"$$\n",
"And the correct answer is:\n",
"$$\n",
"\\omega = \\dfrac{qvB}{p}\n",
"$$\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "MXvGX4p-JMWt",
"colab_type": "text"
},
"source": [
"## Problem: **III.15.14**\n",
"Took more than 5 hours to come up with this result:\n",
"$$\n",
"m = -\\tan{(\\dfrac{1}{ \\times x_0^{-0.93}\\times x_1^{-1.03}\\times x_2^{-0.469}} - 1.01)}\n",
"$$\n",
"While the actual answer is:\n",
"$$\n",
"m = \\dfrac{h^2}{2Ed^2}\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "wjxEmHRMTV3i",
"colab_type": "text"
},
"source": [
"Output sample"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "w5mJi_tVId7V",
"colab_type": "text"
},
"source": [
" Complexity RMSE Expression\n",
"[24.236446955124386, 32.19379398225521, 'x0*x1 + x0*x2 + x1*x2 - x1 - x2**2 + 1']\n",
"[48.33584961180911, 31.9862227670943, '0.001136817047*exp((x1+x0))']\n",
"[48.444908703757726, 31.457560514093935, '-0.957879029931+x1']\n",
"[48.6933025167606, 31.016339707140748, '0.168570230758*exp(x1)']\n",
"[51.261202734823684, 29.67151999967164, '0.999530090276*(x1*x0)']\n",
"[62.98013903114244, 29.63651158757859, '0.055232500314+((x0+log(x2))*(x1-1))']\n",
"[106.30525426555863, 29.531475422563073, x0*(x1 + log(0.408610771597111*x2)) + 0.525839149951935]\n",
"[108.02150104349855, 29.461005247973745, (x0 + log(x2))*(x1 - 0.719529628753662) - 0.0555874854326248]\n",
"[153.74798012440982, 29.440090352742136, '0.1*x0*x1*x2 + x0*x1 - 0.285714285714286*x0*x2**2 + 0.142857142857143*x0*x2*x3 + 0.833333333333333*x0*x2 - 0.428571428571429*x0*x3 - 0.4*x0 - 0.125*x1**2*x2 + 0.25*x1**2 - 0.3*x1*x2**2 + 0.25*x1*x2*x3 + x1*x2 - 0.5*x1*x3 - 0.666666666666667*x1 + 0.333333333333333*x2**3 - x2**2 - 0.111111111111111*x2*x3**2 + 0.285714285714286*x2*x3 - 0.428571428571429*x2 + 0.2*x3**2 - 0.2*x3 + 0.784697875310949']\n",
"[162.58246431046206, 29.325725950623077, x1*(x0 + 0.556240618228912)*sin(x2**0.482438892126083) - 1.94434630870819]\n",
"[200.02103605333068, 28.648861022890436, '0.1*x0*x1*x2 + 0.850311055415562*x0*x1 - 0.285714285714286*x0*x2**2 + 0.142857142857143*x0*x2*x3 + 0.833333333333333*x0*x2 - 0.428571428571429*x0*x3 - 0.4*x0 - 0.125*x1**2*x2 + 0.25*x1**2 - 0.3*x1*x2**2 + 0.25*x1*x2*x3 + x1*x2 - 0.5*x1*x3 - 0.666666666666667*x1 + 0.333333333333333*x2**3 - x2**2 - 0.111111111111111*x2*x3**2 + 0.285714285714286*x2*x3 - 0.428571428571429*x2 + 0.2*x3**2 - 0.2*x3 + 0.784697875310949']\n",
"[240.46710529464815, 28.54127970345586, '0.1*x0*x1*x2 + 0.850311055415562*x0*x1 - 0.285714285714286*x0*x2**2 + 0.142857142857143*x0*x2*x3 + 0.833333333333333*x0*x2 - 0.419409322578989*x0*x3 - 0.4*x0 - 0.125*x1**2*x2 + 0.25*x1**2 - 0.3*x1*x2**2 + 0.25*x1*x2*x3 + x1*x2 - 0.5*x1*x3 - 0.666666666666667*x1 + 0.333333333333333*x2**3 - x2**2 - 0.111111111111111*x2*x3**2 + 0.285714285714286*x2*x3 - 0.428571428571429*x2 + 0.2*x3**2 - 0.2*x3 + 0.784697875310949']\n",
"[451.0046845634026, 28.311589315571727, '0.1*x0*x1*x2 + 0.850311055415562*x0*x1 - 0.285714285714286*x0*x2**2 + 0.142857142857143*x0*x2*x3 + 0.827047248703045*x0*x2 - 0.419409322578989*x0*x3 - 0.4*x0 - 0.125*x1**2*x2 + 0.25*x1**2 - 0.3*x1*x2**2 + 0.25*x1*x2*x3 + x1*x2 - 0.453915765321264*x1*x3 - 0.666666666666667*x1 + 0.333333333333333*x2**3 - 0.896533056720137*x2**2 - 0.111111111111111*x2*x3**2 + 0.275863468660905*x2*x3 - 0.435642558638502*x2 + 0.2*x3**2 - 0.2*x3 + 0.784697875310949']\n",
"[765.2021193259455, 27.68961332841078, '0.0954709145222299*x0*x1*x2 + 0.850311055415562*x0*x1 - 0.281598845270346*x0*x2**2 + 0.142857142857143*x0*x2*x3 + 0.827047248703045*x0*x2 - 0.419409322578989*x0*x3 - 0.393857016024628*x0 - 0.125*x1**2*x2 + 0.25*x1**2 - 0.295615544580811*x1*x2**2 + 0.238779807136057*x1*x2*x3 + 1.08861622104865*x1*x2 - 0.453915765321264*x1*x3 - 0.650985290052454*x1 + 0.333333333333333*x2**3 - 0.0841340395633869*x2**2*x3 - 0.896533056720137*x2**2 - 0.111111111111111*x2*x3**2 + 0.275863468660905*x2*x3 - 0.435642558638502*x2 + 0.2*x3**2 - 0.2*x3 + 0.784697875310949']\n",
"[804.4179933090178, 27.670902454575725, '0.0954709145222299*x0*x1*x2 + 0.850311055415562*x0*x1 - 0.281598845270346*x0*x2**2 + 0.142857142857143*x0*x2*x3 + 0.827047248703045*x0*x2 - 0.419409322578989*x0*x3 - 0.393857016024628*x0 - 0.125*x1**2*x2 + 0.25*x1**2 - 0.295615544580811*x1*x2**2 + 0.238779807136057*x1*x2*x3 + 1.08861622104865*x1*x2 - 0.453915765321264*x1*x3 - 0.650985290052454*x1 + 0.333333333333333*x2**3 - 0.0841340395633869*x2**2*x3 - 0.896533056720137*x2**2 - 0.114928272861219*x2*x3**2 + 0.275863468660905*x2*x3 - 0.435642558638502*x2 + 0.2*x3**2 - 0.2*x3 + 0.784697875310949']\n",
"[1049.3949821424571, 27.65482709345228, '0.0954709145222299*x0*x1*x2 + 0.850311055415562*x0*x1 - 0.281598845270346*x0*x2**2 + 0.143093568988091*x0*x2*x3 + 0.827047248703045*x0*x2 - 0.419409322578989*x0*x3 - 0.393857016024628*x0 - 0.124525299070793*x1**2*x2 + 0.255889644781202*x1**2 - 0.295615544580811*x1*x2**2 + 0.238779807136057*x1*x2*x3 + 1.08861622104865*x1*x2 - 0.453915765321264*x1*x3 - 0.650985290052454*x1 + 0.332150095352896*x2**3 - 0.0841340395633869*x2**2*x3 - 0.896533056720137*x2**2 - 0.114928272861219*x2*x3**2 + 0.275863468660905*x2*x3 - 0.435642558638502*x2 + 0.19934446687829*x3**2 - 0.198171936948463*x3 + 0.784697875310949']\n",
"[1287.6255549331968, 27.57826998133378, '0.0324957167678879*x0*x1**2 + 0.0954709145222299*x0*x1*x2 - 0.0518367881947689*x0*x1*x3 + 0.850311055415562*x0*x1 - 0.281598845270346*x0*x2**2 + 0.142857142857143*x0*x2*x3 + 0.827047248703045*x0*x2 + 0.0195647972984031*x0*x3**2 - 0.419409322578989*x0*x3 - 0.393857016024628*x0 - 0.0325007929091572*x1**3 - 0.124525299070793*x1**2*x2 + 0.0649419539246933*x1**2*x3 + 0.255889644781202*x1**2 - 0.295615544580811*x1*x2**2 + 0.238779807136057*x1*x2*x3 + 1.08861622104865*x1*x2 - 0.0388670663126931*x1*x3**2 - 0.453915765321264*x1*x3 - 0.650985290052454*x1 + 0.332150095352896*x2**3 - 0.0841340395633869*x2**2*x3 - 0.896533056720137*x2**2 - 0.114928272861219*x2*x3**2 + 0.275863468660905*x2*x3 - 0.435642558638502*x2 + 0.00642744864450299*x3**3 + 0.19934446687829*x3**2 - 0.198171936948463*x3 + 0.784697875310949']\n",
"[1327.5202240795804, 27.57798240828162, '0.0324957167678879*x0*x1**2 + 0.0954709145222299*x0*x1*x2 - 0.0518367881947689*x0*x1*x3 + 0.850311055415562*x0*x1 - 0.281598845270346*x0*x2**2 + 0.143093568988091*x0*x2*x3 + 0.827047248703045*x0*x2 + 0.0195647972984031*x0*x3**2 - 0.419409322578989*x0*x3 - 0.393857016024628*x0 - 0.0325007929091572*x1**3 - 0.124525299070793*x1**2*x2 + 0.0649419539246933*x1**2*x3 + 0.255889644781202*x1**2 - 0.295615544580811*x1*x2**2 + 0.238779807136057*x1*x2*x3 + 1.08861622104865*x1*x2 - 0.0388670663126931*x1*x3**2 - 0.453915765321264*x1*x3 - 0.650985290052454*x1 + 0.332150095352896*x2**3 - 0.0841340395633869*x2**2*x3 - 0.896533056720137*x2**2 - 0.114928272861219*x2*x3**2 + 0.275863468660905*x2*x3 - 0.435642558638502*x2 + 0.00642744864450299*x3**3 + 0.19934446687829*x3**2 - 0.198171936948463*x3 + 0.784697875310949']\n",
"Checking for brute force + "
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "lwjXaAnL7q_0",
"colab_type": "text"
},
"source": [
"# Run on all files of the dataset"
]
},
{
"cell_type": "code",
"metadata": {
"id": "SNg_GwTF7rpB",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 955
},
"outputId": "b5eac008-4f8f-4980-dd8d-7d1ac386bb32"
},
"source": [
"%%time\n",
"!parallel --bar --ungroup --joblog ../../log.txt -t -j2 -a files.txt python generate_claimed_results.py --file"
],
"execution_count": 9,
"outputs": [
{
"output_type": "stream",
"text": [
"Academic tradition requires you to cite works you base your article on.\n",
"When using programs that use GNU Parallel to process data for publication\n",
"please cite:\n",
"\n",
" O. Tange (2011): GNU Parallel - The Command-Line Power Tool,\n",
" ;login: The USENIX Magazine, February 2011:42-47.\n",
"\n",
"This helps funding further development; AND IT WON'T COST YOU A CENT.\n",
"If you pay 10000 EUR you should feel free to use GNU Parallel without citing.\n",
"\n",
"To silence this citation notice: run 'parallel --citation'.\n",
"\n",
"python generate_claimed_results.py --file II.13.23\n",
"python generate_claimed_results.py --file II.27.16\n",
"\u001b[7m\u001b[0m0% 0:100=0s II.27.16 \u001b[0mProcess PID: 8847 ---------------- Number of threads: 1\n",
"Process PID: 8848 ---------------- Number of threads: 1\n",
"\u001b[7m\u001b[0m0% 0:100=0s II.27.16 \u001b[0mChecking for brute force + \n",
"\n",
"Trying to solve mysteries with brute force...\n",
"Trying to solve /content/Feynman_without_units/II.27.16_train...\n",
"/bin/cp -p /content/Feynman_without_units/II.27.16_train mystery.dat\n",
"Number of variables..... 0\n",
"Functions used.......... +*-/><~\\RPSCLE\n",
" Arity 0 : P\n",
" Arity 1 : ><~\\RSCLE\n",
" Arity 2 : +*-/\n",
"Loading mystery data....\n",
"\u001b[7m\u001b[0m0% 0:100=0s II.27.16 \u001b[0m 1000000 rows read from file mystery.dat \n",
"Number of examples...... 1000000\n",
" Mystery data has largest magnitude 1.0000000000000000 at j= 1\n",
" Searching for best fit...\n",
" 0.000000000000 -2.141592741013 P 1 0.0000 0.0000 0.0000 0.0000\n",
" All done: results in results.dat \n",
"Checking for brute force * \n",
"\n",
"Trying to solve mysteries with brute force...\n",
"Trying to solve /content/Feynman_without_units/II.27.16_train...\n",
"/bin/cp -p /content/Feynman_without_units/II.27.16_train mystery.dat\n",
"Number of variables..... 0\n",
"Functions used.......... +*-/><~\\RPSCLE\n",
" Arity 0 : P\n",
" Arity 1 : ><~\\RSCLE\n",
" Arity 2 : +*-/\n",
"Loading mystery data....\n",
"\u001b[7m\u001b[0m0% 0:100=0s II.27.16 \u001b[0m 1000000 rows read from file mystery.dat \n",
"Number of examples...... 1000000\n",
" Mystery data has largest magnitude 1.0000000000000000 at j= 1\n",
" Searching for best fit...\n",
" 0.000000000000 0.318309877326 P 1 0.0000 0.0000 0.0000 0.0000\n",
" All done: results in results.dat \n",
"Checking polyfit \n",
"\n",
"\u001b[7m\u001b[0m0% 0:100=0s II.27.16 \u001b[0mComplexity RMSE Expression\n",
"\u001b[7m\u001b[0m0% 0:100=0s II.27.16 \u001b[0m"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "h_qpqwJg8bjw",
"colab_type": "text"
},
"source": [
"# Results"
]
},
{
"cell_type": "code",
"metadata": {
"id": "P5il9KC_8dB4",
"colab_type": "code",
"colab": {}
},
"source": [
"import pprint\n",
"import re\n",
"results = None\n",
"with open(\"/content/AI-Feynman/output_no_units_parallel.log\") as F:\n",
" results = F.readlines() "
],
"execution_count": 268,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "5DLXAa-E8uyD",
"colab_type": "code",
"colab": {}
},
"source": [
"new = str(results).replace('\"', \"\").strip().replace(\"\\n\", \"\").replace(\"'\", \"\")\\\n",
".replace(\" \", \"\").replace(\"\\\\n\", \" \")\\\n",
".replace(\"','\", \"\").replace(\"asin\", \"sin\").split(\"INFO:root:\")\n",
"\n",
"new = [re.sub(r\"(dtype=\\WU\\d*|dtype=object)\", \"\", item) for item in new]"
],
"execution_count": 301,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "AypjKO0n9CMy",
"colab_type": "code",
"colab": {}
},
"source": [
"new = [re.sub(r\"(I+.\\d*.\\d*:array)\", \"\", item.replace(\" ,\", \"\").replace(\"{\", \"\")\\\n",
" .replace(\"}\", \"\"))\\\n",
" .split(\",\") for item in new if len(item) > 10]\n",
" #re.sub(r\"(I+.\\d*.\\d*:array)\", \"\", item.replace(\" ,\", \"\").replace(\"{\", \"\")\\\n",
" # .replace(\"}\", \"\").replace(\"(\", \"\").replace(\")\", \"\"))\\\n",
" # .split(\",\")"
],
"execution_count": 303,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "TvYwdwzjh2QQ",
"colab_type": "code",
"colab": {}
},
"source": [
"import sympy\n",
"import matplotlib.pyplot as plt\n",
"from sympy import init_printing\n",
"from sympy import pprint\n",
"\n",
"init_printing(use_latex=True)\n"
],
"execution_count": 350,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "8bqA0DqRegPN",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 1000
},
"outputId": "2e66e9ea-fc55-46db-ffd2-e4fa8d89bdba"
},
"source": [
"results = []\n",
"for item in new:\n",
" res = []\n",
" for ex in item:\n",
" if len(ex) > 3:\n",
" tmp.append(ex)\n",
" result.append(ex.replace(\"]\", \"\"))\n",
" results.append(result[-1])\n",
" pprint(sympy.sympify(result[-1]))\n",
" print(\"\\n\", \"@\" * 60, \"\\n\")"
],
"execution_count": 355,
"outputs": [
{
"output_type": "stream",
"text": [
"4⋅π⋅x₀\n",
"\n",
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ \n",
"\n",
"x₀ + 1\n",
"\n",
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ \n",
"\n",
"-0.125 \n",
"───────\n",
" 2 \n",
" x₀ \n",
"\n",
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ \n",
"\n",
" 1 \n",
" ── \n",
" x₀ \n",
"ℯ - 1\n",
"\n",
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ \n",
"\n",
" 0.5\n",
"⎛ 2 ⎞ \n",
"⎝x₀ - 0.1591549430918953⋅x₀ + 0.01⎠ \n",
"\n",
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ \n",
"\n",
" 0.5 \n",
"──────\n",
"x₀ + 1\n",
"\n",
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ \n",
"\n",
"sin(0.785437643527985⋅sin(0.1013211780033⋅cos(x₀)))\n",
"\n",
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ \n",
"\n",
"6.283185307179586⋅x₀\n",
"────────────────────\n",
" x₁ \n",
"\n",
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ \n",
"\n",
" 0.5\n",
"⎛ 2 2 ⎞ \n",
"⎝x₀ + x₁ + 1⎠ \n",
"\n",
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ \n",
"\n",
"1.0⋅x₁\n",
"──────\n",
" x₀ \n",
"\n",
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ \n",
"\n",
"0.168816319869⋅x₂⋅(x₀ + x₁)\n",
"\n",
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ \n",
"\n",
"-4⋅π⋅(cos(x₁ - x₂) - 1) \n",
"────────────────────────\n",
" 2 \n",
" x₀⋅(x₁ - x₂) \n",
"\n",
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ \n",
"\n",
"x₀⋅(x₁⋅cos(x₂) + 1)\n",
"\n",
" @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ \n",
"\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "N5qkbSYTx3S7",
"colab_type": "code",
"colab": {}
},
"source": [
""
],
"execution_count": null,
"outputs": []
}
]
}