WIP
This commit is contained in:
parent
a612bee21a
commit
39fc616f32
1 changed files with 46 additions and 36 deletions
|
|
@ -30,14 +30,22 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 147,
|
||||
"execution_count": 206,
|
||||
"id": "efed4eb5-0779-4be1-9849-9816dfd81c5d",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"/home/jaseg/proj/ihsm-secondary-mesh/venv/lib/python3.12/site-packages/traittypes/traittypes.py:97: UserWarning: Given trait value dtype \"int64\" does not match required type \"float32\". A coerced copy has been created.\n",
|
||||
" warnings.warn(\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "226b514ca81642f680dfac750bd03083",
|
||||
"model_id": "bda3e2161d89497ca8ee788334884892",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
|
|
@ -72,7 +80,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 148,
|
||||
"execution_count": 180,
|
||||
"id": "4215b9e5-4533-451a-94be-0fc62ade9b34",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
|
|
@ -82,20 +90,20 @@
|
|||
"xs = np.linspace(-10, 90, 2000, dtype=np.float32)\n",
|
||||
"ys = np.linspace(-10, 10, 40, dtype=np.float32)\n",
|
||||
"zs = np.linspace(-14, 0, 32, dtype=np.float32)\n",
|
||||
"coords = np.array(np.meshgrid(xs, ys, zs)).T.reshape(-1, 3)\n",
|
||||
"coords = np.array(np.meshgrid(xs, ys, zs, indexing='ij')).T.reshape(-1, 3)\n",
|
||||
"sdf_vol = f(coords)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 149,
|
||||
"execution_count": 181,
|
||||
"id": "6b955c31-639d-49a8-983d-744bf9648a38",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "390d49d6697d4d7fab5280849e1e5cec",
|
||||
"model_id": "3fb11fc88976448990c5ee91669cfa77",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
|
|
@ -119,7 +127,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 150,
|
||||
"execution_count": 183,
|
||||
"id": "d3a63bbe-a827-4fe9-8806-50081d844702",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
|
|
@ -140,7 +148,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 151,
|
||||
"execution_count": 184,
|
||||
"id": "ef4b7b64-70ba-4e26-90c1-240be0bb48ce",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
|
|
@ -148,7 +156,7 @@
|
|||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Objective: 53.685368\n"
|
||||
"Objective: 34.75516\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
@ -161,14 +169,14 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 164,
|
||||
"execution_count": 215,
|
||||
"id": "a497cb6b-32dc-4b67-8a84-6a2a99e68fdb",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "aa9392c1926c448f888b133a37e9912c",
|
||||
"model_id": "e55c322c205d42b2ae2cc0d4354964ec",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
|
|
@ -181,10 +189,12 @@
|
|||
}
|
||||
],
|
||||
"source": [
|
||||
"sdf_interp = scipy.interpolate.RegularGridInterpolator((xs, ys, zs), sdf_vol.reshape(len(zs), len(ys), len(xs)).swapaxes(0,2))\n",
|
||||
"\n",
|
||||
"plot = k3d.plot()\n",
|
||||
"sel = (coords[:,2] > -5.5 ) & (coords[:,2] < -5)\n",
|
||||
"sel = (coords[:,1]%-8 > -0.2)\n",
|
||||
"plot += k3d.points(positions=coords[sel],\n",
|
||||
" attribute=sdf_vol[sel],\n",
|
||||
" attribute=sdf_interp(coords[sel]),\n",
|
||||
" point_size=0.6,\n",
|
||||
" opacity=0.2,\n",
|
||||
" shader='flat')\n",
|
||||
|
|
@ -195,15 +205,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "32957084-f420-48f0-8460-6fbdaeb8472b",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 159,
|
||||
"execution_count": 198,
|
||||
"id": "b523f8fd-9119-4c9a-98bb-20f583182509",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
|
|
@ -211,8 +213,8 @@
|
|||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"0.0026245445212232646 9.143656777662026e-06\n",
|
||||
"0.0026336881780009264\n"
|
||||
"0.002690871616336777 0.009143656777662025\n",
|
||||
"0.011834528393998803\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
@ -223,9 +225,9 @@
|
|||
" deltas = idx[:-1] - idx[1:]\n",
|
||||
" dists = np.sqrt(deltas[:,0]**2 + deltas[:,1]**2 + deltas[:,2]**2)\n",
|
||||
" \n",
|
||||
" sdf_vals = f(idx)\n",
|
||||
" sdf_vals = sdf_interp(idx)\n",
|
||||
" sdf_comp = 1/(0.00001 + np.abs(sdf_vals + .1)).sum()\n",
|
||||
" dist_comp = 0.0001* ((dists - (dists.sum()/len(dists)))**2).mean()\n",
|
||||
" dist_comp = 0.1* ((dists - (dists.sum()/len(dists)))**2).mean()\n",
|
||||
"\n",
|
||||
" if debug:\n",
|
||||
" print(sdf_comp, dist_comp)\n",
|
||||
|
|
@ -237,7 +239,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 163,
|
||||
"execution_count": 200,
|
||||
"id": "a31cd866-093b-46f4-9c50-c83e0b84d3d5",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
|
|
@ -248,19 +250,19 @@
|
|||
" message: CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH\n",
|
||||
" success: True\n",
|
||||
" status: 0\n",
|
||||
" fun: 0.00219675070526215\n",
|
||||
" x: [ 4.420e+00 -1.952e-01 ... -1.424e-02 -7.614e+00]\n",
|
||||
" nit: 10\n",
|
||||
" jac: [ 1.164e-06 6.129e-08 ... 1.644e-07 8.372e-07]\n",
|
||||
" nfev: 18585\n",
|
||||
" njev: 63\n",
|
||||
" fun: 0.0020290044959345027\n",
|
||||
" x: [ 4.058e+00 3.529e-02 ... 1.216e-04 -7.654e+00]\n",
|
||||
" nit: 233\n",
|
||||
" jac: [-8.357e-06 -2.846e-06 ... 4.337e-11 1.758e-07]\n",
|
||||
" nfev: 86730\n",
|
||||
" njev: 294\n",
|
||||
" hess_inv: <294x294 LbfgsInvHessProduct with dtype=float64>\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "5a961e0d38c149b7b99ffd8a28af5444",
|
||||
"model_id": "e4aec3152a484d59b060731442352a7b",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
|
|
@ -274,8 +276,8 @@
|
|||
],
|
||||
"source": [
|
||||
"bounds = np.tile([[-10, 90], [-10, 10], [-14, 0]], (len(line_interp)-2, 1))\n",
|
||||
"res = scipy.optimize.minimize(objective_space, x0=line_interp[1:-1].flatten(),\n",
|
||||
" bounds=bounds, method='L-BFGS-B', options=dict(eps=1, maxiter=100000, maxfun=100000, maxls=40))\n",
|
||||
"res = scipy.optimize.minimize(objective_space, x0=line_interp[1:-1].flatten(), tol=1e-8,\n",
|
||||
" bounds=bounds, method='L-BFGS-B', options=dict(maxiter=100000, maxfun=100000, maxls=40))\n",
|
||||
"print(repr(res))\n",
|
||||
"assert res.success\n",
|
||||
"\n",
|
||||
|
|
@ -284,6 +286,14 @@
|
|||
"plot += k3d.line(res.x.reshape(-1, 3))\n",
|
||||
"plot.display()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "ada64018-2fbf-44ce-8880-3680b0195894",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue