├── .gitignore
├── Propuesta Black Hole Algorithm
└── A_Dynamic_Programming_Offloading_Algorithm_for_Mobile_Cloud_Computing.pdf
├── README.md
├── img
├── img1.png
└── img2.png
└── src
├── blackHole.py
└── dinamicProgramming.py
/.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 | pip-wheel-metadata/
24 | share/python-wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 | MANIFEST
29 |
30 | # PyInstaller
31 | # Usually these files are written by a python script from a template
32 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
33 | *.manifest
34 | *.spec
35 |
36 | # Installer logs
37 | pip-log.txt
38 | pip-delete-this-directory.txt
39 |
40 | # Unit test / coverage reports
41 | htmlcov/
42 | .tox/
43 | .nox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | .hypothesis/
51 | .pytest_cache/
52 |
53 | # Translations
54 | *.mo
55 | *.pot
56 |
57 | # Django stuff:
58 | *.log
59 | local_settings.py
60 | db.sqlite3
61 | db.sqlite3-journal
62 |
63 | # Flask stuff:
64 | instance/
65 | .webassets-cache
66 |
67 | # Scrapy stuff:
68 | .scrapy
69 |
70 | # Sphinx documentation
71 | docs/_build/
72 |
73 | # PyBuilder
74 | target/
75 |
76 | # Jupyter Notebook
77 | .ipynb_checkpoints
78 |
79 | # IPython
80 | profile_default/
81 | ipython_config.py
82 |
83 | # pyenv
84 | .python-version
85 |
86 | # pipenv
87 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
88 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
89 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
90 | # install all needed dependencies.
91 | #Pipfile.lock
92 |
93 | # celery beat schedule file
94 | celerybeat-schedule
95 |
96 | # SageMath parsed files
97 | *.sage.py
98 |
99 | # Environments
100 | .env
101 | .venv
102 | env/
103 | venv/
104 | ENV/
105 | env.bak/
106 | venv.bak/
107 |
108 | # Spyder project settings
109 | .spyderproject
110 | .spyproject
111 |
112 | # Rope project settings
113 | .ropeproject
114 |
115 | # mkdocs documentation
116 | /site
117 |
118 | # mypy
119 | .mypy_cache/
120 | .dmypy.json
121 | dmypy.json
122 |
123 | # Pyre type checker
124 | .pyre/
125 |
--------------------------------------------------------------------------------
/Propuesta Black Hole Algorithm/A_Dynamic_Programming_Offloading_Algorithm_for_Mobile_Cloud_Computing.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lehi10/Black-Hole-Algorithm-in-Computational-Offloading-for-Mobile-Cloud-Computing/f9f250f48e993597668d90e75e1dd446493320ec/Propuesta Black Hole Algorithm/A_Dynamic_Programming_Offloading_Algorithm_for_Mobile_Cloud_Computing.pdf
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Black Hole Algorithm in Computational Offloading for Mobile Cloud Computing
2 | Project of Cloud Computer (Short Paper)
3 |
4 | ### Requirements
5 | ```
6 | Python 2.7
7 | Numpy
8 | ```
9 | ### Compile
10 | ```
11 | python blackHole.py
12 | python dinamicProgramming.py
13 | ```
14 |
15 | ### Paper Base : A Dynamic Programming Offloading Algorithm for Mobile Cloud Computing
16 | _"Computational offloading is an effective method to address the limited battery power of a mobile device, by executing some components of a mobile application in the cloud. In this paper, a novel offloading algorithm called ‘Dynamic Programming with Hamming Distance Termination’ ..."_
17 |
18 | https://ieeexplore.ieee.org/document/7726790
19 |
20 |
21 | ### Results of implementation and comparison with DPH algorithm
22 |
23 | Cost of Energy of DPH and BlackHole
24 |
25 |
26 | Time of execution of DPH and BlackHole
27 |
28 |
--------------------------------------------------------------------------------
/img/img1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lehi10/Black-Hole-Algorithm-in-Computational-Offloading-for-Mobile-Cloud-Computing/f9f250f48e993597668d90e75e1dd446493320ec/img/img1.png
--------------------------------------------------------------------------------
/img/img2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lehi10/Black-Hole-Algorithm-in-Computational-Offloading-for-Mobile-Cloud-Computing/f9f250f48e993597668d90e75e1dd446493320ec/img/img2.png
--------------------------------------------------------------------------------
/src/blackHole.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | import random
3 | import math
4 |
5 |
6 | import random as rand
7 | from numpy.random import randint
8 |
9 | # Tareas
10 | tasks = [5930,3900,1700,6880,6800,2400,5960
11 | ,5400,8700,900,800,900,5900,7700,6200]
12 |
13 |
14 | N = len(tasks) # 15 TAREAS
15 |
16 |
17 | def allOf(A,num):
18 | size = len(A)
19 | for i in range(size):
20 | if A[i] != num:
21 | return False
22 | return True
23 |
24 |
25 |
26 | def Cal_E_T7(T_rate, tasks, N):
27 | Beta = 5e-7
28 |
29 | Cff =730e6 # Energia por ciclo
30 | Dff =860e3 # Byte/energia
31 |
32 | TC=np.zeros(N)
33 | EC=np.zeros(N)
34 |
35 | EL=np.zeros(N)
36 | Et=np.zeros(N)
37 | Er=np.zeros(N)
38 |
39 | TL=np.zeros(N)
40 | Tr=np.zeros(N)
41 | Tt=np.zeros(N)
42 |
43 | F_local=500e6
44 | F_cloud=10e9
45 |
46 | D_out=(3*np.random.rand(N))
47 | D_in= randint(10,31,N)
48 |
49 | for ii in range(N):
50 | D_in[ii] = 1/D_in[ii]
51 | D_out[ii] = 1/D_out[ii]
52 |
53 | Cci=D_in
54 | for i in range(N):
55 | EL[i] = tasks[i]/(8*Cff)
56 | TL[i] = tasks[i]/(8*F_local)
57 |
58 | Er[i] = 1/(8*Dff)
59 | Tr[i] = D_out[i]/T_rate
60 | Tc_temp = D_in[i] * tasks[i]/(8*F_cloud)
61 |
62 | Et[i] = 1/(8*Dff)
63 | Tt[i] = D_in[i]/T_rate
64 |
65 | TC[i] = Tr[i] + Tt[i] + Tc_temp
66 | EC[i] = Er[i] + Et[i] + Beta * Cci[i]
67 |
68 | return EL, EC, TL, TC , Cci
69 |
70 |
71 |
72 |
73 |
74 | populationSize =3
75 |
76 | dimention = len(tasks)
77 | numIterations = 1000
78 |
79 | lowerLimit = 0
80 | upperLimit = 2
81 | T_constraint=700
82 |
83 | population=[]
84 |
85 | blackHole={"star":[],"fitness":99999999}
86 |
87 |
88 | iter1 = 50
89 | E_min=1
90 | T_constraint = 700
91 | T_rate = 3e6
92 |
93 | EC = []
94 | EL = []
95 | TL = []
96 | TC = []
97 |
98 | EL, EC, TL, TC , Cci = Cal_E_T7(T_rate, tasks, N)
99 |
100 | E=np.zeros(N);
101 | T=np.zeros(N);
102 |
103 | def printPopulation():
104 | for i in population:
105 | print i
106 |
107 | def initPopulation():
108 | for i in range(populationSize):
109 | star=randint(lowerLimit,upperLimit,dimention)
110 | individual = {"star":star,"fitness":0}
111 | population.append(individual)
112 |
113 |
114 | def objetiveFunction(x):
115 | size_x = len(x)
116 | for i in range(size_x):
117 | E[i]= x[i]*EL[i]+(1-x[i])*EC[i]
118 | T[i]= x[i]*TL[i]+(1-x[i])*TC[i]
119 | if(sum(T)>T_constraint):
120 | return 9999999
121 | return sum(E)
122 |
123 | def evaluatePopulation():
124 | for individual in population:
125 | individual["fitness"]=objetiveFunction(individual["star"])
126 |
127 | def selectBlackHole():
128 | global blackHole
129 | population.sort(key=lambda x: x["fitness"])
130 | if population[0]["fitness"] e:
197 | E1[k]=e
198 | Decision_Matrix[k]=M[k]
199 | table2[i,j]=M[k]
200 | E[i,j]=e
201 | T[i,j]=t
202 |
203 | elif E[i,j] == e:
204 | if e < 2e-7:
205 | Decision_Matrix[k]=M[k]
206 | E_total[iter]= np.sum(E)
207 | T_total[iter]= np.sum(T)
208 |
209 | if iter == iter1/3 and len(Decision_Matrix)==N:
210 | T_rate=5e6
211 | EL,EC,TL,TC,Cci = Cal_E_T7(T_rate,tasks,N)
212 | elif iter== 2*iter1/3 and len(Decision_Matrix)==N :
213 | T_rate=8e6
214 | EL,EC,TL,TC,Cci = Cal_E_T7(T_rate,tasks,N)
215 |
216 | if E_total[iter]<=E_min and T_total[iter] < T_constraint and len(E1)==N:
217 | E_min=E_total[iter]
218 | T_min=T_total[iter]
219 | it=iter
220 | return Decision_Matrix, E_min, T_min
221 |
222 |
223 |
224 |
225 |
226 |
227 | tasks = [5930,3900,1700,6880,6800,2400,5960
228 | ,5400,8700,900,800,900,5900,7700,6200]
229 |
230 | import time
231 | start_time = time.time()
232 |
233 | N = len(tasks)
234 |
235 | Decision_Matrix_Dynamic ,E_min, T_min = dynamicProg(tasks,N)
236 | #Decision_Matrix_Dynamic,E_min, T_min = GA(tasks,N)
237 |
238 | print Decision_Matrix_Dynamic
239 | print "Energia minima : " ,E_min
240 | print "Tiempo mminimo : ", T_min
241 |
242 | print("--- %s seconds ---" % (time.time() - start_time))
243 |
--------------------------------------------------------------------------------