{ "cells": [ { "cell_type": "code", "execution_count": 630, "metadata": { "ExecuteTime": { "end_time": "2018-12-25T04:44:19.936027Z", "start_time": "2018-12-25T04:44:19.297265Z" } }, "outputs": [ { "data": { "text/plain": [ "(0, 100)" ] }, "execution_count": 630, "metadata": {}, "output_type": "execute_result" }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZAAAAFWCAYAAABHDstlAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAIABJREFUeJzt3XtwlOdh7/Hvsxftru6YixACgbCNDcaWDfjKJZhgfMOO4zhJ02TSZhr3TJ1zOm2c055LJtPOOadp55w0bafj49Z1Y5/WSdw2dh07xhjjEDC2uRgDJggbzFVCiJvue999zh+vkMGABI9Wq1fw+8xoJO277/v+9Gql377P+7675tZF91tEREQuUmCkA4iIyOikAhEREScqEBERcaICERERJyoQERFxogIREREnKhAREXESupA7zb35Dq6/cS4TamppaT7Ic8882T8tXFLCvcu/wNXXzCKXzbL1/Y2seWPFBU8XEZHRKTh56ow/GexOlVVVNB/cT1dnB5VV1XywdXP/tHuXP0x5eQX/9I9P8MH297hz6X0AHG45dEHTRURkdLqgIawPm3bwYdMOenu7z7g9FA5z3fU3sebN10gmE3R2tLNh/a9ovOmWC5ouIiKj1wUNYZ3PFWPHEwwGaTtyuP+2I63NjJ9QgzFm0OnWnvtVVKKl5WQz6aFEExGRAgmFS0jGe86+fSgLjZREyGQy2Hy+/7ZkMkkgECQUDg86PZM+uySipeXc9/A3hhJLREQK7NUXfnRWiQypQFLpFOFwGBMI9JdENBoln8+RzWQGnX4up/Y8Vrz4DNnsue8zEBMIMGnqNRw+8OEZxeUXfs8HylgIfs8H/s/o93xweWQMhcLc+/nfPueo0JAK5OSJY+RyOWpqajnS2gJATW0dx48dxVo76PSBZNIpp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IV1n9+itg7XmXZwIBTODi++3UPC7zFoPf84EyFoLf84H/M/o9H1weGQearyAFYgIB7nvgEVa++uIZt0eiUaqqxnCk9XD/bW2tLcRipVRWVtHV2XHeZdY1zBzSMFddwyzneYvB7/lAGQvB7/nA/xn9ng8u7YzBYPC80wpSILfevoijba0c3L+X+mnT+28vKYkAkEol+m9LJr2vI5HIgMts2ddENpO+6CwmEKCuYRYt+3Zi8/mLnn+4+T0fKGMh+D0f+D+j3/PB5ZExFC5hzrwF55421HDVY8Yy95Y7+Mcn/+qsael0CoBIJEYiHgcgGo0BkEqlBlyuzeeH9AsZ6vzDze/5QBkLwe/5wP8Z/Z4PLu2MA80z5AKZMrWB0tJyHv3WdwBvdycSifD73/keP3v+WTo726mZOImO9hOAd6wkkYjT9amD7SIiMroMuUCadmxl754P+7+fPGUq93/uSzz95A9JJOJs27KR+YuW0NJ8gHwux8LFd7F96+YBD6CLiIj/DblAstks2Z7u/u8TCW+oqrfvtvXr3iRWWsajjz3efx3ImtUrhrpaEREZYQW9kBDg4P69/RcRgjd+tmrFS6xa8VKhVyUiIiPIvycvi4iIr6lARETEiQpEREScqEBERMSJCkRERJyoQERExIkKREREnKhARETEiQpEREScqEBERMSJCkRERJyoQERExIkKREREnKhARETEiQpEREScqEBERMSJCkRERJyoQERExIkKREREnKhARETEiQpEREScqEBERMSJCkRERJyoQERExIkKREREnKhARETEiQpEREScqEBERMSJCkRERJyoQERExIkKREREnKhARETEiQpEREScqEBERMSJCkRERJyoQERExIkKREREnKhARETEiQpEREScqEBERMSJCkRERJyoQERExIkKREREnKhARETEiQpEREScqEBERMSJCkRERJyoQERExIkKREREnKhARETEiQpERESchIa6gGAwyLL7Ps+06VdRVlZOT3cX7216m03vvgWACQRYumw5sxvnYoxh187trPzFi+RyuSGHFxGRkTPkAgkEAvT2dPPTf3qK9vaTTKip5Stf+yY93d00/Xob8xcuoX7alTz1xA/I53I88pVvsHjpfaxe+XIh8ouIyAgZcoFkMhnW/nJl//dHjxxmz+4mJtdPo+nX22iccwurV75MT3cXAOvWvM5Dj3yV1a+/Ataed7kmEMAELn6E7dQ8LvMWg9/zgTIWgt/zgf8z+j0fXB4ZB5pvyAVyrpVNrm/g3fVriESjVFWN4Ujr4f7pba0txGKlVFZW0dXZcd7l1DXMHNIwV13DLOd5i8Hv+UAZC8Hv+cD/Gf2eDy7tjMFg8LzTCl4gy+79HKlkkg+2vUdZWTkAqVSif3oy6X0diUQGXE7LviaymfRFr98EAtQ1zKJl305sPn/R8w83v+cDZSwEv+cD/2f0ez64PDKGwiXMmbfg3NOGGu50n122nCn1DTz37JPkcznS6RQAkUiMRDwOQDQaAyCVSg24LJvPD+kXMtT5h5vf84EyFoLf84H/M/o9H1zaGQeap2ADd0vveZCGK2fw42f/rr8sUskknZ3t1Eyc1H+/mto6Eok4XV2dhVq1iIiMgIIUyF33fo6G6Vfz42f/jni894xp27ZsZP6iJZRXVFJaWsbCxXexfevmAQ+gi4iI/w15CKuyqpqbb11ANpvhsT/4r/23Hzqwj+efe5r1694kVlrGo4893n8dyJrVK4a6WhERGWFDLpCuzg7+7E/+83mn23yeVSteYtWKl4a6KhER8RH/nrwsIiK+pgIREREnKhAREXGiAhEREScqEBERcaICERERJyoQERFxogIREREnKhAREXGiAhEREScqEBERcaICERERJyoQERFxogIREREnKhAREXGiAhEREScqEBERcaICERERJyoQERFxogIREREnKhAREXGiAhEREScqEBERcaICuUgWsKFSbGQMFjPScURERkxopAOMBhYDY67BTrwdSieC6evdbBLbcwjT3gQndmCwIxtURKSIVCCDsGV12IYHIFQGx97DHFwJmR7IZ6FsEraiHjtlKUy8HVrWQMdH2i8RkcuCCmQA9orZ2Gn3w9HNmNa3MLnUmXfo3IPp3INtXY+deDu24SHo2AUHVmDymZEJLSJSJDoGch62dgF22v2YAysINK8+uzxOY3IpAi1rME1PQ+lE7MxvYKPjiphWRKT4VCDnYMc1YmvnY3b/FHNi+wXPZ5InME0/gvgR7LW/hS2fMowpRURGlgrkU2xFPbb+Xsz+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Gkyty+4k107P+ifvxhX6w81gx8y+mE7vr/5XW6+bSEVlVUEQyEWLbmbwy2HvLFwH2zDwTL6YRteMXY8k6dMZfv7m86a5pdtOFDGkd6GiXickyeOMffmOwiGQgRDIebduoCuzg4S8XjRtuGoPI0XoH7adB75jd8+8zqQux9g9g1zPjmv+dV/J5fNXtD04c73tW/8HhNqagkEAnR3dbLt/U28+/av+n9hxcg31Ax+yOiH7Ygx3PnZe2m86WYwhuaD+3l9xb/T1dnhi204WEY/bMM777qfurop/PMzT54d3SfbcKCMftiG48ZPYOndDzJx0mSMMbQdOczqlS/TduRw0bbhqC0QEREZWaNmCEtERPxFBSIiIk5UICIi4kQFIiIiTlQgIiLiRAUiIiJOVCAiIuJEBSIiIk5UICIi4uT/Ax5lFeebyds2AAAAAElFTkSuQmCC\n", "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import numpy as np\n", "import mxnet as mx\n", "\n", "# Step1: Load the model in MXNet\n", "\n", "# Use the same prefix and epoch parameters we used in save_mxnet_model API.\n", "sym, arg_params, aux_params = mx.model.load_checkpoint(prefix='siti_fully', epoch=0)\n", "\n", "\n", "# We use the data_names and data_shapes returned by save_mxnet_model API.\n", "mod = mx.mod.Module(symbol=sym, \n", " data_names=['/first_input9'], \n", " context=mx.gpu(), \n", " label_names=None)\n", "mod.bind(for_training=False, \n", " data_shapes=[('/first_input9', (3,16))], \n", " label_shapes=mod._label_shapes)\n", "mod.set_params(arg_params, aux_params, allow_missing=True)\n", "\n", "pt = np.array([ 0.79899497, 1. , -0.79899497, -0.95979899, 0.42713568,\n", " -1. , 1. , 1. , 0.63819095, -1. ,\n", " 1. , -0.59798995, -0.86934673, 0.68844221, -0.34673367,\n", " -0.77889447])\n", "\n", "ttt = np.tile(pt, (1,1))\n", "\n", "\n", "# data_iter = mx.io.NDArrayIter(ttt, None, 1)\n", "# res2 = mod.predict(data_iter).asnumpy()\n", "# lams = np.linspace(400, 800, endpoint=True, num=128)\n", "# plt.plot(lams, 100*res2[0])\n", "# plt.xlim([400, 800])\n", "# plt.ylim ( [0,100])\n", "# plt.xlabel('wavelength (nm)')\n", "\n", "\n", "num_layers = 16\n", "d_min = 0.5\n", "d_max = 100 \n", "\n", "#geom = np.random.uniform(0,1, 16)\n", "\n", "indexx = np.random.randint(0,100)\n", "geom = (bests_g[indexx]-0.5)/99.5\n", "# geom = np.array([0.99740673, 0.16047267, 0.27205694, 0.28930667, 0.39390871,\n", "# 0.12006336, 0.8 , 0. , 0.50488817, 0.10512654,\n", "# 0.31236766, 0.8 , 0.07536845, 0.15084873, 0.33889699,\n", "# 0.14410015])\n", "# geom[3] = 1.0\n", "# geom[12] = 1.0\n", "geom_ac = rndtop5(0.5 + 99.5*(geom))\n", "#print(geom_ac)\n", "geom_nor = geom*2 - 1 \n", "geom_nor_t = np.tile(geom_nor, (3,1))\n", "\n", "# #best_ac = rndtop5(bests_g)\n", "\n", "# indexx = 1\n", "# bests_ac = -1.0 + 2.0*(bests_g - 0.5)/99.5 \n", "# R_gp = 100*mod.predict(bests_ac).asnumpy()\n", "\n", "\n", "# # # #Rs_b = oqx.tmm_eval_wsweep( best_ac ,0, lam_pts=128)\n", "\n", "Rsmod = 100*mod.predict(geom_nor_t)\n", "Rs2 = Rsmod[0].asnumpy()\n", " \n", "Rs = oqx.tmm_eval_wsweep( geom_ac ,0, lam_pts=128)\n", "#Rs = oqx.tmm_eval_wsweep( bests_g[indexx] ,0, lam_pts=128)\n", "\n", "lams = np.linspace(400, 800, endpoint=True, num=128)\n", "plt.plot(lams, Rs)\n", "plt.plot(lams, Rs2)\n", "#plt.plot(lams, R_gp[indexx])\n", "plt.ylim([0,100])\n", "\n", "#bests_g" ] }, { "cell_type": "code", "execution_count": 286, "metadata": { "ExecuteTime": { "end_time": "2018-12-24T18:01:56.495275Z", "start_time": "2018-12-24T18:01:56.104325Z" } }, "outputs": [ { "data": { "text/plain": [ "37" ] }, "execution_count": 286, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.random.randint(0,100)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "start_time": "2018-12-25T05:09:07.786Z" }, "scrolled": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "19 2.145484\n", "19 1.7058325\n", "19 1.4603959\n", "19 5.7456036\n", "19 0.71646935\n", "19 3.3900874\n", "19 3.0784802\n", "19 4.498125\n", "19 0.71264493\n", "19 3.0576346\n", "19 1.0986711\n", "19 2.0329676\n", "19 0.5811589\n", "19 3.1673045\n", "19 2.0246377\n", "19 0.39749807\n", "19 2.8259745\n", "19 2.1281688\n", "19 0.9099479\n", "19 2.9248364\n", "19 0.61283654\n", "19 0.58605856\n", "19 1.7281755\n", "19 1.3529438\n", "19 0.6492966\n", "19 3.4086387\n", "19 7.4517274\n", "19 0.98954445\n", "19 2.7845836\n", "19 4.2110662\n", "19 0.23643689\n", "19 4.0419335\n", "19 0.75664216\n", "19 1.8319095\n", "19 2.589772\n", "19 0.83769\n", "19 2.5495431\n", "19 1.6842563\n", "19 2.3059397\n", "19 3.957266\n", "19 3.5410194\n", "19 4.098542\n", "19 2.7205174\n", "19 3.7979965\n", "19 4.8208394\n", "19 3.9352784\n", "19 0.98185545\n", "19 3.7086015\n", "19 1.9990282\n", "19 2.2729812\n", "19 3.83456\n", "19 0.5428893\n", "19 2.6969342\n", "19 1.1999255\n", "19 0.82775193\n", "19 6.21143\n", "19 2.453705\n", "19 0.7821772\n", "19 1.5110769\n", "19 5.336413\n", "19 4.3306212\n", "19 2.5774252\n", "19 4.3692727\n", "19 4.740422\n", "19 2.4539628\n", "19 2.2458973\n", "19 4.664459\n", "19 1.338175\n", "19 4.991782\n", "19 2.0304432\n", "19 0.8794528\n", "19 1.5645689\n", "19 0.90055156\n", "19 2.201878\n", "19 1.5758773\n", "19 3.557377\n", "19 1.4890728\n", "19 4.6264524\n", "19 0.86303675\n", "19 2.3344035\n", "19 1.4667941\n", "19 2.359611\n", "19 2.1054513\n", "19 3.3979635\n", "19 3.019384\n", "19 2.0481691\n", "19 1.4404808\n", "19 1.1426588\n", "19 0.9758379\n", "19 2.1440084\n", "19 1.5036558\n", "19 1.1557208\n", "19 1.9011215\n", "19 0.7183604\n", "19 3.1034646\n", "19 5.691704\n", "19 1.5435407\n", "19 2.2035913\n", "19 1.7980285\n", "19 2.9189756\n", "19 5.6237955\n", "19 4.368509\n", "19 0.80473113\n", "19 1.2626859\n", "19 1.7749878\n", "19 2.1738415\n", "19 2.2640765\n", "19 2.3684957\n", "19 1.024743\n", "19 5.58028\n", "19 0.7022997\n", "19 3.130474\n", "19 0.2679275\n", "19 8.933801\n", "19 1.5582556\n", "19 4.6233087\n", "19 1.5912901\n", "19 0.28163216\n", "19 1.4554826\n", "19 0.73625153\n", "19 2.310941\n", "19 0.7197853\n", "19 1.4755862\n", "19 1.1453302\n", "19 2.0251205\n", "19 0.54929036\n", "19 3.004418\n", "19 1.552429\n", "19 2.6433198\n", "19 1.3654132\n", "19 2.2436981\n", "19 3.6919432\n", "19 7.5046506\n", "19 0.20434162\n", "19 1.4556583\n", "19 4.002475\n", "19 3.5385597\n", "19 3.1817071\n", "19 0.61927426\n", "19 0.9147479\n", "19 2.8782864\n", "19 1.7163739\n", "19 1.0805705\n", "19 2.1552417\n", "19 4.793881\n", "19 0.6629075\n", "19 1.9463385\n", "19 3.3430736\n", "19 3.6456115\n", "19 0.7610959\n", "19 2.101096\n", "19 3.8255289\n", "19 2.1797955\n", "19 2.7161474\n", "19 0.9451999\n", "19 0.3055028\n", "19 2.1620264\n", "19 5.1449466\n", "19 0.25350115\n", "19 1.0035703\n", "19 5.668507\n", "19 0.9255929\n", "19 4.4246664\n", "19 5.7359347\n", "19 1.8372415\n", "19 2.8896594\n", "19 3.8119235\n", "19 3.3674374\n", "19 3.8271945\n", "19 6.949549\n", "19 2.016043\n", "19 0.6754021\n", "19 1.3718095\n", "19 2.2142878\n", "19 0.9739942\n", "19 3.7862103\n", "19 1.3474847\n", "19 0.5186842\n", "19 5.014672\n", "19 0.39325845\n", "19 0.8193657\n", "19 3.612678\n", "19 2.437639\n", "19 0.85430175\n", "19 0.87173223\n", "19 3.6285217\n", "19 0.7871784\n", "19 1.0242716\n", "19 1.5407869\n", "19 0.47719786\n", "19 0.55732507\n", "19 4.4861174\n", "19 1.1805143\n", "19 5.818069\n", "19 5.6901145\n", "19 5.5345883\n", "19 0.7596863\n", "19 3.505685\n", "19 2.6313179\n", "19 2.374122\n", "19 0.96007454\n", "19 1.9050815\n", "19 0.65780294\n", "19 2.7237618\n", "19 3.0013163\n", "19 3.24692\n", "19 3.1411982\n", "19 2.6707523\n", "19 2.9478686\n", "19 1.9084381\n", "19 1.538825\n", "19 2.6296499\n", "19 1.7462606\n", "19 3.9386299\n", "19 5.6128244\n", "19 1.4382226\n", "19 4.447349\n", "19 4.9211607\n", "19 4.180639\n", "19 3.771706\n", "19 2.338091\n", "19 5.8565755\n", "19 1.7366477\n", "19 3.8900075\n", "19 4.6930394\n", "19 1.5537655\n", "19 3.2266006\n", "19 0.7727722\n", "19 0.6176275\n", "19 0.5291734\n", "19 3.6778383\n", "19 4.319042\n", "19 2.500314\n", "19 1.4117819\n", "19 5.175286\n", "19 3.3923826\n", "19 0.49953392\n", "19 3.0490477\n", "19 2.4729276\n", "19 0.75662094\n", "19 0.48797446\n", "19 1.6237314\n", "19 3.3036134\n", "19 4.4398427\n", "19 2.486386\n", "19 4.0276103\n", "19 1.4907835\n", "19 0.3621653\n", "19 3.1370997\n", "19 0.30053407\n", "19 1.9070094\n", "19 5.1945615\n", "19 1.6695539\n", "19 0.6775428\n", "19 0.27719286\n", "19 2.6086116\n", "19 3.1925802\n", "19 2.4619083\n", "19 4.0060167\n", "19 3.9682052\n", "19 1.7840958\n", "19 0.59733224\n", "19 2.04552\n", "19 4.383955\n", "19 0.9036108\n", "19 3.0489736\n", "19 1.0012523\n", "19 0.87770045\n", "19 2.0328722\n", "19 1.9732761\n", "19 0.5500013\n", "19 2.8254347\n", "19 1.4762164\n", "19 2.546764\n", "19 2.095524\n", "19 2.1495075\n", "19 3.4447722\n", "19 1.525913\n", "19 5.759416\n", "19 1.1295352\n", "19 2.490454\n", "19 4.1012983\n", "19 3.2711453\n", "19 5.0518484\n", "19 2.595835\n", "19 2.8618326\n", "19 1.3055897\n", "19 1.4737674\n", "19 1.3574953\n", "19 1.1413678\n", "19 1.1658391\n", "19 0.7592469\n", "19 1.7754349\n", "19 1.6282872\n", "19 1.7322574\n", "19 0.73256207\n", "19 1.911584\n", "19 2.1499124\n", "19 4.4848146\n", "19 1.9748455\n", "19 1.3196477\n", "19 1.652292\n", "19 6.068109\n", "19 3.1856954\n", "19 2.5682106\n", "19 1.9481666\n", "19 1.4634337\n", "19 4.3104253\n", "19 1.6673222\n", "19 0.5862467\n", "19 0.6312777\n", "19 2.7934194\n", "19 5.2533355\n", "19 3.1333053\n", "19 6.1990724\n", "19 4.652661\n", "19 6.5092487\n", "19 4.6772995\n", "19 1.6142259\n", "19 2.4539857\n", "19 2.2298925\n", "19 2.988916\n", "19 6.2719893\n", "19 2.765656\n", "19 3.0100076\n", "19 1.6056519\n", "19 1.8233916\n", "19 2.7347863\n", "19 0.66082036\n", "19 2.067672\n", "19 1.0126492\n", "19 1.3291769\n", "19 1.4833194\n", "19 0.72776777\n", "19 2.9290216\n", "19 5.694029\n", "19 5.122593\n", "19 0.9154801\n", "19 0.7570206\n", "19 1.0374457\n", "19 1.7411526\n", "19 2.7142215\n", "19 5.182081\n", "19 1.4165676\n", "19 1.5411431\n", "19 3.1339068\n", "19 2.8877647\n", "19 0.5984394\n", "19 5.0189576\n", "19 3.704321\n", "19 2.518182\n", "19 0.5236815\n", "19 2.4549072\n", "19 4.6480575\n", "19 0.6105595\n", "19 3.0354753\n", "19 7.631791\n", "19 3.174835\n", "19 1.9169172\n", "19 4.3121347\n", "19 1.0856465\n", "19 3.421129\n", "19 2.4253986\n", "19 4.1122656\n", "19 1.5441407\n", "19 0.72940797\n", "19 2.1506953\n", "19 2.1032114\n", "19 2.9688392\n", "19 1.2828828\n", "19 1.7577583\n", "19 4.6667657\n", "19 0.97526664\n", "19 1.8017193\n", "19 1.9135476\n", "19 3.308948\n", "19 1.0468926\n", "19 0.8202923\n", "19 4.2752275\n", "19 5.239845\n", "19 0.9210246\n", "19 2.5302422\n", "19 4.674751\n", "19 2.4548652\n", "19 2.6217158\n", "19 2.399535\n", "19 3.2815206\n", "19 1.4185511\n", "19 3.3322928\n", "19 8.11187\n", "19 1.5313104\n", "19 1.6681777\n", "19 2.5856159\n", "19 1.2982211\n", "19 0.25264463\n", "19 1.5146729\n", "19 2.3674824\n", "19 0.91045946\n", "19 1.4635448\n", "19 5.2902594\n", "==============================\n", "Epoch #:1\n", "==============================\n", "----------------- I-1---------------------\n", "19 1.7556610466803872\n", "39 1.5582441734121744\n", "59 1.5582441734121744\n", "79 1.5582441734121744\n", "99 1.5582441734121744\n", "119 1.5582441734121744\n", "139 1.5582441734121744\n", "159 1.5582441734121744\n", "179 1.5582441734121744\n", "199 1.5582441734121744\n", "219 1.5582441734121744\n", "239 1.5582441734121744\n", "807.0844608025387\n", "----------------- I-2---------------------\n", "19 1.6397874688794776\n", "39 0.7106735076518453\n", "59 0.6065330806687415\n", "79 0.5881153721598325\n", "99 0.5697319444768818\n", "119 0.5605219626760273\n", "139 0.5594845361215476\n", "159 0.5593231125861946\n", "179 0.5593231125861946\n", "199 0.5593017273870909\n", "219 0.5592927062867309\n" ] } ], "source": [ "%reload_ext autoreload\n", "%autoreload 2\n", "import warnings\n", "warnings.filterwarnings(\"ignore\",category =RuntimeWarning)\n", "import numpy as np\n", "import de2 as de\n", "import multiprocessing as mp\n", "import makeqx as mkq\n", "import oldqx as oqx\n", "import mxnet.ndarray as nd\n", "\n", "\n", "def arc_metric(R_arr):\n", " pop_size = R_arr.shape[0]\n", " lam_size = R_arr.shape[1]\n", " R_ref = np.linspace(0.0, 0.0, endpoint=True, num=lam_size)\n", " R_ref_tiled = np.tile(R_ref, (pop_size, 1))\n", " return np.mean(np.abs(R_arr - R_ref_tiled), axis=1) \n", "\n", "def bpass_metric(R_arr):\n", " b_low = 550\n", " b_high = 600\n", " pop_size = R_arr.shape[0]\n", " lam_size = R_arr.shape[1]\n", " \n", " lams = np.linspace(400.0, 800.0, endpoint=True, num=lam_size)\n", " \n", " left_r = lams[lams < b_low].size\n", " right_r = lams[lams <= b_high].size\n", " R_ref = np.linspace(100.0, 100.0, endpoint=True, num=lam_size)\n", " R_ref[left_r:right_r] = 0.0\n", " \n", " R_ref_tiled = np.tile(R_ref, (pop_size, 1))\n", " return np.mean(np.abs(R_arr - R_ref_tiled), axis=1) \n", " \n", " diffarr = np.abs(R_arr - R_ref_tiled)\n", " passb = np.mean(diffarr[:, left_r:right_r], axis=1)\n", " stopb = np.mean( diffarr[:, 0:left_r -1], axis=1) + np.mean( diffarr[:, right_r + 1:], axis=1)\n", " return stopb + passb\n", "\n", "# anti-reflection coating\n", "R_ref = np.linspace(100.0, 100.0, endpoint=True, num=50)\n", "# narrow band transmission filter\n", "R_ref[17] = 0.0\n", "\n", "\n", "def rndtop5(x):\n", " return np.round(x*2.0)/2\n", "\n", "def tmm_wrapper2(arg):\n", " args, kwargs = arg\n", " return oqx.tmm_eval_wsweep(*args, **kwargs)\n", "\n", "\n", "def arc_par_gp(pop, **kwargs):\n", " x_in = 2.0*(pop - 0.5)/(99.5) - 1.0\n", " y_in = 100.0*mod.predict(x_in)\n", " means = nd.mean(y_in, axis=1)\n", " return means.asnumpy()\n", "\n", "\n", "\n", "\n", "def arc_par(pop, **kwargs):\n", " jobs = []\n", " pool=mp.Pool(90)\n", " for indiv in pop:\n", " #indiv = indiv.reshape((int(indiv.size/2), 2))\n", " #indiv[:,1] = mkq.digitize_qx(indiv[:,1], dlevels=2)\n", " indiv = rndtop5(indiv)\n", " #indiv = indiv.flatten()\n", " jobs.append((indiv, 0))\n", " arg = [(j, kwargs) for j in jobs]\n", " answ = np.array(pool.map(tmm_wrapper2, arg))\n", " pool.close()\n", "\n", "# c2 = np.zeros(pop.shape[0])\n", "# for idx, indiv in enumerate(pop):\n", "# c2[idx] = np.sum(indiv)\n", "# if c2[idx] <= 385:\n", "# c2[idx] = 385/c2[idx]\n", "# else:\n", "# c2[idx] = 0.0\n", " return answ\n", " #return bpass_metric(answ)\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "bnds = [(d_min, d_max)]*num_layers\n", "its_first = 0\n", "psnew = 5*num_layers\n", "islands = 5\n", "islands_g = islands*psnew \n", "its_second = 25\n", "\n", "isl_g = np.ones((psnew*islands_g, num_layers))\n", "for indiv in range(int(psnew*islands_g)):\n", " isl_g[indiv] = np.random.uniform(0,1, num_layers)\n", "\n", "poplist_g = np.split(isl_g, islands_g)\n", "\n", "bids_g = np.zeros(islands_g, dtype=int)\n", "bfits_g = np.zeros(islands_g)\n", "bests_g = isl_g[0:islands_g]\n", "\n", "for isln in range(islands_g):\n", " #print(\"----------------- I-\" + str(isln + 1)+ \"---------------------\")\n", " poplist_g[isln], bids_g[isln], bfits_g[isln], bests_g[isln] = de.de_cp(\n", " fobj=arc_par_gp, bounds=bnds, \n", " pop=poplist_g[isln], \n", " history=[], \n", " it_start=its_first, \n", " popsize=psnew, \n", " its=its_second, \n", " lam_low=400, \n", " lam_high=800, \n", " lam_pts=128)\n", "\n", "\n", "\n", "\n", "its_second = 256\n", "numgens = 3\n", "\n", "isl = bests_g\n", "poplist = np.split(isl, islands)\n", "\n", "bids = np.zeros(islands, dtype=int)\n", "bfits = np.zeros(islands)\n", "bests = isl[0:islands]\n", "\n", "\n", "\n", "for gen in range(numgens):\n", " print(\"==============================\")\n", " print(\"Epoch #:\" + str(gen + 1))\n", " print(\"==============================\")\n", " \n", " for isln in range(islands):\n", " print(\"----------------- I-\" + str(isln + 1)+ \"---------------------\")\n", " \n", " \n", " poplist[isln], bids[isln], bfits[isln], bests[isln] = de.de_cp(\n", " fobj=arc_par, bounds=bnds, \n", " pop=poplist[isln], \n", " history=[], \n", " it_start=its_first, \n", " popsize=psnew, \n", " its=its_second, \n", " lam_low=400, \n", " lam_high=800, \n", " lam_pts=50)\n", "\n", " \n", " print(np.sum(bests[isln]))\n", " \n", " if its_second > 64:\n", " its_second = int(its_second/2)\n", " \n", " if gen < (numgens - 1):\n", " print(\"Round robin best migration\")\n", " stmp = np.copy(poplist[islands-1][bids[islands-1]])\n", " for isln in range(1, islands):\n", " poplist[isln][bids[isln]] = poplist[isln-1][bids[isln-1]]\n", " poplist[0][bids[0]] = stmp \n", " \n", "print(bfits) \n", "print(bests[np.argmin(bfits)])\n", "\n", "print(np.sum(bests[np.argmin(bfits)]))" ] }, { "cell_type": "code", "execution_count": 635, "metadata": { "ExecuteTime": { "end_time": "2018-12-25T04:55:12.399286Z", "start_time": "2018-12-25T04:55:11.895977Z" } }, "outputs": [ { "data": { "text/plain": [ "(400, 16)" ] }, "execution_count": 635, "metadata": {}, "output_type": "execute_result" } ], "source": [ "isl.shape" ] }, { "cell_type": "code", "execution_count": 60, "metadata": { "ExecuteTime": { "end_time": "2018-12-24T16:21:51.788816Z", "start_time": "2018-12-24T16:21:49.517039Z" } }, "outputs": [ { "data": { "text/plain": [ "array([1.25103446, 1.78700328, 2.3109896 , 1.11588667, 1.45650532,\n", " 2.74298038, 0.94518088, 1.82786372, 1.93577577, 9.17519445,\n", " 2.25408966, 2.21879332, 1.94204131, 1.86506282, 1.54120511,\n", " 4.07923547, 2.2086548 , 2.32715269, 1.80240239, 1.64751775])" ] }, "execution_count": 60, "metadata": {}, "output_type": "execute_result" } ], "source": [ "arc_par(bests_g)" ] }, { "cell_type": "code", "execution_count": 58, "metadata": { "ExecuteTime": { "end_time": "2018-12-24T16:20:21.048595Z", "start_time": "2018-12-24T16:20:20.712691Z" } }, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaYAAAFoCAYAAAAck1/HAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2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iIq7y/wPSN/d99O68gAAAAABJRU5ErkJggg==\n", "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from jupyterthemes import jtplot\n", "# currently installed theme will be used to\n", "# set plot style if no arguments provided\n", "jtplot.style()\n", "\n", "#Rs = oqx.tmm_eval_wsweep(rndtop5(bests[np.argmin(bfits)]),0, lam_pts=50)\n", "Rs = oqx.tmm_eval_wsweep(rndtop5(bests_g[ np.random.randint(0,20) ]),0, lam_pts=50)\n", "\n", "#Rs = qn.tmm_eval_wsweep(qx, d_min=2 , d_max=10, inc_ang=0, lam_low=400, lam_high=800, lam_pts=50, n_subs=1.52) # in nm\n", "lams = np.linspace(400, 800, endpoint=True, num=50)\n", "\n", "meanl = np.ones_like(lams)*np.mean(oqx.tmm_eval_wsweep(rndtop5(bests[np.argmin(bfits)]),0))\n", "plt.plot(lams, Rs )\n", "#plt.plot(lams, R_ref)\n", "plt.xlabel('Wavelength (nm)')\n", "plt.ylabel('Reflectance (%)')\n", "plt.ylim([0,10])\n", "plt.xlim([500,600])\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": 47, "metadata": { "ExecuteTime": { "end_time": "2018-12-24T16:19:52.888956Z", "start_time": "2018-12-24T16:19:52.800125Z" } }, "outputs": [ { "data": { "text/plain": [ "array([400. , 408.16326531, 416.32653061, 424.48979592,\n", " 432.65306122, 440.81632653, 448.97959184, 457.14285714,\n", " 465.30612245, 473.46938776, 481.63265306, 489.79591837,\n", " 497.95918367, 506.12244898, 514.28571429, 522.44897959,\n", " 530.6122449 , 538.7755102 , 546.93877551, 555.10204082,\n", " 563.26530612, 571.42857143, 579.59183673, 587.75510204,\n", " 595.91836735, 604.08163265, 612.24489796, 620.40816327,\n", " 628.57142857, 636.73469388, 644.89795918, 653.06122449,\n", " 661.2244898 , 669.3877551 , 677.55102041, 685.71428571,\n", " 693.87755102, 702.04081633, 710.20408163, 718.36734694,\n", " 726.53061224, 734.69387755, 742.85714286, 751.02040816,\n", " 759.18367347, 767.34693878, 775.51020408, 783.67346939,\n", " 791.83673469, 800. ])" ] }, "execution_count": 47, "metadata": {}, "output_type": "execute_result" } ], "source": [ "R_ref = np.linspace(400.0, 800.0, endpoint=True, num=50)\n", "# narrow band transmission filter\n", "#R_ref[0:83] = 0.0\n", "R_ref" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2018-12-08T17:35:57.288922Z", "start_time": "2018-12-08T17:13:28.915427Z" } }, "outputs": [], "source": [ "%reload_ext autoreload\n", "%autoreload 2\n", "import warnings\n", "warnings.filterwarnings(\"ignore\",category =RuntimeWarning)\n", "import numpy as np\n", "import de2 as de\n", "import multiprocessing as mp\n", "import makeqx as mkq\n", "import qxnew as qn \n", "\n", "def rndtop5(x):\n", " return np.round(x*2.0)/2\n", "\n", "def tmm_wrapper2(arg):\n", " args, kwargs = arg\n", " return qn.tmm_eval_wsweep(*args, **kwargs)\n", "\n", "def arc_par(pop, **kwargs):\n", " jobs = []\n", " pool=mp.Pool(90)\n", " for indiv in pop:\n", " indiv = indiv.reshape((int(indiv.size/2), 2))\n", " indiv[:,1] = mkq.digitize_qx(indiv[:,1], dlevels=2)\n", " indiv[:,0] = rndtop5(indiv[:,0])\n", " indiv = indiv.flatten()\n", " jobs.append((indiv, 0, 1, 0))\n", " arg = [(j, kwargs) for j in jobs]\n", " answ = np.array(pool.map(tmm_wrapper2, arg))\n", " pool.close()\n", " \n", " c1 = np.mean(answ, axis=1)\n", " c2 = np.zeros_like(c1)\n", " for idx, indiv in enumerate(pop):\n", " c2[idx] = np.sum(indiv[::2])\n", " if c2[idx] <= 480:\n", " c2[idx] = 480/c2[idx]\n", " else:\n", " c2[idx] = 0.0\n", " return c1\n", "\n", " \n", "num_layers = 25\n", "d_min = 0.5\n", "d_max = 20 \n", "\n", "bnds = [(d_min, d_max), (0,1)]*num_layers\n", "its_first = 0\n", "psnew = 40\n", "islands = 9\n", "its_second = 256\n", "numgens = 5\n", "\n", "isl = np.ones((psnew*islands, 2*num_layers))\n", "for indiv in range(int(psnew*islands)):\n", " isl[indiv] = np.random.uniform(0,1, 2*num_layers)\n", " #isl[indiv] = qn.make_qxn(num_layers, dlevels=2)\n", "poplist = np.split(isl, islands)\n", "\n", "bids = np.zeros(islands, dtype=int)\n", "bfits = np.zeros(islands)\n", "bests = isl[0:islands]\n", "\n", "\n", "for gen in range(numgens):\n", " print(\"==============================\")\n", " print(\"Epoch #:\" + str(gen + 1))\n", " print(\"==============================\")\n", " \n", " for isln in range(islands):\n", " print(\"----------------- I-\" + str(isln + 1)+ \"---------------------\")\n", " poplist[isln], bids[isln], bfits[isln], bests[isln] = de.de_cp(\n", " fobj=arc_par, \n", " bounds=bnds, \n", " pop=poplist[isln], \n", " history=[], \n", " it_start=its_first, \n", " popsize=psnew, \n", " its=its_second, \n", " lam_low=400, \n", " lam_high=800, \n", " lam_pts=50)\n", " print(np.sum(bests[isln][::2]))\n", " \n", " if its_second > 64:\n", " its_second = int(its_second/2)\n", " \n", " if gen < (numgens - 1):\n", " print(\"Round robin best migration\")\n", " stmp = np.copy(poplist[islands-1][bids[islands-1]])\n", " for isln in range(1, islands):\n", " poplist[isln][bids[isln]] = poplist[isln-1][bids[isln-1]]\n", " poplist[0][bids[0]] = stmp \n", " \n", "print(bfits) \n", "print(bests[np.argmin(bfits)][::2])\n", "print(bests[np.argmin(bfits)][1::2])\n", "print(np.sum(bests[np.argmin(bfits)][::2]))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2018-12-02T16:56:30.208676Z", "start_time": "2018-12-02T16:56:30.117250Z" } }, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from jupyterthemes import jtplot\n", "# currently installed theme will be used to\n", "# set plot style if no arguments provided\n", "jtplot.style()\n", "bri = bests[np.argmin(bfits)][1::2]\n", "brx = bests[np.argmin(bfits)][::2]\n", "xarr = np.cumsum(brx)\n", "print(bri)\n", "# plt.plot(xarr, bri)\n", "# plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2018-11-27T12:04:52.963380Z", "start_time": "2018-11-27T12:04:52.942435Z" } }, "outputs": [], "source": [ "def rndtop5(x):\n", " return np.round(x*2.0)/2\n", "rndtop5(1.63)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2018-12-20T08:01:38.243818Z", "start_time": "2018-12-20T08:01:38.177561Z" } }, "outputs": [], "source": [ "lams" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2018-12-20T08:03:54.562143Z", "start_time": "2018-12-20T08:03:54.497758Z" } }, "outputs": [], "source": [ "lams[88]" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "ExecuteTime": { "end_time": "2018-12-21T05:43:35.814848Z", "start_time": "2018-12-21T05:43:35.798642Z" } }, "outputs": [], "source": [ "a = np.linspace(1, 10, num=10)" ] }, { "cell_type": "code", "execution_count": 22, "metadata": { "ExecuteTime": { "end_time": "2018-12-21T05:45:48.731087Z", "start_time": "2018-12-21T05:45:48.715074Z" } }, "outputs": [], "source": [ "left_r = a[a<4].size\n", "right_r = a[a<=8].size\n", "a[left_r:right_r] = 0.0" ] }, { "cell_type": "code", "execution_count": 23, "metadata": { "ExecuteTime": { "end_time": "2018-12-21T05:45:52.864078Z", "start_time": "2018-12-21T05:45:52.846815Z" } }, "outputs": [ { "data": { "text/plain": [ "array([ 1., 2., 3., 0., 0., 0., 0., 0., 9., 10.])" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "hide_input": false, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.0" }, "latex_envs": { "LaTeX_envs_menu_present": true, "autoclose": false, "autocomplete": true, "bibliofile": "biblio.bib", "cite_by": "apalike", "current_citInitial": 1, "eqLabelWithNumbers": true, "eqNumInitial": 1, "hotkeys": { "equation": "Ctrl-E", "itemize": "Ctrl-I" }, "labels_anchors": false, "latex_user_defs": false, "report_style_numbering": false, "user_envs_cfg": false }, "varInspector": { "cols": { "lenName": 16, "lenType": 16, "lenVar": 40 }, "kernels_config": { "python": { "delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())" }, "r": { "delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) " } }, "types_to_exclude": [ "module", "function", "builtin_function_or_method", "instance", "_Feature" ], "window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }