Commit f9213580 authored by Mathieu Hemery's avatar Mathieu Hemery
Browse files

Update cmsb_2020 benchmark

parent 568ac870
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Benchmark: Binomial Transformation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Options and settings"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"prolog(set_prolog_flag(stack_limit, 4_294_967_296)).\n",
"option(binomial_reduction:sat_reactions)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Circular\n",
"Circular PODE with 2 variables as described here are of the form:\n",
"$$dx/dt = y^k \\\\ dy/dt = x^k$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Circular 2,3"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"14\r\n",
"The previous command takes 96.3223 ms\r\n",
"[0] MA(1.0) for x3=>x3+y\r\n",
"[1] MA(2.0) for x3+y=>x3+y+y2\r\n",
"[2] MA(3.0) for x3+y2=>x3+y2+y3\r\n",
"[3] MA(1.0) for y3=>x+y3\r\n",
"[4] MA(2.0) for x+y3=>x+x2+y3\r\n",
"[5] MA(3.0) for x2+y3=>x2+x3+y3\r\n",
"[0] x3\r\n",
"[1] y\r\n",
"[2] y2\r\n",
"[3] y3\r\n",
"[4] x\r\n",
"[5] x2\r\n"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"with_timer(compile_from_pivp((1.0, d(x)/dt = y^3);(1.0, d(y)/dt = x^3), x)).\n",
"list_reactions.\n",
"list_molecules."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Circular 2,4"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"23\r\n",
"The previous command takes 130.957 ms\r\n",
"[0] MA(1.0) for x4=>x4+y\r\n",
"[1] MA(2.0) for x4+y=>x4+y+y2\r\n",
"[2] MA(3.0) for x4+y2=>x4+y2+y3\r\n",
"[3] MA(4.0) for x4+y3=>x4+y3+y4\r\n",
"[4] MA(1.0) for y4=>x+y4\r\n",
"[5] MA(2.0) for x+y4=>x+x2+y4\r\n",
"[6] MA(3.0) for x2+y4=>x2+x3+y4\r\n",
"[7] MA(4.0) for x3+y4=>x3+x4+y4\r\n",
"[0] x4\r\n",
"[1] y\r\n",
"[2] y2\r\n",
"[3] y3\r\n",
"[4] y4\r\n",
"[5] x\r\n",
"[6] x2\r\n",
"[7] x3\r\n"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"with_timer(compile_from_pivp((1.0, d(x)/dt = y^4);(1.0, d(y)/dt = x^4), x)).\n",
"list_reactions.\n",
"list_molecules."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Circular 2,5"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"34\r\n",
"The previous command takes 903.916 ms\r\n",
"[0] MA(1.0) for x+x4=>x+x4+y\r\n",
"[1] MA(4.0) for x4+xy3=>x4+xy3+y4\r\n",
"[2] MA(1.0) for y+y4=>x+y+y4\r\n",
"[3] MA(1.0) for 2*y4=>xy3+2*y4\r\n",
"[4] MA(3.0) for 2*x3y=>xy3+2*x3y\r\n",
"[5] MA(3.0) for 2*xy3=>x3y+2*xy3\r\n",
"[6] MA(1.0) for 2*x4=>x3y+2*x4\r\n",
"[7] MA(4.0) for x3y+y4=>x3y+x4+y4\r\n",
"[0] x\r\n",
"[1] x4\r\n",
"[2] y\r\n",
"[3] xy3\r\n",
"[4] y4\r\n",
"[5] x3y\r\n"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"with_timer(compile_from_pivp((1.0, d(x)/dt = y^5);(1.0, d(y)/dt = x^5), x)).\n",
"list_reactions.\n",
"list_molecules."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Circular 2,6"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"47\r\n",
"The previous command takes 54118 ms\r\n",
"[0] MA(1.0) for x+x5=>x+x5+y\r\n",
"[1] MA(5.0) for x5+xy4=>x5+xy4+y5\r\n",
"[2] MA(1.0) for y+y5=>x+y+y5\r\n",
"[3] MA(1.0) for 2*y5=>xy4+2*y5\r\n",
"[4] MA(4.0) for x3y2+x4y=>x3y2+x4y+xy4\r\n",
"[5] MA(3.0) for 2*xy4=>x3y2+2*xy4\r\n",
"[6] MA(2.0) for x4y+x5=>x3y2+x4y+x5\r\n",
"[7] MA(4.0) for x3y2+y5=>x3y2+x4y+y5\r\n",
"[8] MA(1.0) for 2*x5=>x4y+2*x5\r\n",
"[9] MA(5.0) for x4y+y5=>x4y+x5+y5\r\n",
"[0] x\r\n",
"[1] x5\r\n",
"[2] y\r\n",
"[3] xy4\r\n",
"[4] y5\r\n",
"[5] x3y2\r\n",
"[6] x4y\r\n"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"with_timer(compile_from_pivp((1.0, d(x)/dt = y^6);(1.0, d(y)/dt = x^6), x)).\n",
"list_reactions.\n",
"list_molecules."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Hard 3\n",
"$$ \\frac{da}{dt} = c^3+a^2 b^2 c^3 \\\\\n",
" \\frac{db}{dt} = a^2 \\\\\n",
" \\frac{dc}{dt} = b^2 $$"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
" 34\r\n",
"The previous command takes 1588.38 ms\r\n",
"[0] MA(1.0) for b2=>b2+c\r\n",
"[1] MA(2.0) for b2c=>b2c+c2\r\n",
"[2] MA(3.0) for b2c2=>b2c2+c3\r\n",
"[3] MA(1.0) for a2=>a2+b\r\n",
"[4] MA(3.0) for b+b2c2=>b+b2c2+bc3\r\n",
"[5] MA(1.0) for a2+c3=>a2+bc3+c3\r\n",
"[6] MA(2.0) for a2b=>a2b+b2\r\n",
"[7] MA(1.0) for 2*b2=>b2c+2*b2\r\n",
"[8] MA(2.0) for a2b+c=>a2b+b2c+c\r\n",
"[9] MA(2.0) for b2+b2c=>b2+b2c+b2c2\r\n",
"[10] MA(2.0) for a2b+c2=>a2b+b2c2+c2\r\n",
"[11] MA(1.0) for c3=>a+c3\r\n",
"[12] MA(1.0) for a2b+bc3=>a+a2b+bc3\r\n",
"[13] MA(1.0) for 2*c3=>ac3+2*c3\r\n",
"[14] MA(3.0) for ab2+c2=>ab2+ac3+c2\r\n",
"[15] MA(1.0) for ab2c3+ac3=>ab2c3+2*ac3\r\n",
"[16] MA(1.0) for b2c2+c=>ab2+b2c2+c\r\n",
"[17] MA(1.0) for ab2+ab2c3=>ab2c3+2*ab2\r\n",
"[18] MA(2.0) for a+a2b=>a+a2b+ab2\r\n",
"[19] MA(1.0) for 2*bc3=>ab2c3+2*bc3\r\n",
"[20] MA(3.0) for ab2+b2c2=>ab2+ab2c3+b2c2\r\n",
"[21] MA(1.0) for 2*ab2c3=>3*ab2c3\r\n",
"[22] MA(2.0) for a2b+ac3=>a2b+ab2c3+ac3\r\n",
"[23] MA(2.0) for ac3=>a2+ac3\r\n",
"[24] MA(2.0) for a2+ab2c3=>ab2c3+2*a2\r\n",
"[25] MA(2.0) for ac3+b=>a2b+ac3+b\r\n",
"[26] MA(2.0) for a2b+ab2c3=>ab2c3+2*a2b\r\n",
"[27] MA(1.0) for 2*a2=>a2b+2*a2\r\n",
"[0] b2\r\n",
"[1] c\r\n",
"[2] b2c\r\n",
"[3] c2\r\n",
"[4] b2c2\r\n",
"[5] c3\r\n",
"[6] a2\r\n",
"[7] b\r\n",
"[8] bc3\r\n",
"[9] a2b\r\n",
"[10] a\r\n",
"[11] ac3\r\n",
"[12] ab2\r\n",
"[13] ab2c3\r\n"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"with_timer(compile_from_pivp((1.0, d(a)/dt = c^3+a^2*b^2*c^3);\n",
"\t\t\t\t\t(1.0, d(b)/dt = a^2);\n",
"\t\t\t\t\t(1.0, d(c)/dt = b^2), a)).\n",
"list_reactions.\n",
"list_molecules."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Hard 4\n",
"$$ \\frac{da}{dt} = c^4+a^2 b^2 c^3 \\\\\n",
" \\frac{db}{dt} = a^2 \\\\\n",
" \\frac{dc}{dt} = b^2 $$"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
" 43\r\n",
"The previous command takes 29196.3 ms\r\n",
"[0] MA(1.0) for b2=>b2+c\r\n",
"[1] MA(2.0) for b2c=>b2c+c2\r\n",
"[2] MA(3.0) for b2c2=>b2c2+c3\r\n",
"[3] MA(4.0) for b2c3=>b2c3+c4\r\n",
"[4] MA(1.0) for a2=>a2+b\r\n",
"[5] MA(4.0) for b+b2c3=>b+b2c3+bc4\r\n",
"[6] MA(1.0) for a2+c4=>a2+bc4+c4\r\n",
"[7] MA(2.0) for a2b=>a2b+b2\r\n",
"[8] MA(1.0) for 2*b2=>b2c+2*b2\r\n",
"[9] MA(2.0) for a2b+c=>a2b+b2c+c\r\n",
"[10] MA(2.0) for b2+b2c=>b2+b2c+b2c2\r\n",
"[11] MA(2.0) for a2b+c2=>a2b+b2c2+c2\r\n",
"[12] MA(3.0) for b2+b2c2=>b2+b2c2+b2c3\r\n",
"[13] MA(2.0) for a2b+c3=>a2b+b2c3+c3\r\n",
"[14] MA(1.0) for c4=>a+c4\r\n",
"[15] MA(1.0) for a2+b2c3=>a+a2+b2c3\r\n",
"[16] MA(1.0) for c3+c4=>ac3+c3+c4\r\n",
"[17] MA(3.0) for ab2+c2=>ab2+ac3+c2\r\n",
"[18] MA(1.0) for ab2c3+ac3=>ab2c3+2*ac3\r\n",
"[19] MA(1.0) for b2c3+c=>ab2+b2c3+c\r\n",
"[20] MA(1.0) for ab2+ab2c3=>ab2c3+2*ab2\r\n",
"[21] MA(2.0) for a+a2b=>a+a2b+ab2\r\n",
"[22] MA(1.0) for b2c3+c4=>ab2c3+b2c3+c4\r\n",
"[23] MA(3.0) for ab2+b2c2=>ab2+ab2c3+b2c2\r\n",
"[24] MA(1.0) for 2*ab2c3=>3*ab2c3\r\n",
"[25] MA(2.0) for a2b+ac3=>a2b+ab2c3+ac3\r\n",
"[26] MA(2.0) for ac3+c=>a2+ac3+c\r\n",
"[27] MA(2.0) for a2+ab2c3=>ab2c3+2*a2\r\n",
"[28] MA(2.0) for a+bc4=>a+a2b+bc4\r\n",
"[29] MA(2.0) for a2b+ab2c3=>ab2c3+2*a2b\r\n",
"[30] MA(1.0) for 2*a2=>a2b+2*a2\r\n",
"[0] b2\r\n",
"[1] c\r\n",
"[2] b2c\r\n",
"[3] c2\r\n",
"[4] b2c2\r\n",
"[5] c3\r\n",
"[6] b2c3\r\n",
"[7] c4\r\n",
"[8] a2\r\n",
"[9] b\r\n",
"[10] bc4\r\n",
"[11] a2b\r\n",
"[12] a\r\n",
"[13] ac3\r\n",
"[14] ab2\r\n",
"[15] ab2c3\r\n"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"with_timer(compile_from_pivp((1.0, d(a)/dt = c^4+a^2*b^2*c^3);\n",
"\t\t\t\t\t(1.0, d(b)/dt = a^2);\n",
"\t\t\t\t\t(1.0, d(c)/dt = b^2), a)).\n",
"list_reactions.\n",
"list_molecules."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Hill functions\n",
"The hill function of order $k$ is described with the PODE of three variables:\n",
"$$ \\frac{dh}{dt} = k i^2 t^{k-1},\\\\\n",
" \\frac{di}{dt} = -k i^2 t^{k-1},\\\\\n",
" \\frac{dt}{dt} = 1.$$\n",
"Note that the third species is a proxy to use the time as an explicit variable."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Hill 2"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
" 5\r\n",
"The previous command takes 81.6991 ms\r\n",
"[0] MA(2.0) for i+it=>h+it\r\n",
"[1] MA(1.0) for i=>i+it\r\n",
"[2] MA(2.0) for 2*it=>it\r\n",
"[0] i\r\n",
"[1] it\r\n",
"[2] h\r\n"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"with_timer(compile_from_pivp((0.0, d(h)/dt = 2*i^2*t^1);\n",
"\t\t\t\t\t(1.0, d(i)/dt = -2*i^2*t^1);\n",
"\t\t\t\t\t(0.0, d(t)/dt = 1.0), h)).\n",
"list_reactions.\n",
"list_molecules."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Hill 2 (input)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
" 11\r\n",
"The previous command takes 85.5587 ms\r\n",
"[0] MA(2.0) for i+itx=>h+itx\r\n",
"[1] MA(1.0) for x=>_\r\n",
"[2] MA(1.0) for ix=>_\r\n",
"[3] MA(2.0) for itx+ix=>itx\r\n",
"[4] MA(1.0) for ix+x=>itx+ix+x\r\n",
"[5] MA(1.0) for itx=>_\r\n",
"[6] MA(2.0) for 2*itx=>itx\r\n",
"[0] i\r\n",
"[1] itx\r\n",
"[2] h\r\n",
"[3] x\r\n",
"[4] ix\r\n"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"with_timer(compile_from_pivp((0.0, d(h)/dt = 2*i^2*t^1);\n",
"\t\t\t\t\t(1.0, d(i)/dt = -2*i^2*t^1);\n",
"\t\t\t\t\t(0.0, d(t)/dt = 1.0), x, h)).\n",
"list_reactions.\n",
"list_molecules."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Hill 3"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
" 8\r\n",
"The previous command takes 81.023 ms\r\n",
"[0] MA(3.0) for i+it2=>h+it2\r\n",
"[1] MA(1.0) for _=>t\r\n",
"[2] MA(2.0) for i+t=>i+it2+t\r\n",
"[3] MA(3.0) for 2*it2=>it2\r\n",
"[0] i\r\n",
"[1] it2\r\n",
"[2] h\r\n",
"[3] t\r\n"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"with_timer(compile_from_pivp((0.0, d(h)/dt = 3*i^2*t^2);\n",
"\t\t\t\t\t(1.0, d(i)/dt = -3*i^2*t^2);\n",
"\t\t\t\t\t(0.0, d(t)/dt = 1.0), h)).\n",
"list_reactions.\n",
"list_molecules."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Hill 3 (input)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
" 17\r\n",
"The previous command takes 101.417 ms\r\n",
"[0] MA(3.0) for i+it2x=>h+it2x\r\n",
"[1] MA(1.0) for x=>_\r\n",
"[2] MA(1.0) for 2*x=>tx+2*x\r\n",
"[3] MA(1.0) for tx=>_\r\n",
"[4] MA(1.0) for ix=>_\r\n",
"[5] MA(3.0) for it2x+ix=>it2x\r\n",
"[6] MA(2.0) for ix+tx=>it2x+ix+tx\r\n",
"[7] MA(1.0) for it2x=>_\r\n",
"[8] MA(3.0) for 2*it2x=>it2x\r\n",
"[0] i\r\n",
"[1] it2x\r\n",
"[2] h\r\n",
"[3] x\r\n",
"[4] tx\r\n",
"[5] ix\r\n"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"with_timer(compile_from_pivp((0.0, d(h)/dt = 3*i^2*t^2);\n",
"\t\t\t\t\t(1.0, d(i)/dt = -3*i^2*t^2);\n",
"\t\t\t\t\t(0.0, d(t)/dt = 1.0), x, h)).\n",
"list_reactions.\n",
"list_molecules."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Hill 4"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
" 11\r\n",
"The previous command takes 86.036 ms\r\n",
"[0] MA(4.0) for i+it3=>h+it3\r\n",
"[1] MA(1.0) for _=>t\r\n",
"[2] MA(2.0) for t=>t+t2\r\n",
"[3] MA(3.0) for i+t2=>i+it3+t2\r\n",
"[4] MA(4.0) for 2*it3=>it3\r\n",
"[0] i\r\n",
"[1] it3\r\n",
"[2] h\r\n",
"[3] t\r\n",
"[4] t2\r\n"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"with_timer(compile_from_pivp((0.0, d(h)/dt = 4*i^2*t^3);\n",
"\t\t\t\t\t(1.0, d(i)/dt = -4*i^2*t^3);\n",
"\t\t\t\t\t(0.0, d(t)/dt = 1.0), h)).\n",
"list_reactions.\n",
"list_molecules."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Hill 4 (input)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
" 23\r\n",
"The previous command takes 154.526 ms\r\n",
"[0] MA(4.0) for i+it3x=>h+it3x\r\n",
"[1] MA(1.0) for x=>t\r\n",
"[2] MA(1.0) for 2*x=>tx+2*x\r\n",
"[3] MA(1.0) for tx=>_\r\n",
"[4] MA(2.0) for tx+x=>t2x+tx+x\r\n",
"[5] MA(1.0) for t2x=>_\r\n",
"[6] MA(1.0) for ix=>_\r\n",
"[7] MA(4.0) for it3x+ix=>it3x\r\n",
"[8] MA(3.0) for ix+t2x=>it3x+ix+t2x\r\n",
"[9] MA(1.0) for it3x=>_\r\n",
"[10] MA(4.0) for 2*it3x=>it3x\r\n",
"[0] i\r\n",
"[1] it3x\r\n",
"[2] h\r\n",
"[3] x\r\n",