Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Coupon Particle Generation "
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"# Amira Abdel-Rahman\n",
"# (c) Massachusetts Institute of Technology 2020"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"using Plots\n",
"import StaticArrays: SVector\n",
"using RegionTrees\n",
"import JSON\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"include(\"adaptive_distance_fields.jl\")\n",
"using .AdaptivelySampledDistanceFields: ASDF, evaluate"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Frep Coupon"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"frepCoupon (generic function with 2 methods)"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function frepCoupon(X,Y)\n",
" return min(min(min(min((min(X-(-123),(123)-X)),(min(Y-(-14.5),(14.5)-Y))),-(min((min(X-(-28.5),(28.5)-X)),(min(Y-(9.5),(100)-Y))))),-(min((min(X-(-28.5),(28.5)-X)),(min(Y-(-100),(-9.5)-Y))))),-(max(max(max(((76)*(76)-((X-(-28.5))*(X-(-28.5))+(Y-(-85.5))*(Y-(-85.5)))),((76)*(76)-((X-(28.5))*(X-(28.5))+(Y-(85.5))*(Y-(85.5))))),((76)*(76)-((X-(28.5))*(X-(28.5))+(Y-(-85.5))*(Y-(-85.5))))),((76)*(76)-((X-(-28.5))*(X-(-28.5))+(Y-(85.5))*(Y-(85.5)))))))\n",
"end\n",
"function frepCoupon(v)\n",
" X=v[1]\n",
" Y=v[2]/1\n",
" return min(min(min(min((min(X-(-123),(123)-X)),(min(Y-(-14.5),(14.5)-Y))),-(min((min(X-(-28.5),(28.5)-X)),(min(Y-(9.5),(100)-Y))))),-(min((min(X-(-28.5),(28.5)-X)),(min(Y-(-100),(-9.5)-Y))))),-(max(max(max(((76)*(76)-((X-(-28.5))*(X-(-28.5))+(Y-(-85.5))*(Y-(-85.5)))),((76)*(76)-((X-(28.5))*(X-(28.5))+(Y-(85.5))*(Y-(85.5))))),((76)*(76)-((X-(28.5))*(X-(28.5))+(Y-(-85.5))*(Y-(-85.5))))),((76)*(76)-((X-(-28.5))*(X-(-28.5))+(Y-(85.5))*(Y-(85.5)))))))\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"frepCouponBW (generic function with 1 method)"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function frepCouponBW(X,Y)\n",
" if frepCoupon(X,Y)>0\n",
" return 1\n",
" else\n",
" return 0\n",
" end\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 445,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"frepCouponScale (generic function with 2 methods)"
]
},
"execution_count": 445,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function frepCouponScale(X,Y)\n",
" scale=100.0\n",
" return min(min(min(min((min(X-(-123/scale),(123/scale)-X)),(min(Y-(-14.5/scale),(14.5/scale)-Y))),-(min((min(X-(-28.5/scale),(28.5/scale)-X)),(min(Y-(9.5/scale),(100/scale)-Y))))),-(min((min(X-(-28.5/scale),(28.5/scale)-X)),(min(Y-(-100/scale),(-9.5/scale)-Y))))),-(max(max(max(((76/scale)*(76/scale)-((X-(-28.5/scale))*(X-(-28.5/scale))+(Y-(-85.5/scale))*(Y-(-85.5/scale)))),((76/scale)*(76/scale)-((X-(28.5/scale))*(X-(28.5/scale))+(Y-(85.5/scale))*(Y-(85.5/scale))))),((76/scale)*(76/scale)-((X-(28.5/scale))*(X-(28.5/scale))+(Y-(-85.5/scale))*(Y-(-85.5/scale))))),((76/scale)*(76/scale)-((X-(-28.5/scale))*(X-(-28.5/scale))+(Y-(85.5/scale))*(Y-(85.5/scale)))))))\n",
"end\n",
"function frepCouponBWScale(X,Y)\n",
" if frepCouponScale(X,Y)>0\n",
" return 1\n",
" else\n",
" return 0\n",
" end\n",
"end\n",
"function frepCouponScale(v)\n",
" X=v[1]\n",
" Y=v[2]\n",
" scale=100.0\n",
" f= min(min(min(min((min(X-(-123/scale),(123/scale)-X)),(min(Y-(-14.5/scale),(14.5/scale)-Y))),-(min((min(X-(-28.5/scale),(28.5/scale)-X)),(min(Y-(9.5/scale),(100/scale)-Y))))),-(min((min(X-(-28.5/scale),(28.5/scale)-X)),(min(Y-(-100/scale),(-9.5/scale)-Y))))),-(max(max(max(((76/scale)*(76/scale)-((X-(-28.5/scale))*(X-(-28.5/scale))+(Y-(-85.5/scale))*(Y-(-85.5/scale)))),((76/scale)*(76/scale)-((X-(28.5/scale))*(X-(28.5/scale))+(Y-(85.5/scale))*(Y-(85.5/scale))))),((76/scale)*(76/scale)-((X-(28.5/scale))*(X-(28.5/scale))+(Y-(-85.5/scale))*(Y-(-85.5/scale))))),((76/scale)*(76/scale)-((X-(-28.5/scale))*(X-(-28.5/scale))+(Y-(85.5/scale))*(Y-(85.5/scale)))))))\n",
" return min(max(f,0.0),0.1)\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 90,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 2400 1600\">\n",
"<defs>\n",
" <clipPath id=\"clip6100\">\n",
" <rect x=\"0\" y=\"0\" width=\"2400\" height=\"1600\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<path clip-path=\"url(#clip6100)\" d=\"\n",
"M0 1600 L2400 1600 L2400 0 L0 0 Z\n",
" \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip6101\">\n",
" <rect x=\"480\" y=\"0\" width=\"1681\" height=\"1600\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<path clip-path=\"url(#clip6100)\" d=\"\n",
"M168.627 1408.35 L2112.76 1408.35 L2112.76 126.373 L168.627 126.373 Z\n",
" \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip6102\">\n",
" <rect x=\"168\" y=\"126\" width=\"1945\" height=\"1283\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip6102)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
" 395.814,1408.35 395.814,126.373 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip6102)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
" 768.253,1408.35 768.253,126.373 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip6102)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
" 1140.69,1408.35 1140.69,126.373 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip6102)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
" 1513.13,1408.35 1513.13,126.373 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip6102)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
" 1885.57,1408.35 1885.57,126.373 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip6102)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
" 168.627,1214.29 2112.76,1214.29 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip6102)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
" 168.627,990.823 2112.76,990.823 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip6102)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
" 168.627,767.359 2112.76,767.359 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip6102)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
" 168.627,543.896 2112.76,543.896 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip6102)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
" 168.627,320.433 2112.76,320.433 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip6100)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
Loading
Loading full blame...