├── README.md ├── x_y_data.csv ├── .gitignore ├── PSO_numpy.py ├── PSO_tensorflow.py ├── PSO_numpy.ipynb ├── PSO_tensorflow.ipynb └── LICENSE /README.md: -------------------------------------------------------------------------------- 1 | # PSO algorithm implemented in Numpy and TensorFlow 2 | 3 | A generic implementation of the PSO algorithm. 4 | * [Numpy PSO](PSO_numpy.ipynb) 5 | * [TensorFlow (<1.0) PSO](PSO_tensorflow.ipynb) -------------------------------------------------------------------------------- /x_y_data.csv: -------------------------------------------------------------------------------- 1 | X,Y 2 | 1,11.57697455 3 | 2,10.83305597 4 | 3,12.60100603 5 | 4,13.44729646 6 | 5,12.90674112 7 | 6,12.70794321 8 | 7,13.05656816 9 | 8,15.19260818 10 | 9,13.87826326 11 | 10,13.23916647 12 | 11,14.19694813 13 | 12,15.52369108 14 | 13,17.99250888 15 | 14,15.1060026 16 | 15,16.81574255 17 | 16,19.76902603 18 | 17,15.39830206 19 | 18,16.04216719 20 | 19,18.97714521 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | docs/_static/ 69 | docs/_templates/ 70 | 71 | # PyBuilder 72 | target/ 73 | 74 | # Jupyter Notebook 75 | .ipynb_checkpoints 76 | 77 | # pyenv 78 | .python-version 79 | 80 | # celery beat schedule file 81 | celerybeat-schedule 82 | 83 | # SageMath parsed files 84 | *.sage.py 85 | 86 | # Environments 87 | .env 88 | .venv 89 | env/ 90 | venv/ 91 | ENV/ 92 | env.bak/ 93 | venv.bak/ 94 | 95 | # Spyder project settings 96 | .spyderproject 97 | .spyproject 98 | 99 | # Rope project settings 100 | .ropeproject 101 | 102 | # mkdocs documentation 103 | /site 104 | 105 | # mypy 106 | .mypy_cache/ 107 | -------------------------------------------------------------------------------- /PSO_numpy.py: -------------------------------------------------------------------------------- 1 | 2 | # coding: utf-8 3 | 4 | # In[1]: 5 | 6 | 7 | 8 | import numpy as np 9 | import pandas as pd 10 | import matplotlib.pyplot as plt 11 | import time 12 | 13 | 14 | def dummy_dataset(): 15 | """A dummy dataset.""" 16 | 17 | df1=pd.read_csv("x_y_data.csv") #Importing data 18 | col1 = df1['X'] 19 | col2 = df1['Y'] 20 | x1 = col1.as_matrix() 21 | y1 = col2.as_matrix() 22 | plt.scatter(x1,y1,color='red') #Plotting data 23 | 24 | return x1,y1 25 | 26 | class PSONumpy(): 27 | """PSO implemented in Numpy.""" 28 | 29 | 30 | #PSO parameters 31 | c1 = 0.1 #PSO hyperparametre 32 | c2 =0.1 33 | P = 30 #Number of particles 34 | N = 500 #Number of Iterations 35 | 36 | 37 | def __init__(self,Xdata,Ydata,name=None): 38 | """Create a PSO object.""" 39 | 40 | self.name = name 41 | 42 | self.Xdata = Xdata 43 | self.Ydata = Ydata 44 | 45 | def initialize_swarm(self,P=10): #Define partilces 46 | """Initialize the particles in a PSO swar.""" 47 | 48 | self.Wpc = np.random.normal(size=P) 49 | self.bpc = np.random.normal(size=P) 50 | self.fitness_pc = np.zeros(P) 51 | self.update_swarm_fitness() 52 | 53 | self.Wpbest = self.Wpc 54 | self.bpbest = self.bpc 55 | self.fitness_pbest = np.copy(self.fitness_pc) 56 | 57 | self.update_globalbest() 58 | 59 | self.V_W = np.zeros(shape=P) 60 | self.V_b = np.zeros(shape=P) 61 | 62 | #Wpc,bpc,Wpbest,bpbest,Wglobal,bglobal,V_W,V_b,fitness_pc,fitness_pbest,fitness_global =swarm(P) 63 | #print(Wglobal) 64 | 65 | #x = tf.placeholder(tf.float32) 66 | #W = tf.placeholder(tf.float32) 67 | #b = tf.placeholder(tf.float32) 68 | #i = tf.placeholder(tf.int32) 69 | #y_ = tf.placeholder(tf.float32) 70 | 71 | 72 | def update_pbest(self): 73 | """Update the particle best.""" 74 | 75 | truth = np.less(self.fitness_pc,self.fitness_pbest) 76 | indices = np.argwhere(truth) 77 | 78 | self.Wpbest[indices] = self.Wpc[indices] 79 | self.bpbest[indices] = self.bpc[indices] 80 | self.fitness_pbest[indices] = self.fitness_pc[indices] 81 | #print(self.fitness_pc,self.fitness_pbest) 82 | 83 | def update_globalbest(self): 84 | """Update the particle best.""" 85 | 86 | self.fitness_global = np.amin(self.fitness_pbest) 87 | self.best_index = np.argmin(self.fitness_pbest) 88 | 89 | self.Wglobal = self.Wpbest[self.best_index] 90 | self.bglobal = self.bpbest[self.best_index] 91 | 92 | def update_swarm_position(self): #Define partilces 93 | """Update particle velocities and positions in PSO swarm.""" 94 | 95 | #Update particles 96 | 97 | self.V_W = self.V_W + (self.Wpbest - self.Wpc)*self.c1*np.random.random() +(self.Wglobal - self.Wpc)*self.c2*np.random.random() 98 | self.V_b = self.V_b + (self.bpbest - self.bpc)*self.c1*np.random.random() +(self.bglobal - self.bpc)*self.c2*np.random.random() 99 | 100 | self.Wpc = self.Wpc + self.V_W 101 | self.bpc = self.bpc + self.V_b 102 | 103 | def update_swarm_fitness(self): 104 | """Update fitness of the swarm.""" 105 | 106 | for i,(Wpi,bpi) in enumerate(zip(self.Wpc,self.bpc)): 107 | 108 | self.fitness_pc[i] = self.fitness_function(Wpi,bpi) 109 | 110 | def PSO_algorithm(self,epochs=10): 111 | """PSO algorithm.""" 112 | 113 | 114 | start_time = time.time() 115 | for i in range(epochs): 116 | self.update_swarm_position() 117 | self.update_swarm_fitness() 118 | 119 | self.update_pbest() 120 | self.update_globalbest() 121 | 122 | print('Global best:Index:{},Fitness:{}'.format(self.best_index,self.fitness_global)) 123 | 124 | if i%5== 0: 125 | print("Iteration:",i) 126 | print('Particle fitness:{}'.format(self.fitness_pc)) 127 | print("Particle best fitness:{}".format(self.fitness_pbest)) 128 | 129 | self.plot_fit(self.Wglobal,self.bglobal) 130 | print("Time taken:{}".format(time.time() - start_time)) 131 | 132 | 133 | def fitness_function(self,Wpi,bpi): 134 | """The objective function.""" 135 | 136 | Ypredicted = Wpi*self.Xdata + bpi 137 | 138 | return np.mean(np.square(Ypredicted - self.Ydata)) 139 | 140 | def plot_fit(self,Wp,bp): 141 | """Plot fit.""" 142 | 143 | Ypredicted = Wp*self.Xdata + bp 144 | 145 | plt.scatter(self.Xdata,self.Ydata,color='red') #Plot original line 146 | plt.scatter(self.Xdata,Ypredicted,color='blue') #Plot fitted line 147 | 148 | -------------------------------------------------------------------------------- /PSO_tensorflow.py: -------------------------------------------------------------------------------- 1 | 2 | # coding: utf-8 3 | 4 | # In[1]: 5 | 6 | 7 | import tensorflow as tf 8 | import numpy as np 9 | import pandas as pd 10 | import matplotlib.pyplot as plt 11 | import time 12 | get_ipython().run_line_magic('matplotlib', 'inline') 13 | 14 | 15 | # In[2]: 16 | 17 | 18 | df1=pd.read_csv("x_y_data.csv") #Importing data 19 | col1 = df1['X'] 20 | col2 = df1['Y'] 21 | x1 = col1.as_matrix() 22 | y1_ = col2.as_matrix() 23 | plt.scatter(x1,y1_,color='red') #Plotting data 24 | 25 | 26 | # In[3]: 27 | 28 | 29 | #PSO parameters 30 | c1 = 0.1 #PSO hyperparametre 31 | c2 =0.1 32 | P = 30 #Number of particles 33 | N = 500 #Number of Iterations 34 | 35 | 36 | # In[4]: 37 | 38 | 39 | def swarm(P=10): #Define partilces 40 | Wpc = tf.Variable(tf.random_normal([P])) #Current value 41 | bpc = tf.Variable(tf.random_normal([P])) 42 | fitness_pc = tf.Variable(tf.zeros([P])) 43 | 44 | Wpbest= tf.Variable(tf.random_normal([P])) 45 | bpbest= tf.Variable(tf.random_normal([P])) 46 | fitness_pbest = tf.Variable(tf.zeros([P])) 47 | 48 | Wglobal= tf.Variable(tf.random_normal([1])) 49 | bglobal= tf.Variable(tf.random_normal([1])) 50 | fitness_global = tf.Variable(tf.zeros([1])) 51 | 52 | V_W = tf.Variable(tf.zeros([P])) #Particle velocity 53 | V_b = tf.Variable(tf.zeros([P])) 54 | return Wpc,bpc,Wpbest,bpbest,Wglobal,bglobal,V_W,V_b,fitness_pc,fitness_pbest,fitness_global 55 | 56 | Wpc,bpc,Wpbest,bpbest,Wglobal,bglobal,V_W,V_b,fitness_pc,fitness_pbest,fitness_global =swarm(P) 57 | print(Wglobal) 58 | 59 | 60 | # In[5]: 61 | 62 | 63 | 64 | x = tf.placeholder(tf.float32) 65 | W = tf.placeholder(tf.float32) 66 | b = tf.placeholder(tf.float32) 67 | i = tf.placeholder(tf.int32) 68 | y_ = tf.placeholder(tf.float32) 69 | 70 | 71 | # In[6]: 72 | 73 | 74 | #Update particles 75 | V_W_update = V_W[i].assign(V_W[i]+(Wpbest[i] - Wpc[i])*c1*np.random.random() +(Wglobal[0] - Wpc[i])*c2*np.random.random() ) 76 | V_b_update = V_b[i].assign(V_b[i]+(bpbest[i] - bpc[i])*c1*np.random.random() +(bglobal[0] - bpc[i])*c2*np.random.random() ) 77 | Wp_update = Wpc[i].assign(V_W[i]+Wpc[i]) 78 | bp_update = bpc[i].assign(V_b[i]+bpc[i]) 79 | 80 | #Cost 81 | y = Wpc[i]*x + bpc[i] 82 | y_best = Wglobal[0]*x + bglobal[0] 83 | error= tf.reduce_mean(tf.square(y- y_)) 84 | #Update fitness 85 | update_fitness_pc = fitness_pc[i].assign(error) 86 | update_fitness_pbest = fitness_pbest[i].assign(fitness_pc[i]) 87 | update_fitness_global = fitness_global[0].assign(fitness_pc[i]) 88 | initialize_fitness_global = fitness_global[0].assign(tf.reduce_min(fitness_pbest)) 89 | 90 | update_Wpbest = Wpbest[i].assign(Wpc[i]) 91 | update_bpbest = bpbest[i].assign(bpc[i]) 92 | update_Wglobal = Wglobal[0].assign(Wpc[i]) 93 | update_bglobal = bglobal[0].assign(bpc[i]) 94 | 95 | def f1():return [Wpbest[i].assign(Wpc[i]),bpbest[i].assign(bpc[i]),fitness_pbest[i].assign(fitness_pc[i])] 96 | def f2():return [Wpbest[i],bpbest[i],fitness_pbest[i]] 97 | pbest_update= tf.cond(tf.less(fitness_pc[i], fitness_pbest[i]), f1, f2) 98 | 99 | def f3():return [Wglobal[0].assign(Wpc[i]),bglobal[0].assign(bpc[i]),fitness_global[0].assign(fitness_pc[i])] 100 | def f4():return [Wglobal[0],bglobal[0],fitness_global[0]] 101 | global_update= tf.cond(tf.less(fitness_pc[i], fitness_global[0]), f3, f4) 102 | 103 | 104 | # In[7]: 105 | 106 | 107 | start_time = time.time() 108 | init = tf.global_variables_initializer() 109 | with tf.Session() as sess: 110 | sess.run(init) 111 | sess.run([V_W_update,V_b_update],feed_dict={i:0}) 112 | sess.run([Wp_update,bp_update],feed_dict={i:0}) 113 | 114 | for k in range(P): #Initialize particles 115 | sess.run([update_fitness_pc],feed_dict={i:k,x:x1,y_:y1_}) 116 | sess.run([update_fitness_pbest],feed_dict={i:k}) 117 | sess.run([initialize_fitness_global]) 118 | print("Particle fitness:",sess.run(fitness_pc)) 119 | print("Global fitness:",sess.run(fitness_global)) 120 | 121 | for j in range(N): #Loop over N iterations 122 | for k in range(P): #Loop over P particles 123 | 124 | sess.run([V_W_update,V_b_update],feed_dict={i:k}) 125 | sess.run([Wp_update,bp_update],feed_dict={i:k}) 126 | sess.run([update_fitness_pc],feed_dict={i:k,x:x1,y_:y1_}) 127 | 128 | 129 | sess.run([pbest_update],feed_dict={i:k}) 130 | 131 | sess.run([global_update],feed_dict={i:k}) 132 | 133 | 134 | if j%50== 0: 135 | print("Iteration:",j) 136 | print("Particle best fitness:",sess.run(fitness_pbest)) 137 | print("Global best fitness:",sess.run(fitness_global)) 138 | print("Global best particle:",sess.run([Wglobal,bglobal])) 139 | 140 | yfinal =sess.run([y_best],feed_dict={x:x1,y_:y1_}) #storing values 141 | print("Time taken:", (time.time() - start_time)) 142 | 143 | 144 | # In[8]: 145 | 146 | 147 | plt.scatter(x1,y1_,color='red') #Plot original line 148 | plt.scatter(x1,yfinal,color='blue') #Plot fitted line 149 | 150 | -------------------------------------------------------------------------------- /PSO_numpy.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import numpy as np\n", 10 | "import pandas as pd\n", 11 | "import matplotlib.pyplot as plt\n", 12 | "import time\n", 13 | "%matplotlib inline" 14 | ] 15 | }, 16 | { 17 | "cell_type": "code", 18 | "execution_count": 2, 19 | "metadata": {}, 20 | "outputs": [], 21 | "source": [ 22 | "from PSO_numpy import PSONumpy,dummy_dataset" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": 3, 28 | "metadata": {}, 29 | "outputs": [ 30 | { 31 | "name": "stderr", 32 | "output_type": "stream", 33 | "text": [ 34 | "C:\\Users\\splathottam\\Documents\\GitHub\\PSO_in_TensorFlow\\PSO_numpy.py:20: FutureWarning: Method .as_matrix will be removed in a future version. Use .values instead.\n", 35 | " x1 = col1.as_matrix()\n", 36 | "C:\\Users\\splathottam\\Documents\\GitHub\\PSO_in_TensorFlow\\PSO_numpy.py:21: FutureWarning: Method .as_matrix will be removed in a future version. Use .values instead.\n", 37 | " y1 = col2.as_matrix()\n" 38 | ] 39 | }, 40 | { 41 | "data": { 42 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAEL9JREFUeJzt3W+MXFd9xvHncZ282JISp96AG3u9gCAqrWiIplFaCqS0TU2EEqjUimjaWk3UFQgqgkpL6EqBvrAESUvVlqpoW1sO1coFRAIRImqsCNVvcNqxZSeOHHCCvMbEtTd1RahWhbr+9cW9G6/HMzuzszP3z5nvR1rNzLlncn+6O3l89tx75zgiBACovw1lFwAAGA4CHQASQaADQCIIdABIBIEOAIkg0AEgEQQ6ACSCQAeARBDoAJCIjUXubPPmzTE9PV3kLgGg9g4dOvRSREz26ldooE9PT6vVahW5SwCoPdsL/fTrOeVie5vtb9o+bvtZ2x/J26+zvd/2ifxx03qLBgAMrp859AuS/jgiflbSrZI+ZPvNku6X9GREvFHSk/lrAEBJegZ6RJyJiMP58x9KOi7pBkl3SXo47/awpPeOqkgAQG9rusrF9rSkt0p6StJrIuKMlIW+pOu7vGfGdst2a3FxcX3VAgC66jvQbb9K0lck3RcRL/f7voiYi4hGRDQmJ3uepAUADKivQLd9lbIwn4+IR/Lms7a35Nu3SDo3mhIBAP3o5yoXS9ot6XhEfHbFpsck7cyf75T0teGXB2Aszc9L09PShg3Z4/x82RXVQj/Xob9N0u9Jesb2kbztzyR9WtKXbN8r6ZSk3x5NiQDGyvy8NDMjLS1lrxcWsteS1GyWV1cNuMg1RRuNRnBjEYBVTU9nId5u+3bp5Mmiq6kE24ciotGrH9/lAqBaTp1aWzteQaADqJapqbW14xUEOoBq2bVLmpi4vG1iImvHqgh0ANXSbEpzc9mcuZ09zs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vqFKx1TS2eVpqfzxXIc+lTmu+QnZ90hqRj7B266Pz8lIRcTZiPi/iLgo6R+67L8Sx9T2Rkm/JemL3fqUfTwHNXaBns+d7ZZ0PCI+26XPa/N+sn2LsuP0n8VV+UodP2n7muXnyk6QHWvr9pik38+vdrlV0g+WpxNK0HXUU5VjmntM0vJVKzslfa1Dn3+RdLvtTfn0we15W6Fs75D0cUl3RsRSlz79fE5Gqu28zfu67P/fJb3R9uvyv+ber+x3UbRfl/RcRJzutLEKx3NgZZ+VLfpH0q8o+zPvaUlH8p87JH1A0gfyPh+W9Kyys/AHJf1ySbW+Pq/haF7PbN6+slZL+jtlVw88I6lRUq0TygL61SvaSj+myv6BOSPpf5WNEO+V9NOSnpR0In+8Lu/bkPSPK957j6Tn858/KKnW55XNOy9/Vj+f9/0ZSd9Y7XNScJ3/lH/+nlYW0lva68xf36HsyrIXyqgzb9+7/Llc0be04znMH+4UBYBEjN2UCwCkikAHgEQQ6ACQCAIdABJBoANAIgh0AEgEgQ4AiSDQASAR/w84tHYUOV1qYgAAAABJRU5ErkJggg==\n", 43 | "text/plain": [ 44 | "
" 45 | ] 46 | }, 47 | "metadata": { 48 | "needs_background": "light" 49 | }, 50 | "output_type": "display_data" 51 | } 52 | ], 53 | "source": [ 54 | "x,y = dummy_dataset()\n", 55 | "pso1= PSONumpy(x,y,'test')" 56 | ] 57 | }, 58 | { 59 | "cell_type": "code", 60 | "execution_count": 4, 61 | "metadata": {}, 62 | "outputs": [], 63 | "source": [ 64 | "pso1.initialize_swarm()" 65 | ] 66 | }, 67 | { 68 | "cell_type": "code", 69 | "execution_count": 5, 70 | "metadata": {}, 71 | "outputs": [ 72 | { 73 | "name": "stdout", 74 | "output_type": "stream", 75 | "text": [ 76 | "Global best:Index:0,Fitness:34.86693188107949\n", 77 | "Iteration: 0\n", 78 | "Particle fitness:[ 34.86693188 252.64430433 51.9507174 463.02527826 78.89149248\n", 79 | " 467.60066725 518.61108445 43.01516434 106.20099914 1106.69500021]\n", 80 | "Particle best fitness:[ 34.86693188 252.64430433 51.9507174 463.02527826 78.89149248\n", 81 | " 467.60066725 518.61108445 43.01516434 106.20099914 1106.69500021]\n", 82 | "Global best:Index:0,Fitness:34.86693188107949\n", 83 | "Global best:Index:0,Fitness:34.86693188107949\n", 84 | "Global best:Index:7,Fitness:33.75969803978372\n", 85 | "Global best:Index:7,Fitness:32.274383899979334\n", 86 | "Global best:Index:7,Fitness:32.274383899979334\n", 87 | "Iteration: 5\n", 88 | "Particle fitness:[34.4521562 40.78199168 36.80184716 53.93924037 32.63973654 45.48310782\n", 89 | " 49.40835947 32.29206455 33.13408254 72.20904078]\n", 90 | "Particle best fitness:[34.4521562 40.78199168 36.80184716 53.93924037 32.63973654 45.48310782\n", 91 | " 49.40835947 32.2743839 33.13408254 72.20904078]\n", 92 | "Global best:Index:9,Fitness:30.075732642399633\n", 93 | "Global best:Index:9,Fitness:30.075732642399633\n", 94 | "Global best:Index:9,Fitness:30.075732642399633\n", 95 | "Global best:Index:9,Fitness:30.075732642399633\n", 96 | "Global best:Index:9,Fitness:30.075732642399633\n", 97 | "Iteration: 10\n", 98 | "Particle fitness:[ 31.00629896 132.89251811 40.43583523 208.60306148 56.05296161\n", 99 | " 219.80493518 237.04261788 39.02990602 73.23852937 468.55113879]\n", 100 | "Particle best fitness:[31.00629896 34.68031497 35.41424369 36.93901023 32.63973654 31.42052173\n", 101 | " 32.29273226 32.2743839 33.13159669 30.07573264]\n", 102 | "Global best:Index:9,Fitness:30.075732642399633\n", 103 | "Global best:Index:0,Fitness:29.921374643302983\n", 104 | "Global best:Index:0,Fitness:29.627725305542388\n", 105 | "Global best:Index:0,Fitness:29.50066698452971\n", 106 | "Global best:Index:0,Fitness:29.50066698452971\n", 107 | "Iteration: 15\n", 108 | "Particle fitness:[29.54019968 31.55449023 30.96386305 32.84411917 30.25023359 30.7682119\n", 109 | " 31.30294836 30.27313086 30.22206045 32.31054472]\n", 110 | "Particle best fitness:[29.50066698 31.55449023 30.96386305 32.84411917 30.25023359 30.7682119\n", 111 | " 31.30294836 29.91894752 30.22206045 30.07573264]\n", 112 | "Global best:Index:2,Fitness:29.21680118572604\n", 113 | "Global best:Index:2,Fitness:28.204704696664013\n", 114 | "Global best:Index:2,Fitness:27.92757357813542\n", 115 | "Global best:Index:2,Fitness:27.92757357813542\n", 116 | "Global best:Index:2,Fitness:27.92757357813542\n", 117 | "Iteration: 20\n", 118 | "Particle fitness:[ 28.04992712 162.0241533 29.45957401 273.08610052 66.75403682\n", 119 | " 284.46622731 310.12875496 34.84589947 81.30339982 688.23989086]\n", 120 | "Particle best fitness:[28.04992712 31.55449023 27.92757358 32.84411917 30.25023359 30.7682119\n", 121 | " 31.30294836 29.91894752 30.22206045 30.07573264]\n", 122 | "Global best:Index:0,Fitness:26.96471984744208\n", 123 | "Global best:Index:0,Fitness:26.333129806752538\n", 124 | "Global best:Index:0,Fitness:26.15515699827646\n", 125 | "Global best:Index:0,Fitness:26.15515699827646\n", 126 | "Global best:Index:0,Fitness:26.15515699827646\n", 127 | "Iteration: 25\n", 128 | "Particle fitness:[27.01961978 28.31501334 28.55648897 28.8484468 27.63594129 27.55097541\n", 129 | " 27.80657234 29.99977988 27.39908208 28.45212183]\n", 130 | "Particle best fitness:[26.155157 28.31501334 27.92757358 28.8484468 27.63594129 27.55097541\n", 131 | " 27.80657234 26.57508548 27.39908208 28.45212183]\n", 132 | "Global best:Index:0,Fitness:26.15515699827646\n", 133 | "Global best:Index:0,Fitness:26.15515699827646\n", 134 | "Global best:Index:0,Fitness:26.15515699827646\n", 135 | "Global best:Index:0,Fitness:26.15515699827646\n", 136 | "Global best:Index:0,Fitness:26.15515699827646\n", 137 | "Iteration: 30\n", 138 | "Particle fitness:[ 28.27408099 179.91652827 31.3788628 293.98235849 67.86516544\n", 139 | " 311.44971772 337.30880062 36.64110597 79.31711063 648.79801779]\n", 140 | "Particle best fitness:[26.155157 28.31501334 27.39929402 28.8484468 27.63594129 27.55097541\n", 141 | " 27.80657234 26.57508548 27.39908208 28.45212183]\n", 142 | "Global best:Index:0,Fitness:26.15515699827646\n", 143 | "Global best:Index:0,Fitness:26.15515699827646\n", 144 | "Global best:Index:0,Fitness:26.15515699827646\n", 145 | "Global best:Index:7,Fitness:26.140058545583383\n", 146 | "Global best:Index:7,Fitness:26.140058545583383\n", 147 | "Iteration: 35\n", 148 | "Particle fitness:[26.81412752 40.17387896 28.50218453 52.99994907 29.6041537 45.50304427\n", 149 | " 48.90036329 26.92335199 30.52657414 68.01272734]\n", 150 | "Particle best fitness:[26.155157 28.31501334 27.39929402 28.8484468 27.63594129 27.55097541\n", 151 | " 27.80657234 26.14005855 27.39908208 28.45212183]\n", 152 | "Global best:Index:3,Fitness:20.063979620415562\n", 153 | "Global best:Index:3,Fitness:20.063979620415562\n", 154 | "Global best:Index:3,Fitness:20.063979620415562\n", 155 | "Global best:Index:3,Fitness:20.063979620415562\n", 156 | "Global best:Index:3,Fitness:20.063979620415562\n", 157 | "Iteration: 40\n", 158 | "Particle fitness:[ 27.95653645 121.91655956 24.86311678 191.59737873 50.24489293\n", 159 | " 256.13625147 290.87453985 31.47813978 65.90199891 649.65861204]\n", 160 | "Particle best fitness:[26.155157 22.48325246 24.56036692 20.06397962 25.19774021 27.55097541\n", 161 | " 26.2126239 26.14005855 25.8531273 28.45212183]\n", 162 | "Global best:Index:3,Fitness:20.063979620415562\n", 163 | "Global best:Index:3,Fitness:20.063979620415562\n", 164 | "Global best:Index:3,Fitness:20.063979620415562\n", 165 | "Global best:Index:3,Fitness:20.063979620415562\n", 166 | "Global best:Index:3,Fitness:12.88422433216582\n", 167 | "Iteration: 45\n", 168 | "Particle fitness:[22.70900503 16.07072761 21.56132859 12.88422433 21.04244841 25.22822842\n", 169 | " 24.1825442 23.78014614 22.59286255 33.18677077]\n", 170 | "Particle best fitness:[22.70900503 16.07072761 21.56132859 12.88422433 21.04244841 25.22822842\n", 171 | " 24.1825442 23.4170345 22.59286255 28.45212183]\n", 172 | "Global best:Index:3,Fitness:12.88422433216582\n", 173 | "Global best:Index:3,Fitness:12.88422433216582\n", 174 | "Global best:Index:3,Fitness:12.88422433216582\n", 175 | "Global best:Index:2,Fitness:12.203305506160191\n", 176 | "Global best:Index:2,Fitness:10.476225815036091\n", 177 | "Iteration: 50\n", 178 | "Particle fitness:[ 14.62332635 170.34464767 10.47622582 297.26451887 54.37173129\n", 179 | " 270.31553351 295.96793805 19.97907061 65.78912238 664.48341937]\n", 180 | "Particle best fitness:[14.62332635 16.07072761 10.47622582 12.88422433 21.04244841 25.22822842\n", 181 | " 24.1825442 19.97907061 22.59286255 28.45212183]\n", 182 | "Global best:Index:2,Fitness:9.187735096286199\n", 183 | "Global best:Index:2,Fitness:8.337833349910525\n", 184 | "Global best:Index:2,Fitness:7.926520575909064\n", 185 | "Global best:Index:2,Fitness:7.926520575909064\n", 186 | "Global best:Index:7,Fitness:6.803585411317786\n", 187 | "Iteration: 55\n", 188 | "Particle fitness:[ 8.31762055 8.22964264 8.28678963 11.28585359 8.1650396 7.17353622\n", 189 | " 8.19989957 6.80358541 7.84866144 6.83952182]\n", 190 | "Particle best fitness:[ 8.31762055 8.22964264 7.92652058 11.28585359 8.1650396 7.17353622\n", 191 | " 8.19989957 6.80358541 7.84866144 6.83952182]\n", 192 | "Global best:Index:7,Fitness:4.623842206823799\n", 193 | "Global best:Index:7,Fitness:3.0182969614449706\n", 194 | "Global best:Index:7,Fitness:1.9869496751813014\n", 195 | "Global best:Index:7,Fitness:1.5298003480327937\n", 196 | "Global best:Index:7,Fitness:1.5298003480327937\n", 197 | "Iteration: 60\n", 198 | "Particle fitness:[ 2.78466949 151.43015054 2.9967855 300.37008149 36.592025\n", 199 | " 250.66237233 308.9763751 1.64684898 51.56952368 657.77788344]\n", 200 | "Particle best fitness:[ 2.78466949 8.22964264 2.9967855 11.28585359 6.98191624 7.17353622\n", 201 | " 8.19989957 1.52980035 7.66914297 6.83952182]\n", 202 | "Global best:Index:7,Fitness:1.5298003480327937\n", 203 | "Global best:Index:7,Fitness:1.5298003480327937\n", 204 | "Global best:Index:7,Fitness:1.5298003480327937\n", 205 | "Global best:Index:7,Fitness:1.5298003480327937\n", 206 | "Global best:Index:7,Fitness:1.5298003480327937\n", 207 | "Iteration: 65\n", 208 | "Particle fitness:[3.95358736 1.6349218 6.408496 2.48985665 2.41174854 1.96079302\n", 209 | " 2.53666151 3.78711748 3.46467442 6.11943384]\n", 210 | "Particle best fitness:[2.32108857 1.6349218 1.65799441 2.48985665 2.41174854 1.96079302\n", 211 | " 2.53666151 1.52980035 3.46467442 6.11943384]\n", 212 | "Global best:Index:7,Fitness:1.5298003480327937\n", 213 | "Global best:Index:7,Fitness:1.5298003480327937\n", 214 | "Global best:Index:7,Fitness:1.5298003480327937\n", 215 | "Global best:Index:7,Fitness:1.5298003480327937\n", 216 | "Global best:Index:7,Fitness:1.5298003480327937\n", 217 | "Iteration: 70\n", 218 | "Particle fitness:[ 2.45281247 205.46004047 4.52661984 353.18251819 54.94999118\n", 219 | " 307.25812288 361.12288868 5.4745631 67.015211 744.57181872]\n", 220 | "Particle best fitness:[2.32108857 1.6349218 1.65799441 2.48985665 2.41174854 1.96079302\n", 221 | " 2.53666151 1.52980035 3.46467442 6.11943384]\n", 222 | "Global best:Index:7,Fitness:1.5298003480327937\n", 223 | "Global best:Index:7,Fitness:1.5298003480327937\n", 224 | "Global best:Index:7,Fitness:1.5298003480327937\n", 225 | "Global best:Index:7,Fitness:1.5298003480327937\n", 226 | "Time taken:0.09701275825500488\n" 227 | ] 228 | }, 229 | { 230 | "data": { 231 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAE/lJREFUeJzt3X+MHOV9x/HP1zY0OkLB1EdiOHwbogQlRS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ekXRulqPcXWpcr+grz/OSdsX/rpD0GUmfidf5nKQXFc0UeErSh3Ou8dx427vjOhbbcmmNJukf47Z+QVIz77aM6xhRFNynLVlWaFsq+qNzUNL/KToSul7RWNDjkvbFj2fE6zYl/fOSz14X758vS/qjAup8WVFf7OK+uThL7SxJ311u/8ixxm/E+9zzikJqbXuN8eufy4M864yX37O4Ly5Zt6i27JY9meybnBkLAIHjzFgACBxBDwCBI+gBIHAEPQAEjqAHgMAR9AAQOIIeAAJH0ANA4P4f3qICXg/ezoAAAAAASUVORK5CYII=\n", 232 | "text/plain": [ 233 | "
" 234 | ] 235 | }, 236 | "metadata": { 237 | "needs_background": "light" 238 | }, 239 | "output_type": "display_data" 240 | } 241 | ], 242 | "source": [ 243 | "pso1.PSO_algorithm(75)" 244 | ] 245 | } 246 | ], 247 | "metadata": { 248 | "kernelspec": { 249 | "display_name": "Python 3", 250 | "language": "python", 251 | "name": "python3" 252 | }, 253 | "language_info": { 254 | "codemirror_mode": { 255 | "name": "ipython", 256 | "version": 3 257 | }, 258 | "file_extension": ".py", 259 | "mimetype": "text/x-python", 260 | "name": "python", 261 | "nbconvert_exporter": "python", 262 | "pygments_lexer": "ipython3", 263 | "version": "3.7.3" 264 | } 265 | }, 266 | "nbformat": 4, 267 | "nbformat_minor": 2 268 | } 269 | -------------------------------------------------------------------------------- /PSO_tensorflow.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stderr", 10 | "output_type": "stream", 11 | "text": [ 12 | "C:\\Users\\Siby\\Anaconda3\\lib\\site-packages\\h5py\\__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\n", 13 | " from ._conv import register_converters as _register_converters\n" 14 | ] 15 | } 16 | ], 17 | "source": [ 18 | "import tensorflow as tf\n", 19 | "import numpy as np\n", 20 | "import pandas as pd\n", 21 | "import matplotlib.pyplot as plt\n", 22 | "import time\n", 23 | "%matplotlib inline" 24 | ] 25 | }, 26 | { 27 | "cell_type": "code", 28 | "execution_count": 2, 29 | "metadata": {}, 30 | "outputs": [ 31 | { 32 | "data": { 33 | "text/plain": [ 34 | "" 35 | ] 36 | }, 37 | "execution_count": 2, 38 | "metadata": {}, 39 | "output_type": "execute_result" 40 | }, 41 | { 42 | "data": { 43 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAgUAAAFkCAYAAACw3EhvAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAAPYQAAD2EBqD+naQAAGplJREFUeJzt3X+M5Hd93/Hnu2MnhktZb0G1U0AF3/6okSLbuy4WpYcx\nbLvL1tgmfySaxXIJlVLLENCqVajbKEBopQJ1jwTXaqtIYMthqkQE7FBuFzYFg0Ox01tcF7h2blcG\n/AOOJLusa1MLZ/3pH9/vhp293b2bme/Md348H9LJns/3OzNvazy3r/38jJQSkiRJf63sAiRJUm8w\nFEiSJMBQIEmScoYCSZIEGAokSVLOUCBJkgBDgSRJyhkKJEkSYCiQJEk5Q4EkSQKaDAURcXtEPBwR\nT0fEmYj4TERM7Lp+QUR8OCIejYhnIuLJiLg7In6++NIlSVKRmu0pOAZ8HLgGmAEuBL4QES/Kr78Y\nuBL4IHAV8DZgErivkGolSVLHRDsHIkXEy4AfAm9IKT14wD1XAw8Bfzul9ETLbyZJkjqq3TkFFwMJ\n2DiPe37U5ntJkqQOarmnICIC+CPgr6eUrj3gnp8F/gT4dkrplgPueSkwC3wHeK6lYiRJGk4XAa8C\nllNKf9Hui13QxnPvAl4DvH6/ixFxAfAHZL0Etx3yOrPA77VRhyRJw+7twKfafZGWQkFE3AnMA8dS\nSt/f5/pOIHgl8KaU0jOHvNx3AO69914uv/zyVspRD1pcXOT48eNll6GC+HkOFj/PwXHq1Cluvvlm\nyH+WtqvpUJAHghuBa1NK39vn+k4guAy4LqW0eY6XfA7g8ssvZ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SJKknKFAkiQBhgJJkpT7/4BtJeL6lOenAAAAAElF\nTkSuQmCC\n", 44 | "text/plain": [ 45 | "" 46 | ] 47 | }, 48 | "metadata": {}, 49 | "output_type": "display_data" 50 | } 51 | ], 52 | "source": [ 53 | "df1=pd.read_csv(\"x_y_data.csv\") #Importing data\n", 54 | "col1 = df1['X']\n", 55 | "col2 = df1['Y']\n", 56 | "x1 = col1.as_matrix()\n", 57 | "y1_ = col2.as_matrix()\n", 58 | "plt.scatter(x1,y1_,color='red') #Plotting data" 59 | ] 60 | }, 61 | { 62 | "cell_type": "code", 63 | "execution_count": 3, 64 | "metadata": { 65 | "collapsed": true 66 | }, 67 | "outputs": [], 68 | "source": [ 69 | "#PSO parameters\n", 70 | "c1 = 0.1 #PSO hyperparametre\n", 71 | "c2 =0.1\n", 72 | "P = 30 #Number of particles\n", 73 | "N = 500 #Number of Iterations" 74 | ] 75 | }, 76 | { 77 | "cell_type": "code", 78 | "execution_count": 4, 79 | "metadata": {}, 80 | "outputs": [ 81 | { 82 | "name": "stdout", 83 | "output_type": "stream", 84 | "text": [ 85 | "Tensor(\"Variable_6/read:0\", shape=(1,), dtype=float32)\n" 86 | ] 87 | } 88 | ], 89 | "source": [ 90 | "def swarm(P=10): #Define partilces\n", 91 | " Wpc = tf.Variable(tf.random_normal([P])) #Current value\n", 92 | " bpc = tf.Variable(tf.random_normal([P]))\n", 93 | " fitness_pc = tf.Variable(tf.zeros([P]))\n", 94 | " \n", 95 | " Wpbest= tf.Variable(tf.random_normal([P]))\n", 96 | " bpbest= tf.Variable(tf.random_normal([P]))\n", 97 | " fitness_pbest = tf.Variable(tf.zeros([P]))\n", 98 | " \n", 99 | " Wglobal= tf.Variable(tf.random_normal([1]))\n", 100 | " bglobal= tf.Variable(tf.random_normal([1]))\n", 101 | " fitness_global = tf.Variable(tf.zeros([1]))\n", 102 | " \n", 103 | " V_W = tf.Variable(tf.zeros([P])) #Particle velocity\n", 104 | " V_b = tf.Variable(tf.zeros([P]))\n", 105 | " return Wpc,bpc,Wpbest,bpbest,Wglobal,bglobal,V_W,V_b,fitness_pc,fitness_pbest,fitness_global\n", 106 | "\n", 107 | "Wpc,bpc,Wpbest,bpbest,Wglobal,bglobal,V_W,V_b,fitness_pc,fitness_pbest,fitness_global =swarm(P)\n", 108 | "print(Wglobal)" 109 | ] 110 | }, 111 | { 112 | "cell_type": "code", 113 | "execution_count": 5, 114 | "metadata": {}, 115 | "outputs": [], 116 | "source": [ 117 | "\n", 118 | "x = tf.placeholder(tf.float32)\n", 119 | "W = tf.placeholder(tf.float32)\n", 120 | "b = tf.placeholder(tf.float32)\n", 121 | "i = tf.placeholder(tf.int32)\n", 122 | "y_ = tf.placeholder(tf.float32)" 123 | ] 124 | }, 125 | { 126 | "cell_type": "code", 127 | "execution_count": 6, 128 | "metadata": {}, 129 | "outputs": [], 130 | "source": [ 131 | "#Update particles\n", 132 | "V_W_update = V_W[i].assign(V_W[i]+(Wpbest[i] - Wpc[i])*c1*np.random.random() +(Wglobal[0] - Wpc[i])*c2*np.random.random() )\n", 133 | "V_b_update = V_b[i].assign(V_b[i]+(bpbest[i] - bpc[i])*c1*np.random.random() +(bglobal[0] - bpc[i])*c2*np.random.random() )\n", 134 | "Wp_update = Wpc[i].assign(V_W[i]+Wpc[i])\n", 135 | "bp_update = bpc[i].assign(V_b[i]+bpc[i])\n", 136 | "\n", 137 | "#Cost\n", 138 | "y = Wpc[i]*x + bpc[i]\n", 139 | "y_best = Wglobal[0]*x + bglobal[0]\n", 140 | "error= tf.reduce_mean(tf.square(y- y_))\n", 141 | "#Update fitness\n", 142 | "update_fitness_pc = fitness_pc[i].assign(error)\n", 143 | "update_fitness_pbest = fitness_pbest[i].assign(fitness_pc[i])\n", 144 | "update_fitness_global = fitness_global[0].assign(fitness_pc[i])\n", 145 | "initialize_fitness_global = fitness_global[0].assign(tf.reduce_min(fitness_pbest))\n", 146 | "\n", 147 | "update_Wpbest = Wpbest[i].assign(Wpc[i])\n", 148 | "update_bpbest = bpbest[i].assign(bpc[i])\n", 149 | "update_Wglobal = Wglobal[0].assign(Wpc[i])\n", 150 | "update_bglobal = bglobal[0].assign(bpc[i])\n", 151 | "\n", 152 | "def f1():return [Wpbest[i].assign(Wpc[i]),bpbest[i].assign(bpc[i]),fitness_pbest[i].assign(fitness_pc[i])]\n", 153 | "def f2():return [Wpbest[i],bpbest[i],fitness_pbest[i]]\n", 154 | "pbest_update= tf.cond(tf.less(fitness_pc[i], fitness_pbest[i]), f1, f2)\n", 155 | "\n", 156 | "def f3():return [Wglobal[0].assign(Wpc[i]),bglobal[0].assign(bpc[i]),fitness_global[0].assign(fitness_pc[i])]\n", 157 | "def f4():return [Wglobal[0],bglobal[0],fitness_global[0]]\n", 158 | "global_update= tf.cond(tf.less(fitness_pc[i], fitness_global[0]), f3, f4)\n" 159 | ] 160 | }, 161 | { 162 | "cell_type": "code", 163 | "execution_count": 7, 164 | "metadata": {}, 165 | "outputs": [ 166 | { 167 | "name": "stdout", 168 | "output_type": "stream", 169 | "text": [ 170 | "Particle fitness: [ 119.44880676 325.26739502 63.47898865 138.46643066 126.3000946\n", 171 | " 130.27157593 488.79714966 187.39117432 30.29364586 40.56044388\n", 172 | " 29.67288589 63.12273407 271.03540039 550.14672852 41.08478165\n", 173 | " 103.86564636 48.12801361 159.07382202 32.86349487 785.2791748\n", 174 | " 82.94963074 793.23181152 174.69995117 313.41827393 64.50994873\n", 175 | " 1303.04797363 45.47896194 34.18169403 229.8939209 383.10617065]\n", 176 | "Global fitness: [ 29.67288589]\n", 177 | "Iteration: 0\n", 178 | "Iteration: 50\n", 179 | "Iteration: 100\n", 180 | "Iteration: 150\n", 181 | "Iteration: 200\n", 182 | "Iteration: 250\n", 183 | "Iteration: 300\n", 184 | "Iteration: 350\n", 185 | "Iteration: 400\n", 186 | "Iteration: 450\n", 187 | "Particle best fitness: [ 1.55862439 1.51461995 1.49847364 1.51188374 1.49782944 1.55737257\n", 188 | " 1.49745011 1.49908888 1.50746918 1.51665199 1.49794161 1.50588655\n", 189 | " 1.49734902 1.49783599 1.49792409 1.49818957 1.50252676 1.51077902\n", 190 | " 1.49849248 1.49620497 1.56630623 1.53947163 1.49599135 1.49559176\n", 191 | " 1.58056188 1.50206459 1.50983071 1.55892324 1.81251132 1.50670815]\n", 192 | "Global best fitness: [ 1.49559176]\n", 193 | "Global best particle: [array([ 0.36932212], dtype=float32), array([ 11.00793552], dtype=float32)]\n", 194 | "Time taken: 54.58162879943848\n" 195 | ] 196 | } 197 | ], 198 | "source": [ 199 | "start_time = time.time()\n", 200 | "init = tf.global_variables_initializer()\n", 201 | "with tf.Session() as sess:\n", 202 | " sess.run(init)\n", 203 | " sess.run([V_W_update,V_b_update],feed_dict={i:0})\n", 204 | " sess.run([Wp_update,bp_update],feed_dict={i:0})\n", 205 | " \n", 206 | " for k in range(P): #Initialize particles\n", 207 | " sess.run([update_fitness_pc],feed_dict={i:k,x:x1,y_:y1_})\n", 208 | " sess.run([update_fitness_pbest],feed_dict={i:k})\n", 209 | " sess.run([initialize_fitness_global])\n", 210 | " print(\"Particle fitness:\",sess.run(fitness_pc))\n", 211 | " print(\"Global fitness:\",sess.run(fitness_global))\n", 212 | " \n", 213 | " for j in range(N): #Loop over N iterations\n", 214 | " for k in range(P): #Loop over P particles\n", 215 | " \n", 216 | " sess.run([V_W_update,V_b_update],feed_dict={i:k})\n", 217 | " sess.run([Wp_update,bp_update],feed_dict={i:k})\n", 218 | " sess.run([update_fitness_pc],feed_dict={i:k,x:x1,y_:y1_})\n", 219 | " \n", 220 | " \n", 221 | " sess.run([pbest_update],feed_dict={i:k}) \n", 222 | " \n", 223 | " sess.run([global_update],feed_dict={i:k})\n", 224 | " \n", 225 | " \n", 226 | " if j%50== 0:\n", 227 | " print(\"Iteration:\",j) \n", 228 | " print(\"Particle best fitness:\",sess.run(fitness_pbest)) \n", 229 | " print(\"Global best fitness:\",sess.run(fitness_global)) \n", 230 | " print(\"Global best particle:\",sess.run([Wglobal,bglobal])) \n", 231 | " \n", 232 | " yfinal =sess.run([y_best],feed_dict={x:x1,y_:y1_}) #storing values\n", 233 | "print(\"Time taken:\", (time.time() - start_time)) " 234 | ] 235 | }, 236 | { 237 | "cell_type": "code", 238 | "execution_count": 8, 239 | "metadata": {}, 240 | "outputs": [ 241 | { 242 | "data": { 243 | "text/plain": [ 244 | "" 245 | ] 246 | }, 247 | "execution_count": 8, 248 | "metadata": {}, 249 | "output_type": "execute_result" 250 | }, 251 | { 252 | "data": { 253 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAgUAAAFkCAYAAACw3EhvAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAAPYQAAD2EBqD+naQAAHhhJREFUeJzt3X+QXWd93/H3l5USg1KEElqbAFPb0q4w0wx418V1qGIM\narVWjDHNTDIrGIbSmZQxFGanTIg7TDGhLT8S16a4bum0BVPi2yYDxI6r3YUNPwIh2J1dHEpwcyXF\nxtgG0bBiHZu4mNXTP87Z+O5qtbr33HN/nHver5k7Zs89e++jw5Hu5z4/vk+klJAkSXrGoBsgSZKG\ng6FAkiQBhgJJkpQzFEiSJMBQIEmScoYCSZIEGAokSVLOUCBJkgBDgSRJyhkKJEkS0GEoiIgbIuLe\niHgsIk5GxKcjYqLl+R0R8YGI+HpEPB4Rj0TE7RHxvPKbLkmSytRpT8EB4MPA5cBBYCfwmYh4Zv78\ns4CXAu8BLgVeC+wH7iyltZIkqWeimw2RIuK5wPeAX0gpffks51wG3AP87ZTSw4XfTJIk9VS3cwqe\nAyRgpY1zftDle0mSpB4q3FMQEQH8PvA3UkpXnuWcnwT+CPhmSukNZznnZ4BDwIPAk4UaI0lSPZ0H\nXAgspJS+3+2L7ejid28DXgy8fKsnI2IH8LtkvQTXb/M6h4Df7qIdkiTV3euAO7p9kUKhICJuBQ4D\nB1JK39ni+fVA8ELglSmlx7d5uQcBPvGJT3DJJZcUaU5tzc7OcvPNNw+6GZXiNSvG69Y5r1kxXrfO\n3H///bz+9a+H/LO0Wx2HgjwQvAa4MqX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R70Y7vrRrbP/Xz+j/STZEOk/wH4m4Nu94Cv2VbX\naw14w6bzvN/avGZl3mtuiCRJkoDhrVMgSZL6zFAgSZIAQ4EkScoZCiRJEmAokCRJOUOBJEkCDAWS\nJClnKJAkSYChQJIk5QwFkiQJMBRIkqTc/wcRtDX2DB/SnQAAAABJRU5ErkJggg==\n", 254 | "text/plain": [ 255 | "" 256 | ] 257 | }, 258 | "metadata": {}, 259 | "output_type": "display_data" 260 | } 261 | ], 262 | "source": [ 263 | "plt.scatter(x1,y1_,color='red') #Plot original line\n", 264 | "plt.scatter(x1,yfinal,color='blue') #Plot fitted line" 265 | ] 266 | } 267 | ], 268 | "metadata": { 269 | "anaconda-cloud": {}, 270 | "kernelspec": { 271 | "display_name": "Python [conda root]", 272 | "language": "python", 273 | "name": "conda-root-py" 274 | }, 275 | "language_info": { 276 | "codemirror_mode": { 277 | "name": "ipython", 278 | "version": 3 279 | }, 280 | "file_extension": ".py", 281 | "mimetype": "text/x-python", 282 | "name": "python", 283 | "nbconvert_exporter": "python", 284 | "pygments_lexer": "ipython3", 285 | "version": "3.5.4" 286 | } 287 | }, 288 | "nbformat": 4, 289 | "nbformat_minor": 1 290 | } 291 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------