Skip to content
Merged
156 changes: 134 additions & 22 deletions examples/3D/Sliced solid torus.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,121 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"forward = IntervalConstraintProgramming.GeneratedFunction(Symbol[:x,:y,:z],Symbol[:_z_1_,:_z_2_,:_z_3_,:_z_4_,:_z_5_,:_z_6_,:_z_7_,:_z_8_],quote \n",
" _z_1_ = x ^ 2\n",
" _z_2_ = y ^ 2\n",
" _z_3_ = _z_1_ + _z_2_\n",
" _z_4_ = sqrt(_z_3_)\n",
" _z_5_ = 3 - _z_4_\n",
" _z_6_ = _z_5_ ^ 2\n",
" _z_7_ = z ^ 2\n",
" _z_8_ = _z_6_ + _z_7_\n",
"end)\n",
"backward = IntervalConstraintProgramming.GeneratedFunction(Symbol[:x,:y,:z,:_z_1_,:_z_2_,:_z_3_,:_z_4_,:_z_5_,:_z_6_,:_z_7_,:_z_8_],Symbol[:x,:y,:z],quote \n",
" (_z_8_,_z_6_,_z_7_) = plus_rev(_z_8_,_z_6_,_z_7_)\n",
" (_z_7_,z,_) = power_rev(_z_7_,z,2)\n",
" (_z_6_,_z_5_,_) = power_rev(_z_6_,_z_5_,2)\n",
" (_z_5_,_,_z_4_) = minus_rev(_z_5_,3,_z_4_)\n",
" (_z_4_,_z_3_) = sqrt_rev(_z_4_,_z_3_)\n",
" (_z_3_,_z_1_,_z_2_) = plus_rev(_z_3_,_z_1_,_z_2_)\n",
" (_z_2_,y,_) = power_rev(_z_2_,y,2)\n",
" (_z_1_,x,_) = power_rev(_z_1_,x,2)\n",
"end)\n",
"code = quote # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/contractor.jl, line 144:\n",
" (_A_,x,y,z)->begin # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/contractor.jl, line 144:\n",
" begin # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/contractor.jl, line 145:\n",
" forward = begin # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/code_generation.jl, line 137:\n",
" (x,y,z)->begin # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/code_generation.jl, line 137:\n",
" begin # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/code_generation.jl, line 138:\n",
" begin \n",
" _z_1_ = x ^ 2\n",
" _z_2_ = y ^ 2\n",
" _z_3_ = _z_1_ + _z_2_\n",
" _z_4_ = sqrt(_z_3_)\n",
" _z_5_ = 3 - _z_4_\n",
" _z_6_ = _z_5_ ^ 2\n",
" _z_7_ = z ^ 2\n",
" _z_8_ = _z_6_ + _z_7_\n",
" end # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/code_generation.jl, line 139:\n",
" return (_z_1_,_z_2_,_z_3_,_z_4_,_z_5_,_z_6_,_z_7_,_z_8_)\n",
" end\n",
" end\n",
" end # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/contractor.jl, line 146:\n",
" backward = begin # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/code_generation.jl, line 137:\n",
" (x,y,z,_z_1_,_z_2_,_z_3_,_z_4_,_z_5_,_z_6_,_z_7_,_z_8_)->begin # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/code_generation.jl, line 137:\n",
" begin # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/code_generation.jl, line 138:\n",
" begin \n",
" (_z_8_,_z_6_,_z_7_) = plus_rev(_z_8_,_z_6_,_z_7_)\n",
" (_z_7_,z,_) = power_rev(_z_7_,z,2)\n",
" (_z_6_,_z_5_,_) = power_rev(_z_6_,_z_5_,2)\n",
" (_z_5_,_,_z_4_) = minus_rev(_z_5_,3,_z_4_)\n",
" (_z_4_,_z_3_) = sqrt_rev(_z_4_,_z_3_)\n",
" (_z_3_,_z_1_,_z_2_) = plus_rev(_z_3_,_z_1_,_z_2_)\n",
" (_z_2_,y,_) = power_rev(_z_2_,y,2)\n",
" (_z_1_,x,_) = power_rev(_z_1_,x,2)\n",
" end # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/code_generation.jl, line 139:\n",
" return (x,y,z)\n",
" end\n",
" end\n",
" end # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/contractor.jl, line 148:\n",
" (_z_1_,_z_2_,_z_3_,_z_4_,_z_5_,_z_6_,_z_7_,_z_8_) = forward(x,y,z) # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/contractor.jl, line 150:\n",
" _z_8_ = _z_8_ ∩ _A_ # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/contractor.jl, line 152:\n",
" (x,y,z) = backward(x,y,z,_z_1_,_z_2_,_z_3_,_z_4_,_z_5_,_z_6_,_z_7_,_z_8_) # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/contractor.jl, line 154:\n",
" return (x,y,z)\n",
" end\n",
" end\n",
"end\n",
"forward = IntervalConstraintProgramming.GeneratedFunction(Symbol[:x,:y,:z],Symbol[:_z_9_,:_z_10_],quote \n",
" _z_9_ = x + y\n",
" _z_10_ = _z_9_ + z\n",
"end)\n",
"backward = IntervalConstraintProgramming.GeneratedFunction(Symbol[:x,:y,:z,:_z_9_,:_z_10_],Symbol[:x,:y,:z],quote \n",
" (_z_10_,_z_9_,z) = plus_rev(_z_10_,_z_9_,z)\n",
" (_z_9_,x,y) = plus_rev(_z_9_,x,y)\n",
"end)\n",
"code = quote # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/contractor.jl, line 144:\n",
" (_A_,x,y,z)->begin # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/contractor.jl, line 144:\n",
" begin # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/contractor.jl, line 145:\n",
" forward = begin # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/code_generation.jl, line 137:\n",
" (x,y,z)->begin # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/code_generation.jl, line 137:\n",
" begin # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/code_generation.jl, line 138:\n",
" begin \n",
" _z_9_ = x + y\n",
" _z_10_ = _z_9_ + z\n",
" end # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/code_generation.jl, line 139:\n",
" return (_z_9_,_z_10_)\n",
" end\n",
" end\n",
" end # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/contractor.jl, line 146:\n",
" backward = begin # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/code_generation.jl, line 137:\n",
" (x,y,z,_z_9_,_z_10_)->begin # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/code_generation.jl, line 137:\n",
" begin # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/code_generation.jl, line 138:\n",
" begin \n",
" (_z_10_,_z_9_,z) = plus_rev(_z_10_,_z_9_,z)\n",
" (_z_9_,x,y) = plus_rev(_z_9_,x,y)\n",
" end # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/code_generation.jl, line 139:\n",
" return (x,y,z)\n",
" end\n",
" end\n",
" end # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/contractor.jl, line 148:\n",
" (_z_9_,_z_10_) = forward(x,y,z) # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/contractor.jl, line 150:\n",
" _z_10_ = _z_10_ ∩ _A_ # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/contractor.jl, line 152:\n",
" (x,y,z) = backward(x,y,z,_z_9_,_z_10_) # /Users/dpsanders/.julia/v0.5/IntervalConstraintProgramming/src/contractor.jl, line 154:\n",
" return (x,y,z)\n",
" end\n",
" end\n",
"end\n"
]
},
{
"data": {
"text/plain": [
Expand All @@ -40,7 +150,7 @@
"- expression: (x + y) + z ∈ [-∞, 1]\n"
]
},
"execution_count": 5,
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -53,7 +163,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 3,
"metadata": {
"collapsed": false
},
Expand All @@ -62,7 +172,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
" 2.505603 seconds (6.72 M allocations: 253.181 MB, 3.97% gc time)\n"
" 3.328242 seconds (7.76 M allocations: 313.713 MB, 3.67% gc time)\n"
]
}
],
Expand All @@ -73,7 +183,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 21,
"metadata": {
"collapsed": false
},
Expand All @@ -82,22 +192,22 @@
"name": "stdout",
"output_type": "stream",
"text": [
" 49.398598 seconds (161.52 M allocations: 5.873 GB, 5.38% gc time)\n"
" 12.920378 seconds (43.82 M allocations: 1.598 GB, 5.94% gc time)\n"
]
},
{
"data": {
"text/plain": [
"0.05"
"0.1"
]
},
"execution_count": 19,
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"@time refine!(paving, 0.05)"
"@time refine!(paving, 0.1)"
]
},
{
Expand Down Expand Up @@ -131,7 +241,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 4,
"metadata": {
"collapsed": false
},
Expand All @@ -143,7 +253,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 5,
"metadata": {
"collapsed": false
},
Expand All @@ -161,7 +271,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 6,
"metadata": {
"collapsed": false
},
Expand All @@ -186,26 +296,19 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 7,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Visualization packages loaded.\n"
]
},
{
"data": {
"text/plain": [
"Task (runnable) @0x000000011513ead0"
"Task (runnable) @0x0000000110be9450"
]
},
"execution_count": 18,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -222,6 +325,15 @@
"\n",
"@async renderloop(window)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Loading