Commit 2ae0d11a authored by SOLIMAN Sylvain's avatar SOLIMAN Sylvain
Browse files

Bench Binomialisation (nom peu parlant)

parent 5326fe84
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Biocham 4.4.9\n",
"Copyright (C) 2003-2020 Inria, EPI Lifeware, Saclay-Île de France, France,\n",
"license GNU GPL 2, http://lifeware.inria.fr/biocham4/\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Biocham 4.4.9\n",
"Copyright (C) 2003-2020 Inria, EPI Lifeware, Saclay-Île de France, France,\n",
"license GNU GPL 2, http://lifeware.inria.fr/biocham4/\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Biocham 4.4.9\n",
"Copyright (C) 2003-2020 Inria, EPI Lifeware, Saclay-Île de France, France,\n",
"license GNU GPL 2, http://lifeware.inria.fr/biocham4/\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Benchmark: Binomial Transformation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Options and settings"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"prolog(set_prolog_flag(stack_limit, 4_294_967_296)).\n",
"option(binomial_reduction:sat_species)."
]
},
{
"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",
"MA(1) for x+x2=>y+x+x2.\r\n",
"2*xy*x2 for xy+x2=>y2+xy+x2.\r\n",
"MA(1) for y+y2=>x+y+y2.\r\n",
"MA(1) for 2*y2=>xy+2*y2.\r\n",
"MA(1) for 2*x2=>xy+2*x2.\r\n",
"2*y2*xy for y2+xy=>x2+y2+xy.\r\n",
"present(y,1.0).\r\n",
"present(y2,1.0).\r\n",
"present(x,1.0).\r\n",
"present(xy,1.0).\r\n",
"present(x2,1.0).\r\n"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"compile_from_pivp((1.0, d(x)/dt = y^3);(1.0, d(y)/dt = x^3), x).\n",
"list_model."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Circular 2,4"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"23\r\n",
"MA(1) for x+x3=>y+x+x3.\r\n",
"3*xy2*x3 for xy2+x3=>y3+xy2+x3.\r\n",
"MA(1) for y+y3=>x+y+y3.\r\n",
"MA(1) for 2*y3=>xy2+2*y3.\r\n",
"2*x2y*x3 for x2y+x3=>xy2+x2y+x3.\r\n",
"2*y3*xy2 for y3+xy2=>x2y+y3+xy2.\r\n",
"MA(1) for 2*x3=>x2y+2*x3.\r\n",
"3*y3*x2y for y3+x2y=>x3+y3+x2y.\r\n",
"present(y,1.0).\r\n",
"present(y3,1.0).\r\n",
"present(x,1.0).\r\n",
"present(xy2,1.0).\r\n",
"present(x2y,1.0).\r\n",
"present(x3,1.0).\r\n"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"compile_from_pivp((1.0, d(x)/dt = y^4);(1.0, d(y)/dt = x^4), x).\n",
"list_model."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Circular 2,5"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"34\r\n",
"MA(1) for x+x4=>y+x+x4.\r\n",
"4*xy3*x4 for xy3+x4=>y4+xy3+x4.\r\n",
"MA(1) for y+y4=>x+y+y4.\r\n",
"MA(1) for 2*y4=>xy3+2*y4.\r\n",
"3*x3y^2 for 2*x3y=>xy3+2*x3y.\r\n",
"3*xy3^2 for 2*xy3=>x3y+2*xy3.\r\n",
"MA(1) for 2*x4=>x3y+2*x4.\r\n",
"4*y4*x3y for y4+x3y=>x4+y4+x3y.\r\n",
"present(y,1.0).\r\n",
"present(y4,1.0).\r\n",
"present(x,1.0).\r\n",
"present(xy3,1.0).\r\n",
"present(x3y,1.0).\r\n",
"present(x4,1.0).\r\n"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"compile_from_pivp((1.0, d(x)/dt = y^5);(1.0, d(y)/dt = x^5), x).\n",
"list_model."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Circular 2,6"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"47\r\n",
"MA(1) for x+x5=>y+x+x5.\r\n",
"5*xy4*x5 for xy4+x5=>y5+xy4+x5.\r\n",
"MA(1) for y+y5=>x+y+y5.\r\n",
"MA(1) for 2*y5=>xy4+2*y5.\r\n",
"4*x3y2*x4y for x3y2+x4y=>xy4+x3y2+x4y.\r\n",
"3*xy4^2 for 2*xy4=>x3y2+2*xy4.\r\n",
"2*x4y*x5 for x4y+x5=>x3y2+x4y+x5.\r\n",
"4*y5*x3y2 for y5+x3y2=>x4y+y5+x3y2.\r\n",
"MA(1) for 2*x5=>x4y+2*x5.\r\n",
"5*y5*x4y for y5+x4y=>x5+y5+x4y.\r\n",
"present(y,1.0).\r\n",
"present(y5,1.0).\r\n",
"present(x,1.0).\r\n",
"present(xy4,1.0).\r\n",
"present(x3y2,1.0).\r\n",
"present(x4y,1.0).\r\n",
"present(x5,1.0).\r\n"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"compile_from_pivp((1.0, d(x)/dt = y^6);(1.0, d(y)/dt = x^6), x).\n",
"list_model."
]
},
{
"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",
"MA(1) for b2=>c+b2.\r\n",
"3*c*b2c for c+b2c=>c3+c+b2c.\r\n",
"MA(1) for a2=>b+a2.\r\n",
"2*a2b for a2b=>b2+a2b.\r\n",
"MA(1) for 2*b2=>b2c+2*b2.\r\n",
"2*c*a2b for c+a2b=>b2c+c+a2b.\r\n",
"3*b2c^2 for 2*b2c=>b2c3+2*b2c.\r\n",
"2*c3*a2b for c3+a2b=>b2c3+c3+a2b.\r\n",
"MA(1) for c3=>a+c3.\r\n",
"MA(1) for b2c3+a2=>a+b2c3+a2.\r\n",
"MA(1) for c+c3=>ac+c+c3.\r\n",
"MA(1) for ab2=>ac+ab2.\r\n",
"MA(1) for ac+ab2c3=>2*ac+ab2c3.\r\n",
"MA(1) for 2*c3=>ac3+2*c3.\r\n",
"3*c*ab2c for c+ab2c=>ac3+c+ab2c.\r\n",
"MA(1) for ac3+ab2c3=>2*ac3+ab2c3.\r\n",
"MA(1) for b2c3=>ab2+b2c3.\r\n",
"MA(1) for ab2+ab2c3=>2*ab2+ab2c3.\r\n",
"2*a*a2b for a+a2b=>ab2+a+a2b.\r\n",
"MA(1) for c+b2c3=>ab2c+c+b2c3.\r\n",
"MA(1) for b2+ab2=>ab2c+b2+ab2.\r\n",
"MA(1) for ab2c+ab2c3=>2*ab2c+ab2c3.\r\n",
"2*ac*a2b for ac+a2b=>ab2c+ac+a2b.\r\n",
"MA(1) for c3+b2c3=>ab2c3+c3+b2c3.\r\n",
"3*b2c*ab2c for b2c+ab2c=>ab2c3+b2c+ab2c.\r\n",
"MA(1) for 2*ab2c3=>3*ab2c3.\r\n",
"2*ac3*a2b for ac3+a2b=>ab2c3+ac3+a2b.\r\n",
"2*ac3 for ac3=>a2+ac3.\r\n",
"2*ab2c3*a2 for ab2c3+a2=>2*a2+ab2c3.\r\n",
"2*b*ac3 for b+ac3=>a2b+b+ac3.\r\n",
"2*ab2c3*a2b for ab2c3+a2b=>2*a2b+ab2c3.\r\n",
"MA(1) for 2*a2=>a2b+2*a2.\r\n",
"present(c,1.0).\r\n",
"present(c3,1.0).\r\n",
"present(b,1.0).\r\n",
"present(b2,1.0).\r\n",
"present(b2c,1.0).\r\n",
"present(b2c3,1.0).\r\n",
"present(a,1.0).\r\n",
"present(ac,1.0).\r\n",
"present(ac3,1.0).\r\n",
"present(ab2,1.0).\r\n",
"present(ab2c,1.0).\r\n",
"present(ab2c3,1.0).\r\n",
"present(a2,1.0).\r\n",
"present(a2b,1.0).\r\n"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"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_model."
]
},
{
"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",
"MA(1) for b2=>c+b2.\r\n",
"3*b2c2 for b2c2=>c3+b2c2.\r\n",
"4*c*b2c2 for c+b2c2=>c4+c+b2c2.\r\n",
"MA(1) for a2=>b+a2.\r\n",
"3*b*b2c2 for b+b2c2=>bc3+b+b2c2.\r\n",
"MA(1) for c+a2c2=>bc3+c+a2c2.\r\n",
"4*bc3*b2 for bc3+b2=>bc4+bc3+b2.\r\n",
"MA(1) for c4+a2=>bc4+c4+a2.\r\n",
"2*a2b for a2b=>b2+a2b.\r\n",
"MA(1) for 2*b2=>b2c+2*b2.\r\n",
"2*c*a2b for c+a2b=>b2c+c+a2b.\r\n",
"2*b2*b2c for b2+b2c=>b2c2+b2+b2c.\r\n",
"2*b*a2c2 for b+a2c2=>b2c2+b+a2c2.\r\n",
"MA(1) for c4=>a+c4.\r\n",
"MA(1) for bc3+a2b=>a+bc3+a2b.\r\n",
"MA(1) for c3+c4=>ac3+c3+c4.\r\n",
"3*b2c2*a for b2c2+a=>ac3+b2c2+a.\r\n",
"MA(1) for ac3+ab2c3=>2*ac3+ab2c3.\r\n",
"MA(1) for c3+b2c=>ab2+c3+b2c.\r\n",
"MA(1) for ab2+ab2c3=>2*ab2+ab2c3.\r\n",
"2*a*a2b for a+a2b=>ab2+a+a2b.\r\n",
"MA(1) for bc3+bc4=>ab2c3+bc3+bc4.\r\n",
"3*b2c2*ab2 for b2c2+ab2=>ab2c3+b2c2+ab2.\r\n",
"MA(1) for 2*ab2c3=>3*ab2c3.\r\n",
"2*ac3*a2b for ac3+a2b=>ab2c3+ac3+a2b.\r\n",
"2*c*ac3 for c+ac3=>a2+c+ac3.\r\n",
"2*ab2c3*a2 for ab2c3+a2=>2*a2+ab2c3.\r\n",
"2*c3*ac3 for c3+ac3=>a2c2+c3+ac3.\r\n",
"2*b2c*a2 for b2c+a2=>a2c2+b2c+a2.\r\n",
"2*ab2c3*a2c2 for ab2c3+a2c2=>2*a2c2+ab2c3.\r\n",
"2*bc4*a for bc4+a=>a2b+bc4+a.\r\n",
"2*ab2c3*a2b for ab2c3+a2b=>2*a2b+ab2c3.\r\n",
"MA(1) for 2*a2=>a2b+2*a2.\r\n",
"present(c,1.0).\r\n",
"present(c3,1.0).\r\n",
"present(c4,1.0).\r\n",
"present(b,1.0).\r\n",
"present(bc3,1.0).\r\n",
"present(bc4,1.0).\r\n",
"present(b2,1.0).\r\n",
"present(b2c,1.0).\r\n",
"present(b2c2,1.0).\r\n",
"present(a,1.0).\r\n",
"present(ac3,1.0).\r\n",
"present(ab2,1.0).\r\n",
"present(ab2c3,1.0).\r\n",
"present(a2,1.0).\r\n",
"present(a2c2,1.0).\r\n",
"present(a2b,1.0).\r\n"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"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_model."
]
},
{
"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",
"2*i*it for i+it=>h+i+it.\r\n",
"2*i*it for i+it=>it.\r\n",
"1*i for i=>it+i.\r\n",
"2*it^2 for 2*it=>it.\r\n",
"present(i,1.0).\r\n"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"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_model.\n",
"list_molecules."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Hill 2 (input)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
" 11\r\n",
"2*i*itx for i+itx=>h+i+itx.\r\n",
"MA(1) for x=>_.\r\n",
"2*i*itx for i+itx=>itx.\r\n",
"MA(1) for ix=>_.\r\n",
"2*ix*itx for ix+itx=>itx.\r\n",
"1*x*ix for x+ix=>itx+x+ix.\r\n",
"MA(1) for itx=>_.\r\n",
"2*itx^2 for 2*itx=>itx.\r\n",
"present(x,input).\r\n",
"present(i,1.0).\r\n",
"present(ix,input).\r\n",
"parameter(\r\n",
" input = 1.0\r\n",
").\r\n",
"[0] i\r\n",
"[1] itx\r\n",
"[2] h\r\n",
"[3] x\r\n",
"[4] ix\r\n"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"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_model.\n",
"list_molecules."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Hill 3"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
" 8\r\n",
"3*i*it2 for i+it2=>h+i+it2.\r\n",
"3*i*it2 for i+it2=>it2.\r\n",
"1*i for i=>it+i.\r\n",
"3*it*it2 for it+it2=>it2.\r\n",
"2*it for it=>it2+it.\r\n",
"3*it2^2 for 2*it2=>it2.\r\n",
"present(i,1.0).\r\n",
"[0] i\r\n",
"[1] it2\r\n",
"[2] h\r\n",
"[3] it\r\n"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"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_model.\n",
"list_molecules."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Hill 3 (input)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
" 17\r\n",
"3*i*it2x for i+it2x=>h+i+it2x.\r\n",
"MA(1) for x=>_.\r\n",
"3*i*it2x for i+it2x=>it2x.\r\n",
"MA(1) for ix=>_.\r\n",
"3*ix*it2x for ix+it2x=>it2x.\r\n",
"1*x*ix for x+ix=>itx+x+ix.\r\n",
"MA(1) for itx=>_.\r\n",
"3*itx*it2x for itx+it2x=>it2x.\r\n",
"2*x*itx for x+itx=>it2x+x+itx.\r\n",
"MA(1) for it2x=>_.\r\n",
"3*it2x^2 for 2*it2x=>it2x.\r\n",
"present(x,input).\r\n",
"present(i,1.0).\r\n",
"present(ix,input).\r\n",
"parameter(\r\n",
" input = 1.0\r\n",
").\r\n",
"[0] i\r\n",
"[1] it2x\r\n",
"[2] h\r\n",
"[3] x\r\n",
"[4] ix\r\n",
"[5] itx\r\n"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"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_model.\n",
"list_molecules."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Hill 4"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
" 11\r\n",
"4*i*it3 for i+it3=>h+i+it3.\r\n",
"MA(1) for _=>t.\r\n",
"4*i*it3 for i+it3=>it3.\r\n",
"2*t*i for t+i=>it2+t+i.\r\n",
"4*it2*it3 for it2+it3=>it3.\r\n",
"3*it2 for it2=>it3+it2.\r\n",
"4*it3^2 for 2*it3=>it3.\r\n",
"present(i,1.0).\r\n",
"[0] i\r\n",
"[1] it3\r\n",
"[2] h\r\n",
"[3] t\r\n",
"[4] it2\r\n"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"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_model.\n",
"list_molecules."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Hill 4 (input)"