anytime-1.0.0.dev2
توضیحات
Anytime algorithms in Python
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | anytime-1.0.0.dev2 |
| نام | anytime |
| نسخه کتابخانه | 1.0.0.dev2 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Erel Segal-Halevi |
| ایمیل نویسنده | erelsgl@gmail.com |
| آدرس صفحه اصلی | https://github.com/erelsgl/anytime.py |
| آدرس اینترنتی | https://pypi.org/project/anytime/ |
| مجوز | - |
INSTALLATION::
sudo -H pip3 install anytime
USAGE EXAMPLE::
"""
The following example program gets a very large vector
and tries to find the largest element in the vector.
It stops after a pre-specified time, and returns the largest element found so far.
"""
import random, numpy as np
from AnytimeAlgorithm2 import AnytimeAlgorithm
class MaximumFinder(AnytimeAlgorithm):
def __init__(self, vector):
self.vector = vector
self.currentMaximum = 0
def update(self):
i = random.randint(0,len(self.vector)-1)
if self.vector[i]>self.currentMaximum:
self.currentMaximum = self.vector[i]
print("self",self,"result",self.currentMaximum)
def result(self):
return self.currentMaximum
v = np.random.rand(10000000)
finder = MaximumFinder(v)
print(finder.result_after(0.0001)) # seconds
print(finder.result_after(0.001)) # seconds
print(finder.result_after(0.01)) # seconds
Keywords: anytime algorithms
Platform: UNKNOWN
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development
Classifier: License :: OSI Approved :: GNU General Public License (GPL)
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
نحوه نصب
نصب پکیج whl anytime-1.0.0.dev2:
pip install anytime-1.0.0.dev2.whl
نصب پکیج tar.gz anytime-1.0.0.dev2:
pip install anytime-1.0.0.dev2.tar.gz