From 2f643007e366789075270d5a98cb2618fbcbac76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grega=20Vrban=C4=8Di=C4=8D?= Date: Fri, 12 Apr 2019 13:24:22 +0200 Subject: [PATCH 01/24] update dependencies, etc --- NiaPy/__init__.py | 2 +- Pipfile | 6 +- Pipfile.lock | 362 ++++++++++++---------------------------------- setup.py | 11 +- 4 files changed, 96 insertions(+), 285 deletions(-) diff --git a/NiaPy/__init__.py b/NiaPy/__init__.py index 9be3d3d5..4c8fe9fc 100644 --- a/NiaPy/__init__.py +++ b/NiaPy/__init__.py @@ -15,7 +15,7 @@ __all__ = ['algorithms', 'benchmarks', 'util'] __project__ = 'NiaPy' -__version__ = '2.0.0rc2' +__version__ = '2.0.0rc4' VERSION = "{0} v{1}".format(__project__, __version__) diff --git a/Pipfile b/Pipfile index e000c341..62ae03b1 100644 --- a/Pipfile +++ b/Pipfile @@ -4,14 +4,13 @@ verify_ssl = true name = "pypi" [packages] -click = "*" numpy = ">=1.16.2" scipy = ">=1.2.1" +"enum34" = {version = ">=1.1.6", markers="python_version < '3.4'"} +XlsxWriter = ">=1.1.5" matplotlib = ">=2.2.4" [dev-packages] -#pylint = [{version = "==1.9.3", markers = "python_version < '3.4'"}, {version = ">=2.3.0", markers = "python_version >= '3.4'"}] -#pylint = ">=2.3.0" pylint = ">=1.9.3" pycodestyle = "*" pydocstyle = "*" @@ -27,7 +26,6 @@ docutils = "*" wheel = "*" twine = "*" sniffer = "*" -"enum34" = "*" singledispatch = "*" configparser = "*" sphinx-rtd-theme = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 82c8f984..c04b3f0d 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "cd81c2132534456738cc07c92bf29991f7f3a696735453900489e763182203c3" + "sha256": "fc6089e976d25fad095f4860f5fc3d051f3412caa4f2d3f4afbdede04cd9dea2" }, "pipfile-spec": 6, "requires": {}, @@ -14,45 +14,12 @@ ] }, "default": { - "alabaster": { - "hashes": [ - "sha256:446438bdcca0e05bd45ea2de1668c1d9b032e1a9154c2c259092d77031ddd359", - "sha256:a661d72d58e6ea8a57f7a86e37d86716863ee5e92788398526d58b26a4e4dc02" - ], - "index": "pypi", - "version": "==0.7.12" - }, - "babel": { - "hashes": [ - "sha256:6778d85147d5d85345c14a26aada5e478ab04e39b078b0745ee6870c2b5cf669", - "sha256:8cba50f48c529ca3fa18cf81fa9403be176d374ac4d60738b839122dfaaa3d23" - ], - "index": "pypi", - "version": "==2.6.0" - }, - "certifi": { - "hashes": [ - "sha256:59b7658e26ca9c7339e00f8f4636cdfe59d34fa37b9b04f6f9e9926b3cece1a5", - "sha256:b26104d6835d1f5e49452a26eb2ff87fe7090b89dfcaee5ea2212697e1e1d7ae" - ], - "index": "pypi", - "version": "==2019.3.9" - }, - "chardet": { - "hashes": [ - "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", - "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" - ], - "index": "pypi", - "version": "==3.0.4" - }, - "click": { + "backports.functools-lru-cache": { "hashes": [ - "sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13", - "sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7" + "sha256:9d98697f088eb1b0fa451391f91afb5e3ebde16bbdb272819fd091151fda4f1a", + "sha256:f0b0e4eba956de51238e17573b7087e852dfe9854afd2e9c873f73fc0ca0a6dd" ], - "index": "pypi", - "version": "==7.0" + "version": "==1.5" }, "cycler": { "hashes": [ @@ -61,38 +28,16 @@ ], "version": "==0.10.0" }, - "docutils": { - "hashes": [ - "sha256:02aec4bd92ab067f6ff27a38a38a41173bf01bed8f89157768c1573f53e474a6", - "sha256:51e64ef2ebfb29cae1faa133b3710143496eca21c530f3f71424d77687764274", - "sha256:7a4bd47eaf6596e1295ecb11361139febe29b084a87bf005bf899f9a42edc3c6" - ], - "index": "pypi", - "version": "==0.14" - }, - "idna": { - "hashes": [ - "sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407", - "sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c" - ], - "index": "pypi", - "version": "==2.8" - }, - "imagesize": { - "hashes": [ - "sha256:3f349de3eb99145973fefb7dbe38554414e5c30abd0c8e4b970a7c9d09f3a1d8", - "sha256:f3832918bc3c66617f92e35f5d70729187676313caa60c187eb0f28b8fe5e3b5" - ], - "index": "pypi", - "version": "==1.1.0" - }, - "jinja2": { + "enum34": { "hashes": [ - "sha256:74c935a1b8bb9a3947c50a54766a969d4846290e1e788ea44c1392163723c3bd", - "sha256:f84be1bb0040caca4cea721fcbbbbd61f9be9464ca236387158b0feea01914a4" + "sha256:2d81cbbe0e73112bdfe6ef8576f2238f2ba27dd0d55752a776c41d38b7da2850", + "sha256:644837f692e5f550741432dd3f223bbb9852018674981b1664e5dc339387588a", + "sha256:6bd0f6ad48ec2aa117d3d141940d484deccda84d4fcd884f5c3d93c23ecd8c79", + "sha256:8ad8c4783bf61ded74527bffb48ed9b54166685e4230386a9ed9b1279e2df5b1" ], "index": "pypi", - "version": "==2.10" + "markers": "python_version < '3.4'", + "version": "==1.1.6" }, "kiwisolver": { "hashes": [ @@ -127,58 +72,33 @@ ], "version": "==1.0.1" }, - "markupsafe": { - "hashes": [ - "sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473", - "sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161", - "sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235", - "sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5", - "sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff", - "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b", - "sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1", - "sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e", - "sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183", - "sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66", - "sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1", - "sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1", - "sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e", - "sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b", - "sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905", - "sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735", - "sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d", - "sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e", - "sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d", - "sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c", - "sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21", - "sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2", - "sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5", - "sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b", - "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6", - "sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f", - "sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f", - "sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7" - ], - "index": "pypi", - "version": "==1.1.1" - }, "matplotlib": { "hashes": [ - "sha256:1ae6549976b6ceb6ee426272a28c0fc9715b3e3669694d560c8f661c5b39e2c5", - "sha256:4d4250bf508dd07cca3b43888097f873cadb66eec6ac63dbbfb798798ec07af2", - "sha256:53af2e01d7f1700ed2b64a9091bc865360c9c4032f625451c4589a826854c787", - "sha256:63e498067d32d627111cd1162cae1621f1221f9d4c6a9745dd7233f29de581b6", - "sha256:7169a34971e398dd58e87e173f97366fd88a3fa80852704530433eb224a8ca57", - "sha256:91c54d6bb9eeaaff965656c5ea6cbdcbf780bad8462ac99b30b451548194746f", - "sha256:aeef177647bb3fccfe09065481989d7dfc5ac59e9367d6a00a3481062cf651e4", - "sha256:cf8ae10559a78aee0409ede1e9d4fda03895433eeafe609dd9ed67e45f552db0", - "sha256:d51d0889d1c4d51c51a9822265c0494ea3e70a52bdd88358e0863daca46fa23a", - "sha256:de5ccd3500247f85fe4f9fad90f80a8bd397e4f110a4c33fabf95f07403e8372", - "sha256:e1d33589e32f482d0a7d1957bf473d43341115d40d33f578dad44432e47df7b7", - "sha256:e8d1939262aa6b36d0c51f50a50a43a04b9618d20db31e6c0192b1463067aeef", - "sha256:e918d51b1fda82a65fdf52d2f3914b2246481cc2a9cd10e223e6be6078916ff3" - ], - "index": "pypi", - "version": "==3.0.3" + "sha256:029620799e581802961ac1dcff5cb5d3ee2f602e0db9c0f202a90495b37d2126", + "sha256:2308f67e085735ed580fcace652339cb517f059cdc9ee8a418c1b55746dbffcb", + "sha256:280aebaec25575e35bf7d1b3ebb2d8ae7e839edb5a403f1a121b7271744b1ef9", + "sha256:295099acb5a8a1148d1b4693ad1a93479a20836cd8b7eb38183a98c84cdcb2f1", + "sha256:75d44c55eb87af653afc3d0a37ab62ab4784c752be0e7c96622713d88ed57e64", + "sha256:95d9d7c2d7f0c7a4317acbcf1a81efa0a2ce5cb5ddfad606ae4c25a783431f0a", + "sha256:9703ffc3e7e369f3ab31d0032719710876cb341eb618e1a8a54447e1946a9f0a", + "sha256:9ff80541d5676207c6e829632b28e22d9875ecaae54eab7a7f8fd82a6552e5e9", + "sha256:a6a04ebd81b3183e7882c9047a9514b7f547b2bae5e4f61a02eaaa6b446bde54", + "sha256:b22b0d3b8d8f769c6ac559f6761878d660bd23d67b36430f07161caf1505c29c", + "sha256:b464d598e36e13f7d798443805f2ba6b4af3d26fc1652c51c77a7847cf665813", + "sha256:c0fa162920185d5d74e6fdf52c1f8cca0fbf897025a9dd81e030cf08a915865a", + "sha256:c452b7aff0a9e4612670a4590e6efc30929dad620a121d423c8f3d0bd93715e2", + "sha256:c90fc796e97815ea3bbbdea63c1e4edf75336361a49b945fdbc2aff1c76008c6", + "sha256:cc1d376963ea9c97338582f3f9d64757c51e71cf2655efe363a3f2414d84aac2", + "sha256:d3f5dfaa345539599308bd83826db242e424e3f4e9657952f8738ce1b5b90e8a", + "sha256:d9e80ba0ffdb0daacaf49e561474d5c5c153d6db853478cf90c8cba5ed8b72b1", + "sha256:daac44fc77cf36ff01953e2acc57a843fb1f6572eb5bf0af10a2930fa7407715", + "sha256:de43c85335d71094a254e8538719752e30db3305005dae8dcb3097b72587ed07", + "sha256:e4621af28a2444f93b5b6d3d60f54767df8ac6daa510a98f68c34377cb474869", + "sha256:f3755a52aae7fb640f5f57b7b63eb5d65688c84931d7833dbc7d03959cd4f8ce", + "sha256:f99c43df8ed2b9d1c95a042f3cacf017f9690092feba0b4292eaa6713f92de97" + ], + "index": "pypi", + "version": "==2.2.4" }, "numpy": { "hashes": [ @@ -209,35 +129,12 @@ "index": "pypi", "version": "==1.16.2" }, - "packaging": { - "hashes": [ - "sha256:0c98a5d0be38ed775798ece1b9727178c4469d9c3b4ada66e8e6b7849f8732af", - "sha256:9e1cbf8c12b1f1ce0bb5344b8d7ecf66a6f8a6e91bcb0c84593ed6d3ab5c4ab3" - ], - "version": "==19.0" - }, - "pockets": { - "hashes": [ - "sha256:109eb91588e9cf722de98c98d300e1c5896e877f5704dc61176fa09686ca635b", - "sha256:21a2405543c439ac091453ed187f558cf5294d3f85f15310f214ad4de057e0af" - ], - "version": "==0.7.2" - }, - "pygments": { - "hashes": [ - "sha256:5ffada19f6203563680669ee7f53b64dabbeb100eb51b61996085e99c03b284a", - "sha256:e8218dd399a61674745138520d0d4cf2621d7e032439341bc3f647bff125818d" - ], - "index": "pypi", - "version": "==2.3.1" - }, "pyparsing": { "hashes": [ - "sha256:66c9268862641abcac4a96ba74506e594c884e3f57690a696d21ad8210ed667a", - "sha256:f6c5ef0d7480ad048c054c37632c67fca55299990fff127850181659eea33fc3" + "sha256:1873c03321fc118f4e9746baf201ff990ceb915f433f23b395f5580d1840cb2a", + "sha256:9b6323ef4ab914af344ba97510e966d64ba91055d6b9afa6b30799340e89cc03" ], - "index": "pypi", - "version": "==2.3.1" + "version": "==2.4.0" }, "python-dateutil": { "hashes": [ @@ -248,19 +145,10 @@ }, "pytz": { "hashes": [ - "sha256:32b0891edff07e28efe91284ed9c31e123d84bea3fd98e1f72be2508f43ef8d9", - "sha256:d5f05e487007e29e03409f9398d074e158d920d36eb82eaf66fb1136b0c5374c" + "sha256:303879e36b721603cc54604edcac9d20401bdbe31e1e4fdee5b9f98d5d31dfda", + "sha256:d747dd3d23d77ef44c6a3526e274af6efeb0a6f1afd5a69ba4d5be4098c8e141" ], - "index": "pypi", - "version": "==2018.9" - }, - "requests": { - "hashes": [ - "sha256:502a824f31acdacb3a35b6690b5fbf0bc41d63a24a45c4004352b0242707598e", - "sha256:7bf2a778576d825600030a110f3c0e3e8edc51dfaafe1c146e39a2027784957b" - ], - "index": "pypi", - "version": "==2.21.0" + "version": "==2019.1" }, "scipy": { "hashes": [ @@ -301,64 +189,22 @@ "sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", "sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73" ], - "index": "pypi", "version": "==1.12.0" }, - "snowballstemmer": { + "subprocess32": { "hashes": [ - "sha256:919f26a68b2c17a7634da993d91339e288964f93c274f1343e3bbbe2096e1128", - "sha256:9f3bcd3c401c3e862ec0ebe6d2c069ebc012ce142cce209c098ccb5b09136e89" - ], - "index": "pypi", - "version": "==1.2.1" - }, - "sphinx": { - "hashes": [ - "sha256:9f3e17c64b34afc653d7c5ec95766e03043cc6d80b0de224f59b6b6e19d37c3c", - "sha256:c7658aab75c920288a8cf6f09f244c6cfdae30d82d803ac1634d9f223a80ca08" + "sha256:24a7f627ef7a5695138601b665057ad131fa26e80d49d5ffa6b4fdb2357a80d3", + "sha256:6bc82992316eef3ccff319b5033809801c0c3372709c5f6985299c88ac7225c3" ], - "index": "pypi", - "version": "==1.8.5" - }, - "sphinx-rtd-theme": { - "hashes": [ - "sha256:00cf895504a7895ee433807c62094cf1e95f065843bf3acd17037c3e9a2becd4", - "sha256:728607e34d60456d736cc7991fd236afb828b21b82f956c5ea75f94c8414040a" - ], - "index": "pypi", - "version": "==0.4.3" - }, - "sphinxcontrib-napoleon": { - "hashes": [ - "sha256:407382beed396e9f2d7f3043fad6afda95719204a1e1a231ac865f40abcbfcf8", - "sha256:711e41a3974bdf110a484aec4c1a556799eb0b3f3b897521a018ad7e2db13fef" - ], - "index": "pypi", - "version": "==0.7" - }, - "sphinxcontrib-websupport": { - "hashes": [ - "sha256:68ca7ff70785cbe1e7bccc71a48b5b6d965d79ca50629606c7861a21b206d9dd", - "sha256:9de47f375baf1ea07cdb3436ff39d7a9c76042c10a769c52353ec46e4e8fc3b9" - ], - "index": "pypi", - "version": "==1.1.0" - }, - "urllib3": { - "hashes": [ - "sha256:61bf29cada3fc2fbefad4fdf059ea4bd1b4a86d2b6d15e1c7c0b582b9752fe39", - "sha256:de9529817c93f27c8ccbfead6985011db27bd0ddfcdb2d86f3f663385c6a9c22" - ], - "index": "pypi", - "version": "==1.24.1" + "version": "==3.5.3" }, "xlsxwriter": { "hashes": [ - "sha256:de9ef46088489915eaaee00c7088cff93cf613e9990b46b933c98eb46f21b47f", - "sha256:df96eafc3136d9e790e35d6725b473e46ada6f585c1f6519da69b27f5c8873f7" + "sha256:3a4e4a24a6753f046dc5a5e5bc5f443fce6a18988486885a258db6963eb54163", + "sha256:92a2ba339ca939815f0e125fcde728e94ccdb3e97e1acd3275ecf25a3cacfdc6" ], "index": "pypi", - "version": "==1.1.5" + "version": "==1.1.6" } }, "develop": { @@ -367,7 +213,6 @@ "sha256:446438bdcca0e05bd45ea2de1668c1d9b032e1a9154c2c259092d77031ddd359", "sha256:a661d72d58e6ea8a57f7a86e37d86716863ee5e92788398526d58b26a4e4dc02" ], - "index": "pypi", "version": "==0.7.12" }, "argh": { @@ -379,10 +224,10 @@ }, "astroid": { "hashes": [ - "sha256:6560e1e1749f68c64a4b5dee4e091fce798d2f0d84ebe638cf0e0585a343acf4", - "sha256:b65db1bbaac9f9f4d190199bb8680af6f6f84fd3769a5ea883df8a91fe68b4c4" + "sha256:87de48a92e29cedf7210ffa853d11441e7ad94cb47bacd91b023499b51cbc756", + "sha256:d25869fc7f44f1d9fb7d24fd7ea0639656f5355fc3089cd1f3d18c6ec6b124c7" ], - "version": "==2.2.5" + "version": "==1.6.6" }, "atomicwrites": { "hashes": [ @@ -410,7 +255,6 @@ "sha256:6778d85147d5d85345c14a26aada5e478ab04e39b078b0745ee6870c2b5cf669", "sha256:8cba50f48c529ca3fa18cf81fa9403be176d374ac4d60738b839122dfaaa3d23" ], - "index": "pypi", "version": "==2.6.0" }, "backports.functools-lru-cache": { @@ -418,7 +262,6 @@ "sha256:9d98697f088eb1b0fa451391f91afb5e3ebde16bbdb272819fd091151fda4f1a", "sha256:f0b0e4eba956de51238e17573b7087e852dfe9854afd2e9c873f73fc0ca0a6dd" ], - "index": "pypi", "version": "==1.5" }, "backports.shutil-get-terminal-size": { @@ -440,7 +283,6 @@ "sha256:59b7658e26ca9c7339e00f8f4636cdfe59d34fa37b9b04f6f9e9926b3cece1a5", "sha256:b26104d6835d1f5e49452a26eb2ff87fe7090b89dfcaee5ea2212697e1e1d7ae" ], - "index": "pypi", "version": "==2019.3.9" }, "chardet": { @@ -448,7 +290,6 @@ "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" ], - "index": "pypi", "version": "==3.0.4" }, "colorama": { @@ -533,6 +374,7 @@ "sha256:8ad8c4783bf61ded74527bffb48ed9b54166685e4230386a9ed9b1279e2df5b1" ], "index": "pypi", + "markers": "python_version < '3.4'", "version": "==1.1.6" }, "freezegun": { @@ -564,7 +406,6 @@ "sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407", "sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c" ], - "index": "pypi", "version": "==2.8" }, "imagesize": { @@ -572,23 +413,21 @@ "sha256:3f349de3eb99145973fefb7dbe38554414e5c30abd0c8e4b970a7c9d09f3a1d8", "sha256:f3832918bc3c66617f92e35f5d70729187676313caa60c187eb0f28b8fe5e3b5" ], - "index": "pypi", "version": "==1.1.0" }, "isort": { "hashes": [ - "sha256:08f8e3f0f0b7249e9fad7e5c41e2113aba44969798a26452ee790c06f155d4ec", - "sha256:4e9e9c4bd1acd66cf6c36973f29b031ec752cbfd991c69695e4e259f9a756927" + "sha256:01cb7e1ca5e6c5b3f235f0385057f70558b70d2f00320208825fa62887292f43", + "sha256:268067462aed7eb2a1e237fcb287852f22077de3fb07964e87e00f829eea2d1a" ], - "version": "==4.3.16" + "version": "==4.3.17" }, "jinja2": { "hashes": [ - "sha256:74c935a1b8bb9a3947c50a54766a969d4846290e1e788ea44c1392163723c3bd", - "sha256:f84be1bb0040caca4cea721fcbbbbd61f9be9464ca236387158b0feea01914a4" + "sha256:065c4f02ebe7f7cf559e49ee5a95fb800a9e4528727aec6f24402a5374c65013", + "sha256:14dd6caf1527abb21f08f86c784eac40853ba93edb79552aa1e4b8aef1b61c7b" ], - "index": "pypi", - "version": "==2.10" + "version": "==2.10.1" }, "lazy-object-proxy": { "hashes": [ @@ -670,7 +509,6 @@ "sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f", "sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7" ], - "index": "pypi", "version": "==1.1.1" }, "mccabe": { @@ -682,10 +520,11 @@ }, "more-itertools": { "hashes": [ - "sha256:0125e8f60e9e031347105eb1682cef932f5e97d7b9a1a28d9bf00c22a5daef40", - "sha256:590044e3942351a1bdb1de960b739ff4ce277960f2425ad4509446dbace8d9d1" + "sha256:38a936c0a6d98a38bcc2d03fdaaedaba9f412879461dd2ceff8d37564d6522e4", + "sha256:c0a5785b1109a6bd7fac76d6837fd1feca158e54e521ccd2ae8bfe393cc9d4fc", + "sha256:fe7a7cae1ccb57d33952113ff4fa1bc5f879963600ed74918f1236e212ee50b9" ], - "version": "==6.0.0" + "version": "==5.0.0" }, "nose": { "hashes": [ @@ -770,19 +609,18 @@ }, "pylint": { "hashes": [ - "sha256:5d77031694a5fb97ea95e828c8d10fc770a1df6eb3906067aaed42201a8a6a09", - "sha256:723e3db49555abaf9bf79dc474c6b9e2935ad82230b10c1138a71ea41ac0fff1" + "sha256:02c2b6d268695a8b64ad61847f92e611e6afcff33fd26c3a2125370c4662905d", + "sha256:ee1e85575587c5b58ddafa25e1c1b01691ef172e139fc25585e5d3f02451da93" ], "index": "pypi", - "version": "==2.3.1" + "version": "==1.9.4" }, "pyparsing": { "hashes": [ - "sha256:66c9268862641abcac4a96ba74506e594c884e3f57690a696d21ad8210ed667a", - "sha256:f6c5ef0d7480ad048c054c37632c67fca55299990fff127850181659eea33fc3" + "sha256:1873c03321fc118f4e9746baf201ff990ceb915f433f23b395f5580d1840cb2a", + "sha256:9b6323ef4ab914af344ba97510e966d64ba91055d6b9afa6b30799340e89cc03" ], - "index": "pypi", - "version": "==2.3.1" + "version": "==2.4.0" }, "pytest": { "hashes": [ @@ -838,11 +676,10 @@ }, "pytz": { "hashes": [ - "sha256:32b0891edff07e28efe91284ed9c31e123d84bea3fd98e1f72be2508f43ef8d9", - "sha256:d5f05e487007e29e03409f9398d074e158d920d36eb82eaf66fb1136b0c5374c" + "sha256:303879e36b721603cc54604edcac9d20401bdbe31e1e4fdee5b9f98d5d31dfda", + "sha256:d747dd3d23d77ef44c6a3526e274af6efeb0a6f1afd5a69ba4d5be4098c8e141" ], - "index": "pypi", - "version": "==2018.9" + "version": "==2019.1" }, "pyyaml": { "hashes": [ @@ -872,7 +709,6 @@ "sha256:502a824f31acdacb3a35b6690b5fbf0bc41d63a24a45c4004352b0242707598e", "sha256:7bf2a778576d825600030a110f3c0e3e8edc51dfaafe1c146e39a2027784957b" ], - "index": "pypi", "version": "==2.21.0" }, "requests-toolbelt": { @@ -912,7 +748,6 @@ "sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", "sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73" ], - "index": "pypi", "version": "==1.12.0" }, "sniffer": { @@ -928,7 +763,6 @@ "sha256:919f26a68b2c17a7634da993d91339e288964f93c274f1343e3bbbe2096e1128", "sha256:9f3bcd3c401c3e862ec0ebe6d2c069ebc012ce142cce209c098ccb5b09136e89" ], - "index": "pypi", "version": "==1.2.1" }, "sphinx": { @@ -960,20 +794,19 @@ "sha256:68ca7ff70785cbe1e7bccc71a48b5b6d965d79ca50629606c7861a21b206d9dd", "sha256:9de47f375baf1ea07cdb3436ff39d7a9c76042c10a769c52353ec46e4e8fc3b9" ], - "index": "pypi", "version": "==1.1.0" }, "tornado": { "hashes": [ - "sha256:1174dcb84d08887b55defb2cda1986faeeea715fff189ef3dc44cce99f5fca6b", - "sha256:2613fab506bd2aedb3722c8c64c17f8f74f4070afed6eea17f20b2115e445aec", - "sha256:44b82bc1146a24e5b9853d04c142576b4e8fa7a92f2e30bc364a85d1f75c4de2", - "sha256:457fcbee4df737d2defc181b9073758d73f54a6cfc1f280533ff48831b39f4a8", - "sha256:49603e1a6e24104961497ad0c07c799aec1caac7400a6762b687e74c8206677d", - "sha256:8c2f40b99a8153893793559919a355d7b74649a11e59f411b0b0a1793e160bc0", - "sha256:e1d897889c3b5a829426b7d52828fb37b28bc181cd598624e65c8be40ee3f7fa" + "sha256:0662d28b1ca9f67108c7e3b77afabfb9c7e87bde174fbda78186ecedc2499a9d", + "sha256:4e5158d97583502a7e2739951553cbd88a72076f152b4b11b64b9a10c4c49409", + "sha256:732e836008c708de2e89a31cb2fa6c0e5a70cb60492bee6f1ea1047500feaf7f", + "sha256:8154ec22c450df4e06b35f131adc4f2f3a12ec85981a203301d310abf580500f", + "sha256:8e9d728c4579682e837c92fdd98036bd5cdefa1da2aaf6acf26947e6dd0c01c5", + "sha256:d4b3e5329f572f055b587efc57d29bd051589fb5a43ec8898c77a47ec2fa2bbb", + "sha256:e5f2585afccbff22390cddac29849df463b252b711aa2ce7c5f3f342a5b3b444" ], - "version": "==6.0.2" + "version": "==5.1.1" }, "tqdm": { "hashes": [ @@ -990,37 +823,20 @@ "index": "pypi", "version": "==1.13.0" }, - "typed-ast": { - "hashes": [ - "sha256:035a54ede6ce1380599b2ce57844c6554666522e376bd111eb940fbc7c3dad23", - "sha256:037c35f2741ce3a9ac0d55abfcd119133cbd821fffa4461397718287092d9d15", - "sha256:049feae7e9f180b64efacbdc36b3af64a00393a47be22fa9cb6794e68d4e73d3", - "sha256:19228f7940beafc1ba21a6e8e070e0b0bfd1457902a3a81709762b8b9039b88d", - "sha256:2ea681e91e3550a30c2265d2916f40a5f5d89b59469a20f3bad7d07adee0f7a6", - "sha256:3a6b0a78af298d82323660df5497bcea0f0a4a25a0b003afd0ce5af049bd1f60", - "sha256:5385da8f3b801014504df0852bf83524599df890387a3c2b17b7caa3d78b1773", - "sha256:606d8afa07eef77280c2bf84335e24390055b478392e1975f96286d99d0cb424", - "sha256:69245b5b23bbf7fb242c9f8f08493e9ecd7711f063259aefffaeb90595d62287", - "sha256:6f6d839ab09830d59b7fa8fb6917023d8cb5498ee1f1dbd82d37db78eb76bc99", - "sha256:730888475f5ac0e37c1de4bd05eeb799fdb742697867f524dc8a4cd74bcecc23", - "sha256:9819b5162ffc121b9e334923c685b0d0826154e41dfe70b2ede2ce29034c71d8", - "sha256:9e60ef9426efab601dd9aa120e4ff560f4461cf8442e9c0a2b92548d52800699", - "sha256:af5fbdde0690c7da68e841d7fc2632345d570768ea7406a9434446d7b33b0ee1", - "sha256:b64efdbdf3bbb1377562c179f167f3bf301251411eb5ac77dec6b7d32bcda463", - "sha256:bac5f444c118aeb456fac1b0b5d14c6a71ea2a42069b09c176f75e9bd4c186f6", - "sha256:bda9068aafb73859491e13b99b682bd299c1b5fd50644d697533775828a28ee0", - "sha256:d659517ca116e6750101a1326107d3479028c5191f0ecee3c7203c50f5b915b0", - "sha256:eddd3fb1f3e0f82e5915a899285a39ee34ce18fd25d89582bc89fc9fb16cd2c6" - ], - "markers": "implementation_name == 'cpython'", - "version": "==1.3.1" + "typing": { + "hashes": [ + "sha256:4027c5f6127a6267a435201981ba156de91ad0d1d98e9ddc2aa173453453492d", + "sha256:57dcf675a99b74d64dacf6fba08fb17cf7e3d5fdff53d4a30ea2a5e7e52543d4", + "sha256:a4c8473ce11a65999c8f59cb093e70686b6c84c98df58c1dae9b3b196089858a" + ], + "markers": "python_version < '3.5'", + "version": "==3.6.6" }, "urllib3": { "hashes": [ "sha256:61bf29cada3fc2fbefad4fdf059ea4bd1b4a86d2b6d15e1c7c0b582b9752fe39", "sha256:de9529817c93f27c8ccbfead6985011db27bd0ddfcdb2d86f3f663385c6a9c22" ], - "index": "pypi", "version": "==1.24.1" }, "watchdog": { diff --git a/setup.py b/setup.py index 5eb5c07e..f658eb10 100644 --- a/setup.py +++ b/setup.py @@ -57,7 +57,6 @@ def build_description(): long_description=build_description(), license='MIT', classifiers=[ - # TODO: update this list to match your application: https://pypi.python.org/pypi?%3Aaction=list_classifiers 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'Intended Audience :: Science/Research', @@ -82,12 +81,10 @@ def build_description(): ], install_requires=[ - # TODO: Add your library's requirements here - 'numpy >= 1.15.0', - 'enum34 >= 1.1.6', - 'click >= 6.0', + 'numpy >= 1.16.2', 'scipy >= 1.1.0', - 'xlsxwriter >= 1.0.2', - 'matplotlib >= 2.2.3', + 'enum34 >= 1.1.6', + 'xlsxwriter >= 1.1.5', + 'matplotlib >= 2.2.4', ] ) From fafa09372556feba0b14be68a22ed44aa69bdf31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grega=20Vrban=C4=8Di=C4=8D?= Date: Fri, 12 Apr 2019 13:52:41 +0200 Subject: [PATCH 02/24] add python 3.7 --- .appveyor.yml | 1 + .travis.yml | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 59ec0f23..44e276a9 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -4,6 +4,7 @@ environment: matrix: - PYTHON: "C:\\Python27-x64" # latest 2.7.x version - PYTHON: "C:\\Python36-x64" # latest 3.6.x version + - PYTHON: "C:\\Python37-x64" # latest 3.7.x version cache: - .venv -> Makefile diff --git a/.travis.yml b/.travis.yml index 400b6c79..27b7329a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,12 @@ language: python -python: -- 2.7.14 -- 2.7.15 -- 3.6 # latest 3.6.x version + +matrix: + include: + - python: 2.7 # latest 2.7.x version + - python: 3.6 # latest 3.6.x version + - python: 3.7 # latest 3.7.x version + dist: xenial + sudo: true cache: pip: true From cafc4c62fdc4c6cffe75667865f18aeae85e92a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grega=20Vrban=C4=8Di=C4=8D?= Date: Fri, 12 Apr 2019 15:20:16 +0200 Subject: [PATCH 03/24] replace pylint with flake8 due to the problems with backward compatibility of newer releases of package. --- .flake8 | 10 +++ Makefile | 11 ++-- NiaPy/benchmarks/ackley.py | 25 +++++-- NiaPy/benchmarks/benchmark.py | 91 +++++++++++++++++--------- NiaPy/benchmarks/happyCat.py | 21 +++++- Pipfile | 7 +- Pipfile.lock | 119 +++++++++++++++++++++++++++++++++- scent.py | 2 +- setup.py | 7 +- tests/conftest.py | 3 +- 10 files changed, 246 insertions(+), 50 deletions(-) create mode 100644 .flake8 diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..70ffeb39 --- /dev/null +++ b/.flake8 @@ -0,0 +1,10 @@ +[flake8] +ignore = E203, E266, E501, W503, D401, D202 +exclude = + .git, + __pycache__, + docs/source/conf.py, + old, + build, + dist, + scent.py \ No newline at end of file diff --git a/Makefile b/Makefile index 130d384f..70014a8f 100644 --- a/Makefile +++ b/Makefile @@ -60,16 +60,17 @@ $(METADATA): setup.py # CHECKS ###################################################################### -PYLINT := pipenv run pylint +FLAKE8 := pipenv run flake8 PYCODESTYLE := pipenv run pycodestyle PYDOCSTYLE := pipenv run pydocstyle .PHONY: check -check: pylint pycodestyle pydocstyle ## Run linters and static analysis +check: flake8 pycodestyle pydocstyle ## Run linters and static analysis -.PHONY: pylint -pylint: install - $(PYLINT) $(PACKAGES) $(CONFIG) --rcfile=.pylint.ini + +.PHONY: flake8 +flake8: install + $(FLAKE8) $(PACKAGES) $(CONFIG) .PHONY: pycodestyle pycodestyle: install diff --git a/NiaPy/benchmarks/ackley.py b/NiaPy/benchmarks/ackley.py index 41421a06..93fc0857 100644 --- a/NiaPy/benchmarks/ackley.py +++ b/NiaPy/benchmarks/ackley.py @@ -1,12 +1,14 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string +"""The module implementing Ackley benchmark.""" + from numpy import exp, pi, cos, sqrt from NiaPy.benchmarks.benchmark import Benchmark __all__ = ['Ackley'] + class Ackley(Benchmark): - r"""Implementation of Ackley function. + ur"""Implementation of Ackley function. Date: 2018 @@ -42,16 +44,31 @@ class Ackley(Benchmark): Reference: https://www.sfu.ca/~ssurjano/ackley.html """ + Name = ['Ackley'] def __init__(self, Lower=-32.768, Upper=32.768): + """The initialization of Ackley benchmark. + + Keyword Arguments: + Lower {float} -- Lower bound. (default: {-32.768}) + Upper {float} -- Upper bound. (default: {32.768}) + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): - return r'''$f(\mathbf{x}) = -a\;\exp\left(-b \sqrt{\frac{1}{D} + """Return the latex code of the problem. + + Returns: + [str] -- latex code + + """ + + return r"""$f(\mathbf{x}) = -a\;\exp\left(-b \sqrt{\frac{1}{D} \sum_{i=1}^D x_i^2}\right) - \exp\left(\frac{1}{D} - \sum_{i=1}^D cos(c\;x_i)\right) + a + \exp(1)$''' + \sum_{i=1}^D cos(c\;x_i)\right) + a + \exp(1)$""" @classmethod def function(cls): diff --git a/NiaPy/benchmarks/benchmark.py b/NiaPy/benchmarks/benchmark.py index bd46a265..d302f39a 100644 --- a/NiaPy/benchmarks/benchmark.py +++ b/NiaPy/benchmarks/benchmark.py @@ -1,5 +1,4 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, line-too-long, bad-continuation, multiple-statements, singleton-comparison, unused-argument, no-self-use, trailing-comma-tuple, logging-not-lazy, no-else-return, unused-variable, no-member """Implementation of benchmarks utility function.""" import logging from numpy import inf, arange, meshgrid, vectorize @@ -12,33 +11,65 @@ __all__ = ['Benchmark'] + class Benchmark: - Name = ['Benchmark', 'BBB'] - - def __init__(self, Lower, Upper, **kwargs): - self.Lower, self.Upper = Lower, Upper - - def function(self): - r"""Get the optimization function.""" - def fun(D, X): return inf - return fun - - def plot2d(self): pass - - def __2dfun(self, x, y, f): return f(2, x, y) - - def plot3d(self, scale=0.32): - fig = plt.figure() - ax = fig.gca(projection='3d') - func = self.function() - Xr, Yr = arange(self.Lower, self.Upper, scale), arange(self.Lower, self.Upper, scale) - X, Y = meshgrid(Xr, Yr) - Z = vectorize(self.__2dfun)(X, Y, func) - ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3) - cset = ax.contourf(X, Y, Z, zdir='z', offset=-10, cmap=cm.coolwarm) - ax.set_xlabel('X') - ax.set_ylabel('Y') - ax.set_zlabel('Z') - plt.show() - -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + r"""Base Benchmark interface class.""" + + Name = ['Benchmark', 'BBB'] + + def __init__(self, Lower, Upper, **kwargs): + r"""Initialization of Benchmark object. + + Arguments: + Lower {[type]} -- Lower bound. + Upper {[type]} -- Upper bound. + """ + + self.Lower = Lower + self.Upper = Upper + + def function(self): + r"""Returns the optimization function.""" + + def fun(D, X): + return inf + + return fun + + def plot2d(self): + """Plot.""" + + pass + + def __2dfun(self, x, y, f): + r"""Plot function. + + Arguments: + x {[type]} -- x value + y {[type]} -- y value + f {[type]} -- function + + """ + + return f(2, x, y) + + def plot3d(self, scale=0.32): + """Plot 3d. + + Keyword Arguments: + scale {float} -- scale (default: {0.32}) + """ + + fig = plt.figure() + ax = fig.gca(projection='3d') + func = self.function() + Xr, Yr = arange(self.Lower, self.Upper, scale), arange( + self.Lower, self.Upper, scale) + X, Y = meshgrid(Xr, Yr) + Z = vectorize(self.__2dfun)(X, Y, func) + ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3) + ax.contourf(X, Y, Z, zdir='z', offset=-10, cmap=cm.coolwarm) + ax.set_xlabel('X') + ax.set_ylabel('Y') + ax.set_zlabel('Z') + plt.show() diff --git a/NiaPy/benchmarks/happyCat.py b/NiaPy/benchmarks/happyCat.py index 5a4c8acc..55d71175 100644 --- a/NiaPy/benchmarks/happyCat.py +++ b/NiaPy/benchmarks/happyCat.py @@ -1,5 +1,6 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string +"""The module implementing Happy Cat benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark @@ -7,7 +8,7 @@ class HappyCat(Benchmark): - r"""Implementation of Happy cat function. + ur"""Implementation of Happy cat function. Date: 2018 @@ -43,19 +44,35 @@ class HappyCat(Benchmark): Beyer, H. G., & Finck, S. (2012). HappyCat - A Simple Function Class Where Well-Known Direct Search Algorithms Do Fail. In International Conference on Parallel Problem Solving from Nature (pp. 367-376). Springer, Berlin, Heidelberg. """ + Name = ['HappyCat'] def __init__(self, Lower=-100.0, Upper=100.0): + """The initialization of Happy Cat benchmark. + + Keyword Arguments: + Lower {float} -- Lower bound. (default: {-100.0}) + Upper {float} -- Upper bound. (default: {100.0}) + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code + + """ + return r'''$f(\mathbf{x}) = {\left|\sum_{i = 1}^D {x_i}^2 - D \right|}^{1/4} + (0.5 \sum_{i = 1}^D {x_i}^2 + \sum_{i = 1}^D x_i) / D + 0.5$''' @classmethod def function(cls): + """Return benchmark evaluation function.""" def evaluate(D, sol): val1 = 0.0 diff --git a/Pipfile b/Pipfile index 62ae03b1..bb47ae1a 100644 --- a/Pipfile +++ b/Pipfile @@ -6,9 +6,10 @@ name = "pypi" [packages] numpy = ">=1.16.2" scipy = ">=1.2.1" -"enum34" = {version = ">=1.1.6", markers="python_version < '3.4'"} +enum34 = {version = ">=1.1.6",markers = "python_version < '3.4'"} XlsxWriter = ">=1.1.5" matplotlib = ">=2.2.4" +flake8 = "*" [dev-packages] pylint = ">=1.9.3" @@ -37,4 +38,6 @@ scandir = "*" Pygments = "*" "backports.functools_lru_cache" = "*" Sphinx = "*" -MacFSEvents = {sys_platform = "== 'darwin'",version = "*"} +MacFSEvents = {version = "*",sys_platform = "== 'darwin'"} +pep8 = "*" +flake8-docstrings = "*" diff --git a/Pipfile.lock b/Pipfile.lock index c04b3f0d..b673f794 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "fc6089e976d25fad095f4860f5fc3d051f3412caa4f2d3f4afbdede04cd9dea2" + "sha256": "5c86ee5b3a1faaa2aec7ac78c0d5735664aeecb27baa94c440d02bd1c915efdb" }, "pipfile-spec": 6, "requires": {}, @@ -21,6 +21,14 @@ ], "version": "==1.5" }, + "configparser": { + "hashes": [ + "sha256:8be81d89d6e7b4c0d4e44bcc525845f6da25821de80cb5e06e7e0238a2899e32", + "sha256:da60d0014fd8c55eb48c1c5354352e363e2d30bbf7057e5e171a468390184c75" + ], + "markers": "python_version == '2.7'", + "version": "==3.7.4" + }, "cycler": { "hashes": [ "sha256:1d8a5ae1ff6c5cf9b93e8811e581232ad8920aeec647c37316ceac982b08cb2d", @@ -28,6 +36,13 @@ ], "version": "==0.10.0" }, + "entrypoints": { + "hashes": [ + "sha256:589f874b313739ad35be6e0cd7efde2a4e9b6fea91edcc34e58ecbb8dbe56d19", + "sha256:c70dd71abe5a8c85e55e12c19bd91ccfeec11a6e99044204511f9ed547d48451" + ], + "version": "==0.3" + }, "enum34": { "hashes": [ "sha256:2d81cbbe0e73112bdfe6ef8576f2238f2ba27dd0d55752a776c41d38b7da2850", @@ -39,6 +54,22 @@ "markers": "python_version < '3.4'", "version": "==1.1.6" }, + "flake8": { + "hashes": [ + "sha256:859996073f341f2670741b51ec1e67a01da142831aa1fdc6242dbf88dffbe661", + "sha256:a796a115208f5c03b18f332f7c11729812c8c3ded6c46319c59b53efd3819da8" + ], + "index": "pypi", + "version": "==3.7.7" + }, + "functools32": { + "hashes": [ + "sha256:89d824aa6c358c421a234d7f9ee0bd75933a67c29588ce50aaa3acdf4d403fa0", + "sha256:f6253dfbe0538ad2e387bd8fdfd9293c925d63553f5813c4e587745416501e6d" + ], + "markers": "python_version < '3.2'", + "version": "==3.2.3.post2" + }, "kiwisolver": { "hashes": [ "sha256:0ee4ed8b3ae8f5f712b0aa9ebd2858b5b232f1b9a96b0943dceb34df2a223bc3", @@ -100,6 +131,13 @@ "index": "pypi", "version": "==2.2.4" }, + "mccabe": { + "hashes": [ + "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", + "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f" + ], + "version": "==0.6.1" + }, "numpy": { "hashes": [ "sha256:1980f8d84548d74921685f68096911585fee393975f53797614b34d4f409b6da", @@ -129,6 +167,20 @@ "index": "pypi", "version": "==1.16.2" }, + "pycodestyle": { + "hashes": [ + "sha256:95a2219d12372f05704562a14ec30bc76b05a5b297b21a5dfe3f6fac3491ae56", + "sha256:e40a936c9a450ad81df37f549d676d127b1b66000a6c500caa2b085bc0ca976c" + ], + "version": "==2.5.0" + }, + "pyflakes": { + "hashes": [ + "sha256:17dbeb2e3f4d772725c777fabc446d5634d1038f234e77343108ce445ea69ce0", + "sha256:d976835886f8c5b31d47970ed689944a0262b5f3afa00a5a7b4dc81e5449f8a2" + ], + "version": "==2.1.1" + }, "pyparsing": { "hashes": [ "sha256:1873c03321fc118f4e9746baf201ff990ceb915f433f23b395f5580d1840cb2a", @@ -198,6 +250,15 @@ ], "version": "==3.5.3" }, + "typing": { + "hashes": [ + "sha256:4027c5f6127a6267a435201981ba156de91ad0d1d98e9ddc2aa173453453492d", + "sha256:57dcf675a99b74d64dacf6fba08fb17cf7e3d5fdff53d4a30ea2a5e7e52543d4", + "sha256:a4c8473ce11a65999c8f59cb093e70686b6c84c98df58c1dae9b3b196089858a" + ], + "markers": "python_version < '3.5'", + "version": "==3.6.6" + }, "xlsxwriter": { "hashes": [ "sha256:3a4e4a24a6753f046dc5a5e5bc5f443fce6a18988486885a258db6963eb54163", @@ -304,7 +365,7 @@ "sha256:8be81d89d6e7b4c0d4e44bcc525845f6da25821de80cb5e06e7e0238a2899e32", "sha256:da60d0014fd8c55eb48c1c5354352e363e2d30bbf7057e5e171a468390184c75" ], - "index": "pypi", + "markers": "python_version == '2.7'", "version": "==3.7.4" }, "coverage": { @@ -366,6 +427,13 @@ "index": "pypi", "version": "==0.14" }, + "entrypoints": { + "hashes": [ + "sha256:589f874b313739ad35be6e0cd7efde2a4e9b6fea91edcc34e58ecbb8dbe56d19", + "sha256:c70dd71abe5a8c85e55e12c19bd91ccfeec11a6e99044204511f9ed547d48451" + ], + "version": "==0.3" + }, "enum34": { "hashes": [ "sha256:2d81cbbe0e73112bdfe6ef8576f2238f2ba27dd0d55752a776c41d38b7da2850", @@ -377,6 +445,29 @@ "markers": "python_version < '3.4'", "version": "==1.1.6" }, + "flake8": { + "hashes": [ + "sha256:859996073f341f2670741b51ec1e67a01da142831aa1fdc6242dbf88dffbe661", + "sha256:a796a115208f5c03b18f332f7c11729812c8c3ded6c46319c59b53efd3819da8" + ], + "index": "pypi", + "version": "==3.7.7" + }, + "flake8-docstrings": { + "hashes": [ + "sha256:4e0ce1476b64e6291520e5570cf12b05016dd4e8ae454b8a8a9a48bc5f84e1cd", + "sha256:8436396b5ecad51a122a2c99ba26e5b4e623bf6e913b0fea0cb6c2c4050f91eb" + ], + "index": "pypi", + "version": "==1.3.0" + }, + "flake8-polyfill": { + "hashes": [ + "sha256:12be6a34ee3ab795b19ca73505e7b55826d5f6ad7230d31b18e106400169b9e9", + "sha256:e44b087597f6da52ec6393a709e7108b2905317d0c0b744cdca6208e670d8eda" + ], + "version": "==1.0.2" + }, "freezegun": { "hashes": [ "sha256:6cb82b276f83f2acce67f121dc2656f4df26c71e32238334eb071170b892a278", @@ -393,6 +484,14 @@ "index": "pypi", "version": "==1.0.2" }, + "functools32": { + "hashes": [ + "sha256:89d824aa6c358c421a234d7f9ee0bd75933a67c29588ce50aaa3acdf4d403fa0", + "sha256:f6253dfbe0538ad2e387bd8fdfd9293c925d63553f5813c4e587745416501e6d" + ], + "markers": "python_version < '3.2'", + "version": "==3.2.3.post2" + }, "futures": { "hashes": [ "sha256:51ecb45f0add83c806c68e4b06106f90db260585b25ef2abfcda0bd95c0132fd", @@ -555,6 +654,14 @@ ], "version": "==0.1.2" }, + "pep8": { + "hashes": [ + "sha256:b22cfae5db09833bb9bd7c8463b53e1a9c9b39f12e304a8d0bba729c501827ee", + "sha256:fe249b52e20498e59e0b5c5256aa52ee99fc295b26ec9eaa85776ffdb9fe6374" + ], + "index": "pypi", + "version": "==1.7.1" + }, "pkginfo": { "hashes": [ "sha256:7424f2c8511c186cd5424bbf31045b77435b37a8d604990b79d4e70d741148bb", @@ -587,7 +694,6 @@ "sha256:95a2219d12372f05704562a14ec30bc76b05a5b297b21a5dfe3f6fac3491ae56", "sha256:e40a936c9a450ad81df37f549d676d127b1b66000a6c500caa2b085bc0ca976c" ], - "index": "pypi", "version": "==2.5.0" }, "pydocstyle": { @@ -599,6 +705,13 @@ "index": "pypi", "version": "==3.0.0" }, + "pyflakes": { + "hashes": [ + "sha256:17dbeb2e3f4d772725c777fabc446d5634d1038f234e77343108ce445ea69ce0", + "sha256:d976835886f8c5b31d47970ed689944a0262b5f3afa00a5a7b4dc81e5449f8a2" + ], + "version": "==2.1.1" + }, "pygments": { "hashes": [ "sha256:5ffada19f6203563680669ee7f53b64dabbeb100eb51b61996085e99c03b284a", diff --git a/scent.py b/scent.py index b25f9b95..d1fe41b1 100644 --- a/scent.py +++ b/scent.py @@ -1,5 +1,5 @@ """Configuration file for sniffer.""" -# pylint: disable=superfluous-parens, bad-continuation, unpacking-non-sequence, no-init + import time import subprocess diff --git a/setup.py b/setup.py index f658eb10..2231db2a 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,8 @@ def read_package_variable(key, filename='__init__.py'): def build_description(): """Build a description for the project from documentation files.""" try: - readme = open("README.rst").read() # changelog = open("CHANGELOG.rst").read() + # changelog = open("CHANGELOG.rst").read() + readme = open("README.rst").read() except IOError: return "" else: @@ -47,7 +48,9 @@ def build_description(): name=read_package_variable('__project__'), version=read_package_variable('__version__'), - description="Python micro framework for building nature-inspired algorithms.", + description=""" + Python micro framework for building nature-inspired algorithms. + """, url='https://github.com/NiaOrg/NiaPy', author='NiaOrg', author_email='niapy.organization@gmail.com', diff --git a/tests/conftest.py b/tests/conftest.py index e8bd6ede..394865cb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ """Integration tests configuration file.""" -# pylint: disable=unused-import from NiaPy.tests.conftest import pytest_configure + +__all__ = ["pytest_configure"] From 2a9f3e650662c22c34b1385d11c6cc8403014707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grega=20Vrban=C4=8Di=C4=8D?= Date: Fri, 12 Apr 2019 13:24:22 +0200 Subject: [PATCH 04/24] update dependencies, etc --- NiaPy/__init__.py | 2 +- Pipfile | 6 ++---- setup.py | 11 ++++------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/NiaPy/__init__.py b/NiaPy/__init__.py index 9be3d3d5..4c8fe9fc 100644 --- a/NiaPy/__init__.py +++ b/NiaPy/__init__.py @@ -15,7 +15,7 @@ __all__ = ['algorithms', 'benchmarks', 'util'] __project__ = 'NiaPy' -__version__ = '2.0.0rc2' +__version__ = '2.0.0rc4' VERSION = "{0} v{1}".format(__project__, __version__) diff --git a/Pipfile b/Pipfile index e000c341..62ae03b1 100644 --- a/Pipfile +++ b/Pipfile @@ -4,14 +4,13 @@ verify_ssl = true name = "pypi" [packages] -click = "*" numpy = ">=1.16.2" scipy = ">=1.2.1" +"enum34" = {version = ">=1.1.6", markers="python_version < '3.4'"} +XlsxWriter = ">=1.1.5" matplotlib = ">=2.2.4" [dev-packages] -#pylint = [{version = "==1.9.3", markers = "python_version < '3.4'"}, {version = ">=2.3.0", markers = "python_version >= '3.4'"}] -#pylint = ">=2.3.0" pylint = ">=1.9.3" pycodestyle = "*" pydocstyle = "*" @@ -27,7 +26,6 @@ docutils = "*" wheel = "*" twine = "*" sniffer = "*" -"enum34" = "*" singledispatch = "*" configparser = "*" sphinx-rtd-theme = "*" diff --git a/setup.py b/setup.py index 5eb5c07e..f658eb10 100644 --- a/setup.py +++ b/setup.py @@ -57,7 +57,6 @@ def build_description(): long_description=build_description(), license='MIT', classifiers=[ - # TODO: update this list to match your application: https://pypi.python.org/pypi?%3Aaction=list_classifiers 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'Intended Audience :: Science/Research', @@ -82,12 +81,10 @@ def build_description(): ], install_requires=[ - # TODO: Add your library's requirements here - 'numpy >= 1.15.0', - 'enum34 >= 1.1.6', - 'click >= 6.0', + 'numpy >= 1.16.2', 'scipy >= 1.1.0', - 'xlsxwriter >= 1.0.2', - 'matplotlib >= 2.2.3', + 'enum34 >= 1.1.6', + 'xlsxwriter >= 1.1.5', + 'matplotlib >= 2.2.4', ] ) From 88b2670e9f2e4cbaeb36b73cd7b0a0929c8d41da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grega=20Vrban=C4=8Di=C4=8D?= Date: Fri, 12 Apr 2019 13:52:41 +0200 Subject: [PATCH 05/24] add python 3.7 --- .appveyor.yml | 1 + .travis.yml | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 59ec0f23..44e276a9 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -4,6 +4,7 @@ environment: matrix: - PYTHON: "C:\\Python27-x64" # latest 2.7.x version - PYTHON: "C:\\Python36-x64" # latest 3.6.x version + - PYTHON: "C:\\Python37-x64" # latest 3.7.x version cache: - .venv -> Makefile diff --git a/.travis.yml b/.travis.yml index 400b6c79..27b7329a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,12 @@ language: python -python: -- 2.7.14 -- 2.7.15 -- 3.6 # latest 3.6.x version + +matrix: + include: + - python: 2.7 # latest 2.7.x version + - python: 3.6 # latest 3.6.x version + - python: 3.7 # latest 3.7.x version + dist: xenial + sudo: true cache: pip: true From d3462b6d1e2efdb0f40148d493055fc21cd2b3cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grega=20Vrban=C4=8Di=C4=8D?= Date: Fri, 12 Apr 2019 15:20:16 +0200 Subject: [PATCH 06/24] replace pylint with flake8 due to the problems with backward compatibility of newer releases of package. --- .flake8 | 10 ++++ Makefile | 11 +++-- NiaPy/benchmarks/ackley.py | 25 ++++++++-- NiaPy/benchmarks/benchmark.py | 91 +++++++++++++++++++++++------------ NiaPy/benchmarks/happyCat.py | 21 +++++++- Pipfile | 7 ++- scent.py | 2 +- setup.py | 7 ++- tests/conftest.py | 3 +- 9 files changed, 130 insertions(+), 47 deletions(-) create mode 100644 .flake8 diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..70ffeb39 --- /dev/null +++ b/.flake8 @@ -0,0 +1,10 @@ +[flake8] +ignore = E203, E266, E501, W503, D401, D202 +exclude = + .git, + __pycache__, + docs/source/conf.py, + old, + build, + dist, + scent.py \ No newline at end of file diff --git a/Makefile b/Makefile index 130d384f..70014a8f 100644 --- a/Makefile +++ b/Makefile @@ -60,16 +60,17 @@ $(METADATA): setup.py # CHECKS ###################################################################### -PYLINT := pipenv run pylint +FLAKE8 := pipenv run flake8 PYCODESTYLE := pipenv run pycodestyle PYDOCSTYLE := pipenv run pydocstyle .PHONY: check -check: pylint pycodestyle pydocstyle ## Run linters and static analysis +check: flake8 pycodestyle pydocstyle ## Run linters and static analysis -.PHONY: pylint -pylint: install - $(PYLINT) $(PACKAGES) $(CONFIG) --rcfile=.pylint.ini + +.PHONY: flake8 +flake8: install + $(FLAKE8) $(PACKAGES) $(CONFIG) .PHONY: pycodestyle pycodestyle: install diff --git a/NiaPy/benchmarks/ackley.py b/NiaPy/benchmarks/ackley.py index 41421a06..93fc0857 100644 --- a/NiaPy/benchmarks/ackley.py +++ b/NiaPy/benchmarks/ackley.py @@ -1,12 +1,14 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string +"""The module implementing Ackley benchmark.""" + from numpy import exp, pi, cos, sqrt from NiaPy.benchmarks.benchmark import Benchmark __all__ = ['Ackley'] + class Ackley(Benchmark): - r"""Implementation of Ackley function. + ur"""Implementation of Ackley function. Date: 2018 @@ -42,16 +44,31 @@ class Ackley(Benchmark): Reference: https://www.sfu.ca/~ssurjano/ackley.html """ + Name = ['Ackley'] def __init__(self, Lower=-32.768, Upper=32.768): + """The initialization of Ackley benchmark. + + Keyword Arguments: + Lower {float} -- Lower bound. (default: {-32.768}) + Upper {float} -- Upper bound. (default: {32.768}) + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): - return r'''$f(\mathbf{x}) = -a\;\exp\left(-b \sqrt{\frac{1}{D} + """Return the latex code of the problem. + + Returns: + [str] -- latex code + + """ + + return r"""$f(\mathbf{x}) = -a\;\exp\left(-b \sqrt{\frac{1}{D} \sum_{i=1}^D x_i^2}\right) - \exp\left(\frac{1}{D} - \sum_{i=1}^D cos(c\;x_i)\right) + a + \exp(1)$''' + \sum_{i=1}^D cos(c\;x_i)\right) + a + \exp(1)$""" @classmethod def function(cls): diff --git a/NiaPy/benchmarks/benchmark.py b/NiaPy/benchmarks/benchmark.py index bd46a265..d302f39a 100644 --- a/NiaPy/benchmarks/benchmark.py +++ b/NiaPy/benchmarks/benchmark.py @@ -1,5 +1,4 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, line-too-long, bad-continuation, multiple-statements, singleton-comparison, unused-argument, no-self-use, trailing-comma-tuple, logging-not-lazy, no-else-return, unused-variable, no-member """Implementation of benchmarks utility function.""" import logging from numpy import inf, arange, meshgrid, vectorize @@ -12,33 +11,65 @@ __all__ = ['Benchmark'] + class Benchmark: - Name = ['Benchmark', 'BBB'] - - def __init__(self, Lower, Upper, **kwargs): - self.Lower, self.Upper = Lower, Upper - - def function(self): - r"""Get the optimization function.""" - def fun(D, X): return inf - return fun - - def plot2d(self): pass - - def __2dfun(self, x, y, f): return f(2, x, y) - - def plot3d(self, scale=0.32): - fig = plt.figure() - ax = fig.gca(projection='3d') - func = self.function() - Xr, Yr = arange(self.Lower, self.Upper, scale), arange(self.Lower, self.Upper, scale) - X, Y = meshgrid(Xr, Yr) - Z = vectorize(self.__2dfun)(X, Y, func) - ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3) - cset = ax.contourf(X, Y, Z, zdir='z', offset=-10, cmap=cm.coolwarm) - ax.set_xlabel('X') - ax.set_ylabel('Y') - ax.set_zlabel('Z') - plt.show() - -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + r"""Base Benchmark interface class.""" + + Name = ['Benchmark', 'BBB'] + + def __init__(self, Lower, Upper, **kwargs): + r"""Initialization of Benchmark object. + + Arguments: + Lower {[type]} -- Lower bound. + Upper {[type]} -- Upper bound. + """ + + self.Lower = Lower + self.Upper = Upper + + def function(self): + r"""Returns the optimization function.""" + + def fun(D, X): + return inf + + return fun + + def plot2d(self): + """Plot.""" + + pass + + def __2dfun(self, x, y, f): + r"""Plot function. + + Arguments: + x {[type]} -- x value + y {[type]} -- y value + f {[type]} -- function + + """ + + return f(2, x, y) + + def plot3d(self, scale=0.32): + """Plot 3d. + + Keyword Arguments: + scale {float} -- scale (default: {0.32}) + """ + + fig = plt.figure() + ax = fig.gca(projection='3d') + func = self.function() + Xr, Yr = arange(self.Lower, self.Upper, scale), arange( + self.Lower, self.Upper, scale) + X, Y = meshgrid(Xr, Yr) + Z = vectorize(self.__2dfun)(X, Y, func) + ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3) + ax.contourf(X, Y, Z, zdir='z', offset=-10, cmap=cm.coolwarm) + ax.set_xlabel('X') + ax.set_ylabel('Y') + ax.set_zlabel('Z') + plt.show() diff --git a/NiaPy/benchmarks/happyCat.py b/NiaPy/benchmarks/happyCat.py index 5a4c8acc..55d71175 100644 --- a/NiaPy/benchmarks/happyCat.py +++ b/NiaPy/benchmarks/happyCat.py @@ -1,5 +1,6 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string +"""The module implementing Happy Cat benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark @@ -7,7 +8,7 @@ class HappyCat(Benchmark): - r"""Implementation of Happy cat function. + ur"""Implementation of Happy cat function. Date: 2018 @@ -43,19 +44,35 @@ class HappyCat(Benchmark): Beyer, H. G., & Finck, S. (2012). HappyCat - A Simple Function Class Where Well-Known Direct Search Algorithms Do Fail. In International Conference on Parallel Problem Solving from Nature (pp. 367-376). Springer, Berlin, Heidelberg. """ + Name = ['HappyCat'] def __init__(self, Lower=-100.0, Upper=100.0): + """The initialization of Happy Cat benchmark. + + Keyword Arguments: + Lower {float} -- Lower bound. (default: {-100.0}) + Upper {float} -- Upper bound. (default: {100.0}) + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code + + """ + return r'''$f(\mathbf{x}) = {\left|\sum_{i = 1}^D {x_i}^2 - D \right|}^{1/4} + (0.5 \sum_{i = 1}^D {x_i}^2 + \sum_{i = 1}^D x_i) / D + 0.5$''' @classmethod def function(cls): + """Return benchmark evaluation function.""" def evaluate(D, sol): val1 = 0.0 diff --git a/Pipfile b/Pipfile index 62ae03b1..bb47ae1a 100644 --- a/Pipfile +++ b/Pipfile @@ -6,9 +6,10 @@ name = "pypi" [packages] numpy = ">=1.16.2" scipy = ">=1.2.1" -"enum34" = {version = ">=1.1.6", markers="python_version < '3.4'"} +enum34 = {version = ">=1.1.6",markers = "python_version < '3.4'"} XlsxWriter = ">=1.1.5" matplotlib = ">=2.2.4" +flake8 = "*" [dev-packages] pylint = ">=1.9.3" @@ -37,4 +38,6 @@ scandir = "*" Pygments = "*" "backports.functools_lru_cache" = "*" Sphinx = "*" -MacFSEvents = {sys_platform = "== 'darwin'",version = "*"} +MacFSEvents = {version = "*",sys_platform = "== 'darwin'"} +pep8 = "*" +flake8-docstrings = "*" diff --git a/scent.py b/scent.py index b25f9b95..d1fe41b1 100644 --- a/scent.py +++ b/scent.py @@ -1,5 +1,5 @@ """Configuration file for sniffer.""" -# pylint: disable=superfluous-parens, bad-continuation, unpacking-non-sequence, no-init + import time import subprocess diff --git a/setup.py b/setup.py index f658eb10..2231db2a 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,8 @@ def read_package_variable(key, filename='__init__.py'): def build_description(): """Build a description for the project from documentation files.""" try: - readme = open("README.rst").read() # changelog = open("CHANGELOG.rst").read() + # changelog = open("CHANGELOG.rst").read() + readme = open("README.rst").read() except IOError: return "" else: @@ -47,7 +48,9 @@ def build_description(): name=read_package_variable('__project__'), version=read_package_variable('__version__'), - description="Python micro framework for building nature-inspired algorithms.", + description=""" + Python micro framework for building nature-inspired algorithms. + """, url='https://github.com/NiaOrg/NiaPy', author='NiaOrg', author_email='niapy.organization@gmail.com', diff --git a/tests/conftest.py b/tests/conftest.py index e8bd6ede..394865cb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ """Integration tests configuration file.""" -# pylint: disable=unused-import from NiaPy.tests.conftest import pytest_configure + +__all__ = ["pytest_configure"] From 13fe080807a0186cb832964a1793244c249802e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grega=20Vrban=C4=8Di=C4=8D?= Date: Sat, 13 Apr 2019 23:32:28 +0200 Subject: [PATCH 07/24] switch from pylint to flake8. fix dependencies. finished work on benchmark coding style and documentation. --- .flake8 | 2 +- .pylint.ini | 501 ------------------------- NiaPy/benchmarks/ackley.py | 27 +- NiaPy/benchmarks/alpine.py | 54 ++- NiaPy/benchmarks/benchmark.py | 47 ++- NiaPy/benchmarks/bentcigar.py | 106 ++++-- NiaPy/benchmarks/chungReynolds.py | 35 +- NiaPy/benchmarks/cosinemixture.py | 107 ++++-- NiaPy/benchmarks/csendes.py | 36 +- NiaPy/benchmarks/discus.py | 106 ++++-- NiaPy/benchmarks/dixonprice.py | 107 ++++-- NiaPy/benchmarks/elliptic.py | 104 ++++-- NiaPy/benchmarks/griewank.py | 224 ++++++++---- NiaPy/benchmarks/happyCat.py | 32 +- NiaPy/benchmarks/hgbat.py | 111 ++++-- NiaPy/benchmarks/infinity.py | 106 ++++-- NiaPy/benchmarks/katsuura.py | 112 ++++-- NiaPy/benchmarks/levy.py | 111 ++++-- NiaPy/benchmarks/michalewichz.py | 115 +++--- NiaPy/benchmarks/perm.py | 121 ++++--- NiaPy/benchmarks/pinter.py | 35 +- NiaPy/benchmarks/powell.py | 105 ++++-- NiaPy/benchmarks/qing.py | 36 +- NiaPy/benchmarks/quintic.py | 39 +- NiaPy/benchmarks/rastrigin.py | 32 +- NiaPy/benchmarks/ridge.py | 33 +- NiaPy/benchmarks/rosenbrock.py | 35 +- NiaPy/benchmarks/salomon.py | 35 +- NiaPy/benchmarks/schaffer.py | 289 ++++++++++----- NiaPy/benchmarks/schumerSteiglitz.py | 37 +- NiaPy/benchmarks/schwefel.py | 524 +++++++++++++++++---------- NiaPy/benchmarks/sphere.py | 309 ++++++++++------ NiaPy/benchmarks/step.py | 102 +++++- NiaPy/benchmarks/stepint.py | 36 +- NiaPy/benchmarks/styblinskiTang.py | 40 +- NiaPy/benchmarks/sumSquares.py | 38 +- NiaPy/benchmarks/trid.py | 103 ++++-- NiaPy/benchmarks/weierstrass.py | 123 ++++--- NiaPy/benchmarks/whitley.py | 36 +- NiaPy/benchmarks/zakharov.py | 103 ++++-- Pipfile | 60 +-- codemeta.json | 14 - gen-codemeta | 146 -------- setup.py | 11 + tests/__init__.py | 11 + tests/conftest.py | 11 + 46 files changed, 2662 insertions(+), 1845 deletions(-) delete mode 100644 .pylint.ini delete mode 100644 codemeta.json delete mode 100755 gen-codemeta diff --git a/.flake8 b/.flake8 index 70ffeb39..f23a525c 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,5 @@ [flake8] -ignore = E203, E266, E501, W503, D401, D202 +ignore = E203, E266, E501, W503, D401, D202, RST299, RST304, RST399, FI exclude = .git, __pycache__, diff --git a/.pylint.ini b/.pylint.ini deleted file mode 100644 index d886c652..00000000 --- a/.pylint.ini +++ /dev/null @@ -1,501 +0,0 @@ -[MASTER] - -# A comma-separated list of package or module names from where C extensions may -# be loaded. Extensions are loading into the active Python interpreter and may -# run arbitrary code -extension-pkg-whitelist=numpy - -# Add files or directories to the blacklist. They should be base names, not -# paths. -ignore=CVS - -# Add files or directories matching the regex patterns to the blacklist. The -# regex matches against base names, not paths. -ignore-patterns= - -# Python code to execute, usually for sys.path manipulation such as -# pygtk.require(). -#init-hook= - -# Use multiple processes to speed up Pylint. -jobs=1 - -# List of plugins (as comma separated values of python modules names) to load, -# usually to register additional checkers. -load-plugins= - -# Pickle collected data for later comparisons. -persistent=yes - -# Specify a configuration file. -#rcfile= - -# Allow loading of arbitrary C extensions. Extensions are imported into the -# active Python interpreter and may run arbitrary code. -unsafe-load-any-extension=no - - -[MESSAGES CONTROL] - -# Only show warnings with the listed confidence levels. Leave empty to show -# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED -confidence= - -# Disable the message, report, category or checker with the given id(s). You -# can either give multiple identifiers separated by comma (,) or put this -# option multiple times (only on the command line, not in the configuration -# file where it should appear only once).You can also use "--disable=all" to -# disable everything first and then reenable specific checks. For example, if -# you want to run only the similarities checker, you can use "--disable=all -# --enable=similarities". If you want to run only the classes checker, but have -# no Warning level messages displayed, use"--disable=all --enable=classes -# --disable=W" -disable=print-statement, - parameter-unpacking, - unpacking-in-except, - old-raise-syntax, - backtick, - long-suffix, - old-ne-operator, - old-octal-literal, - import-star-module-level, - raw-checker-failed, - bad-inline-option, - locally-disabled, - locally-enabled, - file-ignored, - suppressed-message, - useless-suppression, - deprecated-pragma, - apply-builtin, - basestring-builtin, - buffer-builtin, - cmp-builtin, - coerce-builtin, - execfile-builtin, - file-builtin, - long-builtin, - raw_input-builtin, - reduce-builtin, - standarderror-builtin, - unicode-builtin, - xrange-builtin, - coerce-method, - delslice-method, - getslice-method, - setslice-method, - no-absolute-import, - old-division, - dict-iter-method, - dict-view-method, - next-method-called, - metaclass-assignment, - indexing-exception, - raising-string, - reload-builtin, - oct-method, - hex-method, - nonzero-method, - cmp-method, - input-builtin, - round-builtin, - intern-builtin, - unichr-builtin, - map-builtin-not-iterating, - zip-builtin-not-iterating, - range-builtin-not-iterating, - filter-builtin-not-iterating, - using-cmp-argument, - eq-without-hash, - div-method, - idiv-method, - rdiv-method, - exception-message-attribute, - invalid-str-codec, - sys-max-int, - bad-python3-import, - deprecated-string-function, - deprecated-str-translate-call, - missing-docstring, - invalid-name, - too-few-public-methods, - fixme, - too-many-arguments, - too-many-branches, - similarities, - too-many-locals, - too-many-statements, - too-many-instance-attributes, - old-style-class - -# Enable the message, report, category or checker with the given id(s). You can -# either give multiple identifier separated by comma (,) or put this option -# multiple time (only on the command line, not in the configuration file where -# it should appear only once). See also the "--disable" option for examples. -enable= - - -[REPORTS] - -# Python expression which should return a note less than 10 (10 is the highest -# note). You have access to the variables errors warning, statement which -# respectively contain the number of errors / warnings messages and the total -# number of statements analyzed. This is used by the global evaluation report -# (RP0004). -evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) - -# Template used to display messages. This is a python new-style format string -# used to format the message information. See doc for all details -#msg-template= - -# Set the output format. Available formats are text, parseable, colorized, json -# and msvs (visual studio).You can also give a reporter class, eg -# mypackage.mymodule.MyReporterClass. -output-format=text - -# Tells whether to display a full report or only the messages -reports=no - -# Activate the evaluation score. -score=no - - -[REFACTORING] - -# Maximum number of nested blocks for function / method body -max-nested-blocks=5 - - -[BASIC] - -# Naming hint for argument names -argument-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Regular expression matching correct argument names -argument-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Naming hint for attribute names -attr-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Regular expression matching correct attribute names -attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Bad variable names which should always be refused, separated by a comma -bad-names=foo,bar,baz,toto,tutu,tata - -# Naming hint for class attribute names -class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ - -# Regular expression matching correct class attribute names -class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ - -# Naming hint for class names -class-name-hint=[A-Z_][a-zA-Z0-9]+$ - -# Regular expression matching correct class names -class-rgx=[A-Z_][a-zA-Z0-9]+$ - -# Naming hint for constant names -const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$ - -# Regular expression matching correct constant names -const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ - -# Minimum line length for functions/classes that require docstrings, shorter -# ones are exempt. -docstring-min-length=-1 - -# Naming hint for function names -function-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Regular expression matching correct function names -function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Good variable names which should always be accepted, separated by a comma -good-names=i,j,k,ex,Run,_ - -# Include a hint for the correct naming format with invalid-name -include-naming-hint=no - -# Naming hint for inline iteration names -inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$ - -# Regular expression matching correct inline iteration names -inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ - -# Naming hint for method names -method-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Regular expression matching correct method names -method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Naming hint for module names -module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - -# Regular expression matching correct module names -module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - -# Colon-delimited sets of names that determine each other's naming style when -# the name regexes allow several styles. -name-group= - -# Regular expression which should only match function or class names that do -# not require a docstring. -no-docstring-rgx=^_ - -# List of decorators that produce properties, such as abc.abstractproperty. Add -# to this list to register other decorators that produce valid properties. -property-classes=abc.abstractproperty - -# Naming hint for variable names -variable-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Regular expression matching correct variable names -variable-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - - -[FORMAT] - -# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. -expected-line-ending-format= - -# Regexp for a line that is allowed to be longer than the limit. -ignore-long-lines=^.*((https?:)|(pragma:)|(TODO:)).*$ - -# Number of spaces of indent required inside a hanging or continued line. -indent-after-paren=4 - -# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 -# tab). -indent-string=' ' - -# Maximum number of characters on a single line. -max-line-length=150 - -# Maximum number of lines in a module -max-module-lines=1000 - -# List of optional constructs for which whitespace checking is disabled. `dict- -# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. -# `trailing-comma` allows a space between comma and closing bracket: (a, ). -# `empty-line` allows space-only lines. -no-space-check=trailing-comma,dict-separator - -# Allow the body of a class to be on the same line as the declaration if body -# contains single statement. -single-line-class-stmt=no - -# Allow the body of an if to be on the same line as the test if there is no -# else. -single-line-if-stmt=no - - -[LOGGING] - -# Logging modules to check that the string format arguments are in logging -# function parameter format -logging-modules=logging - - -[MISCELLANEOUS] - -# List of note tags to take in consideration, separated by a comma. -notes=FIXME,XXX,TODO - - -[SIMILARITIES] - -# Ignore comments when computing similarities. -ignore-comments=yes - -# Ignore docstrings when computing similarities. -ignore-docstrings=yes - -# Ignore imports when computing similarities. -ignore-imports=no - -# Minimum lines number of a similarity. -min-similarity-lines=4 - - -[SPELLING] - -# Spelling dictionary name. Available dictionaries: none. To make it working -# install python-enchant package. -spelling-dict= - -# List of comma separated words that should not be checked. -spelling-ignore-words= - -# A path to a file that contains private dictionary; one word per line. -spelling-private-dict-file= - -# Tells whether to store unknown words to indicated private dictionary in -# --spelling-private-dict-file option instead of raising a message. -spelling-store-unknown-words=no - - -[TYPECHECK] - -# List of decorators that produce context managers, such as -# contextlib.contextmanager. Add to this list to register other decorators that -# produce valid context managers. -contextmanager-decorators=contextlib.contextmanager - -# List of members which are set dynamically and missed by pylint inference -# system, and so shouldn't trigger E1101 when accessed. Python regular -# expressions are accepted. -generated-members= - -# Tells whether missing members accessed in mixin class should be ignored. A -# mixin class is detected if its name ends with "mixin" (case insensitive). -ignore-mixin-members=yes - -# This flag controls whether pylint should warn about no-member and similar -# checks whenever an opaque object is returned when inferring. The inference -# can return multiple potential results while evaluating a Python object, but -# some branches might not be evaluated, which results in partial inference. In -# that case, it might be useful to still emit no-member and other checks for -# the rest of the inferred objects. -ignore-on-opaque-inference=yes - -# List of class names for which member attributes should not be checked (useful -# for classes with dynamically set attributes). This supports the use of -# qualified names. -ignored-classes=optparse.Values,thread._local,_thread._local - -# List of module names for which member attributes should not be checked -# (useful for modules/projects where namespaces are manipulated during runtime -# and thus existing member attributes cannot be deduced by static analysis. It -# supports qualified module names, as well as Unix pattern matching. -ignored-modules= - -# Show a hint with possible names when a member name was not found. The aspect -# of finding the hint is based on edit distance. -missing-member-hint=yes - -# The minimum edit distance a name should have in order to be considered a -# similar match for a missing member name. -missing-member-hint-distance=1 - -# The total number of similar names that should be taken in consideration when -# showing a hint for a missing member. -missing-member-max-choices=1 - - -[VARIABLES] - -# List of additional names supposed to be defined in builtins. Remember that -# you should avoid to define new builtins when possible. -additional-builtins= - -# Tells whether unused global variables should be treated as a violation. -allow-global-unused-variables=yes - -# List of strings which can identify a callback function by name. A callback -# name must start or end with one of those strings. -callbacks=cb_,_cb - -# A regular expression matching the name of dummy variables (i.e. expectedly -# not used). -dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ - -# Argument names that match this expression will be ignored. Default to name -# with leading underscore -ignored-argument-names=_.*|^ignored_|^unused_ - -# Tells whether we should check for unused import in __init__ files. -init-import=no - -# List of qualified module names which can have objects that can redefine -# builtins. -redefining-builtins-modules=six.moves,future.builtins - - -[CLASSES] - -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__,__new__,setUp - -# List of member names, which should be excluded from the protected access -# warning. -exclude-protected=_asdict,_fields,_replace,_source,_make - -# List of valid names for the first argument in a class method. -valid-classmethod-first-arg=cls - -# List of valid names for the first argument in a metaclass class method. -valid-metaclass-classmethod-first-arg=mcs - - -[DESIGN] - -# Maximum number of arguments for function / method -max-args=5 - -# Maximum number of attributes for a class (see R0902). -max-attributes=7 - -# Maximum number of boolean expressions in a if statement -max-bool-expr=5 - -# Maximum number of branch for function / method body -max-branches=12 - -# Maximum number of locals for function / method body -max-locals=15 - -# Maximum number of parents for a class (see R0901). -max-parents=7 - -# Maximum number of public methods for a class (see R0904). -max-public-methods=20 - -# Maximum number of return / yield for function / method body -max-returns=6 - -# Maximum number of statements in function / method body -max-statements=50 - -# Minimum number of public methods for a class (see R0903). -min-public-methods=2 - - -[IMPORTS] - -# Allow wildcard imports from modules that define __all__. -allow-wildcard-with-all=no - -# Analyse import fallback blocks. This can be used to support both Python 2 and -# 3 compatible code, which means that the block might have code that exists -# only in one or another interpreter, leading to false positives when analysed. -analyse-fallback-blocks=no - -# Deprecated modules which should not be used, separated by a comma -deprecated-modules=regsub,TERMIOS,Bastion,rexec - -# Create a graph of external dependencies in the given file (report RP0402 must -# not be disabled) -ext-import-graph= - -# Create a graph of every (i.e. internal and external) dependencies in the -# given file (report RP0402 must not be disabled) -import-graph= - -# Create a graph of internal dependencies in the given file (report RP0402 must -# not be disabled) -int-import-graph= - -# Force import order to recognize a module as part of the standard -# compatibility libraries. -known-standard-library= - -# Force import order to recognize a module as part of a third party library. -known-third-party=enchant - - -[EXCEPTIONS] - -# Exceptions that will emit a warning when being caught. Defaults to -# "Exception" -overgeneral-exceptions=Exception diff --git a/NiaPy/benchmarks/ackley.py b/NiaPy/benchmarks/ackley.py index 93fc0857..01fd3903 100644 --- a/NiaPy/benchmarks/ackley.py +++ b/NiaPy/benchmarks/ackley.py @@ -1,14 +1,15 @@ # encoding=utf8 + """The module implementing Ackley benchmark.""" from numpy import exp, pi, cos, sqrt from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Ackley'] +__all__ = ["Ackley"] class Ackley(Benchmark): - ur"""Implementation of Ackley function. + r"""Implementation of Ackley function. Date: 2018 @@ -45,14 +46,18 @@ class Ackley(Benchmark): Reference: https://www.sfu.ca/~ssurjano/ackley.html """ - Name = ['Ackley'] + Name = ["Ackley"] def __init__(self, Lower=-32.768, Upper=32.768): """The initialization of Ackley benchmark. - Keyword Arguments: - Lower {float} -- Lower bound. (default: {-32.768}) - Upper {float} -- Upper bound. (default: {32.768}) + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + """ Benchmark.__init__(self, Lower, Upper) @@ -62,7 +67,7 @@ def latex_code(): """Return the latex code of the problem. Returns: - [str] -- latex code + [str] -- latex code. """ @@ -72,7 +77,13 @@ def latex_code(): @classmethod def function(cls): - """Return benchmark evaluation function.""" + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): a = 20 # Recommended variable value diff --git a/NiaPy/benchmarks/alpine.py b/NiaPy/benchmarks/alpine.py index a2805b00..a5c8e056 100644 --- a/NiaPy/benchmarks/alpine.py +++ b/NiaPy/benchmarks/alpine.py @@ -1,11 +1,11 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string -"""Implementations of Alpine functions.""" + +"""Implementations of Alpine benchmarks.""" import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Alpine1', 'Alpine2'] +__all__ = ["Alpine1", "Alpine2"] class Alpine1(Benchmark): @@ -42,11 +42,13 @@ class Alpine1(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Alpine1'] + + Name = ["Alpine1"] def __init__(self, Lower=-10.0, Upper=10.0): - r"""Initialize Alpine1 benchmark. + r"""The initialization of Alpine1 benchmark. Args: Lower (Optional[float]): Lower bound of problem. @@ -54,15 +56,31 @@ def __init__(self, Lower=-10.0, Upper=10.0): See Also: :func:`NiaPy.benchmarks.Benchmark.__init__` + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): - return r'''$f(\mathbf{x}) = \sum_{i=1}^{D} \left |x_i \sin(x_i)+0.1x_i \right|$''' + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + + return r"""$f(\mathbf{x}) = \sum_{i=1}^{D} \left |x_i \sin(x_i)+0.1x_i \right|$""" @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 @@ -110,11 +128,13 @@ class Alpine2(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Alpine2'] + + Name = ["Alpine2"] def __init__(self, Lower=0.0, Upper=10.0): - r"""Initialize Alpine2 benchmark. + r"""The initialization of Alpine2 benchmark. Args: Lower (Optional[float]): Lower bound of problem. @@ -122,15 +142,31 @@ def __init__(self, Lower=0.0, Upper=10.0): See Also: :func:`NiaPy.benchmarks.Benchmark.__init__` + """ + Benchmark.__init__(self, Lower=Lower, Upper=Upper) @staticmethod def latex_code(): - return r'''$f(\mathbf{x}) = \prod_{i=1}^{D} \sqrt{x_i} \sin(x_i)$''' + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + + return r"""$f(\mathbf{x}) = \prod_{i=1}^{D} \sqrt{x_i} \sin(x_i)$""" @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 1.0 diff --git a/NiaPy/benchmarks/benchmark.py b/NiaPy/benchmarks/benchmark.py index d302f39a..4a5b4bd3 100644 --- a/NiaPy/benchmarks/benchmark.py +++ b/NiaPy/benchmarks/benchmark.py @@ -1,21 +1,23 @@ # encoding=utf8 -"""Implementation of benchmarks utility function.""" + +"""Implementation of base benchmark class.""" + import logging from numpy import inf, arange, meshgrid, vectorize from matplotlib import pyplot as plt from matplotlib import cm logging.basicConfig() -logger = logging.getLogger('NiaPy.benchmarks.benchmark') -logger.setLevel('INFO') +logger = logging.getLogger("NiaPy.benchmarks.benchmark") +logger.setLevel("INFO") -__all__ = ['Benchmark'] +__all__ = ["Benchmark"] class Benchmark: - r"""Base Benchmark interface class.""" + """Base Benchmark interface class.""" - Name = ['Benchmark', 'BBB'] + Name = ["Benchmark", "BBB"] def __init__(self, Lower, Upper, **kwargs): r"""Initialization of Benchmark object. @@ -23,18 +25,35 @@ def __init__(self, Lower, Upper, **kwargs): Arguments: Lower {[type]} -- Lower bound. Upper {[type]} -- Upper bound. + """ self.Lower = Lower self.Upper = Upper def function(self): - r"""Returns the optimization function.""" + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + + def evaluate(D, sol): + """The implementation on evaluation function. + + Arguments: + D [int]} -- Dimension of the problem. + sol [array[float]] -- Solution array. + + Returns: + [float] -- Return fitness value. + + """ - def fun(D, X): return inf - return fun + return evaluate def plot2d(self): """Plot.""" @@ -61,15 +80,15 @@ def plot3d(self, scale=0.32): """ fig = plt.figure() - ax = fig.gca(projection='3d') + ax = fig.gca(projection="3d") func = self.function() Xr, Yr = arange(self.Lower, self.Upper, scale), arange( self.Lower, self.Upper, scale) X, Y = meshgrid(Xr, Yr) Z = vectorize(self.__2dfun)(X, Y, func) ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3) - ax.contourf(X, Y, Z, zdir='z', offset=-10, cmap=cm.coolwarm) - ax.set_xlabel('X') - ax.set_ylabel('Y') - ax.set_zlabel('Z') + ax.contourf(X, Y, Z, zdir="z", offset=-10, cmap=cm.coolwarm) + ax.set_xlabel("X") + ax.set_ylabel("Y") + ax.set_zlabel("Z") plt.show() diff --git a/NiaPy/benchmarks/bentcigar.py b/NiaPy/benchmarks/bentcigar.py index 7f797244..e2e7c01d 100644 --- a/NiaPy/benchmarks/bentcigar.py +++ b/NiaPy/benchmarks/bentcigar.py @@ -1,59 +1,89 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, multiple-statements -"""Implementations of Bent Cigar functions.""" + +"""Implementation of Bent Cigar benchmark.""" from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['BentCigar'] +__all__ = ["BentCigar"] + class BentCigar(Benchmark): - r"""Implementations of Bent Cigar functions. + r"""Implementations of Bent Cigar functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: + **Bent Cigar Function** + + :math:`f(\textbf{x}) = x_1^2 + 10^6 \sum_{i=2}^D x_i^2` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = x_1^2 + 10^6 \sum_{i=2}^D x_i^2$ + + Equation: + \begin{equation} f(\textbf{x}) = x_1^2 + 10^6 \sum_{i=2}^D x_i^2 \end{equation} + + Domain: + $-100 \leq x_i \leq 100$ + + Reference: http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf + + """ + + Name = ["BentCigar"] + + def __init__(self, Lower=-100.0, Upper=100.0): + r"""The initialization of Bent Cigar benchmark. - Date: 2018 + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - Author: Klemen Berkovič + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - License: MIT + """ - Function: - **Bent Cigar Function** + Benchmark.__init__(self, Lower, Upper) - :math:`f(\textbf{x}) = x_1^2 + 10^6 \sum_{i=2}^D x_i^2` + @staticmethod + def latex_code(): + """Return the latex code of the problem. - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + Returns: + [str] -- latex code. - **Global minimum:** - :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + """ - LaTeX formats: - Inline: - $f(\textbf{x}) = x_1^2 + 10^6 \sum_{i=2}^D x_i^2$ + return r"""$f(\textbf{x}) = x_1^2 + 10^6 \sum_{i=2}^D x_i^2$""" - Equation: - \begin{equation} f(\textbf{x}) = x_1^2 + 10^6 \sum_{i=2}^D x_i^2 \end{equation} + @classmethod + def function(cls): + """Return benchmark evaluation function. - Domain: - $-100 \leq x_i \leq 100$ + Returns: + [fun] -- Evaluation function. - Reference: - http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - """ - Name = ['BentCigar'] + """ - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower, Upper) + def evaluate(D, sol): - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = x_1^2 + 10^6 \sum_{i=2}^D x_i^2$''' + val = 0.0 - @classmethod - def function(cls): - def f(D, sol): - val = 0.0 - for i in range(1, D): val += sol[i] ** 2 - return sol[0] ** 2 + 10 ** 6 * val - return f + for i in range(1, D): + val += sol[i] ** 2 + return sol[0] ** 2 + 10 ** 6 * val -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/chungReynolds.py b/NiaPy/benchmarks/chungReynolds.py index 9c7daddf..e6137361 100644 --- a/NiaPy/benchmarks/chungReynolds.py +++ b/NiaPy/benchmarks/chungReynolds.py @@ -1,9 +1,11 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Chung Reynolds benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['ChungReynolds'] +__all__ = ["ChungReynolds"] class ChungReynolds(Benchmark): @@ -40,18 +42,45 @@ class ChungReynolds(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['ChungReynolds'] + + Name = ["ChungReynolds"] def __init__(self, Lower=-100.0, Upper=100.0): + """The initialization of Chung Reynolds benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + return r'''$f(\mathbf{x}) = \left(\sum_{i=1}^D x_i^2\right)^2$''' @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/cosinemixture.py b/NiaPy/benchmarks/cosinemixture.py index e1bae493..c0117348 100644 --- a/NiaPy/benchmarks/cosinemixture.py +++ b/NiaPy/benchmarks/cosinemixture.py @@ -1,60 +1,91 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, multiple-statements -"""Implementations of Cosine mixture functions.""" + +"""Implementation of Cosine mixture benchmark.""" from numpy import cos, pi from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['CosineMixture'] +__all__ = ["CosineMixture"] + class CosineMixture(Benchmark): - r"""Implementations of Cosine mixture function. + r"""Implementations of Cosine mixture function. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: + **Cosine Mixture Function** + + :math:`f(\textbf{x}) = - 0.1 \sum_{i = 1}^D \cos (5 \pi x_i) - \sum_{i = 1}^D x_i^2` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-1, 1]`, for all :math:`i = 1, 2,..., D`. + + **Global maximu:** + :math:`f(x^*) = -0.1 D`, at :math:`x^* = (0.0,...,0.0)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = - 0.1 \sum_{i = 1}^D \cos (5 \pi x_i) - \sum_{i = 1}^D x_i^2$ + + Equation: + \begin{equation} f(\textbf{x}) = - 0.1 \sum_{i = 1}^D \cos (5 \pi x_i) - \sum_{i = 1}^D x_i^2 \end{equation} + + Domain: + $-1 \leq x_i \leq 1$ + + Reference: + http://infinity77.net/global_optimization/test_functions_nd_C.html#go_benchmark.CosineMixture + + """ + + Name = ["CosineMixture"] + + def __init__(self, Lower=-1.0, Upper=1.0): + r"""The initialization of Cosine mixture benchmark. - Date: 2018 + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - Author: Klemen Berkovič + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - License: MIT + """ - Function: - **Cosine Mixture Function** + Benchmark.__init__(self, Lower, Upper) - :math:`f(\textbf{x}) = - 0.1 \sum_{i = 1}^D \cos (5 \pi x_i) - \sum_{i = 1}^D x_i^2` + @staticmethod + def latex_code(): + """Return the latex code of the problem. - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-1, 1]`, for all :math:`i = 1, 2,..., D`. + Returns: + [str] -- latex code. - **Global maximu:** - :math:`f(x^*) = -0.1 D`, at :math:`x^* = (0.0,...,0.0)` + """ - LaTeX formats: - Inline: - $f(\textbf{x}) = - 0.1 \sum_{i = 1}^D \cos (5 \pi x_i) - \sum_{i = 1}^D x_i^2$ + return r"""$f(\textbf{x}) = - 0.1 \sum_{i = 1}^D \cos (5 \pi x_i) - \sum_{i = 1}^D x_i^2$""" - Equation: - \begin{equation} f(\textbf{x}) = - 0.1 \sum_{i = 1}^D \cos (5 \pi x_i) - \sum_{i = 1}^D x_i^2 \end{equation} + @classmethod + def function(cls): + """Return benchmark evaluation function. - Domain: - $-1 \leq x_i \leq 1$ + Returns: + [fun] -- Evaluation function. - Reference: - http://infinity77.net/global_optimization/test_functions_nd_C.html#go_benchmark.CosineMixture - """ - Name = ['CosineMixture'] + """ - def __init__(self, Lower=-1.0, Upper=1.0): Benchmark.__init__(self, Lower, Upper) + def evaluate(D, sol): + v1, v2 = 0.0, 0.0 - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = - 0.1 \sum_{i = 1}^D \cos (5 \pi x_i) - \sum_{i = 1}^D x_i^2$''' + for i in range(D): + v1, v2 = v1 + cos(5 * pi * sol[i]), v2 + sol[i] ** 2 - @classmethod - def function(cls): - def f(D, X): - v1, v2 = 0.0, 0.0 - for i in range(D): v1, v2 = v1 + cos(5 * pi * X[i]), v2 + X[i] ** 2 - return -0.1 * v1 - v2 - return f + return -0.1 * v1 - v2 -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/csendes.py b/NiaPy/benchmarks/csendes.py index 807ce856..966249e3 100644 --- a/NiaPy/benchmarks/csendes.py +++ b/NiaPy/benchmarks/csendes.py @@ -1,9 +1,11 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Csendes benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Csendes'] +__all__ = ["Csendes"] class Csendes(Benchmark): @@ -41,18 +43,44 @@ class Csendes(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Csendes'] + + Name = ["Csendes"] def __init__(self, Lower=-1.0, Upper=1.0): + r"""The initialization of Csendes benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): - return r'''$f(\mathbf{x}) = \sum_{i=1}^D x_i^6\left( 2 + \sin \frac{1}{x_i}\right)$''' + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + + return r"""$f(\mathbf{x}) = \sum_{i=1}^D x_i^6\left( 2 + \sin \frac{1}{x_i}\right)$""" @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/discus.py b/NiaPy/benchmarks/discus.py index 1846796b..ae5dcbf2 100644 --- a/NiaPy/benchmarks/discus.py +++ b/NiaPy/benchmarks/discus.py @@ -1,59 +1,89 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, multiple-statements -"""Implementations of Discus functions.""" + +"""Implementation of Discus benchmark.""" from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Discus'] +__all__ = ["Discus"] + class Discus(Benchmark): - r"""Implementations of Discus functions. + r"""Implementations of Discus functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: + **Discus Function** + + :math:`f(\textbf{x}) = x_1^2 10^6 + \sum_{i=2}^D x_i^2` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = x_1^2 10^6 + \sum_{i=2}^D x_i^2$ + + Equation: + \begin{equation} f(\textbf{x}) = x_1^2 10^6 + \sum_{i=2}^D x_i^2 \end{equation} + + Domain: + $-100 \leq x_i \leq 100$ + + Reference: + http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf + + """ + + Name = ["Discus"] - Date: 2018 + def __init__(self, Lower=-100.0, Upper=100.0): + r"""The initialization of Alpine1 benchmark. - Author: Klemen Berkovič + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - License: MIT + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Function: - **Discus Function** + """ - :math:`f(\textbf{x}) = x_1^2 10^6 + \sum_{i=2}^D x_i^2` + Benchmark.__init__(self, Lower, Upper) - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + @staticmethod + def latex_code(): + """Return the latex code of the problem. - **Global minimum:** - :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + Returns: + [str] -- latex code. - LaTeX formats: - Inline: - $f(\textbf{x}) = x_1^2 10^6 + \sum_{i=2}^D x_i^2$ + """ - Equation: - \begin{equation} f(\textbf{x}) = x_1^2 10^6 + \sum_{i=2}^D x_i^2 \end{equation} + return r"""$f(\textbf{x}) = x_1^2 10^6 + \sum_{i=2}^D x_i^2$""" - Domain: - $-100 \leq x_i \leq 100$ + @classmethod + def function(cls): + """Return benchmark evaluation function. - Reference: - http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - """ - Name = ['Discus'] + Returns: + [fun] -- Evaluation function. - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower, Upper) + """ - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = x_1^2 10^6 + \sum_{i=2}^D x_i^2$''' + def evaluate(D, sol): + val = 0.0 - @classmethod - def function(cls): - def f(D, sol): - val = 0.0 - for i in range(1, D): val += sol[i] ** 2 - return sol[0] * 10 ** 6 + val - return f + for i in range(1, D): + val += sol[i] ** 2 -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return sol[0] * 10 ** 6 + val + return evaluate diff --git a/NiaPy/benchmarks/dixonprice.py b/NiaPy/benchmarks/dixonprice.py index a0c741db..9c0a5a79 100644 --- a/NiaPy/benchmarks/dixonprice.py +++ b/NiaPy/benchmarks/dixonprice.py @@ -1,59 +1,90 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, multiple-statements, line-too-long -"""Implementations of Dixon Price function.""" + +"""Implementation of Dixon Price benchmark.""" from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['DixonPrice'] +__all__ = ["DixonPrice"] + class DixonPrice(Benchmark): - r"""Implementations of Dixon Price function. + r"""Implementations of Dixon Price function. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: + **Levy Function** + + :math:`f(\textbf{x}) = (x_1 - 1)^2 + \sum_{i = 2}^D i (2x_i^2 - x_{i - 1})^2` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-10, 10]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + :math:`f(\textbf{x}^*) = 0` at :math:`\textbf{x}^* = (2^{-\frac{2^1 - 2}{2^1}}, \cdots , 2^{-\frac{2^i - 2}{2^i}} , \cdots , 2^{-\frac{2^D - 2}{2^D}})` + + LaTeX formats: + Inline: + $f(\textbf{x}) = (x_1 - 1)^2 + \sum_{i = 2}^D i (2x_i^2 - x_{i - 1})^2$ + + Equation: + \begin{equation} f(\textbf{x}) = (x_1 - 1)^2 + \sum_{i = 2}^D i (2x_i^2 - x_{i - 1})^2 \end{equation} + + Domain: + $-10 \leq x_i \leq 10$ + + Reference: https://www.sfu.ca/~ssurjano/dixonpr.html + + """ + + Name = ["DixonPrice"] + + def __init__(self, Lower=-10.0, Upper=10): + r"""The initialization of Dixon Price benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - Date: 2018 + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Author: Klemen Berkovič + """ - License: MIT + Benchmark.__init__(self, Lower, Upper) - Function: - **Levy Function** + @staticmethod + def latex_code(): + """Return the latex code of the problem. - :math:`f(\textbf{x}) = (x_1 - 1)^2 + \sum_{i = 2}^D i (2x_i^2 - x_{i - 1})^2` + Returns: + [str] -- latex code. - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-10, 10]`, for all :math:`i = 1, 2,..., D`. + """ - **Global minimum:** - :math:`f(\textbf{x}^*) = 0` at :math:`\textbf{x}^* = (2^{-\frac{2^1 - 2}{2^1}}, \cdots , 2^{-\frac{2^i - 2}{2^i}} , \cdots , 2^{-\frac{2^D - 2}{2^D}})` + return r"""$f(\textbf{x}) = (x_1 - 1)^2 + \sum_{i = 2}^D i (2x_i^2 - x_{i - 1})^2$""" - LaTeX formats: - Inline: - $f(\textbf{x}) = (x_1 - 1)^2 + \sum_{i = 2}^D i (2x_i^2 - x_{i - 1})^2$ + @classmethod + def function(cls): + """Return benchmark evaluation function. - Equation: - \begin{equation} f(\textbf{x}) = (x_1 - 1)^2 + \sum_{i = 2}^D i (2x_i^2 - x_{i - 1})^2 \end{equation} + Returns: + [fun] -- Evaluation function. - Domain: - $-10 \leq x_i \leq 10$ + """ - Reference: - https://www.sfu.ca/~ssurjano/dixonpr.html - """ - Name = ['DixonPrice'] + def evaluate(D, sol): - def __init__(self, Lower=-10.0, Upper=10): Benchmark.__init__(self, Lower, Upper) + v = 0.0 - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = (x_1 - 1)^2 + \sum_{i = 2}^D i (2x_i^2 - x_{i - 1})^2$''' + for i in range(2, D): + v += i * (2 * sol[i] ** 2 - sol[i - 1]) ** 2 - @classmethod - def function(cls): - def f(D, X): - v = 0.0 - for i in range(2, D): v += i * (2 * X[i] ** 2 - X[i - 1]) ** 2 - return (X[0] - 1) ** 2 + v - return f + return (sol[0] - 1) ** 2 + v -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/elliptic.py b/NiaPy/benchmarks/elliptic.py index 1f8a8e44..1a4abafa 100644 --- a/NiaPy/benchmarks/elliptic.py +++ b/NiaPy/benchmarks/elliptic.py @@ -1,59 +1,89 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, multiple-statements + """Implementations of High Conditioned Elliptic functions.""" from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Elliptic'] +__all__ = ["Elliptic"] + class Elliptic(Benchmark): - r"""Implementations of High Conditioned Elliptic functions. + r"""Implementations of High Conditioned Elliptic functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **High Conditioned Elliptic Function** + + :math:`f(\textbf{x}) = \sum_{i=1}^D \left( 10^6 \right)^{ \frac{i - 1}{D - 1} } x_i^2` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = \sum_{i=1}^D \left( 10^6 \right)^{ \frac{i - 1}{D - 1} } x_i^2$ + + Equation: + \begin{equation} f(\textbf{x}) = \sum_{i=1}^D \left( 10^6 \right)^{ \frac{i - 1}{D - 1} } x_i^2 \end{equation} + + Domain: + $-100 \leq x_i \leq 100$ + + Reference: + http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf + + """ + + Name = ["Elliptic"] + + def __init__(self, Lower=-100.0, Upper=100.0): + r"""The initialization of Elliptic benchmark. - Date: 2018 + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - Author: Klemen Berkovič + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - License: MIT + """ - Function: - **High Conditioned Elliptic Function** + Benchmark.__init__(self, Lower, Upper) - :math:`f(\textbf{x}) = \sum_{i=1}^D \left( 10^6 \right)^{ \frac{i - 1}{D - 1} } x_i^2` + @staticmethod + def latex_code(): + """Return the latex code of the problem. - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + Returns: + [str] -- latex code. - **Global minimum:** - :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + """ - LaTeX formats: - Inline: - $f(\textbf{x}) = \sum_{i=1}^D \left( 10^6 \right)^{ \frac{i - 1}{D - 1} } x_i^2$ + return r"""$f(\textbf{x}) = \sum_{i=1}^D \left( 10^6 \right)^{ \frac{i - 1}{D - 1} } x_i^2$""" - Equation: - \begin{equation} f(\textbf{x}) = \sum_{i=1}^D \left( 10^6 \right)^{ \frac{i - 1}{D - 1} } x_i^2 \end{equation} + @classmethod + def function(cls): + """Return benchmark evaluation function. - Domain: - $-100 \leq x_i \leq 100$ + Returns: + [fun] -- Evaluation function. - Reference: - http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - """ - Name = ['Elliptic'] + """ - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower, Upper) + def evaluate(D, sol): + val = 0.0 - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = \sum_{i=1}^D \left( 10^6 \right)^{ \frac{i - 1}{D - 1} } x_i^2$''' + for i in range(D): + val += (10 ** 6) ** (i / (D - 1)) * sol[i] - @classmethod - def function(cls): - def evaluate(D, sol): - val = 0.0 - for i in range(D): val += (10 ** 6) ** (i / (D - 1)) * sol[i] - return val - return evaluate + return val -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/griewank.py b/NiaPy/benchmarks/griewank.py index c30e169a..bf5cf862 100644 --- a/NiaPy/benchmarks/griewank.py +++ b/NiaPy/benchmarks/griewank.py @@ -1,116 +1,184 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string, mixed-indentation, multiple-statements, line-too-long + +"""Implementations of Griewank benchmarks.""" + from math import sqrt, cos from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Griewank', 'ExpandedGriewankPlusRosenbrock'] +__all__ = ["Griewank", "ExpandedGriewankPlusRosenbrock"] class Griewank(Benchmark): - r"""Implementation of Griewank function. + r"""Implementation of Griewank function. + + Date: 2018 + + Authors: Iztok Fister Jr. and Lucija Brezočnik + + License: MIT + + Function: **Griewank function** + + :math:`f(\mathbf{x}) = \sum_{i=1}^D \frac{x_i^2}{4000} - \prod_{i=1}^D \cos(\frac{x_i}{\sqrt{i}}) + 1` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (0,...,0)` + + LaTeX formats: + Inline: + $f(\mathbf{x}) = \sum_{i=1}^D \frac{x_i^2}{4000} - + \prod_{i=1}^D \cos(\frac{x_i}{\sqrt{i}}) + 1$ + + Equation: + \begin{equation} f(\mathbf{x}) = \sum_{i=1}^D \frac{x_i^2}{4000} - + \prod_{i=1}^D \cos(\frac{x_i}{\sqrt{i}}) + 1 \end{equation} + + Domain: + $-100 \leq x_i \leq 100$ + + Reference paper: + Jamil, M., and Yang, X. S. (2013). + A literature survey of benchmark functions for global optimisation problems. + International Journal of Mathematical Modelling and Numerical Optimisation, + 4(2), 150-194. + + """ + + Name = ["Griewank"] + + def __init__(self, Lower=-100.0, Upper=100.0): + """The initialization of Griewank benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Date: 2018 + """ - Authors: Iztok Fister Jr. and Lucija Brezočnik + Benchmark.__init__(self, Lower, Upper) - License: MIT + @staticmethod + def latex_code(): + """Return the latex code of the problem. - Function: **Griewank function** + Returns: + [str] -- latex code. - :math:`f(\mathbf{x}) = \sum_{i=1}^D \frac{x_i^2}{4000} - \prod_{i=1}^D \cos(\frac{x_i}{\sqrt{i}}) + 1` + """ - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + return r'''$f(\mathbf{x}) = \sum_{i=1}^D \frac{x_i^2}{4000} - + \prod_{i=1}^D \cos(\frac{x_i}{\sqrt{i}}) + 1$''' - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (0,...,0)` + @classmethod + def function(cls): + """Return benchmark evaluation function. - LaTeX formats: - Inline: - $f(\mathbf{x}) = \sum_{i=1}^D \frac{x_i^2}{4000} - - \prod_{i=1}^D \cos(\frac{x_i}{\sqrt{i}}) + 1$ + Returns: + [fun] -- Evaluation function. - Equation: - \begin{equation} f(\mathbf{x}) = \sum_{i=1}^D \frac{x_i^2}{4000} - - \prod_{i=1}^D \cos(\frac{x_i}{\sqrt{i}}) + 1 \end{equation} + """ - Domain: - $-100 \leq x_i \leq 100$ + def evaluate(D, sol): - Reference paper: - Jamil, M., and Yang, X. S. (2013). - A literature survey of benchmark functions for global optimisation problems. - International Journal of Mathematical Modelling and Numerical Optimisation, - 4(2), 150-194. - """ - Name = ['Griewank'] + val1, val2 = 0.0, 1.0 - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower, Upper) + for i in range(D): + val1 += sol[i] ** 2 / 4000.0 + val2 *= cos(sol[i] / sqrt(i + 1)) - @staticmethod - def latex_code(): - return r'''$f(\mathbf{x}) = \sum_{i=1}^D \frac{x_i^2}{4000} - - \prod_{i=1}^D \cos(\frac{x_i}{\sqrt{i}}) + 1$''' + return val1 - val2 + 1.0 + + return evaluate - @classmethod - def function(cls): - def evaluate(D, sol): - val1, val2 = 0.0, 1.0 - for i in range(D): - val1 += sol[i] ** 2 / 4000.0 - val2 *= cos(sol[i] / sqrt(i + 1)) - return val1 - val2 + 1.0 - return evaluate class ExpandedGriewankPlusRosenbrock(Benchmark): - r"""Implementation of Expanded Griewank's plus Rosenbrock function. + r"""Implementation of Expanded Griewank's plus Rosenbrock benchmark. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **Expanded Griewank's plus Rosenbrock function** + + :math:`f(\textbf{x}) = h(g(x_D, x_1)) + \sum_{i=2}^D h(g(x_{i - 1}, x_i)) \\ g(x, y) = 100 (x^2 - y)^2 + (x - 1)^2 \\ h(z) = \frac{z^2}{4000} - \cos \left( \frac{z}{\sqrt{1}} \right) + 1` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = h(g(x_D, x_1)) + \sum_{i=2}^D h(g(x_{i - 1}, x_i)) \\ g(x, y) = 100 (x^2 - y)^2 + (x - 1)^2 \\ h(z) = \frac{z^2}{4000} - \cos \left( \frac{z}{\sqrt{1}} \right) + 1$ + + Equation: + \begin{equation} f(\textbf{x}) = h(g(x_D, x_1)) + \sum_{i=2}^D h(g(x_{i - 1}, x_i)) \\ g(x, y) = 100 (x^2 - y)^2 + (x - 1)^2 \\ h(z) = \frac{z^2}{4000} - \cos \left( \frac{z}{\sqrt{1}} \right) + 1 \end{equation} + + Domain: + $-100 \leq x_i \leq 100$ + + Reference: http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf + + """ + + Name = ["ExpandedGriewankPlusRosenbrock"] + + def __init__(self, Lower=-100.0, Upper=100.0): + """The initialization of Expanded Griewank Plus Rosenbrock benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Date: 2018 + """ - Author: Klemen Berkovič + Benchmark.__init__(self, Lower, Upper) - License: MIT + @staticmethod + def latex_code(): + """Return the latex code of the problem. - Function: **Expanded Griewank's plus Rosenbrock function** + Returns: + [str] -- latex code. - :math:`f(\textbf{x}) = h(g(x_D, x_1)) + \sum_{i=2}^D h(g(x_{i - 1}, x_i)) \\ g(x, y) = 100 (x^2 - y)^2 + (x - 1)^2 \\ h(z) = \frac{z^2}{4000} - \cos \left( \frac{z}{\sqrt{1}} \right) + 1` + """ - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + return r'''$f(\textbf{x}) = h(g(x_D, x_1)) + \sum_{i=2}^D h(g(x_{i - 1}, x_i)) \\ g(x, y) = 100 (x^2 - y)^2 + (x - 1)^2 \\ h(z) = \frac{z^2}{4000} - \cos \left( \frac{z}{\sqrt{1}} \right) + 1$''' - **Global minimum:** - :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + @classmethod + def function(cls): + """Return benchmark evaluation function. - LaTeX formats: - Inline: - $f(\textbf{x}) = h(g(x_D, x_1)) + \sum_{i=2}^D h(g(x_{i - 1}, x_i)) \\ g(x, y) = 100 (x^2 - y)^2 + (x - 1)^2 \\ h(z) = \frac{z^2}{4000} - \cos \left( \frac{z}{\sqrt{1}} \right) + 1$ + Returns: + [fun] -- Evaluation function. - Equation: - \begin{equation} f(\textbf{x}) = h(g(x_D, x_1)) + \sum_{i=2}^D h(g(x_{i - 1}, x_i)) \\ g(x, y) = 100 (x^2 - y)^2 + (x - 1)^2 \\ h(z) = \frac{z^2}{4000} - \cos \left( \frac{z}{\sqrt{1}} \right) + 1 \end{equation} + """ - Domain: - $-100 \leq x_i \leq 100$ + def h(z): + return z ** 2 / 4000 - cos(z / sqrt(1)) + 1 - Reference: - http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - """ - Name = ['ExpandedGriewankPlusRosenbrock'] + def g(x, y): + return 100 * (x ** 2 - y ** 2) ** 2 + (x - 1) ** 2 - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower, Upper) + def evaluate(D, sol): + val = 0.0 - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = h(g(x_D, x_1)) + \sum_{i=2}^D h(g(x_{i - 1}, x_i)) \\ g(x, y) = 100 (x^2 - y)^2 + (x - 1)^2 \\ h(z) = \frac{z^2}{4000} - \cos \left( \frac{z}{\sqrt{1}} \right) + 1$''' + for i in range(1, D): + val += h(g(sol[i - 1], sol[i])) - @classmethod - def function(cls): - def h(z): return z ** 2 / 4000 - cos(z / sqrt(1)) + 1 - def g(x, y): return 100 * (x ** 2 - y ** 2) ** 2 + (x - 1) ** 2 - def f(D, x): - val = 0.0 - for i in range(1, D): val += h(g(x[i - 1], x[i])) - return h(g(x[D - 1], x[0])) + val - return f + return h(g(sol[D - 1], sol[0])) + val -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/happyCat.py b/NiaPy/benchmarks/happyCat.py index 55d71175..23ac8464 100644 --- a/NiaPy/benchmarks/happyCat.py +++ b/NiaPy/benchmarks/happyCat.py @@ -1,14 +1,15 @@ # encoding=utf8 -"""The module implementing Happy Cat benchmark.""" + +"""Implementation of Happy Cat benchmark.""" import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['HappyCat'] +__all__ = ["HappyCat"] class HappyCat(Benchmark): - ur"""Implementation of Happy cat function. + r"""Implementation of Happy cat function. Date: 2018 @@ -41,18 +42,23 @@ class HappyCat(Benchmark): $-100 \leq x_i \leq 100$ Reference: http://bee22.com/manual/tf_images/Liang%20CEC2014.pdf & - Beyer, H. G., & Finck, S. (2012). HappyCat - A Simple Function Class Where Well-Known Direct Search Algorithms Do Fail. - In International Conference on Parallel Problem Solving from Nature (pp. 367-376). Springer, Berlin, Heidelberg. + Beyer, H. G., & Finck, S. (2012). HappyCat - A Simple Function Class Where Well-Known Direct Search Algorithms Do Fail. + In International Conference on Parallel Problem Solving from Nature (pp. 367-376). Springer, Berlin, Heidelberg. + """ - Name = ['HappyCat'] + Name = ["HappyCat"] def __init__(self, Lower=-100.0, Upper=100.0): """The initialization of Happy Cat benchmark. - Keyword Arguments: - Lower {float} -- Lower bound. (default: {-100.0}) - Upper {float} -- Upper bound. (default: {100.0}) + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + """ Benchmark.__init__(self, Lower, Upper) @@ -72,7 +78,13 @@ def latex_code(): @classmethod def function(cls): - """Return benchmark evaluation function.""" + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val1 = 0.0 diff --git a/NiaPy/benchmarks/hgbat.py b/NiaPy/benchmarks/hgbat.py index decf8916..fd0f8e90 100644 --- a/NiaPy/benchmarks/hgbat.py +++ b/NiaPy/benchmarks/hgbat.py @@ -1,60 +1,93 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, line-too-long, multiple-statements -"""Implementations of HGBat functions.""" + +"""Implementation of HGBat benchmark.""" from math import fabs from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['HGBat'] +__all__ = ["HGBat"] + class HGBat(Benchmark): - r"""Implementations of HGBat functions. + r"""Implementations of HGBat functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **HGBat Function** + :math:``f(\textbf{x}) = \left| \left( \sum_{i=1}^D x_i^2 \right)^2 - \left( \sum_{i=1}^D x_i \right)^2 \right|^{\frac{1}{2}} + \frac{0.5 \sum_{i=1}^D x_i^2 + \sum_{i=1}^D x_i}{D} + 0.5 + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + + LaTeX formats: + Inline: + $$f(\textbf{x}) = \left| \left( \sum_{i=1}^D x_i^2 \right)^2 - \left( \sum_{i=1}^D x_i \right)^2 \right|^{\frac{1}{2}} + \frac{0.5 \sum_{i=1}^D x_i^2 + \sum_{i=1}^D x_i}{D} + 0.5 + + Equation: + \begin{equation} f(\textbf{x}) = \left| \left( \sum_{i=1}^D x_i^2 \right)^2 - \left( \sum_{i=1}^D x_i \right)^2 \right|^{\frac{1}{2}} + \frac{0.5 \sum_{i=1}^D x_i^2 + \sum_{i=1}^D x_i}{D} + 0.5 \end{equation} + + Domain: + $-100 \leq x_i \leq 100$ + + Reference: + http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf + + """ + + Name = ["HGBat"] + + def __init__(self, Lower=-100.0, Upper=100.0): + r"""The initialization of HGBat benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ - Date: 2018 + Benchmark.__init__(self, Lower, Upper) - Author: Klemen Berkovič + @staticmethod + def latex_code(): + """Return the latex code of the problem. - License: MIT + Returns: + [str] -- latex code. - Function: - **HGBat Function** - :math:``f(\textbf{x}) = \left| \left( \sum_{i=1}^D x_i^2 \right)^2 - \left( \sum_{i=1}^D x_i \right)^2 \right|^{\frac{1}{2}} + \frac{0.5 \sum_{i=1}^D x_i^2 + \sum_{i=1}^D x_i}{D} + 0.5 + """ - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + return r"""$f(\textbf{x}) = \left| \left( \sum_{i=1}^D x_i^2 \right)^2 - \left( \sum_{i=1}^D x_i \right)^2 \right|^{\frac{1}{2}} + \frac{0.5 \sum_{i=1}^D x_i^2 + \sum_{i=1}^D x_i}{D} + 0.5$""" - **Global minimum:** - :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + @classmethod + def function(cls): + """Return benchmark evaluation function. - LaTeX formats: - Inline: - $$f(\textbf{x}) = \left| \left( \sum_{i=1}^D x_i^2 \right)^2 - \left( \sum_{i=1}^D x_i \right)^2 \right|^{\frac{1}{2}} + \frac{0.5 \sum_{i=1}^D x_i^2 + \sum_{i=1}^D x_i}{D} + 0.5 + Returns: + [fun] -- Evaluation function. - Equation: - \begin{equation} f(\textbf{x}) = \left| \left( \sum_{i=1}^D x_i^2 \right)^2 - \left( \sum_{i=1}^D x_i \right)^2 \right|^{\frac{1}{2}} + \frac{0.5 \sum_{i=1}^D x_i^2 + \sum_{i=1}^D x_i}{D} + 0.5 \end{equation} + """ - Domain: - $-100 \leq x_i \leq 100$ + def evaluate(D, sol): - Reference: - http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - """ - Name = ['HGBat'] + val1, val2 = 0.0, 0.0 - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower, Upper) + for i in range(D): + val1 += sol[i] ** 2 - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = \left| \left( \sum_{i=1}^D x_i^2 \right)^2 - \left( \sum_{i=1}^D x_i \right)^2 \right|^{\frac{1}{2}} + \frac{0.5 \sum_{i=1}^D x_i^2 + \sum_{i=1}^D x_i}{D} + 0.5$''' + for i in range(D): + val2 += sol[i] - @classmethod - def function(cls): - def f(D, x): - val1, val2 = 0.0, 0.0 - for i in range(D): val1 += x[i] ** 2 - for i in range(D): val2 += x[i] - return fabs(val1 ** 2 - val2 ** 2) ** (1 / 2) + (0.5 * val1 + val2) / D + 0.5 - return f + return fabs(val1 ** 2 - val2 ** 2) ** (1 / 2) + (0.5 * val1 + val2) / D + 0.5 -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/infinity.py b/NiaPy/benchmarks/infinity.py index 3a81a2f4..a7b7e1f1 100644 --- a/NiaPy/benchmarks/infinity.py +++ b/NiaPy/benchmarks/infinity.py @@ -1,60 +1,90 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, multiple-statements -"""Implementations of Infinity function.""" + +"""Implementation of Infinity benchmark.""" from numpy import sin from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Infinity'] +__all__ = ["Infinity"] + class Infinity(Benchmark): - r"""Implementations of Infinity function. + r"""Implementations of Infinity function. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **Infinity Function** + + :math:`f(\textbf{x}) = \sum_{i = 1}^D x_i^6 \left( \sin \left( \frac{1}{x_i} \right) + 2 \right)` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-1, 1]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = \sum_{i = 1}^D x_i^6 \left( \sin \left( \frac{1}{x_i} \right) + 2 \right)$ + + Equation: + \begin{equation} f(\textbf{x}) = \sum_{i = 1}^D x_i^6 \left( \sin \left( \frac{1}{x_i} \right) + 2 \right) \end{equation} + + Domain: + $-1 \leq x_i \leq 1$ + + Reference: + http://infinity77.net/global_optimization/test_functions_nd_I.html#go_benchmark.Infinity + + """ + + Name = ["Infinity"] + + def __init__(self, Lower=-1.0, Upper=1.0): + r"""The initialization of Infinity benchmark. - Date: 2018 + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - Author: Klemen Berkovič + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - License: MIT + """ - Function: - **Infinity Function** + Benchmark.__init__(self, Lower, Upper) - :math:`f(\textbf{x}) = \sum_{i = 1}^D x_i^6 \left( \sin \left( \frac{1}{x_i} \right) + 2 \right)` + @staticmethod + def latex_code(): + """Return the latex code of the problem. - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-1, 1]`, for all :math:`i = 1, 2,..., D`. + Returns: + [str] -- latex code. - **Global minimum:** - :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + """ - LaTeX formats: - Inline: - $f(\textbf{x}) = \sum_{i = 1}^D x_i^6 \left( \sin \left( \frac{1}{x_i} \right) + 2 \right)$ + return r"""$f(\textbf{x}) = \sum_{i = 1}^D x_i^6 \left( \sin \left( \frac{1}{x_i} \right) + 2 \right)$""" - Equation: - \begin{equation} f(\textbf{x}) = \sum_{i = 1}^D x_i^6 \left( \sin \left( \frac{1}{x_i} \right) + 2 \right) \end{equation} + @classmethod + def function(cls): + """Return benchmark evaluation function. - Domain: - $-1 \leq x_i \leq 1$ + Returns: + [fun] -- Evaluation function. - Reference: - http://infinity77.net/global_optimization/test_functions_nd_I.html#go_benchmark.Infinity - """ - Name = ['Infinity'] + """ - def __init__(self, Lower=-1.0, Upper=1.0): Benchmark.__init__(self, Lower, Upper) + def evaluate(D, sol): + val = 0.0 - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = \sum_{i = 1}^D x_i^6 \left( \sin \left( \frac{1}{x_i} \right) + 2 \right)$''' + for i in range(D): + val += sol[i] ** 6 * (sin(1 / sol[i]) + 2) - @classmethod - def function(cls): - def f(D, X): - val = 0.0 - for i in range(D): val += X[i] ** 6 * (sin(1 / X[i]) + 2) - return val - return f + return val -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/katsuura.py b/NiaPy/benchmarks/katsuura.py index dc167745..b0d162e7 100644 --- a/NiaPy/benchmarks/katsuura.py +++ b/NiaPy/benchmarks/katsuura.py @@ -1,62 +1,94 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, line-too-long, multiple-statements -"""Implementations of Katsuura functions.""" + +"""Implementation of Katsuura benchmark.""" from math import fabs from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Katsuura'] +__all__ = ["Katsuura"] + class Katsuura(Benchmark): - r"""Implementations of Katsuura functions. + r"""Implementations of Katsuura functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **Katsuura Function** + + :math:`f(\textbf{x}) = \frac{10}{D^2} \prod_{i=1}^D \left( 1 + i \sum_{j=1}^{32} \frac{| 2^j x_i - round\left(2^j x_i \right) |}{2^j} \right)^\frac{10}{D^{1.2}} - \frac{10}{D^2}` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = \frac{10}{D^2} \prod_{i=1}^D \left( 1 + i \sum_{j=1}^{32} \frac{| 2^j x_i - round\left(2^j x_i \right) |}{2^j} \right)^\frac{10}{D^{1.2}} - \frac{10}{D^2}$ + + Equation: + \begin{equation} f(\textbf{x}) = \frac{10}{D^2} \prod_{i=1}^D \left( 1 + i \sum_{j=1}^{32} \frac{| 2^j x_i - round\left(2^j x_i \right) |}{2^j} \right)^\frac{10}{D^{1.2}} - \frac{10}{D^2} \end{equation} + + Domain: + $-100 \leq x_i \leq 100$ + + Reference: + http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf + + """ + + Name = ["Katsuura"] + + def __init__(self, Lower=-100.0, Upper=100.0, **kwargs): + r"""The initialization of Katsuura benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Date: 2018 + """ - Author: Klemen Berkovič + Benchmark.__init__(self, Lower, Upper, **kwargs) - License: MIT + @staticmethod + def latex_code(): + """Return the latex code of the problem. - Function: - **Katsuura Function** + Returns: + [str] -- latex code. - :math:`f(\textbf{x}) = \frac{10}{D^2} \prod_{i=1}^D \left( 1 + i \sum_{j=1}^{32} \frac{| 2^j x_i - round\left(2^j x_i \right) |}{2^j} \right)^\frac{10}{D^{1.2}} - \frac{10}{D^2}` + """ - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + return r"""$f(\textbf{x}) = \frac{10}{D^2} \prod_{i=1}^D \left( 1 + i \sum_{j=1}^{32} \frac{| 2^j x_i - round\left(2^j x_i \right) |}{2^j} \right)^\frac{10}{D^{1.2}} - \frac{10}{D^2}$""" - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + @classmethod + def function(cls): + """Return benchmark evaluation function. - LaTeX formats: - Inline: - $f(\textbf{x}) = \frac{10}{D^2} \prod_{i=1}^D \left( 1 + i \sum_{j=1}^{32} \frac{| 2^j x_i - round\left(2^j x_i \right) |}{2^j} \right)^\frac{10}{D^{1.2}} - \frac{10}{D^2}$ + Returns: + [fun] -- Evaluation function. - Equation: - \begin{equation} f(\textbf{x}) = \frac{10}{D^2} \prod_{i=1}^D \left( 1 + i \sum_{j=1}^{32} \frac{| 2^j x_i - round\left(2^j x_i \right) |}{2^j} \right)^\frac{10}{D^{1.2}} - \frac{10}{D^2} \end{equation} + """ - Domain: - $-100 \leq x_i \leq 100$ + def evaluate(D, sol): + val = 1.0 - Reference: - http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - """ - Name = ['Katsuura'] + for i in range(D): + valt = 1.0 - def __init__(self, Lower=-100.0, Upper=100.0, **kwargs): Benchmark.__init__(self, Lower, Upper, **kwargs) + for j in range(1, 33): + valt += fabs(2 ** j * sol[i] - round(2 ** j * sol[i])) / 2 ** j - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = \frac{10}{D^2} \prod_{i=1}^D \left( 1 + i \sum_{j=1}^{32} \frac{| 2^j x_i - round\left(2^j x_i \right) |}{2^j} \right)^\frac{10}{D^{1.2}} - \frac{10}{D^2}$''' + val *= (1 + (i + 1) * valt) ** (10 / D ** 1.2) - (10 / D ** 2) - @classmethod - def function(cls): - def f(D, x): - val = 1.0 - for i in range(D): - valt = 1.0 - for j in range(1, 33): valt += fabs(2 ** j * x[i] - round(2 ** j * x[i])) / 2 ** j - val *= (1 + (i + 1) * valt) ** (10 / D ** 1.2) - (10 / D ** 2) - return 10 / D ** 2 * val - return f + return 10 / D ** 2 * val -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/levy.py b/NiaPy/benchmarks/levy.py index b9d2ffb0..e36e368d 100644 --- a/NiaPy/benchmarks/levy.py +++ b/NiaPy/benchmarks/levy.py @@ -1,61 +1,94 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, multiple-statements, line-too-long -"""Implementations of Levy function.""" + +"""Implementation of Levy benchmark.""" from numpy import sin, pi from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Levy'] +__all__ = ["Levy"] + class Levy(Benchmark): - r"""Implementations of Levy functions. + r"""Implementations of Levy functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **Levy Function** + + :math:`f(\textbf{x}) = \sin^2 (\pi w_1) + \sum_{i = 1}^{D - 1} (w_i - 1)^2 \left( 1 + 10 \sin^2 (\pi w_i + 1) \right) + (w_d - 1)^2 (1 + \sin^2 (2 \pi w_d)) \\ w_i = 1 + \frac{x_i - 1}{4}` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-10, 10]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + :math:`f(\textbf{x}^*) = 0` at :math:`\textbf{x}^* = (1, \cdots, 1)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = \sin^2 (\pi w_1) + \sum_{i = 1}^{D - 1} (w_i - 1)^2 \left( 1 + 10 \sin^2 (\pi w_i + 1) \right) + (w_d - 1)^2 (1 + \sin^2 (2 \pi w_d)) \\ w_i = 1 + \frac{x_i - 1}{4}$ + + Equation: + \begin{equation} f(\textbf{x}) = \sin^2 (\pi w_1) + \sum_{i = 1}^{D - 1} (w_i - 1)^2 \left( 1 + 10 \sin^2 (\pi w_i + 1) \right) + (w_d - 1)^2 (1 + \sin^2 (2 \pi w_d)) \\ w_i = 1 + \frac{x_i - 1}{4} \end{equation} + + Domain: + $-10 \leq x_i \leq 10$ + + Reference: + https://www.sfu.ca/~ssurjano/levy.html + + """ + + Name = ["Levy"] + + def __init__(self, Lower=0.0, Upper=pi): + r"""The initialization of Levy benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Date: 2018 + """ - Author: Klemen Berkovič + Benchmark.__init__(self, Lower, Upper) - License: MIT + @staticmethod + def latex_code(): + """Return the latex code of the problem. - Function: - **Levy Function** + Returns: + [str] -- latex code. - :math:`f(\textbf{x}) = \sin^2 (\pi w_1) + \sum_{i = 1}^{D - 1} (w_i - 1)^2 \left( 1 + 10 \sin^2 (\pi w_i + 1) \right) + (w_d - 1)^2 (1 + \sin^2 (2 \pi w_d)) \\ w_i = 1 + \frac{x_i - 1}{4}` + """ - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-10, 10]`, for all :math:`i = 1, 2,..., D`. + return r"""$f(\textbf{x}) = \sin^2 (\pi w_1) + \sum_{i = 1}^{D - 1} (w_i - 1)^2 \left( 1 + 10 \sin^2 (\pi w_i + 1) \right) + (w_d - 1)^2 (1 + \sin^2 (2 \pi w_d)) \\ w_i = 1 + \frac{x_i - 1}{4}$""" - **Global minimum:** - :math:`f(\textbf{x}^*) = 0` at :math:`\textbf{x}^* = (1, \cdots, 1)` + @classmethod + def function(cls): + """Return benchmark evaluation function. - LaTeX formats: - Inline: - $f(\textbf{x}) = \sin^2 (\pi w_1) + \sum_{i = 1}^{D - 1} (w_i - 1)^2 \left( 1 + 10 \sin^2 (\pi w_i + 1) \right) + (w_d - 1)^2 (1 + \sin^2 (2 \pi w_d)) \\ w_i = 1 + \frac{x_i - 1}{4}$ + Returns: + [fun] -- Evaluation function. - Equation: - \begin{equation} f(\textbf{x}) = \sin^2 (\pi w_1) + \sum_{i = 1}^{D - 1} (w_i - 1)^2 \left( 1 + 10 \sin^2 (\pi w_i + 1) \right) + (w_d - 1)^2 (1 + \sin^2 (2 \pi w_d)) \\ w_i = 1 + \frac{x_i - 1}{4} \end{equation} + """ - Domain: - $-10 \leq x_i \leq 10$ + def w(x): + return 1 + (x - 1) / 4 - Reference: - https://www.sfu.ca/~ssurjano/levy.html - """ - Name = ['Levy'] + def evaluate(D, sol): - def __init__(self, Lower=0.0, Upper=pi): Benchmark.__init__(self, Lower, Upper) + v = 0.0 - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = \sin^2 (\pi w_1) + \sum_{i = 1}^{D - 1} (w_i - 1)^2 \left( 1 + 10 \sin^2 (\pi w_i + 1) \right) + (w_d - 1)^2 (1 + \sin^2 (2 \pi w_d)) \\ w_i = 1 + \frac{x_i - 1}{4}$''' + for i in range(D - 1): + v += (w(sol[i]) - 1) ** 2 * (1 + 10 * sin(pi * w(sol[i]) + 1) ** 2) + (w(sol[-1]) - 1) ** 2 * (1 + sin(2 * pi * w(sol[-1]) ** 2)) - @classmethod - def function(cls): - def w(x): return 1 + (x - 1) / 4 - def f(D, X): - v = 0.0 - for i in range(D - 1): v += (w(X[i]) - 1) ** 2 * (1 + 10 * sin(pi * w(X[i]) + 1) ** 2) + (w(X[-1]) - 1) ** 2 * (1 + sin(2 * pi * w(X[-1]) ** 2)) - return sin(pi * w(X[0])) ** 2 + v - return f + return sin(pi * w(sol[0])) ** 2 + v -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/michalewichz.py b/NiaPy/benchmarks/michalewichz.py index 367df0f5..ab94905e 100644 --- a/NiaPy/benchmarks/michalewichz.py +++ b/NiaPy/benchmarks/michalewichz.py @@ -1,64 +1,95 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, multiple-statements -"""Implementations of Michalewichz's function.""" + +"""Implementation of Michalewichz"s benchmark.""" from numpy import sin, pi from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Michalewichz'] +__all__ = ["Michalewichz"] + class Michalewichz(Benchmark): - r"""Implementations of Michalewichz's functions. + r"""Implementations of Michalewichz"s functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **High Conditioned Elliptic Function** + + :math:`f(\textbf{x}) = \sum_{i=1}^D \left( 10^6 \right)^{ \frac{i - 1}{D - 1} } x_i^2` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [0, \pi]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + at :math:`d = 2` :math:`f(\textbf{x}^*) = -1.8013` at :math:`\textbf{x}^* = (2.20, 1.57)` + at :math:`d = 5` :math:`f(\textbf{x}^*) = -4.687658` + at :math:`d = 10` :math:`f(\textbf{x}^*) = -9.66015` + + LaTeX formats: + Inline: + $f(\textbf{x}) = - \sum_{i = 1}^{D} \sin(x_i) \sin\left( \frac{ix_i^2}{\pi} \right)^{2m}$ + + Equation: + \begin{equation} f(\textbf{x}) = - \sum_{i = 1}^{D} \sin(x_i) \sin\left( \frac{ix_i^2}{\pi} \right)^{2m} \end{equation} + + Domain: + $0 \leq x_i \leq \pi$ + + Reference URL: + https://www.sfu.ca/~ssurjano/michal.html + + """ + + Name = ["Michalewichz"] + + def __init__(self, Lower=0.0, Upper=pi, m=10): + r"""The initialization of Alpine1 benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + m (Optional[int]): m attribute. - Date: 2018 + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Author: Klemen Berkovič + """ - License: MIT + Benchmark.__init__(self, Lower, Upper) + self.m = m - Function: - **High Conditioned Elliptic Function** + @staticmethod + def latex_code(): + """Return the latex code of the problem. - :math:`f(\textbf{x}) = \sum_{i=1}^D \left( 10^6 \right)^{ \frac{i - 1}{D - 1} } x_i^2` + Returns: + [str] -- latex code. - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [0, \pi]`, for all :math:`i = 1, 2,..., D`. + """ - **Global minimum:** - at :math:`d = 2` :math:`f(\textbf{x}^*) = -1.8013` at :math:`\textbf{x}^* = (2.20, 1.57)` - at :math:`d = 5` :math:`f(\textbf{x}^*) = -4.687658` - at :math:`d = 10` :math:`f(\textbf{x}^*) = -9.66015` + return r"""$f(\textbf{x}) = - \sum_{i = 1}^{D} \sin(x_i) \sin\left( \frac{ix_i^2}{\pi} \right)^{2m}$""" - LaTeX formats: - Inline: - $f(\textbf{x}) = - \sum_{i = 1}^{D} \sin(x_i) \sin\left( \frac{ix_i^2}{\pi} \right)^{2m}$ + @classmethod + def function(cls): + """Return benchmark evaluation function. - Equation: - \begin{equation} f(\textbf{x}) = - \sum_{i = 1}^{D} \sin(x_i) \sin\left( \frac{ix_i^2}{\pi} \right)^{2m} \end{equation} + Returns: + [fun] -- Evaluation function. - Domain: - $0 \leq x_i \leq \pi$ + """ - Reference URL: - https://www.sfu.ca/~ssurjano/michal.html - """ - Name = ['Michalewichz'] + def evaluate(D, sol): - def __init__(self, Lower=0.0, Upper=pi, m=10): - Benchmark.__init__(self, Lower, Upper) - Michalewichz.m = m + v = 0.0 - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = - \sum_{i = 1}^{D} \sin(x_i) \sin\left( \frac{ix_i^2}{\pi} \right)^{2m}$''' + for i in range(D): + v += sin(sol[i]) * sin(((i + 1) * sol[i] ** 2) / pi) ** (2 * cls.m) - @classmethod - def function(cls): - def evaluate(D, X): - v = 0.0 - for i in range(D): v += sin(X[i]) * sin(((i + 1) * X[i] ** 2) / pi) ** (2 * cls.m) - return -v - return evaluate + return -v -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/perm.py b/NiaPy/benchmarks/perm.py index 6f7bbb83..f738a04a 100644 --- a/NiaPy/benchmarks/perm.py +++ b/NiaPy/benchmarks/perm.py @@ -1,67 +1,98 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, multiple-statements -"""Implementations of Perm function.""" + +"""Implementation of Perm benchmark.""" from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Perm'] +__all__ = ["Perm"] + class Perm(Benchmark): - r"""Implementations of Perm functions. + r"""Implementations of Perm functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Arguments: + beta {real} -- value added to inner sum of funciton + + Function: **Perm Function** + + :math:`f(\textbf{x}) = \sum_{i = 1}^D \left( \sum_{j = 1}^D (j - \beta) \left( x_j^i - \frac{1}{j^i} \right) \right)^2` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-D, D]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + :math:`f(\textbf{x}^*) = 0` at :math:`\textbf{x}^* = (1, \frac{1}{2}, \cdots , \frac{1}{i} , \cdots , \frac{1}{D})` + + LaTeX formats: + Inline: + $f(\textbf{x}) = \sum_{i = 1}^D \left( \sum_{j = 1}^D (j - \beta) \left( x_j^i - \frac{1}{j^i} \right) \right)^2$ + + Equation: + \begin{equation} f(\textbf{x}) = \sum_{i = 1}^D \left( \sum_{j = 1}^D (j - \beta) \left( x_j^i - \frac{1}{j^i} \right) \right)^2 \end{equation} + + Domain: + $-D \leq x_i \leq D$ + + Reference: + https://www.sfu.ca/~ssurjano/perm0db.html + + """ + + Name = ["Perm"] + + def __init__(self, D=10.0, beta=0.5): + """The initialization of Perm benchmark. + + Args: + D [float] -- Dimension on problem. (default: {10.0}) + beta [float] -- beat parameter. (default: {0.5}) - Date: 2018 + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Author: Klemen Berkovič + """ - License: MIT + Benchmark.__init__(self, -D, D) + self.beta = beta - Arguments: - beta {real} -- value added to inner sum of funciton + @staticmethod + def latex_code(): + """Return the latex code of the problem. - Function: - **Perm Function** + Returns: + [str] -- latex code. - :math:`f(\textbf{x}) = \sum_{i = 1}^D \left( \sum_{j = 1}^D (j - \beta) \left( x_j^i - \frac{1}{j^i} \right) \right)^2` + """ - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-D, D]`, for all :math:`i = 1, 2,..., D`. + return r"""$f(\textbf{x}) = \sum_{i = 1}^D \left( \sum_{j = 1}^D (j - \beta) \left( x_j^i - \frac{1}{j^i} \right) \right)^2$""" - **Global minimum:** - :math:`f(\textbf{x}^*) = 0` at :math:`\textbf{x}^* = (1, \frac{1}{2}, \cdots , \frac{1}{i} , \cdots , \frac{1}{D})` + @classmethod + def function(cls): + """Return benchmark evaluation function. - LaTeX formats: - Inline: - $f(\textbf{x}) = \sum_{i = 1}^D \left( \sum_{j = 1}^D (j - \beta) \left( x_j^i - \frac{1}{j^i} \right) \right)^2$ + Returns: + [fun] -- Evaluation function. - Equation: - \begin{equation} f(\textbf{x}) = \sum_{i = 1}^D \left( \sum_{j = 1}^D (j - \beta) \left( x_j^i - \frac{1}{j^i} \right) \right)^2 \end{equation} + """ - Domain: - $-D \leq x_i \leq D$ + def evaluate(D, sol): + v = 0.0 - Reference: - https://www.sfu.ca/~ssurjano/perm0db.html - """ - Name = ['Perm'] + for i in range(1, D + 1): + vv = .0 - def __init__(self, D=10.0, beta=.5): - Benchmark.__init__(self, -D, D) - Perm.beta = beta + for j in range(1, D + 1): + vv += (j + cls.beta) * (sol[j - 1] ** i - 1 / j ** i) - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = \sum_{i = 1}^D \left( \sum_{j = 1}^D (j - \beta) \left( x_j^i - \frac{1}{j^i} \right) \right)^2$''' + v += vv ** 2 - @classmethod - def function(cls): - def f(D, X): - v = .0 - for i in range(1, D + 1): - vv = .0 - for j in range(1, D + 1): vv += (j + cls.beta) * (X[j - 1] ** i - 1 / j ** i) - v += vv ** 2 - return v - return f + return v -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/pinter.py b/NiaPy/benchmarks/pinter.py index d16d15f8..2358736e 100644 --- a/NiaPy/benchmarks/pinter.py +++ b/NiaPy/benchmarks/pinter.py @@ -1,9 +1,11 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Pinter benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Pinter'] +__all__ = ["Pinter"] class Pinter(Benchmark): @@ -51,14 +53,34 @@ class Pinter(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Pinter'] + + Name = ["Pinter"] def __init__(self, Lower=-10.0, Upper=10.0): + r"""The initialization of Pinter benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + return r''' $f(\mathbf{x}) = \sum_{i=1}^D ix_i^2 + \sum_{i=1}^D 20i \sin^2 A + \sum_{i=1}^D i \log_{10} (1 + iB^2); @@ -67,6 +89,13 @@ def latex_code(): @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val1 = 0.0 diff --git a/NiaPy/benchmarks/powell.py b/NiaPy/benchmarks/powell.py index 8b664ec4..1b3d8052 100644 --- a/NiaPy/benchmarks/powell.py +++ b/NiaPy/benchmarks/powell.py @@ -1,59 +1,88 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, multiple-statements, line-too-long -"""Implementations of Levy function.""" + +"""Implementations of Powell benchmark.""" from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Powell'] +__all__ = ["Powell"] + class Powell(Benchmark): - r"""Implementations of Powell functions. + r"""Implementations of Powell functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **Levy Function** + + :math:`f(\textbf{x}) = \sum_{i = 1}^{D / 4} \left( (x_{4 i - 3} + 10 x_{4 i - 2})^2 + 5 (x_{4 i - 1} - x_{4 i})^2 + (x_{4 i - 2} - 2 x_{4 i - 1})^4 + 10 (x_{4 i - 3} - x_{4 i})^4 \right)` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-4, 5]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + :math:`f(\textbf{x}^*) = 0` at :math:`\textbf{x}^* = (0, \cdots, 0)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = \sum_{i = 1}^{D / 4} \left( (x_{4 i - 3} + 10 x_{4 i - 2})^2 + 5 (x_{4 i - 1} - x_{4 i})^2 + (x_{4 i - 2} - 2 x_{4 i - 1})^4 + 10 (x_{4 i - 3} - x_{4 i})^4 \right)$ + + Equation: + \begin{equation} f(\textbf{x}) = \sum_{i = 1}^{D / 4} \left( (x_{4 i - 3} + 10 x_{4 i - 2})^2 + 5 (x_{4 i - 1} - x_{4 i})^2 + (x_{4 i - 2} - 2 x_{4 i - 1})^4 + 10 (x_{4 i - 3} - x_{4 i})^4 \right) \end{equation} + + Domain: + $-4 \leq x_i \leq 5$ + + Reference: + https://www.sfu.ca/~ssurjano/levy.html + + """ + + Name = ["Powell"] - Date: 2018 + def __init__(self, Lower=-4.0, Upper=5.0): + r"""The initialization of Powell benchmark. - Author: Klemen Berkovič + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - License: MIT + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Function: - **Levy Function** + """ - :math:`f(\textbf{x}) = \sum_{i = 1}^{D / 4} \left( (x_{4 i - 3} + 10 x_{4 i - 2})^2 + 5 (x_{4 i - 1} - x_{4 i})^2 + (x_{4 i - 2} - 2 x_{4 i - 1})^4 + 10 (x_{4 i - 3} - x_{4 i})^4 \right)` + Benchmark.__init__(self, Lower, Upper) - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-4, 5]`, for all :math:`i = 1, 2,..., D`. + @staticmethod + def latex_code(): + """Return the latex code of the problem. - **Global minimum:** - :math:`f(\textbf{x}^*) = 0` at :math:`\textbf{x}^* = (0, \cdots, 0)` + Returns: + [str] -- latex code. - LaTeX formats: - Inline: - $f(\textbf{x}) = \sum_{i = 1}^{D / 4} \left( (x_{4 i - 3} + 10 x_{4 i - 2})^2 + 5 (x_{4 i - 1} - x_{4 i})^2 + (x_{4 i - 2} - 2 x_{4 i - 1})^4 + 10 (x_{4 i - 3} - x_{4 i})^4 \right)$ + """ - Equation: - \begin{equation} f(\textbf{x}) = \sum_{i = 1}^{D / 4} \left( (x_{4 i - 3} + 10 x_{4 i - 2})^2 + 5 (x_{4 i - 1} - x_{4 i})^2 + (x_{4 i - 2} - 2 x_{4 i - 1})^4 + 10 (x_{4 i - 3} - x_{4 i})^4 \right) \end{equation} + return r"""$f(\textbf{x}) = \sum_{i = 1}^{D / 4} \left( (x_{4 i - 3} + 10 x_{4 i - 2})^2 + 5 (x_{4 i - 1} - x_{4 i})^2 + (x_{4 i - 2} - 2 x_{4 i - 1})^4 + 10 (x_{4 i - 3} - x_{4 i})^4 \right)$""" - Domain: - $-4 \leq x_i \leq 5$ + @classmethod + def function(cls): + """Return benchmark evaluation function. - Reference: - https://www.sfu.ca/~ssurjano/levy.html - """ - Name = ['Powell'] + Returns: + [fun] -- Evaluation function. - def __init__(self, Lower=-4.0, Upper=5.0): Benchmark.__init__(self, Lower, Upper) + """ - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = \sum_{i = 1}^{D / 4} \left( (x_{4 i - 3} + 10 x_{4 i - 2})^2 + 5 (x_{4 i - 1} - x_{4 i})^2 + (x_{4 i - 2} - 2 x_{4 i - 1})^4 + 10 (x_{4 i - 3} - x_{4 i})^4 \right)$''' + def evaluate(D, sol): + v = 0.0 - @classmethod - def function(cls): - def f(D, X): - v = 0.0 - for i in range(1, (D // 4) + 1): v += (X[4 * i - 4] + 10 * X[4 * i - 3]) ** 2 + 5 * (X[4 * i - 2] - X[4 * i - 1]) ** 2 + (X[4 * i - 3] - 2 * X[4 * i - 2]) ** 4 + 10 * (X[4 * i - 4] - X[4 * i - 1]) ** 4 - return v - return f + for i in range(1, (D // 4) + 1): + v += (sol[4 * i - 4] + 10 * sol[4 * i - 3]) ** 2 + 5 * (sol[4 * i - 2] - sol[4 * i - 1]) ** 2 + (sol[4 * i - 3] - 2 * sol[4 * i - 2]) ** 4 + 10 * (sol[4 * i - 4] - sol[4 * i - 1]) ** 4 -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return v + return evaluate diff --git a/NiaPy/benchmarks/qing.py b/NiaPy/benchmarks/qing.py index ed11aaa8..17eceef3 100644 --- a/NiaPy/benchmarks/qing.py +++ b/NiaPy/benchmarks/qing.py @@ -1,9 +1,12 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Quing benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Qing'] +__all__ = ["Qing"] + class Qing(Benchmark): r"""Implementation of Qing function. @@ -40,18 +43,45 @@ class Qing(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Qing'] + + Name = ["Qing"] def __init__(self, Lower=-500.0, Upper=500.0): + """The initialization of Quing benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + return r'''$f(\mathbf{x}) = \sum_{i=1}^D \left (x_i^2 - i\right)^2$''' @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/quintic.py b/NiaPy/benchmarks/quintic.py index 3786c441..9cecd31c 100644 --- a/NiaPy/benchmarks/quintic.py +++ b/NiaPy/benchmarks/quintic.py @@ -1,9 +1,11 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Quintic benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Quintic'] +__all__ = ["Quintic"] class Quintic(Benchmark): @@ -44,26 +46,53 @@ class Quintic(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Quintic'] + + Name = ["Quintic"] def __init__(self, Lower=-10.0, Upper=10.0): + """The initialization of Quintic benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + return r'''$f(\mathbf{x}) = \sum_{i=1}^D \left| x_i^5 - 3x_i^4 + 4x_i^3 + 2x_i^2 - 10x_i - 4\right|$''' @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 for i in range(D): - val += abs(math.pow(sol[i], 5) - 3.0 * math.pow(sol[i], 4) + 4.0 * - math.pow(sol[i], 3) + 2.0 * math.pow(sol[i], 2) - 10.0 * sol[i] - 4) + val += abs( + math.pow(sol[i], 5) - 3.0 * math.pow(sol[i], 4) + 4.0 * math.pow(sol[i], 3) + 2.0 * math.pow(sol[i], 2) - 10.0 * sol[i] - 4) return val diff --git a/NiaPy/benchmarks/rastrigin.py b/NiaPy/benchmarks/rastrigin.py index a3595b5b..1f1eae66 100644 --- a/NiaPy/benchmarks/rastrigin.py +++ b/NiaPy/benchmarks/rastrigin.py @@ -1,9 +1,11 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implemenatation of Rastrigin benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Rastrigin'] +__all__ = ["Rastrigin"] class Rastrigin(Benchmark): @@ -38,18 +40,44 @@ class Rastrigin(Benchmark): $-5.12 \leq x_i \leq 5.12$ Reference: https://www.sfu.ca/~ssurjano/rastr.html + """ + Name = ['Rastrigin'] def __init__(self, Lower=-5.12, Upper=5.12): + """The initialization of Rastrigin benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ return r'''$f(\mathbf{x}) = 10D + \sum_{i=1}^D \left(x_i^2 -10\cos(2\pi x_i)\right)$''' @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/ridge.py b/NiaPy/benchmarks/ridge.py index 425aa15b..5bc278f5 100644 --- a/NiaPy/benchmarks/ridge.py +++ b/NiaPy/benchmarks/ridge.py @@ -1,9 +1,11 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Ridge benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Ridge'] +__all__ = ["Ridge"] class Ridge(Benchmark): @@ -37,18 +39,45 @@ class Ridge(Benchmark): $-64 \leq x_i \leq 64$ Reference: http://www.cs.unm.edu/~neal.holts/dga/benchmarkFunction/ridge.html + """ + Name = ['Ridge'] def __init__(self, Lower=-64.0, Upper=64.0): + """The initialization of Ridge benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + return r'''$f(\mathbf{x}) = \sum_{i=1}^D (\sum_{j=1}^i x_j)^2 $''' @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/rosenbrock.py b/NiaPy/benchmarks/rosenbrock.py index bbf0e505..1d20a804 100644 --- a/NiaPy/benchmarks/rosenbrock.py +++ b/NiaPy/benchmarks/rosenbrock.py @@ -1,9 +1,11 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Rosenbrock benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Rosenbrock'] +__all__ = ["Rosenbrock"] class Rosenbrock(Benchmark): @@ -42,18 +44,45 @@ class Rosenbrock(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Rosenbrock'] + + Name = ["Rosenbrock"] def __init__(self, Lower=-30.0, Upper=30.0): + """The initialization of Rosenbrock benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + return r'''$f(\mathbf{x}) = \sum_{i=1}^{D-1} (100 (x_{i+1} - x_i^2)^2 + (x_i - 1)^2)$''' @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/salomon.py b/NiaPy/benchmarks/salomon.py index cab386bc..576c74d7 100644 --- a/NiaPy/benchmarks/salomon.py +++ b/NiaPy/benchmarks/salomon.py @@ -1,9 +1,11 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Salomon benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Salomon'] +__all__ = ["Salomon"] class Salomon(Benchmark): @@ -44,19 +46,46 @@ class Salomon(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Salomon'] + + Name = ["Salomon"] def __init__(self, Lower=-100.0, Upper=100.0): + """The initialization of Salomon benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + return r'''$f(\mathbf{x}) = 1 - \cos\left(2\pi\sqrt{\sum_{i=1}^D x_i^2} \right)+ 0.1 \sqrt{\sum_{i=1}^D x_i^2}$''' @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/schaffer.py b/NiaPy/benchmarks/schaffer.py index 3136f607..2cd2bfe7 100644 --- a/NiaPy/benchmarks/schaffer.py +++ b/NiaPy/benchmarks/schaffer.py @@ -1,149 +1,242 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string, mixed-indentation, multiple-statements, line-too-long, no-else-return, unused-argument -"""Implementations of Schwefels functions.""" + +"""Implementations of Schaffer benchmarks.""" from math import sin, cos, sqrt from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['SchafferN2', 'SchafferN4', 'ExpandedSchaffer'] +__all__ = ["SchafferN2", "SchafferN4", "ExpandedSchaffer"] + class SchafferN2(Benchmark): - r"""Implementations of Schaffer N. 2 functions. + r"""Implementations of Schaffer N. 2 functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **Schaffer N. 2 Function** + + :math:`f(\textbf{x}) = 0.5 + \frac{ \sin^2 \left( x_1^2 - x_2^2 \right) - 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 }` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = 0.5 + \frac{ \sin^2 \left( x_1^2 - x_2^2 \right) - 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 }$ + + Equation: + \begin{equation} f(\textbf{x}) = 0.5 + \frac{ \sin^2 \left( x_1^2 - x_2^2 \right) - 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 } \end{equation} + + Domain: + $-100 \leq x_i \leq 100$ - Date: 2018 + Reference: + http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf + """ - Author: Klemen Berkovič + Name = ["SchafferN2"] - License: MIT + def __init__(self, Lower=-100.0, Upper=100.0): + r"""The initialization of Schaffer N. 2 benchmark. - Function: - **Schaffer N. 2 Function** - :math:`f(\textbf{x}) = 0.5 + \frac{ \sin^2 \left( x_1^2 - x_2^2 \right) - 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 }` + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + """ - LaTeX formats: - Inline: - $f(\textbf{x}) = 0.5 + \frac{ \sin^2 \left( x_1^2 - x_2^2 \right) - 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 }$ + Benchmark.__init__(self, Lower, Upper) - Equation: - \begin{equation} f(\textbf{x}) = 0.5 + \frac{ \sin^2 \left( x_1^2 - x_2^2 \right) - 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 } \end{equation} + @staticmethod + def latex_code(): + """Return the latex code of the problem. - Domain: - $-100 \leq x_i \leq 100$ + Returns: + [str] -- latex code. - Reference: - http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - """ - Name = ['SchafferN2'] + """ - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower, Upper) + return r"""$f(\textbf{x}) = 0.5 + \frac{ \sin^2 \left( x_1^2 - x_2^2 \right) - 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 }$""" - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = 0.5 + \frac{ \sin^2 \left( x_1^2 - x_2^2 \right) - 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 }$''' + @classmethod + def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + + def evaluate(D, sol): + return 0.5 + (sin(sol[0] ** 2 - sol[1] ** 2) ** 2 - 0.5) / (1 + 0.001 * (sol[0] ** 2 + sol[1] ** 2)) ** 2 + + return evaluate - @classmethod - def function(cls): - def f(D, x): return 0.5 + (sin(x[0] ** 2 - x[1] ** 2) ** 2 - 0.5) / (1 + 0.001 * (x[0] ** 2 + x[1] ** 2)) ** 2 - return f class SchafferN4(Benchmark): - r"""Implementations of Schaffer N. 2 functions. + r"""Implementations of Schaffer N. 4 functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **Schaffer N. 4 Function** + + :math:`f(\textbf{x}) = 0.5 + \frac{ \cos^2 \left( \sin \left( x_1^2 - x_2^2 \right) \right)- 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 }` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` - Date: 2018 + LaTeX formats: + Inline: + $f(\textbf{x}) = 0.5 + \frac{ \cos^2 \left( \sin \left( x_1^2 - x_2^2 \right) \right)- 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 }$ - Author: Klemen Berkovič + Equation: + \begin{equation} f(\textbf{x}) = 0.5 + \frac{ \cos^2 \left( \sin \left( x_1^2 - x_2^2 \right) \right)- 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 } \end{equation} - License: MIT + Domain: + $-100 \leq x_i \leq 100$ - Function: - **Schaffer N. 2 Function** - :math:`f(\textbf{x}) = 0.5 + \frac{ \cos^2 \left( \sin \left( x_1^2 - x_2^2 \right) \right)- 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 }` + Reference: + http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + """ - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + Name = ["SchafferN4"] - LaTeX formats: - Inline: - $f(\textbf{x}) = 0.5 + \frac{ \cos^2 \left( \sin \left( x_1^2 - x_2^2 \right) \right)- 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 }$ + def __init__(self, Lower=-100.0, Upper=100.0): + r"""The initialization of Schaffer N. 4 benchmark. - Equation: - \begin{equation} f(\textbf{x}) = 0.5 + \frac{ \cos^2 \left( \sin \left( x_1^2 - x_2^2 \right) \right)- 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 } \end{equation} + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - Domain: - $-100 \leq x_i \leq 100$ + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Reference: - http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - """ - Name = ['SchafferN4'] + """ - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower, Upper) + Benchmark.__init__(self, Lower, Upper) - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = 0.5 + \frac{ \cos^2 \left( \sin \left( x_1^2 - x_2^2 \right) \right)- 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 }$''' + @staticmethod + def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + + return r"""$f(\textbf{x}) = 0.5 + \frac{ \cos^2 \left( \sin \left( x_1^2 - x_2^2 \right) \right)- 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 }$""" + + @classmethod + def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + + def evaluate(D, sol): + return 0.5 + (cos(sin(sol[0] ** 2 - sol[1] ** 2)) ** 2 - 0.5) / (1 + 0.001 * (sol[0] ** 2 + sol[1] ** 2)) ** 2 + + return evaluate - @classmethod - def function(cls): - def f(D, x): return 0.5 + (cos(sin(x[0] ** 2 - x[1] ** 2)) ** 2 - 0.5) / (1 + 0.001 * (x[0] ** 2 + x[1] ** 2)) ** 2 - return f class ExpandedSchaffer(Benchmark): - r"""Implementations of Expanded Schaffer functions. + r"""Implementations of Expanded Schaffer functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **Expanded Schaffer Function** + + :math:`f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2$ + + Equation: + \begin{equation} f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2 \end{equation} + + Domain: + $-100 \leq x_i \leq 100$ + + Reference: + http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf + """ + + Name = ["ExpandedSchaffer"] + + def __init__(self, Lower=-100.0, Upper=100.0): + r"""The initialization of Expanded Schaffer benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Date: 2018 + """ - Author: Klemen Berkovič + Benchmark.__init__(self, Lower, Upper) - License: MIT + @staticmethod + def latex_code(): + """Return the latex code of the problem. - Function: - **Expanded Schaffer Function** - :math:`f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2` + Returns: + [str] -- latex code. - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + """ - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + return r"""$f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2$""" - LaTeX formats: - Inline: - $f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2$ + @classmethod + def function(cls): + """Return benchmark evaluation function. - Equation: - \begin{equation} f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2 \end{equation} + Returns: + [fun] -- Evaluation function. - Domain: - $-100 \leq x_i \leq 100$ + """ - Reference: - http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - """ - Name = ['ExpandedSchaffer'] + def g(x, y): + return 0.5 + (sin(sqrt(x ** 2 + y ** 2)) ** 2 - 0.5) / (1 + 0.001 * (x ** 2 + y ** 2)) ** 2 - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower, Upper) + def evaluate(D, sol): - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2$''' + val = 0.0 - @classmethod - def function(cls): - def g(x, y): return 0.5 + (sin(sqrt(x ** 2 + y ** 2)) ** 2 - 0.5) / (1 + 0.001 * (x ** 2 + y ** 2)) ** 2 - def f(D, x): - val = 0.0 - for i in range(1, D): val += g(x[i - 1], x[i]) - return g(x[D - 1], x[0]) + val - return f + for i in range(1, D): + val += g(sol[i - 1], sol[i]) -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return g(sol[D - 1], sol[0]) + val + return evaluate diff --git a/NiaPy/benchmarks/schumerSteiglitz.py b/NiaPy/benchmarks/schumerSteiglitz.py index cc973613..1169193d 100644 --- a/NiaPy/benchmarks/schumerSteiglitz.py +++ b/NiaPy/benchmarks/schumerSteiglitz.py @@ -1,9 +1,11 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Schumer Steiglitz benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['SchumerSteiglitz'] +__all__ = ["SchumerSteiglitz"] class SchumerSteiglitz(Benchmark): @@ -40,18 +42,45 @@ class SchumerSteiglitz(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['SchumerSteiglitz'] + + Name = ["SchumerSteiglitz"] def __init__(self, Lower=-100.0, Upper=100.0): + r"""The initialization of Schumer Steiglitz benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): - return r'''$f(\mathbf{x}) = \sum_{i=1}^D x_i^4$''' + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + + return r"""$f(\mathbf{x}) = \sum_{i=1}^D x_i^4$""" @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/schwefel.py b/NiaPy/benchmarks/schwefel.py index 458c2669..b43a27c6 100644 --- a/NiaPy/benchmarks/schwefel.py +++ b/NiaPy/benchmarks/schwefel.py @@ -1,271 +1,425 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string, mixed-indentation, multiple-statements, line-too-long, no-else-return -"""Implementations of Schwefels functions.""" + +"""Implementations of Schwefels benchmarks.""" from math import sin, fmod, fabs, sqrt from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Schwefel', 'Schwefel221', 'Schwefel222', 'ModifiedSchwefel'] +__all__ = ["Schwefel", "Schwefel221", "Schwefel222", "ModifiedSchwefel"] + class Schwefel(Benchmark): - r"""Implementation of Schewel function. + r"""Implementation of Schewel function. + + Date: 2018 + + Author: Lucija Brezočnik + + License: MIT + + Function: **Schwefel function** + + :math:`f(\textbf{x}) = 418.9829d - \sum_{i=1}^{D} x_i \sin(\sqrt{|x_i|})` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-500, 500]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` - Date: 2018 + LaTeX formats: + Inline: + $f(\textbf{x}) = 418.9829d - \sum_{i=1}^{D} x_i \sin(\sqrt{|x_i|})$ - Author: Lucija Brezočnik + Equation: + \begin{equation} f(\textbf{x}) = 418.9829d - \sum_{i=1}^{D} x_i + \sin(\sqrt{|x_i|}) \end{equation} - License: MIT + Domain: + $-500 \leq x_i \leq 500$ - Function: **Schwefel function** + Reference: https://www.sfu.ca/~ssurjano/schwef.html - :math:`f(\textbf{x}) = 418.9829d - \sum_{i=1}^{D} x_i \sin(\sqrt{|x_i|})` + """ - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-500, 500]`, for all :math:`i = 1, 2,..., D`. + Name = ["Schwefel"] - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + def __init__(self, Lower=-500.0, Upper=500.0): + """The initialization of Schewefel benchmark. - LaTeX formats: - Inline: - $f(\textbf{x}) = 418.9829d - \sum_{i=1}^{D} x_i \sin(\sqrt{|x_i|})$ + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - Equation: - \begin{equation} f(\textbf{x}) = 418.9829d - \sum_{i=1}^{D} x_i - \sin(\sqrt{|x_i|}) \end{equation} + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Domain: - $-500 \leq x_i \leq 500$ + """ - Reference: https://www.sfu.ca/~ssurjano/schwef.html - """ - Name = ['Schwefel'] + Benchmark.__init__(self, Lower, Upper) - def __init__(self, Lower=-500.0, Upper=500.0): Benchmark.__init__(self, Lower, Upper) + @staticmethod + def latex_code(): + """Return the latex code of the problem. - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = 418.9829d - \sum_{i=1}^{D} x_i \sin(\sqrt{|x_i|})$''' + Returns: + [str] -- latex code. + + """ + + return r"""$f(\textbf{x}) = 418.9829d - \sum_{i=1}^{D} x_i \sin(\sqrt{|x_i|})$""" + + @classmethod + def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + + def evaluate(D, sol): + val = 0.0 + for i in range(D): + val += (sol[i] * sin(sqrt(abs(sol[i])))) + return 418.9829 * D - val + return evaluate - @classmethod - def function(cls): - def evaluate(D, sol): - val = 0.0 - for i in range(D): - val += (sol[i] * sin(sqrt(abs(sol[i])))) - return 418.9829 * D - val - return evaluate class Schwefel221(Benchmark): - r"""Schwefel 2.21 function implementation. + r"""Schwefel 2.21 function implementation. + + Date: 2018 + + Author: Grega Vrbančič + + Licence: MIT - Date: 2018 + Function: **Schwefel 2.21 function** - Author: Grega Vrbančič + :math:`f(\mathbf{x})=\max_{i=1,...,D}|x_i|` - Licence: MIT + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. - Function: **Schwefel 2.21 function** + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (0,...,0)` - :math:`f(\mathbf{x})=\max_{i=1,...,D}|x_i|` + LaTeX formats: + Inline: + $f(\mathbf{x})=\max_{i=1,...,D}|x_i|$ - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + Equation: + \begin{equation}f(\mathbf{x}) = \max_{i=1,...,D}|x_i| \end{equation} - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (0,...,0)` + Domain: + $-100 \leq x_i \leq 100$ - LaTeX formats: - Inline: - $f(\mathbf{x})=\max_{i=1,...,D}|x_i|$ + Reference paper: + Jamil, M., and Yang, X. S. (2013). + A literature survey of benchmark functions for global optimisation problems. + International Journal of Mathematical Modelling and Numerical Optimisation, + 4(2), 150-194. - Equation: - \begin{equation}f(\mathbf{x}) = \max_{i=1,...,D}|x_i| \end{equation} + """ - Domain: - $-100 \leq x_i \leq 100$ + Name = ["Schwefel221"] - Reference paper: - Jamil, M., and Yang, X. S. (2013). - A literature survey of benchmark functions for global optimisation problems. - International Journal of Mathematical Modelling and Numerical Optimisation, - 4(2), 150-194. - """ - Name = ['Schwefel221'] + def __init__(self, Lower=-100.0, Upper=100.0): + """The initialization of Schwefel221 benchmark. - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower, Upper) + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - @staticmethod - def latex_code(): - return r'''$f(\mathbf{x})=\max_{i=1,...,D}|x_i|$''' + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + + Benchmark.__init__(self, Lower, Upper) + + @staticmethod + def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + return r'''$f(\mathbf{x})=\max_{i=1,...,D}|x_i|$''' + + @classmethod + def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + + def evaluate(D, sol): + maximum = 0.0 + for i in range(D): + if abs(sol[i]) > maximum: + maximum = abs(sol[i]) + return maximum + return evaluate - @classmethod - def function(cls): - def evaluate(D, sol): - maximum = 0.0 - for i in range(D): - if abs(sol[i]) > maximum: - maximum = abs(sol[i]) - return maximum - return evaluate class Schwefel222(Benchmark): - r"""Schwefel 2.22 function implementation. + r"""Schwefel 2.22 function implementation. + + Date: 2018 + + Author: Grega Vrbančič + + Licence: MIT + + Function: **Schwefel 2.22 function** + + :math:`f(\mathbf{x})=\sum_{i=1}^{D}|x_i|+\prod_{i=1}^{D}|x_i|` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (0,...,0)` + + LaTeX formats: + Inline: + $f(\mathbf{x})=\sum_{i=1}^{D}|x_i|+\prod_{i=1}^{D}|x_i|$ - Date: 2018 + Equation: + \begin{equation}f(\mathbf{x}) = \sum_{i=1}^{D}|x_i| + + \prod_{i=1}^{D}|x_i| \end{equation} - Author: Grega Vrbančič + Domain: + $-100 \leq x_i \leq 100$ - Licence: MIT + Reference paper: + Jamil, M., and Yang, X. S. (2013). + A literature survey of benchmark functions for global optimisation problems. + International Journal of Mathematical Modelling and Numerical Optimisation, + 4(2), 150-194. - Function: **Schwefel 2.22 function** + """ - :math:`f(\mathbf{x})=\sum_{i=1}^{D}|x_i|+\prod_{i=1}^{D}|x_i|` + Name = ["Schwefel222"] - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + def __init__(self, Lower=-100.0, Upper=100.0): + """The initialization of Schwefel222 benchmark. - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (0,...,0)` + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - LaTeX formats: - Inline: - $f(\mathbf{x})=\sum_{i=1}^{D}|x_i|+\prod_{i=1}^{D}|x_i|$ + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Equation: - \begin{equation}f(\mathbf{x}) = \sum_{i=1}^{D}|x_i| + - \prod_{i=1}^{D}|x_i| \end{equation} + """ - Domain: - $-100 \leq x_i \leq 100$ + Benchmark.__init__(self, Lower, Upper) - Reference paper: - Jamil, M., and Yang, X. S. (2013). - A literature survey of benchmark functions for global optimisation problems. - International Journal of Mathematical Modelling and Numerical Optimisation, - 4(2), 150-194. - """ - Name = ['Schwefel222'] + @staticmethod + def latex_code(): + """Return the latex code of the problem. - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower, Upper) + Returns: + [str] -- latex code. - @staticmethod - def latex_code(): - return r'''$f(\mathbf{x})=\sum_{i=1}^{D}|x_i|+\prod_{i=1}^{D}|x_i|$''' + """ + + return r"""$f(\mathbf{x})=\sum_{i=1}^{D}|x_i|+\prod_{i=1}^{D}|x_i|$""" + + @classmethod + def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + + def evaluate(D, sol): + part1 = 0.0 + part2 = 1.0 + for i in range(D): + part1 += abs(sol[i]) + part2 *= abs(sol[i]) + return part1 + part2 + return evaluate - @classmethod - def function(cls): - def evaluate(D, sol): - part1 = 0.0 - part2 = 1.0 - for i in range(D): - part1 += abs(sol[i]) - part2 *= abs(sol[i]) - return part1 + part2 - return evaluate class ModifiedSchwefel(Benchmark): - r"""Implementations of Modified Schwefel functions. + r"""Implementations of Modified Schwefel functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: + **Modified Schwefel Function** + + :math:`f(\textbf{x}) = 418.9829 \cdot D - \sum_{i=1}^D h(x_i) \\ h(x) = g(x + 420.9687462275036) \\ g(z) = \begin{cases} z \sin \left( | z |^{\frac{1}{2}} \right) &\quad | z | \leq 500 \\ \left( 500 - \mod (z, 500) \right) \sin \left( \sqrt{| 500 - \mod (z, 500) |} \right) - \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z > 500 \\ \left( \mod (| z |, 500) - 500 \right) \sin \left( \sqrt{| \mod (|z|, 500) - 500 |} \right) + \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z < -500\end{cases}` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = 418.9829 \cdot D - \sum_{i=1}^D h(x_i) \\ h(x) = g(x + 420.9687462275036) \\ g(z) = \begin{cases} z \sin \left( | z |^{\frac{1}{2}} \right) &\quad | z | \leq 500 \\ \left( 500 - \mod (z, 500) \right) \sin \left( \sqrt{| 500 - \mod (z, 500) |} \right) - \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z > 500 \\ \left( \mod (| z |, 500) - 500 \right) \sin \left( \sqrt{| \mod (|z|, 500) - 500 |} \right) + \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z < -500\end{cases}$ + + Equation: + \begin{equation} f(\textbf{x}) = 418.9829 \cdot D - \sum_{i=1}^D h(x_i) \\ h(x) = g(x + 420.9687462275036) \\ g(z) = \begin{cases} z \sin \left( | z |^{\frac{1}{2}} \right) &\quad | z | \leq 500 \\ \left( 500 - \mod (z, 500) \right) \sin \left( \sqrt{| 500 - \mod (z, 500) |} \right) - \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z > 500 \\ \left( \mod (| z |, 500) - 500 \right) \sin \left( \sqrt{| \mod (|z|, 500) - 500 |} \right) + \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z < -500\end{cases} \end{equation} + + Domain: + $-100 \leq x_i \leq 100$ + + Reference: + http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf + + """ + + Name = ["ModifiedSchwefel"] - Date: 2018 + def __init__(self, Lower=-100.0, Upper=100.0): + """The initialization of Modified Schwefel benchmark. - Author: Klemen Berkovič + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - License: MIT + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Function: - **Modified Schwefel Function** + """ - :math:`f(\textbf{x}) = 418.9829 \cdot D - \sum_{i=1}^D h(x_i) \\ h(x) = g(x + 420.9687462275036) \\ g(z) = \begin{cases} z \sin \left( | z |^{\frac{1}{2}} \right) &\quad | z | \leq 500 \\ \left( 500 - \mod (z, 500) \right) \sin \left( \sqrt{| 500 - \mod (z, 500) |} \right) - \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z > 500 \\ \left( \mod (| z |, 500) - 500 \right) \sin \left( \sqrt{| \mod (|z|, 500) - 500 |} \right) + \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z < -500\end{cases}` + Benchmark.__init__(self, Lower, Upper) - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + @staticmethod + def latex_code(): + """Return the latex code of the problem. - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + Returns: + [str] -- latex code. - LaTeX formats: - Inline: - $f(\textbf{x}) = 418.9829 \cdot D - \sum_{i=1}^D h(x_i) \\ h(x) = g(x + 420.9687462275036) \\ g(z) = \begin{cases} z \sin \left( | z |^{\frac{1}{2}} \right) &\quad | z | \leq 500 \\ \left( 500 - \mod (z, 500) \right) \sin \left( \sqrt{| 500 - \mod (z, 500) |} \right) - \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z > 500 \\ \left( \mod (| z |, 500) - 500 \right) \sin \left( \sqrt{| \mod (|z|, 500) - 500 |} \right) + \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z < -500\end{cases}$ + """ - Equation: - \begin{equation} f(\textbf{x}) = 418.9829 \cdot D - \sum_{i=1}^D h(x_i) \\ h(x) = g(x + 420.9687462275036) \\ g(z) = \begin{cases} z \sin \left( | z |^{\frac{1}{2}} \right) &\quad | z | \leq 500 \\ \left( 500 - \mod (z, 500) \right) \sin \left( \sqrt{| 500 - \mod (z, 500) |} \right) - \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z > 500 \\ \left( \mod (| z |, 500) - 500 \right) \sin \left( \sqrt{| \mod (|z|, 500) - 500 |} \right) + \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z < -500\end{cases} \end{equation} + return r"""$f(\textbf{x}) = 418.9829 \cdot D - \sum_{i=1}^D h(x_i) \\ h(x) = g(x + 420.9687462275036) \\ g(z) = \begin{cases} z \sin \left( | z |^{\frac{1}{2}} \right) &\quad | z | \leq 500 \\ \left( 500 - \mod (z, 500) \right) \sin \left( \sqrt{| 500 - \mod (z, 500) |} \right) - \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z > 500 \\ \left( \mod (| z |, 500) - 500 \right) \sin \left( \sqrt{| \mod (|z|, 500) - 500 |} \right) + \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z < -500\end{cases}$""" - Domain: - $-100 \leq x_i \leq 100$ + @classmethod + def function(cls): + """Return benchmark evaluation function. - Reference: - http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - """ - Name = ['ModifiedSchwefel'] + Returns: + [fun] -- Evaluation function. - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower, Upper) + """ - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = 418.9829 \cdot D - \sum_{i=1}^D h(x_i) \\ h(x) = g(x + 420.9687462275036) \\ g(z) = \begin{cases} z \sin \left( | z |^{\frac{1}{2}} \right) &\quad | z | \leq 500 \\ \left( 500 - \mod (z, 500) \right) \sin \left( \sqrt{| 500 - \mod (z, 500) |} \right) - \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z > 500 \\ \left( \mod (| z |, 500) - 500 \right) \sin \left( \sqrt{| \mod (|z|, 500) - 500 |} \right) + \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z < -500\end{cases}$''' + def g(z, D): + if z > 500: + return (500 - fmod(z, 500)) * sin(sqrt(fabs(500 - fmod(z, 500)))) - (z - 500) ** 2 / (10000 * D) + elif z < -500: + return (fmod(z, 500) - 500) * sin(sqrt(fabs(fmod(z, 500) - 500))) + (z - 500) ** 2 / (10000 * D) + return z * sin(fabs(z) ** (1 / 2)) + + def h(x, D): + return g(x + 420.9687462275036, D) + + def evaluate(D, sol): + val = 0.0 + for i in range(D): + val += h(sol[i], D) + return 418.9829 * D - val + return evaluate - @classmethod - def function(cls): - def g(z, D): - if z > 500: return (500 - fmod(z, 500)) * sin(sqrt(fabs(500 - fmod(z, 500)))) - (z - 500) ** 2 / (10000 * D) - elif z < -500: return (fmod(z, 500) - 500) * sin(sqrt(fabs(fmod(z, 500) - 500))) + (z - 500) ** 2 / (10000 * D) - return z * sin(fabs(z) ** (1 / 2)) - def h(x, D): return g(x + 420.9687462275036, D) - def f(D, sol): - val = 0.0 - for i in range(D): val += h(sol[i], D) - return 418.9829 * D - val - return f class ExpandedScaffer(Benchmark): - r"""Implementations of High Conditioned Elliptic functions. + r"""Implementation of High Conditioned Elliptic functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: + **High Conditioned Elliptic Function** + + :math:`f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2$ + + Equation: + \begin{equation} f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2 \end{equation} + + Domain: + $-100 \leq x_i \leq 100$ + + Reference: + http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf + + """ + + Name = ["ExpandedScaffer"] + + def __init__(self, Lower=-100.0, Upper=100.0): + """The initialization of Expanded Scaffer benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - Date: 2018 + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Author: Klemen Berkovič + """ - License: MIT + Benchmark.__init__(self, Lower=Lower, Upper=Lower) - Function: - **High Conditioned Elliptic Function** + @staticmethod + def latex_code(): + """Return latex code of the problem. - :math:`f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2` + Returns: + [str] -- latex code. - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + """ - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + return r"""$f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2$""" - LaTeX formats: - Inline: - $f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2$ + @classmethod + def function(cls): + """Return benchmark evaluation function. - Equation: - \begin{equation} f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2 \end{equation} + Returns: + [fun] -- Evaluation function. - Domain: - $-100 \leq x_i \leq 100$ + """ - Reference: - http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - """ - Name = ['ExpandedScaffer'] + def g(x, y): + return 0.5 + (sin(sqrt(x ** 2 + y ** 2)) ** 2 - 0.5) / (1 + 0.001 * (x ** 2 + y ** 2)) ** 2 - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower=Lower, Upper=Lower) + def evaluate(D, x): + val = 0.0 - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2$''' + for i in range(1, D): + val += g(x[i - 1], x[i]) - @classmethod - def function(cls): - def g(x, y): return 0.5 + (sin(sqrt(x ** 2 + y ** 2)) ** 2 - 0.5) / (1 + 0.001 * (x ** 2 + y ** 2)) ** 2 - def f(D, x): - val = 0.0 - for i in range(1, D): val += g(x[i - 1], x[i]) - return g(x[D - 1], x[0]) + val - return f + return g(x[D - 1], x[0]) + val -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/sphere.py b/NiaPy/benchmarks/sphere.py index 006d0c90..78e05982 100644 --- a/NiaPy/benchmarks/sphere.py +++ b/NiaPy/benchmarks/sphere.py @@ -1,159 +1,258 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string, mixed-indentation, redefined-builtin, multiple-statements + +"""Implementations of Sphere benchmarks.""" from numpy import abs from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Sphere', 'Sphere2', 'Sphere3'] +__all__ = ["Sphere", "Sphere2", "Sphere3"] + class Sphere(Benchmark): - r"""Implementation of Sphere functions. + r"""Implementation of Sphere functions. + + Date: 2018 + + Authors: Iztok Fister Jr. + + License: MIT + + Function: **Sphere function** + + :math:`f(\mathbf{x}) = \sum_{i=1}^D x_i^2` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [0, 10]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (0,...,0)` + + LaTeX formats: + Inline: + $f(\mathbf{x}) = \sum_{i=1}^D x_i^2$ + + Equation: + \begin{equation}f(\mathbf{x}) = \sum_{i=1}^D x_i^2 \end{equation} + + Domain: + $0 \leq x_i \leq 10$ + + Reference paper: + Jamil, M., and Yang, X. S. (2013). + A literature survey of benchmark functions for global optimisation problems. + International Journal of Mathematical Modelling and Numerical Optimisation, + 4(2), 150-194. - Date: 2018 + """ - Authors: Iztok Fister Jr. + Name = ["Sphere"] - License: MIT + def __init__(self, Lower=-5.12, Upper=5.12): + r"""The initialization of Sphere benchmark. - Function: **Sphere function** + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - :math:`f(\mathbf{x}) = \sum_{i=1}^D x_i^2` + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [0, 10]`, for all :math:`i = 1, 2,..., D`. + """ - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (0,...,0)` + Benchmark.__init__(self, Lower, Upper) - LaTeX formats: - Inline: - $f(\mathbf{x}) = \sum_{i=1}^D x_i^2$ + @staticmethod + def latex_code(): + """Return the latex code of the problem. - Equation: - \begin{equation}f(\mathbf{x}) = \sum_{i=1}^D x_i^2 \end{equation} + Returns: + [str] -- latex code. - Domain: - $0 \leq x_i \leq 10$ + """ - Reference paper: - Jamil, M., and Yang, X. S. (2013). - A literature survey of benchmark functions for global optimisation problems. - International Journal of Mathematical Modelling and Numerical Optimisation, - 4(2), 150-194. - """ - Name = ['Sphere'] + return r"""$f(\mathbf{x}) = \sum_{i=1}^D x_i^2$""" - def __init__(self, Lower=-5.12, Upper=5.12): Benchmark.__init__(self, Lower, Upper) + @classmethod + def function(cls): + """Return benchmark evaluation function. - @staticmethod - def latex_code(): - return r'''$f(\mathbf{x}) = \sum_{i=1}^D x_i^2$''' + Returns: + [fun] -- Evaluation function. + + """ + + def evaluate(D, sol): + val = 0.0 + + for i in range(D): + val += sol[i] ** 2 + + return val + + return evaluate - @classmethod - def function(cls): - def evaluate(D, sol): - val = 0.0 - for i in range(D): val += sol[i] ** 2 - return val - return evaluate class Sphere2(Benchmark): - r"""Implementation of Sphere with different powers function. + r"""Implementation of Sphere with different powers function. + + Date: 2018 + + Authors: Klemen Berkovič + + License: MIT + + Function: **Sun of different powers function** + + :math:`f(\textbf{x}) = \sum_{i = 1}^D | x_i |^{i + 1}` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-1, 1]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (0,...,0)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = \sum_{i = 1}^D | x_i |^{i + 1}$ - Date: 2018 + Equation: + \begin{equation} f(\textbf{x}) = \sum_{i = 1}^D | x_i |^{i + 1} \end{equation} - Authors: Klemen Berkovič + Domain: + $-1 \leq x_i \leq 1$ - License: MIT + Reference URL: https://www.sfu.ca/~ssurjano/sumpow.html - Function: **Sun of different powers function** + """ - :math:`f(\textbf{x}) = \sum_{i = 1}^D | x_i |^{i + 1}` + Name = ["Sphere2"] - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-1, 1]`, for all :math:`i = 1, 2,..., D`. + def __init__(self, Lower=-1.0, Upper=1.0): + r"""The initialization of Sphere benchmark. - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (0,...,0)` + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - LaTeX formats: - Inline: - $f(\textbf{x}) = \sum_{i = 1}^D | x_i |^{i + 1}$ + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Equation: - \begin{equation} f(\textbf{x}) = \sum_{i = 1}^D | x_i |^{i + 1} \end{equation} + """ - Domain: - $-1 \leq x_i \leq 1$ + Benchmark.__init__(self, Lower, Upper) - Reference URL: - https://www.sfu.ca/~ssurjano/sumpow.html - """ - Name = ['Sphere2'] + @staticmethod + def latex_code(): + """Return the latex code of the problem. - def __init__(self, Lower=-1., Upper=1.): Benchmark.__init__(self, Lower, Upper) + Returns: + [str] -- latex code. - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = \sum_{i = 1}^D | x_i |^{i + 1}$''' + """ + + return r"""$f(\textbf{x}) = \sum_{i = 1}^D | x_i |^{i + 1}$""" + + @classmethod + def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + + def evaluate(D, sol): + val = 0.0 + + for i in range(D): + val += abs(sol[i]) ** (i + 2) + + return val + + return evaluate - @classmethod - def function(cls): - def evaluate(D, sol): - val = 0.0 - for i in range(D): val += abs(sol[i]) ** (i + 2) - return val - return evaluate class Sphere3(Benchmark): - r"""Implementation of rotated hyper-ellipsoid function. + r"""Implementation of rotated hyper-ellipsoid function. + + Date: 2018 + + Authors: Klemen Berkovič + + License: MIT + + Function: **Sun of rotated hyper-elliposid function** + + :math:`f(\textbf{x}) = \sum_{i = 1}^D \sum_{j = 1}^i x_j^2` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-65.536, 65.536]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (0,...,0)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = \sum_{i = 1}^D \sum_{j = 1}^i x_j^2$ + + Equation: + \begin{equation} f(\textbf{x}) = \sum_{i = 1}^D \sum_{j = 1}^i x_j^2 \end{equation} + + Domain: + $-65.536 \leq x_i \leq 65.536$ + + Reference URL: https://www.sfu.ca/~ssurjano/rothyp.html + + """ + + Name = ["Sphere3"] + + def __init__(self, Lower=-65.536, Upper=65.536): + r"""The initialization of Sphere3 benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ - Date: 2018 + Benchmark.__init__(self, Lower, Upper) - Authors: Klemen Berkovič + @staticmethod + def latex_code(): + """Return the latex code of the problem. - License: MIT + Returns: + [str] -- latex code. - Function: **Sun of rotated hyper-elliposid function** + """ - :math:`f(\textbf{x}) = \sum_{i = 1}^D \sum_{j = 1}^i x_j^2` + return r"""$f(\textbf{x}) = \sum_{i = 1}^D \sum_{j = 1}^i x_j^2$""" - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-65.536, 65.536]`, for all :math:`i = 1, 2,..., D`. + @classmethod + def function(cls): + """Return benchmark evaluation function. - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (0,...,0)` + Returns: + [fun] -- Evaluation function. - LaTeX formats: - Inline: - $f(\textbf{x}) = \sum_{i = 1}^D \sum_{j = 1}^i x_j^2$ + """ - Equation: - \begin{equation} f(\textbf{x}) = \sum_{i = 1}^D \sum_{j = 1}^i x_j^2 \end{equation} + def evaluate(D, sol): - Domain: - $-65.536 \leq x_i \leq 65.536$ + val = 0.0 - Reference URL: - https://www.sfu.ca/~ssurjano/rothyp.html - """ - Name = ['Sphere3'] + for i in range(D): + v = 0.0 - def __init__(self, Lower=-65.536, Upper=65.536): Benchmark.__init__(self, Lower, Upper) + for j in range(i + 1): + val += abs(sol[j]) ** 2 - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = \sum_{i = 1}^D \sum_{j = 1}^i x_j^2$''' + val += v - @classmethod - def function(cls): - def evaluate(D, sol): - val = 0.0 - for i in range(D): - v = .0 - for j in range(i + 1): val += abs(sol[j]) ** 2 - val += v - return val - return evaluate + return val -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/step.py b/NiaPy/benchmarks/step.py index 9cfbc980..1d3dd279 100644 --- a/NiaPy/benchmarks/step.py +++ b/NiaPy/benchmarks/step.py @@ -1,11 +1,12 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string -"""Implementations of Step functions.""" + +"""Implementations of Step benchmarks.""" import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Step', 'Step2', 'Step3'] +__all__ = ["Step", "Step2", "Step3"] + class Step(Benchmark): r"""Implementation of Step function. @@ -44,19 +45,46 @@ class Step(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Step'] + + Name = ["Step"] def __init__(self, Lower=-100.0, Upper=100.0): + r"""The initialization of Step benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): - return r'''$f(\mathbf{x}) = \sum_{i=1}^D \left( \lfloor \left | - x_i \right | \rfloor \right)$''' + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + + return r"""$f(\mathbf{x}) = \sum_{i=1}^D \left( \lfloor \left | + x_i \right | \rfloor \right)$""" @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 @@ -104,18 +132,45 @@ class Step2(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Step2'] + + Name = ["Step2"] def __init__(self, Lower=-100.0, Upper=100.0): + r"""The initialization of Step2 benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): - return r'''$f(\mathbf{x}) = \sum_{i=1}^D \left( \lfloor x_i + 0.5 \rfloor \right)^2$''' + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + + return r"""$f(\mathbf{x}) = \sum_{i=1}^D \left( \lfloor x_i + 0.5 \rfloor \right)^2$""" @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 @@ -163,18 +218,45 @@ class Step3(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Step3'] + + Name = ["Step3"] def __init__(self, Lower=-100.0, Upper=100.0): + r"""The initialization of Alpine1 benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): - return r'''$f(\mathbf{x}) = \sum_{i=1}^D \left( \lfloor x_i^2 \rfloor \right)$''' + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + + return r"""$f(\mathbf{x}) = \sum_{i=1}^D \left( \lfloor x_i^2 \rfloor \right)$""" @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/stepint.py b/NiaPy/benchmarks/stepint.py index 711e9045..d9514e34 100644 --- a/NiaPy/benchmarks/stepint.py +++ b/NiaPy/benchmarks/stepint.py @@ -1,9 +1,12 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Stepint benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Stepint'] +__all__ = ["Stepint"] + class Stepint(Benchmark): r"""Implementation of Stepint functions. @@ -39,18 +42,45 @@ class Stepint(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Stepint'] + + Name = ["Stepint"] def __init__(self, Lower=-5.12, Upper=5.12): + """The initialization of Stepint benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + return r'''$f(\mathbf{x}) = \sum_{i=1}^D x_i^2$''' @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/styblinskiTang.py b/NiaPy/benchmarks/styblinskiTang.py index 9287b6d9..edf0e529 100644 --- a/NiaPy/benchmarks/styblinskiTang.py +++ b/NiaPy/benchmarks/styblinskiTang.py @@ -1,9 +1,12 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Styblinski Tang benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['StyblinskiTang'] +__all__ = ["StyblinskiTang"] + class StyblinskiTang(Benchmark): r"""Implementation of Styblinski-Tang functions. @@ -42,19 +45,46 @@ class StyblinskiTang(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['StyblinskiTang'] + + Name = ["StyblinskiTang"] def __init__(self, Lower=-5.0, Upper=5.0): + r"""The initialization of Styblinski Tang benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): - return r'''$f(\mathbf{x}) = \frac{1}{2} \sum_{i=1}^D \left( - x_i^4 - 16x_i^2 + 5x_i \right) $''' + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + + return r"""$f(\mathbf{x}) = \frac{1}{2} \sum_{i=1}^D \left( + x_i^4 - 16x_i^2 + 5x_i \right) $""" @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/sumSquares.py b/NiaPy/benchmarks/sumSquares.py index 6f937842..c7cd3658 100644 --- a/NiaPy/benchmarks/sumSquares.py +++ b/NiaPy/benchmarks/sumSquares.py @@ -1,9 +1,12 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Sum Squares benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['SumSquares'] +__all__ = ["SumSquares"] + class SumSquares(Benchmark): r"""Implementation of Sum Squares functions. @@ -39,18 +42,45 @@ class SumSquares(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['SumSquares'] + + Name = ["SumSquares"] def __init__(self, Lower=-10.0, Upper=10.0): + """The initialization of Sum Squares benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): - return r'''$f(\mathbf{x}) = \sum_{i=1}^D i x_i^2$''' + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + + return r"""$f(\mathbf{x}) = \sum_{i=1}^D i x_i^2$""" @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/trid.py b/NiaPy/benchmarks/trid.py index 1ba5e46d..7eef9dfa 100644 --- a/NiaPy/benchmarks/trid.py +++ b/NiaPy/benchmarks/trid.py @@ -4,57 +4,86 @@ from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Trid'] +__all__ = ["Trid"] + class Trid(Benchmark): - r"""Implementations of Trid functions. + r"""Implementations of Trid functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **Levy Function** + + :math:`f(\textbf{x}) = \sum_{i = 1}^D \left( x_i - 1 \right)^2 - \sum_{i = 2}^D x_i x_{i - 1}` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-D^2, D^2]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + :math:`f(\textbf{x}^*) = \frac{-D(D + 4)(D - 1)}{6}` at :math:`\textbf{x}^* = (1 (D + 1 - 1), \cdots , i (D + 1 - i) , \cdots , D (D + 1 - D))` + + LaTeX formats: + Inline: + $f(\textbf{x}) = \sum_{i = 1}^D \left( x_i - 1 \right)^2 - \sum_{i = 2}^D x_i x_{i - 1}$ + + Equation: + \begin{equation} f(\textbf{x}) = \sum_{i = 1}^D \left( x_i - 1 \right)^2 - \sum_{i = 2}^D x_i x_{i - 1} \end{equation} + + Domain: + $-D^2 \leq x_i \leq D^2$ + + Reference: https://www.sfu.ca/~ssurjano/trid.html + + """ + + Name = ["Trid"] + + def __init__(self, D=2): + r"""The initialization of Trid benchmark. - Date: 2018 + Args: + D (Optional[int]): Dimension of problem. - Author: Klemen Berkovič + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - License: MIT + """ - Function: - **Levy Function** + Benchmark.__init__(self, -(D ** 2), D ** 2) - :math:`f(\textbf{x}) = \sum_{i = 1}^D \left( x_i - 1 \right)^2 - \sum_{i = 2}^D x_i x_{i - 1}` + @staticmethod + def latex_code(): + """Return the latex code of the problem. - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-D^2, D^2]`, for all :math:`i = 1, 2,..., D`. + Returns: + [str] -- latex code. - **Global minimum:** - :math:`f(\textbf{x}^*) = \frac{-D(D + 4)(D - 1)}{6}` at :math:`\textbf{x}^* = (1 (D + 1 - 1), \cdots , i (D + 1 - i) , \cdots , D (D + 1 - D))` + """ - LaTeX formats: - Inline: - $f(\textbf{x}) = \sum_{i = 1}^D \left( x_i - 1 \right)^2 - \sum_{i = 2}^D x_i x_{i - 1}$ + return r"""$f(\textbf{x}) = \sum_{i = 1}^D \left( x_i - 1 \right)^2 - \sum_{i = 2}^D x_i x_{i - 1}$""" - Equation: - \begin{equation} f(\textbf{x}) = \sum_{i = 1}^D \left( x_i - 1 \right)^2 - \sum_{i = 2}^D x_i x_{i - 1} \end{equation} + @classmethod + def function(cls): + """Return benchmark evaluation function. - Domain: - $-D^2 \leq x_i \leq D^2$ + Returns: + [fun] -- Evaluation function. - Reference: - https://www.sfu.ca/~ssurjano/trid.html - """ - Name = ['Trid'] + """ - def __init__(self, D=2): Benchmark.__init__(self, -(D ** 2), D ** 2) + def evaluate(D, sol): + v1, v2 = 0.0, 0.0 - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = \sum_{i = 1}^D \left( x_i - 1 \right)^2 - \sum_{i = 2}^D x_i x_{i - 1}$''' + for i in range(D): + v1 += (sol[i] - 1) ** 2 + for i in range(1, D): + v2 += sol[i] * sol[i - 1] - @classmethod - def function(cls): - def f(D, X): - v1, v2 = 0.0, 0.0 - for i in range(D): v1 += (X[i] - 1) ** 2 - for i in range(1, D): v2 += X[i] * X[i - 1] - return v1 - v2 - return f + return v1 - v2 -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/weierstrass.py b/NiaPy/benchmarks/weierstrass.py index 7b709190..25217f30 100644 --- a/NiaPy/benchmarks/weierstrass.py +++ b/NiaPy/benchmarks/weierstrass.py @@ -1,68 +1,101 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, line-too-long, multiple-statements + """Implementations of Weierstrass functions.""" from math import pi, cos from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Weierstrass'] +__all__ = ["Weierstrass"] + class Weierstrass(Benchmark): - r"""Implementations of Weierstrass functions. + r"""Implementations of Weierstrass functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **Weierstass Function** + + :math:`f(\textbf{x}) = \sum_{i=1}^D \left( \sum_{k=0}^{k_{max}} a^k \cos\left( 2 \pi b^k ( x_i + 0.5) \right) \right) - D \sum_{k=0}^{k_{max}} a^k \cos \left( 2 \pi b^k \cdot 0.5 \right)` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + Default value of a = 0.5, b = 3 and k_max = 20. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + + LaTeX formats: + Inline: + $$f(\textbf{x}) = \sum_{i=1}^D \left( \sum_{k=0}^{k_{max}} a^k \cos\left( 2 \pi b^k ( x_i + 0.5) \right) \right) - D \sum_{k=0}^{k_{max}} a^k \cos \left( 2 \pi b^k \cdot 0.5 \right) + + Equation: + \begin{equation} f(\textbf{x}) = \sum_{i=1}^D \left( \sum_{k=0}^{k_{max}} a^k \cos\left( 2 \pi b^k ( x_i + 0.5) \right) \right) - D \sum_{k=0}^{k_{max}} a^k \cos \left( 2 \pi b^k \cdot 0.5 \right) \end{equation} + + Domain: + $-100 \leq x_i \leq 100$ + + Reference: + http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf + """ + + Name = ["Weierstrass"] + + def __init__(self, Lower=-100.0, Upper=100.0, a=0.5, b=3, k_max=20): + """The initialization of Weierstrass benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + a (Optional[float]) -- a value. (default: {0.5}) + b (Optional[int]) -- b value. (default: {3}) + k_max (Optional[int]) -- k_max value. (default: {20}) + """ + + Benchmark.__init__(self, Lower, Upper) + self.a = a + self.b = b + self.k_max = k_max - Date: 2018 + @staticmethod + def latex_code(): + """Return the latex code of the problem. - Author: Klemen Berkovič + Returns: + [str] -- latex code. - License: MIT + """ - Function: - **Weierstass Function** + return r"""$$f(\textbf{x}) = \sum_{i=1}^D \left( \sum_{k=0}^{k_{max}} a^k \cos\left( 2 \pi b^k ( x_i + 0.5) \right) \right) - D \sum_{k=0}^{k_{max}} a^k \cos \left( 2 \pi b^k \cdot 0.5 \right)""" - :math:`f(\textbf{x}) = \sum_{i=1}^D \left( \sum_{k=0}^{k_{max}} a^k \cos\left( 2 \pi b^k ( x_i + 0.5) \right) \right) - D \sum_{k=0}^{k_{max}} a^k \cos \left( 2 \pi b^k \cdot 0.5 \right)` + @classmethod + def function(cls): + """Return benchmark evaluation function. - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. - Default value of a = 0.5, b = 3 and k_max = 20. + Returns: + [fun] -- Evaluation function. - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + """ - LaTeX formats: - Inline: - $$f(\textbf{x}) = \sum_{i=1}^D \left( \sum_{k=0}^{k_{max}} a^k \cos\left( 2 \pi b^k ( x_i + 0.5) \right) \right) - D \sum_{k=0}^{k_{max}} a^k \cos \left( 2 \pi b^k \cdot 0.5 \right) + def evaluate(D, sol, a=cls.a, b=cls.b, k_max=cls.k_max): - Equation: - \begin{equation} f(\textbf{x}) = \sum_{i=1}^D \left( \sum_{k=0}^{k_{max}} a^k \cos\left( 2 \pi b^k ( x_i + 0.5) \right) \right) - D \sum_{k=0}^{k_{max}} a^k \cos \left( 2 \pi b^k \cdot 0.5 \right) \end{equation} + val1 = 0.0 - Domain: - $-100 \leq x_i \leq 100$ + for i in range(D): + val = 0.0 - Reference: - http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - """ - Name = ['Weierstrass'] - a, b, k_max = 0.5, 3, 20 + for k in range(k_max): + val += a ** k * cos(2 * pi * b ** k * (sol[i] + 0.5)) - def __init__(self, Lower=-100.0, Upper=100.0, a=0.5, b=3, k_max=20): - Benchmark.__init__(self, Lower, Upper) - Weierstrass.a, Weierstrass.b, Weierstrass.k_max = a, b, k_max + val1 += val + val2 = 0.0 - @staticmethod - def latex_code(): - return r'''$$f(\textbf{x}) = \sum_{i=1}^D \left( \sum_{k=0}^{k_{max}} a^k \cos\left( 2 \pi b^k ( x_i + 0.5) \right) \right) - D \sum_{k=0}^{k_{max}} a^k \cos \left( 2 \pi b^k \cdot 0.5 \right)''' + for k in range(k_max): + val2 += a ** k * cos(2 * pi * b ** k * 0.5) - @classmethod - def function(cls): - def f(D, sol, a=cls.a, b=cls.b, k_max=cls.k_max): - val1 = 0.0 - for i in range(D): - val = 0.0 - for k in range(k_max): val += a ** k * cos(2 * pi * b ** k * (sol[i] + 0.5)) - val1 += val - val2 = 0.0 - for k in range(k_max): val2 += a ** k * cos(2 * pi * b ** k * 0.5) - return val1 - D * val2 - return f + return val1 - D * val2 -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/whitley.py b/NiaPy/benchmarks/whitley.py index d6423fb5..23d4f3b8 100644 --- a/NiaPy/benchmarks/whitley.py +++ b/NiaPy/benchmarks/whitley.py @@ -1,9 +1,12 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Whitley benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Whitley'] +__all__ = ["Whitley"] + class Whitley(Benchmark): r"""Implementation of Whitley function. @@ -46,20 +49,47 @@ class Whitley(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Whitley'] + + Name = ["Whitley"] def __init__(self, Lower=-10.24, Upper=10.24): + """The initialization of Whitley benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + return r'''$f(\mathbf{x}) = \sum_{i=1}^D \sum_{j=1}^D \left(\frac{(100(x_i^2-x_j)^2 + (1-x_j)^2)^2}{4000} - \cos(100(x_i^2-x_j)^2 + (1-x_j)^2)+1\right)$''' @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/zakharov.py b/NiaPy/benchmarks/zakharov.py index ad9b367e..cacb684a 100644 --- a/NiaPy/benchmarks/zakharov.py +++ b/NiaPy/benchmarks/zakharov.py @@ -1,59 +1,88 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, multiple-statements, line-too-long + """Implementations of Zakharov function.""" from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Zakharov'] +__all__ = ["Zakharov"] + class Zakharov(Benchmark): - r"""Implementations of Zakharov functions. + r"""Implementations of Zakharov functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: + **Levy Function** + + :math:`f(\textbf{x}) = \sum_{i = 1}^D x_i^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^4` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-5, 10]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + :math:`f(\textbf{x}^*) = 0` at :math:`\textbf{x}^* = (0, \cdots, 0)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = \sum_{i = 1}^D x_i^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^4$ + + Equation: + \begin{equation} f(\textbf{x}) = \sum_{i = 1}^D x_i^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^4 \end{equation} + + Domain: + $-5 \leq x_i \leq 10$ + + Reference: https://www.sfu.ca/~ssurjano/levy.html + + """ + + Name = ["Zakharov"] - Date: 2018 + def __init__(self, Lower=-5.0, Upper=10.0): + r"""The initialization of Zakharov benchmark. - Author: Klemen Berkovič + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - License: MIT + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Function: - **Levy Function** + """ + Benchmark.__init__(self, Lower, Upper) - :math:`f(\textbf{x}) = \sum_{i = 1}^D x_i^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^4` + @staticmethod + def latex_code(): + """Return the latex code of the problem. - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-5, 10]`, for all :math:`i = 1, 2,..., D`. + Returns: + [str] -- latex code. - **Global minimum:** - :math:`f(\textbf{x}^*) = 0` at :math:`\textbf{x}^* = (0, \cdots, 0)` + """ - LaTeX formats: - Inline: - $f(\textbf{x}) = \sum_{i = 1}^D x_i^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^4$ + return r"""$f(\textbf{x}) = \sum_{i = 1}^D x_i^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^4$""" - Equation: - \begin{equation} f(\textbf{x}) = \sum_{i = 1}^D x_i^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^4 \end{equation} + @classmethod + def function(cls): + """Return benchmark evaluation function. - Domain: - $-5 \leq x_i \leq 10$ + Returns: + [fun] -- Evaluation function. - Reference: - https://www.sfu.ca/~ssurjano/levy.html - """ - Name = ['Zakharov'] + """ - def __init__(self, Lower=-5.0, Upper=10.0): Benchmark.__init__(self, Lower, Upper) + def evaluate(D, sol): + v1, v2 = 0.0, 0.0 - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = \sum_{i = 1}^D x_i^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^4$''' + for i in range(D): + v1, v2 = v1 + sol[i] ** 2, v2 + 0.5 * (i + 1) * sol[i] - @classmethod - def function(cls): - def f(D, X): - v1, v2 = 0.0, 0.0 - for i in range(D): v1, v2 = v1 + X[i] ** 2, v2 + 0.5 * (i + 1) * X[i] - return v1 + v2 ** 2 + v2 ** 4 - return f + return v1 + v2 ** 2 + v2 ** 4 -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/Pipfile b/Pipfile index bb47ae1a..2414056d 100644 --- a/Pipfile +++ b/Pipfile @@ -9,35 +9,35 @@ scipy = ">=1.2.1" enum34 = {version = ">=1.1.6",markers = "python_version < '3.4'"} XlsxWriter = ">=1.1.5" matplotlib = ">=2.2.4" -flake8 = "*" [dev-packages] -pylint = ">=1.9.3" -pycodestyle = "*" -pydocstyle = "*" -pytest = "~=3.3" -pytest-describe = "*" -pytest-expecter = "*" -pytest-random = "*" -pytest-cov = "*" -freezegun = "*" -coverage-space = "*" -docutils = "*" -"pathlib2" = "*" -wheel = "*" -twine = "*" -sniffer = "*" -singledispatch = "*" -configparser = "*" -sphinx-rtd-theme = "*" -funcsigs = "*" -futures = "==3.1.1" -"autopep8" = "*" -sphinx-autobuild = "*" -scandir = "*" -Pygments = "*" -"backports.functools_lru_cache" = "*" -Sphinx = "*" -MacFSEvents = {version = "*",sys_platform = "== 'darwin'"} -pep8 = "*" -flake8-docstrings = "*" +flake8 = "~=3.7.7" +flake8-docstrings = "~=1.3.0" +flake8-rst-docstrings = ">=0.0.8" +flake8-bugbear = "~=19.3.0" +flake8-bandit = "~=2.1.0" +pycodestyle = "~=2.5.0" +pydocstyle = "~=3.0.0" +pytest = "~=4.4.0" +pytest-describe = "~=0.12.0" +pytest-expecter = "~=1.3" +pytest-random = "~=0.02" +pytest-cov = "~=2.6.1" +sniffer = "~=0.4.0" +freezegun = "~=0.3.11" +coverage-space = "~=1.0.2" +docutils = "~=0.14" +scandir = "~=1.10.0" +pathlib2 = "~=2.3.3" +wheel = "~=0.33.1" +twine = "~=1.13.0" +singledispatch = "~=3.4.0.3" +configparser = "~=3.7.4" +funcsigs = "~=1.0.2" +futures = ">=3.1.1" +Pygments = "~=2.3.1" +"backports.functools_lru_cache" = "~=1.5" +MacFSEvents = {version = "~=0.8.1",sys_platform = "== 'darwin'"} +Sphinx = "~=2.0.1" +sphinx-rtd-theme = "~=0.4.3" +sphinx-autobuild = "~=0.7.1" diff --git a/codemeta.json b/codemeta.json deleted file mode 100644 index 8d97ed68..00000000 --- a/codemeta.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "@context": "https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld", - "@type": "Code", - "identifier": "", - "codeRepository": "https://github.com/NiaOrg/NiaPy", - "datePublished": "2018-02-28", - "dateModified": "2018-02-28", - "dateCreated": "2018-02-28", - "description": "Python micro framework for building nature-inspired algorithms.", - "keywords": "nature-inspired algorithms, microframework", - "license": "MIT", - "title": "NiaPy", - "version": "1.0.1" -} \ No newline at end of file diff --git a/gen-codemeta b/gen-codemeta deleted file mode 100755 index 768139d2..00000000 --- a/gen-codemeta +++ /dev/null @@ -1,146 +0,0 @@ -#!/usr/bin/ruby - -# For an OO language, this is distinctly procedural. Should probably fix that. -require 'json' - -details = Hash.new({}) - -capture_params = [ - { :name => "title", :message => "Enter project name." }, - { :name => "url", :message => "Enter the URL of the project repository." }, - { :name => "description", :message => "Enter the (short) project description." }, - { :name => "license", :message => "Enter the license this software shared under. (hit enter to skip)\nFor example MIT, BSD, GPL v3.0, Apache 2.0" }, - { :name => "doi", :message => "Enter the DOI of the archived version of this code. (hit enter to skip)\nFor example http://dx.doi.org/10.6084/m9.figshare.828487" }, - { :name => "keywords", :message => "Enter keywords that should be associated with this project (hit enter to skip)\nComma-separated, for example: turkey, chicken, pot pie" }, - { :name => "version", :message => "Enter the version of your software (hit enter to skip)\nSEMVER preferred: http://semver.org e.g. v1.0.0" } -] - -puts "I'm going to try and help you prepare some things for your JOSS submission" -puts "If all goes well then we'll have a nice codemeta.json file soon..." -puts "" -puts "************************************" -puts "* First, some basic details *" -puts "************************************" -puts "" - -# Loop through the desired captures and print out for clarity -capture_params.each do |param| - puts param[:message] - print "> " - input = gets - - details[param[:name]] = input.chomp - - puts "" - puts "OK, your project has #{param[:name]}: #{input}" - puts "" -end - -puts "" -puts "************************************" -puts "* Experimental stuff *" -puts "************************************" -puts "" - -puts "Would you like me to try and build a list of authors for you?" -puts "(You need to be running this script in a git repository for this to work)" -print "> (Y/N)" -answer = gets.chomp - -case answer.downcase -when "y", "yes" - - # Use git shortlog to extract a list of author names and commit counts. - # Note we don't extract emails here as there's often different emails for - # each user. Instead we capture emails at the end. - - git_log = `git shortlog --summary --numbered --no-merges` - - # ["252\tMichael Jackson", "151\tMC Hammer"] - authors_and_counts = git_log.split("\n").map(&:strip) - - authors_and_counts.each do |author_count| - count, author = author_count.split("\t").map(&:strip) - - puts "Looks like #{author} made #{count} commits" - puts "Add them to the output?" - print "> (Y/N)" - answer = gets.chomp - - # If a user chooses to add this author to the output then we ask for some - # additional information including their email, ORCID and affiliation. - case answer.downcase - when "y", "yes" - puts "What is #{author}'s email address? (hit enter to skip)" - print "> " - email = gets.chomp - - puts "What is #{author}'s ORCID? (hit enter to skip)" - puts "For example: http://orcid.org/0000-0000-0000-0000" - print "> " - orcid = gets.chomp - - puts "What is #{author}'s affiliation? (hit enter to skip)" - print "> " - affiliation = gets.chomp - - - details['authors'].merge!(author => { 'commits' => count, - 'email' => email, - 'orcid' => orcid, - 'affiliation' => affiliation }) - - when "n", "no" - puts "OK boss..." - puts "" - end - end -when "n", "no" - puts "OK boss..." - puts "" -end - -puts "Reticulating splines" - -5.times do - print "." - sleep 0.5 -end - -puts "" -puts "Generating some JSON goodness..." - -# TODO: work out how to use some kind of JSON template here. -# Build the output list of authors from the inputs we've collected. -output_authors = [] - -details['authors'].each do |author_name, values| - entry = { - "@id" => values['orcid'], - "@type" => "Person", - "email" => values['email'], - "name" => author_name, - "affiliation" => values['affiliation'] - } - output_authors << entry -end - -# TODO: this is currently a static template (written out here). It would be good -# to do something smarter here. -output = { - "@context" => "https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld", - "@type" => "Code", - "author" => output_authors, - "identifier" => details['doi'], - "codeRepository" => details['url'], - "datePublished" => Time.now.strftime("%Y-%m-%d"), - "dateModified" => Time.now.strftime("%Y-%m-%d"), - "dateCreated" => Time.now.strftime("%Y-%m-%d"), - "description" => details['description'], - "keywords" => details['keywords'], - "license" => details['license'], - "title" => details['title'], - "version" => details['version'] -} - -File.open('codemeta.json', 'w') {|f| f.write(JSON.pretty_generate(output)) } \ No newline at end of file diff --git a/setup.py b/setup.py index 2231db2a..36d0f186 100644 --- a/setup.py +++ b/setup.py @@ -2,6 +2,17 @@ """Setup script for the package.""" +from __future__ import ( + division, + absolute_import, + with_statement, + print_function, + unicode_literals, + generator_stop, + nested_scopes, + generators +) + import os import sys import logging diff --git a/tests/__init__.py b/tests/__init__.py index a916f18f..4d3e2474 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1 +1,12 @@ """Integration tests for the package.""" + +from __future__ import ( + division, + absolute_import, + with_statement, + print_function, + unicode_literals, + generator_stop, + nested_scopes, + generators +) diff --git a/tests/conftest.py b/tests/conftest.py index 394865cb..69729907 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,16 @@ """Integration tests configuration file.""" +from __future__ import ( + division, + absolute_import, + with_statement, + print_function, + unicode_literals, + generator_stop, + nested_scopes, + generators +) + from NiaPy.tests.conftest import pytest_configure __all__ = ["pytest_configure"] From 8aeab08727ec0f0d016d7a2c1495e36b54eb0e30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grega=20Vrban=C4=8Di=C4=8D?= Date: Sat, 13 Apr 2019 23:39:08 +0200 Subject: [PATCH 08/24] small fix --- NiaPy/benchmarks/ackley.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NiaPy/benchmarks/ackley.py b/NiaPy/benchmarks/ackley.py index 2347db63..c6f9a9b1 100644 --- a/NiaPy/benchmarks/ackley.py +++ b/NiaPy/benchmarks/ackley.py @@ -9,7 +9,7 @@ class Ackley(Benchmark): - ur"""Implementation of Ackley function. + r"""Implementation of Ackley function. Date: 2018 From 1f3682359154b9afdb5b5aae338bc040979b72a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grega=20Vrban=C4=8Di=C4=8D?= Date: Fri, 12 Apr 2019 13:24:22 +0200 Subject: [PATCH 09/24] update dependencies, etc --- NiaPy/__init__.py | 2 +- Pipfile | 6 ++---- setup.py | 11 ++++------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/NiaPy/__init__.py b/NiaPy/__init__.py index 9be3d3d5..4c8fe9fc 100644 --- a/NiaPy/__init__.py +++ b/NiaPy/__init__.py @@ -15,7 +15,7 @@ __all__ = ['algorithms', 'benchmarks', 'util'] __project__ = 'NiaPy' -__version__ = '2.0.0rc2' +__version__ = '2.0.0rc4' VERSION = "{0} v{1}".format(__project__, __version__) diff --git a/Pipfile b/Pipfile index e000c341..62ae03b1 100644 --- a/Pipfile +++ b/Pipfile @@ -4,14 +4,13 @@ verify_ssl = true name = "pypi" [packages] -click = "*" numpy = ">=1.16.2" scipy = ">=1.2.1" +"enum34" = {version = ">=1.1.6", markers="python_version < '3.4'"} +XlsxWriter = ">=1.1.5" matplotlib = ">=2.2.4" [dev-packages] -#pylint = [{version = "==1.9.3", markers = "python_version < '3.4'"}, {version = ">=2.3.0", markers = "python_version >= '3.4'"}] -#pylint = ">=2.3.0" pylint = ">=1.9.3" pycodestyle = "*" pydocstyle = "*" @@ -27,7 +26,6 @@ docutils = "*" wheel = "*" twine = "*" sniffer = "*" -"enum34" = "*" singledispatch = "*" configparser = "*" sphinx-rtd-theme = "*" diff --git a/setup.py b/setup.py index 5eb5c07e..f658eb10 100644 --- a/setup.py +++ b/setup.py @@ -57,7 +57,6 @@ def build_description(): long_description=build_description(), license='MIT', classifiers=[ - # TODO: update this list to match your application: https://pypi.python.org/pypi?%3Aaction=list_classifiers 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'Intended Audience :: Science/Research', @@ -82,12 +81,10 @@ def build_description(): ], install_requires=[ - # TODO: Add your library's requirements here - 'numpy >= 1.15.0', - 'enum34 >= 1.1.6', - 'click >= 6.0', + 'numpy >= 1.16.2', 'scipy >= 1.1.0', - 'xlsxwriter >= 1.0.2', - 'matplotlib >= 2.2.3', + 'enum34 >= 1.1.6', + 'xlsxwriter >= 1.1.5', + 'matplotlib >= 2.2.4', ] ) From f76bfc4f45327d37f0e8882ed95da88a3ac74919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grega=20Vrban=C4=8Di=C4=8D?= Date: Fri, 12 Apr 2019 13:52:41 +0200 Subject: [PATCH 10/24] add python 3.7 --- .appveyor.yml | 1 + .travis.yml | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 59ec0f23..44e276a9 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -4,6 +4,7 @@ environment: matrix: - PYTHON: "C:\\Python27-x64" # latest 2.7.x version - PYTHON: "C:\\Python36-x64" # latest 3.6.x version + - PYTHON: "C:\\Python37-x64" # latest 3.7.x version cache: - .venv -> Makefile diff --git a/.travis.yml b/.travis.yml index 400b6c79..27b7329a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,12 @@ language: python -python: -- 2.7.14 -- 2.7.15 -- 3.6 # latest 3.6.x version + +matrix: + include: + - python: 2.7 # latest 2.7.x version + - python: 3.6 # latest 3.6.x version + - python: 3.7 # latest 3.7.x version + dist: xenial + sudo: true cache: pip: true From e81e9eedf7dab88b4c9db8d9fafcb41fa1398167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grega=20Vrban=C4=8Di=C4=8D?= Date: Fri, 12 Apr 2019 15:20:16 +0200 Subject: [PATCH 11/24] replace pylint with flake8 due to the problems with backward compatibility of newer releases of package. --- .flake8 | 10 ++++ Makefile | 11 +++-- NiaPy/benchmarks/ackley.py | 25 ++++++++-- NiaPy/benchmarks/benchmark.py | 91 +++++++++++++++++++++++------------ NiaPy/benchmarks/happyCat.py | 21 +++++++- Pipfile | 7 ++- scent.py | 2 +- setup.py | 7 ++- tests/conftest.py | 3 +- 9 files changed, 130 insertions(+), 47 deletions(-) create mode 100644 .flake8 diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..70ffeb39 --- /dev/null +++ b/.flake8 @@ -0,0 +1,10 @@ +[flake8] +ignore = E203, E266, E501, W503, D401, D202 +exclude = + .git, + __pycache__, + docs/source/conf.py, + old, + build, + dist, + scent.py \ No newline at end of file diff --git a/Makefile b/Makefile index 130d384f..70014a8f 100644 --- a/Makefile +++ b/Makefile @@ -60,16 +60,17 @@ $(METADATA): setup.py # CHECKS ###################################################################### -PYLINT := pipenv run pylint +FLAKE8 := pipenv run flake8 PYCODESTYLE := pipenv run pycodestyle PYDOCSTYLE := pipenv run pydocstyle .PHONY: check -check: pylint pycodestyle pydocstyle ## Run linters and static analysis +check: flake8 pycodestyle pydocstyle ## Run linters and static analysis -.PHONY: pylint -pylint: install - $(PYLINT) $(PACKAGES) $(CONFIG) --rcfile=.pylint.ini + +.PHONY: flake8 +flake8: install + $(FLAKE8) $(PACKAGES) $(CONFIG) .PHONY: pycodestyle pycodestyle: install diff --git a/NiaPy/benchmarks/ackley.py b/NiaPy/benchmarks/ackley.py index 41421a06..93fc0857 100644 --- a/NiaPy/benchmarks/ackley.py +++ b/NiaPy/benchmarks/ackley.py @@ -1,12 +1,14 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string +"""The module implementing Ackley benchmark.""" + from numpy import exp, pi, cos, sqrt from NiaPy.benchmarks.benchmark import Benchmark __all__ = ['Ackley'] + class Ackley(Benchmark): - r"""Implementation of Ackley function. + ur"""Implementation of Ackley function. Date: 2018 @@ -42,16 +44,31 @@ class Ackley(Benchmark): Reference: https://www.sfu.ca/~ssurjano/ackley.html """ + Name = ['Ackley'] def __init__(self, Lower=-32.768, Upper=32.768): + """The initialization of Ackley benchmark. + + Keyword Arguments: + Lower {float} -- Lower bound. (default: {-32.768}) + Upper {float} -- Upper bound. (default: {32.768}) + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): - return r'''$f(\mathbf{x}) = -a\;\exp\left(-b \sqrt{\frac{1}{D} + """Return the latex code of the problem. + + Returns: + [str] -- latex code + + """ + + return r"""$f(\mathbf{x}) = -a\;\exp\left(-b \sqrt{\frac{1}{D} \sum_{i=1}^D x_i^2}\right) - \exp\left(\frac{1}{D} - \sum_{i=1}^D cos(c\;x_i)\right) + a + \exp(1)$''' + \sum_{i=1}^D cos(c\;x_i)\right) + a + \exp(1)$""" @classmethod def function(cls): diff --git a/NiaPy/benchmarks/benchmark.py b/NiaPy/benchmarks/benchmark.py index bd46a265..d302f39a 100644 --- a/NiaPy/benchmarks/benchmark.py +++ b/NiaPy/benchmarks/benchmark.py @@ -1,5 +1,4 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, line-too-long, bad-continuation, multiple-statements, singleton-comparison, unused-argument, no-self-use, trailing-comma-tuple, logging-not-lazy, no-else-return, unused-variable, no-member """Implementation of benchmarks utility function.""" import logging from numpy import inf, arange, meshgrid, vectorize @@ -12,33 +11,65 @@ __all__ = ['Benchmark'] + class Benchmark: - Name = ['Benchmark', 'BBB'] - - def __init__(self, Lower, Upper, **kwargs): - self.Lower, self.Upper = Lower, Upper - - def function(self): - r"""Get the optimization function.""" - def fun(D, X): return inf - return fun - - def plot2d(self): pass - - def __2dfun(self, x, y, f): return f(2, x, y) - - def plot3d(self, scale=0.32): - fig = plt.figure() - ax = fig.gca(projection='3d') - func = self.function() - Xr, Yr = arange(self.Lower, self.Upper, scale), arange(self.Lower, self.Upper, scale) - X, Y = meshgrid(Xr, Yr) - Z = vectorize(self.__2dfun)(X, Y, func) - ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3) - cset = ax.contourf(X, Y, Z, zdir='z', offset=-10, cmap=cm.coolwarm) - ax.set_xlabel('X') - ax.set_ylabel('Y') - ax.set_zlabel('Z') - plt.show() - -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + r"""Base Benchmark interface class.""" + + Name = ['Benchmark', 'BBB'] + + def __init__(self, Lower, Upper, **kwargs): + r"""Initialization of Benchmark object. + + Arguments: + Lower {[type]} -- Lower bound. + Upper {[type]} -- Upper bound. + """ + + self.Lower = Lower + self.Upper = Upper + + def function(self): + r"""Returns the optimization function.""" + + def fun(D, X): + return inf + + return fun + + def plot2d(self): + """Plot.""" + + pass + + def __2dfun(self, x, y, f): + r"""Plot function. + + Arguments: + x {[type]} -- x value + y {[type]} -- y value + f {[type]} -- function + + """ + + return f(2, x, y) + + def plot3d(self, scale=0.32): + """Plot 3d. + + Keyword Arguments: + scale {float} -- scale (default: {0.32}) + """ + + fig = plt.figure() + ax = fig.gca(projection='3d') + func = self.function() + Xr, Yr = arange(self.Lower, self.Upper, scale), arange( + self.Lower, self.Upper, scale) + X, Y = meshgrid(Xr, Yr) + Z = vectorize(self.__2dfun)(X, Y, func) + ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3) + ax.contourf(X, Y, Z, zdir='z', offset=-10, cmap=cm.coolwarm) + ax.set_xlabel('X') + ax.set_ylabel('Y') + ax.set_zlabel('Z') + plt.show() diff --git a/NiaPy/benchmarks/happyCat.py b/NiaPy/benchmarks/happyCat.py index 5a4c8acc..55d71175 100644 --- a/NiaPy/benchmarks/happyCat.py +++ b/NiaPy/benchmarks/happyCat.py @@ -1,5 +1,6 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string +"""The module implementing Happy Cat benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark @@ -7,7 +8,7 @@ class HappyCat(Benchmark): - r"""Implementation of Happy cat function. + ur"""Implementation of Happy cat function. Date: 2018 @@ -43,19 +44,35 @@ class HappyCat(Benchmark): Beyer, H. G., & Finck, S. (2012). HappyCat - A Simple Function Class Where Well-Known Direct Search Algorithms Do Fail. In International Conference on Parallel Problem Solving from Nature (pp. 367-376). Springer, Berlin, Heidelberg. """ + Name = ['HappyCat'] def __init__(self, Lower=-100.0, Upper=100.0): + """The initialization of Happy Cat benchmark. + + Keyword Arguments: + Lower {float} -- Lower bound. (default: {-100.0}) + Upper {float} -- Upper bound. (default: {100.0}) + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code + + """ + return r'''$f(\mathbf{x}) = {\left|\sum_{i = 1}^D {x_i}^2 - D \right|}^{1/4} + (0.5 \sum_{i = 1}^D {x_i}^2 + \sum_{i = 1}^D x_i) / D + 0.5$''' @classmethod def function(cls): + """Return benchmark evaluation function.""" def evaluate(D, sol): val1 = 0.0 diff --git a/Pipfile b/Pipfile index 62ae03b1..bb47ae1a 100644 --- a/Pipfile +++ b/Pipfile @@ -6,9 +6,10 @@ name = "pypi" [packages] numpy = ">=1.16.2" scipy = ">=1.2.1" -"enum34" = {version = ">=1.1.6", markers="python_version < '3.4'"} +enum34 = {version = ">=1.1.6",markers = "python_version < '3.4'"} XlsxWriter = ">=1.1.5" matplotlib = ">=2.2.4" +flake8 = "*" [dev-packages] pylint = ">=1.9.3" @@ -37,4 +38,6 @@ scandir = "*" Pygments = "*" "backports.functools_lru_cache" = "*" Sphinx = "*" -MacFSEvents = {sys_platform = "== 'darwin'",version = "*"} +MacFSEvents = {version = "*",sys_platform = "== 'darwin'"} +pep8 = "*" +flake8-docstrings = "*" diff --git a/scent.py b/scent.py index b25f9b95..d1fe41b1 100644 --- a/scent.py +++ b/scent.py @@ -1,5 +1,5 @@ """Configuration file for sniffer.""" -# pylint: disable=superfluous-parens, bad-continuation, unpacking-non-sequence, no-init + import time import subprocess diff --git a/setup.py b/setup.py index f658eb10..2231db2a 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,8 @@ def read_package_variable(key, filename='__init__.py'): def build_description(): """Build a description for the project from documentation files.""" try: - readme = open("README.rst").read() # changelog = open("CHANGELOG.rst").read() + # changelog = open("CHANGELOG.rst").read() + readme = open("README.rst").read() except IOError: return "" else: @@ -47,7 +48,9 @@ def build_description(): name=read_package_variable('__project__'), version=read_package_variable('__version__'), - description="Python micro framework for building nature-inspired algorithms.", + description=""" + Python micro framework for building nature-inspired algorithms. + """, url='https://github.com/NiaOrg/NiaPy', author='NiaOrg', author_email='niapy.organization@gmail.com', diff --git a/tests/conftest.py b/tests/conftest.py index e8bd6ede..394865cb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ """Integration tests configuration file.""" -# pylint: disable=unused-import from NiaPy.tests.conftest import pytest_configure + +__all__ = ["pytest_configure"] From 38c00617805722f4222b874690151b201c591201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grega=20Vrban=C4=8Di=C4=8D?= Date: Sat, 13 Apr 2019 23:32:28 +0200 Subject: [PATCH 12/24] switch from pylint to flake8. fix dependencies. finished work on benchmark coding style and documentation. --- .flake8 | 2 +- .pylint.ini | 501 ------------------------- NiaPy/benchmarks/ackley.py | 27 +- NiaPy/benchmarks/alpine.py | 54 ++- NiaPy/benchmarks/benchmark.py | 47 ++- NiaPy/benchmarks/bentcigar.py | 106 ++++-- NiaPy/benchmarks/chungReynolds.py | 35 +- NiaPy/benchmarks/cosinemixture.py | 107 ++++-- NiaPy/benchmarks/csendes.py | 36 +- NiaPy/benchmarks/discus.py | 106 ++++-- NiaPy/benchmarks/dixonprice.py | 107 ++++-- NiaPy/benchmarks/elliptic.py | 104 ++++-- NiaPy/benchmarks/griewank.py | 224 ++++++++---- NiaPy/benchmarks/happyCat.py | 32 +- NiaPy/benchmarks/hgbat.py | 111 ++++-- NiaPy/benchmarks/infinity.py | 106 ++++-- NiaPy/benchmarks/katsuura.py | 112 ++++-- NiaPy/benchmarks/levy.py | 111 ++++-- NiaPy/benchmarks/michalewichz.py | 115 +++--- NiaPy/benchmarks/perm.py | 121 ++++--- NiaPy/benchmarks/pinter.py | 35 +- NiaPy/benchmarks/powell.py | 105 ++++-- NiaPy/benchmarks/qing.py | 36 +- NiaPy/benchmarks/quintic.py | 39 +- NiaPy/benchmarks/rastrigin.py | 32 +- NiaPy/benchmarks/ridge.py | 33 +- NiaPy/benchmarks/rosenbrock.py | 35 +- NiaPy/benchmarks/salomon.py | 35 +- NiaPy/benchmarks/schaffer.py | 289 ++++++++++----- NiaPy/benchmarks/schumerSteiglitz.py | 37 +- NiaPy/benchmarks/schwefel.py | 524 +++++++++++++++++---------- NiaPy/benchmarks/sphere.py | 309 ++++++++++------ NiaPy/benchmarks/step.py | 102 +++++- NiaPy/benchmarks/stepint.py | 36 +- NiaPy/benchmarks/styblinskiTang.py | 40 +- NiaPy/benchmarks/sumSquares.py | 38 +- NiaPy/benchmarks/trid.py | 103 ++++-- NiaPy/benchmarks/weierstrass.py | 123 ++++--- NiaPy/benchmarks/whitley.py | 36 +- NiaPy/benchmarks/zakharov.py | 103 ++++-- Pipfile | 60 +-- codemeta.json | 14 - gen-codemeta | 146 -------- setup.py | 11 + tests/__init__.py | 11 + tests/conftest.py | 11 + 46 files changed, 2662 insertions(+), 1845 deletions(-) delete mode 100644 .pylint.ini delete mode 100644 codemeta.json delete mode 100755 gen-codemeta diff --git a/.flake8 b/.flake8 index 70ffeb39..f23a525c 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,5 @@ [flake8] -ignore = E203, E266, E501, W503, D401, D202 +ignore = E203, E266, E501, W503, D401, D202, RST299, RST304, RST399, FI exclude = .git, __pycache__, diff --git a/.pylint.ini b/.pylint.ini deleted file mode 100644 index d886c652..00000000 --- a/.pylint.ini +++ /dev/null @@ -1,501 +0,0 @@ -[MASTER] - -# A comma-separated list of package or module names from where C extensions may -# be loaded. Extensions are loading into the active Python interpreter and may -# run arbitrary code -extension-pkg-whitelist=numpy - -# Add files or directories to the blacklist. They should be base names, not -# paths. -ignore=CVS - -# Add files or directories matching the regex patterns to the blacklist. The -# regex matches against base names, not paths. -ignore-patterns= - -# Python code to execute, usually for sys.path manipulation such as -# pygtk.require(). -#init-hook= - -# Use multiple processes to speed up Pylint. -jobs=1 - -# List of plugins (as comma separated values of python modules names) to load, -# usually to register additional checkers. -load-plugins= - -# Pickle collected data for later comparisons. -persistent=yes - -# Specify a configuration file. -#rcfile= - -# Allow loading of arbitrary C extensions. Extensions are imported into the -# active Python interpreter and may run arbitrary code. -unsafe-load-any-extension=no - - -[MESSAGES CONTROL] - -# Only show warnings with the listed confidence levels. Leave empty to show -# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED -confidence= - -# Disable the message, report, category or checker with the given id(s). You -# can either give multiple identifiers separated by comma (,) or put this -# option multiple times (only on the command line, not in the configuration -# file where it should appear only once).You can also use "--disable=all" to -# disable everything first and then reenable specific checks. For example, if -# you want to run only the similarities checker, you can use "--disable=all -# --enable=similarities". If you want to run only the classes checker, but have -# no Warning level messages displayed, use"--disable=all --enable=classes -# --disable=W" -disable=print-statement, - parameter-unpacking, - unpacking-in-except, - old-raise-syntax, - backtick, - long-suffix, - old-ne-operator, - old-octal-literal, - import-star-module-level, - raw-checker-failed, - bad-inline-option, - locally-disabled, - locally-enabled, - file-ignored, - suppressed-message, - useless-suppression, - deprecated-pragma, - apply-builtin, - basestring-builtin, - buffer-builtin, - cmp-builtin, - coerce-builtin, - execfile-builtin, - file-builtin, - long-builtin, - raw_input-builtin, - reduce-builtin, - standarderror-builtin, - unicode-builtin, - xrange-builtin, - coerce-method, - delslice-method, - getslice-method, - setslice-method, - no-absolute-import, - old-division, - dict-iter-method, - dict-view-method, - next-method-called, - metaclass-assignment, - indexing-exception, - raising-string, - reload-builtin, - oct-method, - hex-method, - nonzero-method, - cmp-method, - input-builtin, - round-builtin, - intern-builtin, - unichr-builtin, - map-builtin-not-iterating, - zip-builtin-not-iterating, - range-builtin-not-iterating, - filter-builtin-not-iterating, - using-cmp-argument, - eq-without-hash, - div-method, - idiv-method, - rdiv-method, - exception-message-attribute, - invalid-str-codec, - sys-max-int, - bad-python3-import, - deprecated-string-function, - deprecated-str-translate-call, - missing-docstring, - invalid-name, - too-few-public-methods, - fixme, - too-many-arguments, - too-many-branches, - similarities, - too-many-locals, - too-many-statements, - too-many-instance-attributes, - old-style-class - -# Enable the message, report, category or checker with the given id(s). You can -# either give multiple identifier separated by comma (,) or put this option -# multiple time (only on the command line, not in the configuration file where -# it should appear only once). See also the "--disable" option for examples. -enable= - - -[REPORTS] - -# Python expression which should return a note less than 10 (10 is the highest -# note). You have access to the variables errors warning, statement which -# respectively contain the number of errors / warnings messages and the total -# number of statements analyzed. This is used by the global evaluation report -# (RP0004). -evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) - -# Template used to display messages. This is a python new-style format string -# used to format the message information. See doc for all details -#msg-template= - -# Set the output format. Available formats are text, parseable, colorized, json -# and msvs (visual studio).You can also give a reporter class, eg -# mypackage.mymodule.MyReporterClass. -output-format=text - -# Tells whether to display a full report or only the messages -reports=no - -# Activate the evaluation score. -score=no - - -[REFACTORING] - -# Maximum number of nested blocks for function / method body -max-nested-blocks=5 - - -[BASIC] - -# Naming hint for argument names -argument-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Regular expression matching correct argument names -argument-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Naming hint for attribute names -attr-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Regular expression matching correct attribute names -attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Bad variable names which should always be refused, separated by a comma -bad-names=foo,bar,baz,toto,tutu,tata - -# Naming hint for class attribute names -class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ - -# Regular expression matching correct class attribute names -class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ - -# Naming hint for class names -class-name-hint=[A-Z_][a-zA-Z0-9]+$ - -# Regular expression matching correct class names -class-rgx=[A-Z_][a-zA-Z0-9]+$ - -# Naming hint for constant names -const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$ - -# Regular expression matching correct constant names -const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ - -# Minimum line length for functions/classes that require docstrings, shorter -# ones are exempt. -docstring-min-length=-1 - -# Naming hint for function names -function-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Regular expression matching correct function names -function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Good variable names which should always be accepted, separated by a comma -good-names=i,j,k,ex,Run,_ - -# Include a hint for the correct naming format with invalid-name -include-naming-hint=no - -# Naming hint for inline iteration names -inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$ - -# Regular expression matching correct inline iteration names -inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ - -# Naming hint for method names -method-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Regular expression matching correct method names -method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Naming hint for module names -module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - -# Regular expression matching correct module names -module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - -# Colon-delimited sets of names that determine each other's naming style when -# the name regexes allow several styles. -name-group= - -# Regular expression which should only match function or class names that do -# not require a docstring. -no-docstring-rgx=^_ - -# List of decorators that produce properties, such as abc.abstractproperty. Add -# to this list to register other decorators that produce valid properties. -property-classes=abc.abstractproperty - -# Naming hint for variable names -variable-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Regular expression matching correct variable names -variable-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - - -[FORMAT] - -# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. -expected-line-ending-format= - -# Regexp for a line that is allowed to be longer than the limit. -ignore-long-lines=^.*((https?:)|(pragma:)|(TODO:)).*$ - -# Number of spaces of indent required inside a hanging or continued line. -indent-after-paren=4 - -# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 -# tab). -indent-string=' ' - -# Maximum number of characters on a single line. -max-line-length=150 - -# Maximum number of lines in a module -max-module-lines=1000 - -# List of optional constructs for which whitespace checking is disabled. `dict- -# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. -# `trailing-comma` allows a space between comma and closing bracket: (a, ). -# `empty-line` allows space-only lines. -no-space-check=trailing-comma,dict-separator - -# Allow the body of a class to be on the same line as the declaration if body -# contains single statement. -single-line-class-stmt=no - -# Allow the body of an if to be on the same line as the test if there is no -# else. -single-line-if-stmt=no - - -[LOGGING] - -# Logging modules to check that the string format arguments are in logging -# function parameter format -logging-modules=logging - - -[MISCELLANEOUS] - -# List of note tags to take in consideration, separated by a comma. -notes=FIXME,XXX,TODO - - -[SIMILARITIES] - -# Ignore comments when computing similarities. -ignore-comments=yes - -# Ignore docstrings when computing similarities. -ignore-docstrings=yes - -# Ignore imports when computing similarities. -ignore-imports=no - -# Minimum lines number of a similarity. -min-similarity-lines=4 - - -[SPELLING] - -# Spelling dictionary name. Available dictionaries: none. To make it working -# install python-enchant package. -spelling-dict= - -# List of comma separated words that should not be checked. -spelling-ignore-words= - -# A path to a file that contains private dictionary; one word per line. -spelling-private-dict-file= - -# Tells whether to store unknown words to indicated private dictionary in -# --spelling-private-dict-file option instead of raising a message. -spelling-store-unknown-words=no - - -[TYPECHECK] - -# List of decorators that produce context managers, such as -# contextlib.contextmanager. Add to this list to register other decorators that -# produce valid context managers. -contextmanager-decorators=contextlib.contextmanager - -# List of members which are set dynamically and missed by pylint inference -# system, and so shouldn't trigger E1101 when accessed. Python regular -# expressions are accepted. -generated-members= - -# Tells whether missing members accessed in mixin class should be ignored. A -# mixin class is detected if its name ends with "mixin" (case insensitive). -ignore-mixin-members=yes - -# This flag controls whether pylint should warn about no-member and similar -# checks whenever an opaque object is returned when inferring. The inference -# can return multiple potential results while evaluating a Python object, but -# some branches might not be evaluated, which results in partial inference. In -# that case, it might be useful to still emit no-member and other checks for -# the rest of the inferred objects. -ignore-on-opaque-inference=yes - -# List of class names for which member attributes should not be checked (useful -# for classes with dynamically set attributes). This supports the use of -# qualified names. -ignored-classes=optparse.Values,thread._local,_thread._local - -# List of module names for which member attributes should not be checked -# (useful for modules/projects where namespaces are manipulated during runtime -# and thus existing member attributes cannot be deduced by static analysis. It -# supports qualified module names, as well as Unix pattern matching. -ignored-modules= - -# Show a hint with possible names when a member name was not found. The aspect -# of finding the hint is based on edit distance. -missing-member-hint=yes - -# The minimum edit distance a name should have in order to be considered a -# similar match for a missing member name. -missing-member-hint-distance=1 - -# The total number of similar names that should be taken in consideration when -# showing a hint for a missing member. -missing-member-max-choices=1 - - -[VARIABLES] - -# List of additional names supposed to be defined in builtins. Remember that -# you should avoid to define new builtins when possible. -additional-builtins= - -# Tells whether unused global variables should be treated as a violation. -allow-global-unused-variables=yes - -# List of strings which can identify a callback function by name. A callback -# name must start or end with one of those strings. -callbacks=cb_,_cb - -# A regular expression matching the name of dummy variables (i.e. expectedly -# not used). -dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ - -# Argument names that match this expression will be ignored. Default to name -# with leading underscore -ignored-argument-names=_.*|^ignored_|^unused_ - -# Tells whether we should check for unused import in __init__ files. -init-import=no - -# List of qualified module names which can have objects that can redefine -# builtins. -redefining-builtins-modules=six.moves,future.builtins - - -[CLASSES] - -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__,__new__,setUp - -# List of member names, which should be excluded from the protected access -# warning. -exclude-protected=_asdict,_fields,_replace,_source,_make - -# List of valid names for the first argument in a class method. -valid-classmethod-first-arg=cls - -# List of valid names for the first argument in a metaclass class method. -valid-metaclass-classmethod-first-arg=mcs - - -[DESIGN] - -# Maximum number of arguments for function / method -max-args=5 - -# Maximum number of attributes for a class (see R0902). -max-attributes=7 - -# Maximum number of boolean expressions in a if statement -max-bool-expr=5 - -# Maximum number of branch for function / method body -max-branches=12 - -# Maximum number of locals for function / method body -max-locals=15 - -# Maximum number of parents for a class (see R0901). -max-parents=7 - -# Maximum number of public methods for a class (see R0904). -max-public-methods=20 - -# Maximum number of return / yield for function / method body -max-returns=6 - -# Maximum number of statements in function / method body -max-statements=50 - -# Minimum number of public methods for a class (see R0903). -min-public-methods=2 - - -[IMPORTS] - -# Allow wildcard imports from modules that define __all__. -allow-wildcard-with-all=no - -# Analyse import fallback blocks. This can be used to support both Python 2 and -# 3 compatible code, which means that the block might have code that exists -# only in one or another interpreter, leading to false positives when analysed. -analyse-fallback-blocks=no - -# Deprecated modules which should not be used, separated by a comma -deprecated-modules=regsub,TERMIOS,Bastion,rexec - -# Create a graph of external dependencies in the given file (report RP0402 must -# not be disabled) -ext-import-graph= - -# Create a graph of every (i.e. internal and external) dependencies in the -# given file (report RP0402 must not be disabled) -import-graph= - -# Create a graph of internal dependencies in the given file (report RP0402 must -# not be disabled) -int-import-graph= - -# Force import order to recognize a module as part of the standard -# compatibility libraries. -known-standard-library= - -# Force import order to recognize a module as part of a third party library. -known-third-party=enchant - - -[EXCEPTIONS] - -# Exceptions that will emit a warning when being caught. Defaults to -# "Exception" -overgeneral-exceptions=Exception diff --git a/NiaPy/benchmarks/ackley.py b/NiaPy/benchmarks/ackley.py index 93fc0857..01fd3903 100644 --- a/NiaPy/benchmarks/ackley.py +++ b/NiaPy/benchmarks/ackley.py @@ -1,14 +1,15 @@ # encoding=utf8 + """The module implementing Ackley benchmark.""" from numpy import exp, pi, cos, sqrt from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Ackley'] +__all__ = ["Ackley"] class Ackley(Benchmark): - ur"""Implementation of Ackley function. + r"""Implementation of Ackley function. Date: 2018 @@ -45,14 +46,18 @@ class Ackley(Benchmark): Reference: https://www.sfu.ca/~ssurjano/ackley.html """ - Name = ['Ackley'] + Name = ["Ackley"] def __init__(self, Lower=-32.768, Upper=32.768): """The initialization of Ackley benchmark. - Keyword Arguments: - Lower {float} -- Lower bound. (default: {-32.768}) - Upper {float} -- Upper bound. (default: {32.768}) + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + """ Benchmark.__init__(self, Lower, Upper) @@ -62,7 +67,7 @@ def latex_code(): """Return the latex code of the problem. Returns: - [str] -- latex code + [str] -- latex code. """ @@ -72,7 +77,13 @@ def latex_code(): @classmethod def function(cls): - """Return benchmark evaluation function.""" + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): a = 20 # Recommended variable value diff --git a/NiaPy/benchmarks/alpine.py b/NiaPy/benchmarks/alpine.py index a2805b00..a5c8e056 100644 --- a/NiaPy/benchmarks/alpine.py +++ b/NiaPy/benchmarks/alpine.py @@ -1,11 +1,11 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string -"""Implementations of Alpine functions.""" + +"""Implementations of Alpine benchmarks.""" import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Alpine1', 'Alpine2'] +__all__ = ["Alpine1", "Alpine2"] class Alpine1(Benchmark): @@ -42,11 +42,13 @@ class Alpine1(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Alpine1'] + + Name = ["Alpine1"] def __init__(self, Lower=-10.0, Upper=10.0): - r"""Initialize Alpine1 benchmark. + r"""The initialization of Alpine1 benchmark. Args: Lower (Optional[float]): Lower bound of problem. @@ -54,15 +56,31 @@ def __init__(self, Lower=-10.0, Upper=10.0): See Also: :func:`NiaPy.benchmarks.Benchmark.__init__` + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): - return r'''$f(\mathbf{x}) = \sum_{i=1}^{D} \left |x_i \sin(x_i)+0.1x_i \right|$''' + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + + return r"""$f(\mathbf{x}) = \sum_{i=1}^{D} \left |x_i \sin(x_i)+0.1x_i \right|$""" @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 @@ -110,11 +128,13 @@ class Alpine2(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Alpine2'] + + Name = ["Alpine2"] def __init__(self, Lower=0.0, Upper=10.0): - r"""Initialize Alpine2 benchmark. + r"""The initialization of Alpine2 benchmark. Args: Lower (Optional[float]): Lower bound of problem. @@ -122,15 +142,31 @@ def __init__(self, Lower=0.0, Upper=10.0): See Also: :func:`NiaPy.benchmarks.Benchmark.__init__` + """ + Benchmark.__init__(self, Lower=Lower, Upper=Upper) @staticmethod def latex_code(): - return r'''$f(\mathbf{x}) = \prod_{i=1}^{D} \sqrt{x_i} \sin(x_i)$''' + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + + return r"""$f(\mathbf{x}) = \prod_{i=1}^{D} \sqrt{x_i} \sin(x_i)$""" @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 1.0 diff --git a/NiaPy/benchmarks/benchmark.py b/NiaPy/benchmarks/benchmark.py index d302f39a..4a5b4bd3 100644 --- a/NiaPy/benchmarks/benchmark.py +++ b/NiaPy/benchmarks/benchmark.py @@ -1,21 +1,23 @@ # encoding=utf8 -"""Implementation of benchmarks utility function.""" + +"""Implementation of base benchmark class.""" + import logging from numpy import inf, arange, meshgrid, vectorize from matplotlib import pyplot as plt from matplotlib import cm logging.basicConfig() -logger = logging.getLogger('NiaPy.benchmarks.benchmark') -logger.setLevel('INFO') +logger = logging.getLogger("NiaPy.benchmarks.benchmark") +logger.setLevel("INFO") -__all__ = ['Benchmark'] +__all__ = ["Benchmark"] class Benchmark: - r"""Base Benchmark interface class.""" + """Base Benchmark interface class.""" - Name = ['Benchmark', 'BBB'] + Name = ["Benchmark", "BBB"] def __init__(self, Lower, Upper, **kwargs): r"""Initialization of Benchmark object. @@ -23,18 +25,35 @@ def __init__(self, Lower, Upper, **kwargs): Arguments: Lower {[type]} -- Lower bound. Upper {[type]} -- Upper bound. + """ self.Lower = Lower self.Upper = Upper def function(self): - r"""Returns the optimization function.""" + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + + def evaluate(D, sol): + """The implementation on evaluation function. + + Arguments: + D [int]} -- Dimension of the problem. + sol [array[float]] -- Solution array. + + Returns: + [float] -- Return fitness value. + + """ - def fun(D, X): return inf - return fun + return evaluate def plot2d(self): """Plot.""" @@ -61,15 +80,15 @@ def plot3d(self, scale=0.32): """ fig = plt.figure() - ax = fig.gca(projection='3d') + ax = fig.gca(projection="3d") func = self.function() Xr, Yr = arange(self.Lower, self.Upper, scale), arange( self.Lower, self.Upper, scale) X, Y = meshgrid(Xr, Yr) Z = vectorize(self.__2dfun)(X, Y, func) ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3) - ax.contourf(X, Y, Z, zdir='z', offset=-10, cmap=cm.coolwarm) - ax.set_xlabel('X') - ax.set_ylabel('Y') - ax.set_zlabel('Z') + ax.contourf(X, Y, Z, zdir="z", offset=-10, cmap=cm.coolwarm) + ax.set_xlabel("X") + ax.set_ylabel("Y") + ax.set_zlabel("Z") plt.show() diff --git a/NiaPy/benchmarks/bentcigar.py b/NiaPy/benchmarks/bentcigar.py index 7f797244..e2e7c01d 100644 --- a/NiaPy/benchmarks/bentcigar.py +++ b/NiaPy/benchmarks/bentcigar.py @@ -1,59 +1,89 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, multiple-statements -"""Implementations of Bent Cigar functions.""" + +"""Implementation of Bent Cigar benchmark.""" from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['BentCigar'] +__all__ = ["BentCigar"] + class BentCigar(Benchmark): - r"""Implementations of Bent Cigar functions. + r"""Implementations of Bent Cigar functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: + **Bent Cigar Function** + + :math:`f(\textbf{x}) = x_1^2 + 10^6 \sum_{i=2}^D x_i^2` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = x_1^2 + 10^6 \sum_{i=2}^D x_i^2$ + + Equation: + \begin{equation} f(\textbf{x}) = x_1^2 + 10^6 \sum_{i=2}^D x_i^2 \end{equation} + + Domain: + $-100 \leq x_i \leq 100$ + + Reference: http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf + + """ + + Name = ["BentCigar"] + + def __init__(self, Lower=-100.0, Upper=100.0): + r"""The initialization of Bent Cigar benchmark. - Date: 2018 + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - Author: Klemen Berkovič + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - License: MIT + """ - Function: - **Bent Cigar Function** + Benchmark.__init__(self, Lower, Upper) - :math:`f(\textbf{x}) = x_1^2 + 10^6 \sum_{i=2}^D x_i^2` + @staticmethod + def latex_code(): + """Return the latex code of the problem. - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + Returns: + [str] -- latex code. - **Global minimum:** - :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + """ - LaTeX formats: - Inline: - $f(\textbf{x}) = x_1^2 + 10^6 \sum_{i=2}^D x_i^2$ + return r"""$f(\textbf{x}) = x_1^2 + 10^6 \sum_{i=2}^D x_i^2$""" - Equation: - \begin{equation} f(\textbf{x}) = x_1^2 + 10^6 \sum_{i=2}^D x_i^2 \end{equation} + @classmethod + def function(cls): + """Return benchmark evaluation function. - Domain: - $-100 \leq x_i \leq 100$ + Returns: + [fun] -- Evaluation function. - Reference: - http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - """ - Name = ['BentCigar'] + """ - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower, Upper) + def evaluate(D, sol): - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = x_1^2 + 10^6 \sum_{i=2}^D x_i^2$''' + val = 0.0 - @classmethod - def function(cls): - def f(D, sol): - val = 0.0 - for i in range(1, D): val += sol[i] ** 2 - return sol[0] ** 2 + 10 ** 6 * val - return f + for i in range(1, D): + val += sol[i] ** 2 + return sol[0] ** 2 + 10 ** 6 * val -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/chungReynolds.py b/NiaPy/benchmarks/chungReynolds.py index 9c7daddf..e6137361 100644 --- a/NiaPy/benchmarks/chungReynolds.py +++ b/NiaPy/benchmarks/chungReynolds.py @@ -1,9 +1,11 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Chung Reynolds benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['ChungReynolds'] +__all__ = ["ChungReynolds"] class ChungReynolds(Benchmark): @@ -40,18 +42,45 @@ class ChungReynolds(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['ChungReynolds'] + + Name = ["ChungReynolds"] def __init__(self, Lower=-100.0, Upper=100.0): + """The initialization of Chung Reynolds benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + return r'''$f(\mathbf{x}) = \left(\sum_{i=1}^D x_i^2\right)^2$''' @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/cosinemixture.py b/NiaPy/benchmarks/cosinemixture.py index e1bae493..c0117348 100644 --- a/NiaPy/benchmarks/cosinemixture.py +++ b/NiaPy/benchmarks/cosinemixture.py @@ -1,60 +1,91 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, multiple-statements -"""Implementations of Cosine mixture functions.""" + +"""Implementation of Cosine mixture benchmark.""" from numpy import cos, pi from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['CosineMixture'] +__all__ = ["CosineMixture"] + class CosineMixture(Benchmark): - r"""Implementations of Cosine mixture function. + r"""Implementations of Cosine mixture function. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: + **Cosine Mixture Function** + + :math:`f(\textbf{x}) = - 0.1 \sum_{i = 1}^D \cos (5 \pi x_i) - \sum_{i = 1}^D x_i^2` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-1, 1]`, for all :math:`i = 1, 2,..., D`. + + **Global maximu:** + :math:`f(x^*) = -0.1 D`, at :math:`x^* = (0.0,...,0.0)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = - 0.1 \sum_{i = 1}^D \cos (5 \pi x_i) - \sum_{i = 1}^D x_i^2$ + + Equation: + \begin{equation} f(\textbf{x}) = - 0.1 \sum_{i = 1}^D \cos (5 \pi x_i) - \sum_{i = 1}^D x_i^2 \end{equation} + + Domain: + $-1 \leq x_i \leq 1$ + + Reference: + http://infinity77.net/global_optimization/test_functions_nd_C.html#go_benchmark.CosineMixture + + """ + + Name = ["CosineMixture"] + + def __init__(self, Lower=-1.0, Upper=1.0): + r"""The initialization of Cosine mixture benchmark. - Date: 2018 + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - Author: Klemen Berkovič + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - License: MIT + """ - Function: - **Cosine Mixture Function** + Benchmark.__init__(self, Lower, Upper) - :math:`f(\textbf{x}) = - 0.1 \sum_{i = 1}^D \cos (5 \pi x_i) - \sum_{i = 1}^D x_i^2` + @staticmethod + def latex_code(): + """Return the latex code of the problem. - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-1, 1]`, for all :math:`i = 1, 2,..., D`. + Returns: + [str] -- latex code. - **Global maximu:** - :math:`f(x^*) = -0.1 D`, at :math:`x^* = (0.0,...,0.0)` + """ - LaTeX formats: - Inline: - $f(\textbf{x}) = - 0.1 \sum_{i = 1}^D \cos (5 \pi x_i) - \sum_{i = 1}^D x_i^2$ + return r"""$f(\textbf{x}) = - 0.1 \sum_{i = 1}^D \cos (5 \pi x_i) - \sum_{i = 1}^D x_i^2$""" - Equation: - \begin{equation} f(\textbf{x}) = - 0.1 \sum_{i = 1}^D \cos (5 \pi x_i) - \sum_{i = 1}^D x_i^2 \end{equation} + @classmethod + def function(cls): + """Return benchmark evaluation function. - Domain: - $-1 \leq x_i \leq 1$ + Returns: + [fun] -- Evaluation function. - Reference: - http://infinity77.net/global_optimization/test_functions_nd_C.html#go_benchmark.CosineMixture - """ - Name = ['CosineMixture'] + """ - def __init__(self, Lower=-1.0, Upper=1.0): Benchmark.__init__(self, Lower, Upper) + def evaluate(D, sol): + v1, v2 = 0.0, 0.0 - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = - 0.1 \sum_{i = 1}^D \cos (5 \pi x_i) - \sum_{i = 1}^D x_i^2$''' + for i in range(D): + v1, v2 = v1 + cos(5 * pi * sol[i]), v2 + sol[i] ** 2 - @classmethod - def function(cls): - def f(D, X): - v1, v2 = 0.0, 0.0 - for i in range(D): v1, v2 = v1 + cos(5 * pi * X[i]), v2 + X[i] ** 2 - return -0.1 * v1 - v2 - return f + return -0.1 * v1 - v2 -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/csendes.py b/NiaPy/benchmarks/csendes.py index 807ce856..966249e3 100644 --- a/NiaPy/benchmarks/csendes.py +++ b/NiaPy/benchmarks/csendes.py @@ -1,9 +1,11 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Csendes benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Csendes'] +__all__ = ["Csendes"] class Csendes(Benchmark): @@ -41,18 +43,44 @@ class Csendes(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Csendes'] + + Name = ["Csendes"] def __init__(self, Lower=-1.0, Upper=1.0): + r"""The initialization of Csendes benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): - return r'''$f(\mathbf{x}) = \sum_{i=1}^D x_i^6\left( 2 + \sin \frac{1}{x_i}\right)$''' + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + + return r"""$f(\mathbf{x}) = \sum_{i=1}^D x_i^6\left( 2 + \sin \frac{1}{x_i}\right)$""" @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/discus.py b/NiaPy/benchmarks/discus.py index 1846796b..ae5dcbf2 100644 --- a/NiaPy/benchmarks/discus.py +++ b/NiaPy/benchmarks/discus.py @@ -1,59 +1,89 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, multiple-statements -"""Implementations of Discus functions.""" + +"""Implementation of Discus benchmark.""" from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Discus'] +__all__ = ["Discus"] + class Discus(Benchmark): - r"""Implementations of Discus functions. + r"""Implementations of Discus functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: + **Discus Function** + + :math:`f(\textbf{x}) = x_1^2 10^6 + \sum_{i=2}^D x_i^2` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = x_1^2 10^6 + \sum_{i=2}^D x_i^2$ + + Equation: + \begin{equation} f(\textbf{x}) = x_1^2 10^6 + \sum_{i=2}^D x_i^2 \end{equation} + + Domain: + $-100 \leq x_i \leq 100$ + + Reference: + http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf + + """ + + Name = ["Discus"] - Date: 2018 + def __init__(self, Lower=-100.0, Upper=100.0): + r"""The initialization of Alpine1 benchmark. - Author: Klemen Berkovič + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - License: MIT + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Function: - **Discus Function** + """ - :math:`f(\textbf{x}) = x_1^2 10^6 + \sum_{i=2}^D x_i^2` + Benchmark.__init__(self, Lower, Upper) - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + @staticmethod + def latex_code(): + """Return the latex code of the problem. - **Global minimum:** - :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + Returns: + [str] -- latex code. - LaTeX formats: - Inline: - $f(\textbf{x}) = x_1^2 10^6 + \sum_{i=2}^D x_i^2$ + """ - Equation: - \begin{equation} f(\textbf{x}) = x_1^2 10^6 + \sum_{i=2}^D x_i^2 \end{equation} + return r"""$f(\textbf{x}) = x_1^2 10^6 + \sum_{i=2}^D x_i^2$""" - Domain: - $-100 \leq x_i \leq 100$ + @classmethod + def function(cls): + """Return benchmark evaluation function. - Reference: - http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - """ - Name = ['Discus'] + Returns: + [fun] -- Evaluation function. - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower, Upper) + """ - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = x_1^2 10^6 + \sum_{i=2}^D x_i^2$''' + def evaluate(D, sol): + val = 0.0 - @classmethod - def function(cls): - def f(D, sol): - val = 0.0 - for i in range(1, D): val += sol[i] ** 2 - return sol[0] * 10 ** 6 + val - return f + for i in range(1, D): + val += sol[i] ** 2 -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return sol[0] * 10 ** 6 + val + return evaluate diff --git a/NiaPy/benchmarks/dixonprice.py b/NiaPy/benchmarks/dixonprice.py index a0c741db..9c0a5a79 100644 --- a/NiaPy/benchmarks/dixonprice.py +++ b/NiaPy/benchmarks/dixonprice.py @@ -1,59 +1,90 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, multiple-statements, line-too-long -"""Implementations of Dixon Price function.""" + +"""Implementation of Dixon Price benchmark.""" from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['DixonPrice'] +__all__ = ["DixonPrice"] + class DixonPrice(Benchmark): - r"""Implementations of Dixon Price function. + r"""Implementations of Dixon Price function. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: + **Levy Function** + + :math:`f(\textbf{x}) = (x_1 - 1)^2 + \sum_{i = 2}^D i (2x_i^2 - x_{i - 1})^2` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-10, 10]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + :math:`f(\textbf{x}^*) = 0` at :math:`\textbf{x}^* = (2^{-\frac{2^1 - 2}{2^1}}, \cdots , 2^{-\frac{2^i - 2}{2^i}} , \cdots , 2^{-\frac{2^D - 2}{2^D}})` + + LaTeX formats: + Inline: + $f(\textbf{x}) = (x_1 - 1)^2 + \sum_{i = 2}^D i (2x_i^2 - x_{i - 1})^2$ + + Equation: + \begin{equation} f(\textbf{x}) = (x_1 - 1)^2 + \sum_{i = 2}^D i (2x_i^2 - x_{i - 1})^2 \end{equation} + + Domain: + $-10 \leq x_i \leq 10$ + + Reference: https://www.sfu.ca/~ssurjano/dixonpr.html + + """ + + Name = ["DixonPrice"] + + def __init__(self, Lower=-10.0, Upper=10): + r"""The initialization of Dixon Price benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - Date: 2018 + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Author: Klemen Berkovič + """ - License: MIT + Benchmark.__init__(self, Lower, Upper) - Function: - **Levy Function** + @staticmethod + def latex_code(): + """Return the latex code of the problem. - :math:`f(\textbf{x}) = (x_1 - 1)^2 + \sum_{i = 2}^D i (2x_i^2 - x_{i - 1})^2` + Returns: + [str] -- latex code. - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-10, 10]`, for all :math:`i = 1, 2,..., D`. + """ - **Global minimum:** - :math:`f(\textbf{x}^*) = 0` at :math:`\textbf{x}^* = (2^{-\frac{2^1 - 2}{2^1}}, \cdots , 2^{-\frac{2^i - 2}{2^i}} , \cdots , 2^{-\frac{2^D - 2}{2^D}})` + return r"""$f(\textbf{x}) = (x_1 - 1)^2 + \sum_{i = 2}^D i (2x_i^2 - x_{i - 1})^2$""" - LaTeX formats: - Inline: - $f(\textbf{x}) = (x_1 - 1)^2 + \sum_{i = 2}^D i (2x_i^2 - x_{i - 1})^2$ + @classmethod + def function(cls): + """Return benchmark evaluation function. - Equation: - \begin{equation} f(\textbf{x}) = (x_1 - 1)^2 + \sum_{i = 2}^D i (2x_i^2 - x_{i - 1})^2 \end{equation} + Returns: + [fun] -- Evaluation function. - Domain: - $-10 \leq x_i \leq 10$ + """ - Reference: - https://www.sfu.ca/~ssurjano/dixonpr.html - """ - Name = ['DixonPrice'] + def evaluate(D, sol): - def __init__(self, Lower=-10.0, Upper=10): Benchmark.__init__(self, Lower, Upper) + v = 0.0 - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = (x_1 - 1)^2 + \sum_{i = 2}^D i (2x_i^2 - x_{i - 1})^2$''' + for i in range(2, D): + v += i * (2 * sol[i] ** 2 - sol[i - 1]) ** 2 - @classmethod - def function(cls): - def f(D, X): - v = 0.0 - for i in range(2, D): v += i * (2 * X[i] ** 2 - X[i - 1]) ** 2 - return (X[0] - 1) ** 2 + v - return f + return (sol[0] - 1) ** 2 + v -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/elliptic.py b/NiaPy/benchmarks/elliptic.py index 1f8a8e44..1a4abafa 100644 --- a/NiaPy/benchmarks/elliptic.py +++ b/NiaPy/benchmarks/elliptic.py @@ -1,59 +1,89 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, multiple-statements + """Implementations of High Conditioned Elliptic functions.""" from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Elliptic'] +__all__ = ["Elliptic"] + class Elliptic(Benchmark): - r"""Implementations of High Conditioned Elliptic functions. + r"""Implementations of High Conditioned Elliptic functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **High Conditioned Elliptic Function** + + :math:`f(\textbf{x}) = \sum_{i=1}^D \left( 10^6 \right)^{ \frac{i - 1}{D - 1} } x_i^2` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = \sum_{i=1}^D \left( 10^6 \right)^{ \frac{i - 1}{D - 1} } x_i^2$ + + Equation: + \begin{equation} f(\textbf{x}) = \sum_{i=1}^D \left( 10^6 \right)^{ \frac{i - 1}{D - 1} } x_i^2 \end{equation} + + Domain: + $-100 \leq x_i \leq 100$ + + Reference: + http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf + + """ + + Name = ["Elliptic"] + + def __init__(self, Lower=-100.0, Upper=100.0): + r"""The initialization of Elliptic benchmark. - Date: 2018 + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - Author: Klemen Berkovič + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - License: MIT + """ - Function: - **High Conditioned Elliptic Function** + Benchmark.__init__(self, Lower, Upper) - :math:`f(\textbf{x}) = \sum_{i=1}^D \left( 10^6 \right)^{ \frac{i - 1}{D - 1} } x_i^2` + @staticmethod + def latex_code(): + """Return the latex code of the problem. - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + Returns: + [str] -- latex code. - **Global minimum:** - :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + """ - LaTeX formats: - Inline: - $f(\textbf{x}) = \sum_{i=1}^D \left( 10^6 \right)^{ \frac{i - 1}{D - 1} } x_i^2$ + return r"""$f(\textbf{x}) = \sum_{i=1}^D \left( 10^6 \right)^{ \frac{i - 1}{D - 1} } x_i^2$""" - Equation: - \begin{equation} f(\textbf{x}) = \sum_{i=1}^D \left( 10^6 \right)^{ \frac{i - 1}{D - 1} } x_i^2 \end{equation} + @classmethod + def function(cls): + """Return benchmark evaluation function. - Domain: - $-100 \leq x_i \leq 100$ + Returns: + [fun] -- Evaluation function. - Reference: - http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - """ - Name = ['Elliptic'] + """ - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower, Upper) + def evaluate(D, sol): + val = 0.0 - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = \sum_{i=1}^D \left( 10^6 \right)^{ \frac{i - 1}{D - 1} } x_i^2$''' + for i in range(D): + val += (10 ** 6) ** (i / (D - 1)) * sol[i] - @classmethod - def function(cls): - def evaluate(D, sol): - val = 0.0 - for i in range(D): val += (10 ** 6) ** (i / (D - 1)) * sol[i] - return val - return evaluate + return val -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/griewank.py b/NiaPy/benchmarks/griewank.py index c30e169a..bf5cf862 100644 --- a/NiaPy/benchmarks/griewank.py +++ b/NiaPy/benchmarks/griewank.py @@ -1,116 +1,184 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string, mixed-indentation, multiple-statements, line-too-long + +"""Implementations of Griewank benchmarks.""" + from math import sqrt, cos from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Griewank', 'ExpandedGriewankPlusRosenbrock'] +__all__ = ["Griewank", "ExpandedGriewankPlusRosenbrock"] class Griewank(Benchmark): - r"""Implementation of Griewank function. + r"""Implementation of Griewank function. + + Date: 2018 + + Authors: Iztok Fister Jr. and Lucija Brezočnik + + License: MIT + + Function: **Griewank function** + + :math:`f(\mathbf{x}) = \sum_{i=1}^D \frac{x_i^2}{4000} - \prod_{i=1}^D \cos(\frac{x_i}{\sqrt{i}}) + 1` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (0,...,0)` + + LaTeX formats: + Inline: + $f(\mathbf{x}) = \sum_{i=1}^D \frac{x_i^2}{4000} - + \prod_{i=1}^D \cos(\frac{x_i}{\sqrt{i}}) + 1$ + + Equation: + \begin{equation} f(\mathbf{x}) = \sum_{i=1}^D \frac{x_i^2}{4000} - + \prod_{i=1}^D \cos(\frac{x_i}{\sqrt{i}}) + 1 \end{equation} + + Domain: + $-100 \leq x_i \leq 100$ + + Reference paper: + Jamil, M., and Yang, X. S. (2013). + A literature survey of benchmark functions for global optimisation problems. + International Journal of Mathematical Modelling and Numerical Optimisation, + 4(2), 150-194. + + """ + + Name = ["Griewank"] + + def __init__(self, Lower=-100.0, Upper=100.0): + """The initialization of Griewank benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Date: 2018 + """ - Authors: Iztok Fister Jr. and Lucija Brezočnik + Benchmark.__init__(self, Lower, Upper) - License: MIT + @staticmethod + def latex_code(): + """Return the latex code of the problem. - Function: **Griewank function** + Returns: + [str] -- latex code. - :math:`f(\mathbf{x}) = \sum_{i=1}^D \frac{x_i^2}{4000} - \prod_{i=1}^D \cos(\frac{x_i}{\sqrt{i}}) + 1` + """ - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + return r'''$f(\mathbf{x}) = \sum_{i=1}^D \frac{x_i^2}{4000} - + \prod_{i=1}^D \cos(\frac{x_i}{\sqrt{i}}) + 1$''' - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (0,...,0)` + @classmethod + def function(cls): + """Return benchmark evaluation function. - LaTeX formats: - Inline: - $f(\mathbf{x}) = \sum_{i=1}^D \frac{x_i^2}{4000} - - \prod_{i=1}^D \cos(\frac{x_i}{\sqrt{i}}) + 1$ + Returns: + [fun] -- Evaluation function. - Equation: - \begin{equation} f(\mathbf{x}) = \sum_{i=1}^D \frac{x_i^2}{4000} - - \prod_{i=1}^D \cos(\frac{x_i}{\sqrt{i}}) + 1 \end{equation} + """ - Domain: - $-100 \leq x_i \leq 100$ + def evaluate(D, sol): - Reference paper: - Jamil, M., and Yang, X. S. (2013). - A literature survey of benchmark functions for global optimisation problems. - International Journal of Mathematical Modelling and Numerical Optimisation, - 4(2), 150-194. - """ - Name = ['Griewank'] + val1, val2 = 0.0, 1.0 - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower, Upper) + for i in range(D): + val1 += sol[i] ** 2 / 4000.0 + val2 *= cos(sol[i] / sqrt(i + 1)) - @staticmethod - def latex_code(): - return r'''$f(\mathbf{x}) = \sum_{i=1}^D \frac{x_i^2}{4000} - - \prod_{i=1}^D \cos(\frac{x_i}{\sqrt{i}}) + 1$''' + return val1 - val2 + 1.0 + + return evaluate - @classmethod - def function(cls): - def evaluate(D, sol): - val1, val2 = 0.0, 1.0 - for i in range(D): - val1 += sol[i] ** 2 / 4000.0 - val2 *= cos(sol[i] / sqrt(i + 1)) - return val1 - val2 + 1.0 - return evaluate class ExpandedGriewankPlusRosenbrock(Benchmark): - r"""Implementation of Expanded Griewank's plus Rosenbrock function. + r"""Implementation of Expanded Griewank's plus Rosenbrock benchmark. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **Expanded Griewank's plus Rosenbrock function** + + :math:`f(\textbf{x}) = h(g(x_D, x_1)) + \sum_{i=2}^D h(g(x_{i - 1}, x_i)) \\ g(x, y) = 100 (x^2 - y)^2 + (x - 1)^2 \\ h(z) = \frac{z^2}{4000} - \cos \left( \frac{z}{\sqrt{1}} \right) + 1` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = h(g(x_D, x_1)) + \sum_{i=2}^D h(g(x_{i - 1}, x_i)) \\ g(x, y) = 100 (x^2 - y)^2 + (x - 1)^2 \\ h(z) = \frac{z^2}{4000} - \cos \left( \frac{z}{\sqrt{1}} \right) + 1$ + + Equation: + \begin{equation} f(\textbf{x}) = h(g(x_D, x_1)) + \sum_{i=2}^D h(g(x_{i - 1}, x_i)) \\ g(x, y) = 100 (x^2 - y)^2 + (x - 1)^2 \\ h(z) = \frac{z^2}{4000} - \cos \left( \frac{z}{\sqrt{1}} \right) + 1 \end{equation} + + Domain: + $-100 \leq x_i \leq 100$ + + Reference: http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf + + """ + + Name = ["ExpandedGriewankPlusRosenbrock"] + + def __init__(self, Lower=-100.0, Upper=100.0): + """The initialization of Expanded Griewank Plus Rosenbrock benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Date: 2018 + """ - Author: Klemen Berkovič + Benchmark.__init__(self, Lower, Upper) - License: MIT + @staticmethod + def latex_code(): + """Return the latex code of the problem. - Function: **Expanded Griewank's plus Rosenbrock function** + Returns: + [str] -- latex code. - :math:`f(\textbf{x}) = h(g(x_D, x_1)) + \sum_{i=2}^D h(g(x_{i - 1}, x_i)) \\ g(x, y) = 100 (x^2 - y)^2 + (x - 1)^2 \\ h(z) = \frac{z^2}{4000} - \cos \left( \frac{z}{\sqrt{1}} \right) + 1` + """ - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + return r'''$f(\textbf{x}) = h(g(x_D, x_1)) + \sum_{i=2}^D h(g(x_{i - 1}, x_i)) \\ g(x, y) = 100 (x^2 - y)^2 + (x - 1)^2 \\ h(z) = \frac{z^2}{4000} - \cos \left( \frac{z}{\sqrt{1}} \right) + 1$''' - **Global minimum:** - :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + @classmethod + def function(cls): + """Return benchmark evaluation function. - LaTeX formats: - Inline: - $f(\textbf{x}) = h(g(x_D, x_1)) + \sum_{i=2}^D h(g(x_{i - 1}, x_i)) \\ g(x, y) = 100 (x^2 - y)^2 + (x - 1)^2 \\ h(z) = \frac{z^2}{4000} - \cos \left( \frac{z}{\sqrt{1}} \right) + 1$ + Returns: + [fun] -- Evaluation function. - Equation: - \begin{equation} f(\textbf{x}) = h(g(x_D, x_1)) + \sum_{i=2}^D h(g(x_{i - 1}, x_i)) \\ g(x, y) = 100 (x^2 - y)^2 + (x - 1)^2 \\ h(z) = \frac{z^2}{4000} - \cos \left( \frac{z}{\sqrt{1}} \right) + 1 \end{equation} + """ - Domain: - $-100 \leq x_i \leq 100$ + def h(z): + return z ** 2 / 4000 - cos(z / sqrt(1)) + 1 - Reference: - http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - """ - Name = ['ExpandedGriewankPlusRosenbrock'] + def g(x, y): + return 100 * (x ** 2 - y ** 2) ** 2 + (x - 1) ** 2 - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower, Upper) + def evaluate(D, sol): + val = 0.0 - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = h(g(x_D, x_1)) + \sum_{i=2}^D h(g(x_{i - 1}, x_i)) \\ g(x, y) = 100 (x^2 - y)^2 + (x - 1)^2 \\ h(z) = \frac{z^2}{4000} - \cos \left( \frac{z}{\sqrt{1}} \right) + 1$''' + for i in range(1, D): + val += h(g(sol[i - 1], sol[i])) - @classmethod - def function(cls): - def h(z): return z ** 2 / 4000 - cos(z / sqrt(1)) + 1 - def g(x, y): return 100 * (x ** 2 - y ** 2) ** 2 + (x - 1) ** 2 - def f(D, x): - val = 0.0 - for i in range(1, D): val += h(g(x[i - 1], x[i])) - return h(g(x[D - 1], x[0])) + val - return f + return h(g(sol[D - 1], sol[0])) + val -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/happyCat.py b/NiaPy/benchmarks/happyCat.py index 55d71175..23ac8464 100644 --- a/NiaPy/benchmarks/happyCat.py +++ b/NiaPy/benchmarks/happyCat.py @@ -1,14 +1,15 @@ # encoding=utf8 -"""The module implementing Happy Cat benchmark.""" + +"""Implementation of Happy Cat benchmark.""" import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['HappyCat'] +__all__ = ["HappyCat"] class HappyCat(Benchmark): - ur"""Implementation of Happy cat function. + r"""Implementation of Happy cat function. Date: 2018 @@ -41,18 +42,23 @@ class HappyCat(Benchmark): $-100 \leq x_i \leq 100$ Reference: http://bee22.com/manual/tf_images/Liang%20CEC2014.pdf & - Beyer, H. G., & Finck, S. (2012). HappyCat - A Simple Function Class Where Well-Known Direct Search Algorithms Do Fail. - In International Conference on Parallel Problem Solving from Nature (pp. 367-376). Springer, Berlin, Heidelberg. + Beyer, H. G., & Finck, S. (2012). HappyCat - A Simple Function Class Where Well-Known Direct Search Algorithms Do Fail. + In International Conference on Parallel Problem Solving from Nature (pp. 367-376). Springer, Berlin, Heidelberg. + """ - Name = ['HappyCat'] + Name = ["HappyCat"] def __init__(self, Lower=-100.0, Upper=100.0): """The initialization of Happy Cat benchmark. - Keyword Arguments: - Lower {float} -- Lower bound. (default: {-100.0}) - Upper {float} -- Upper bound. (default: {100.0}) + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + """ Benchmark.__init__(self, Lower, Upper) @@ -72,7 +78,13 @@ def latex_code(): @classmethod def function(cls): - """Return benchmark evaluation function.""" + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val1 = 0.0 diff --git a/NiaPy/benchmarks/hgbat.py b/NiaPy/benchmarks/hgbat.py index decf8916..fd0f8e90 100644 --- a/NiaPy/benchmarks/hgbat.py +++ b/NiaPy/benchmarks/hgbat.py @@ -1,60 +1,93 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, line-too-long, multiple-statements -"""Implementations of HGBat functions.""" + +"""Implementation of HGBat benchmark.""" from math import fabs from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['HGBat'] +__all__ = ["HGBat"] + class HGBat(Benchmark): - r"""Implementations of HGBat functions. + r"""Implementations of HGBat functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **HGBat Function** + :math:``f(\textbf{x}) = \left| \left( \sum_{i=1}^D x_i^2 \right)^2 - \left( \sum_{i=1}^D x_i \right)^2 \right|^{\frac{1}{2}} + \frac{0.5 \sum_{i=1}^D x_i^2 + \sum_{i=1}^D x_i}{D} + 0.5 + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + + LaTeX formats: + Inline: + $$f(\textbf{x}) = \left| \left( \sum_{i=1}^D x_i^2 \right)^2 - \left( \sum_{i=1}^D x_i \right)^2 \right|^{\frac{1}{2}} + \frac{0.5 \sum_{i=1}^D x_i^2 + \sum_{i=1}^D x_i}{D} + 0.5 + + Equation: + \begin{equation} f(\textbf{x}) = \left| \left( \sum_{i=1}^D x_i^2 \right)^2 - \left( \sum_{i=1}^D x_i \right)^2 \right|^{\frac{1}{2}} + \frac{0.5 \sum_{i=1}^D x_i^2 + \sum_{i=1}^D x_i}{D} + 0.5 \end{equation} + + Domain: + $-100 \leq x_i \leq 100$ + + Reference: + http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf + + """ + + Name = ["HGBat"] + + def __init__(self, Lower=-100.0, Upper=100.0): + r"""The initialization of HGBat benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ - Date: 2018 + Benchmark.__init__(self, Lower, Upper) - Author: Klemen Berkovič + @staticmethod + def latex_code(): + """Return the latex code of the problem. - License: MIT + Returns: + [str] -- latex code. - Function: - **HGBat Function** - :math:``f(\textbf{x}) = \left| \left( \sum_{i=1}^D x_i^2 \right)^2 - \left( \sum_{i=1}^D x_i \right)^2 \right|^{\frac{1}{2}} + \frac{0.5 \sum_{i=1}^D x_i^2 + \sum_{i=1}^D x_i}{D} + 0.5 + """ - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + return r"""$f(\textbf{x}) = \left| \left( \sum_{i=1}^D x_i^2 \right)^2 - \left( \sum_{i=1}^D x_i \right)^2 \right|^{\frac{1}{2}} + \frac{0.5 \sum_{i=1}^D x_i^2 + \sum_{i=1}^D x_i}{D} + 0.5$""" - **Global minimum:** - :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + @classmethod + def function(cls): + """Return benchmark evaluation function. - LaTeX formats: - Inline: - $$f(\textbf{x}) = \left| \left( \sum_{i=1}^D x_i^2 \right)^2 - \left( \sum_{i=1}^D x_i \right)^2 \right|^{\frac{1}{2}} + \frac{0.5 \sum_{i=1}^D x_i^2 + \sum_{i=1}^D x_i}{D} + 0.5 + Returns: + [fun] -- Evaluation function. - Equation: - \begin{equation} f(\textbf{x}) = \left| \left( \sum_{i=1}^D x_i^2 \right)^2 - \left( \sum_{i=1}^D x_i \right)^2 \right|^{\frac{1}{2}} + \frac{0.5 \sum_{i=1}^D x_i^2 + \sum_{i=1}^D x_i}{D} + 0.5 \end{equation} + """ - Domain: - $-100 \leq x_i \leq 100$ + def evaluate(D, sol): - Reference: - http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - """ - Name = ['HGBat'] + val1, val2 = 0.0, 0.0 - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower, Upper) + for i in range(D): + val1 += sol[i] ** 2 - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = \left| \left( \sum_{i=1}^D x_i^2 \right)^2 - \left( \sum_{i=1}^D x_i \right)^2 \right|^{\frac{1}{2}} + \frac{0.5 \sum_{i=1}^D x_i^2 + \sum_{i=1}^D x_i}{D} + 0.5$''' + for i in range(D): + val2 += sol[i] - @classmethod - def function(cls): - def f(D, x): - val1, val2 = 0.0, 0.0 - for i in range(D): val1 += x[i] ** 2 - for i in range(D): val2 += x[i] - return fabs(val1 ** 2 - val2 ** 2) ** (1 / 2) + (0.5 * val1 + val2) / D + 0.5 - return f + return fabs(val1 ** 2 - val2 ** 2) ** (1 / 2) + (0.5 * val1 + val2) / D + 0.5 -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/infinity.py b/NiaPy/benchmarks/infinity.py index 3a81a2f4..a7b7e1f1 100644 --- a/NiaPy/benchmarks/infinity.py +++ b/NiaPy/benchmarks/infinity.py @@ -1,60 +1,90 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, multiple-statements -"""Implementations of Infinity function.""" + +"""Implementation of Infinity benchmark.""" from numpy import sin from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Infinity'] +__all__ = ["Infinity"] + class Infinity(Benchmark): - r"""Implementations of Infinity function. + r"""Implementations of Infinity function. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **Infinity Function** + + :math:`f(\textbf{x}) = \sum_{i = 1}^D x_i^6 \left( \sin \left( \frac{1}{x_i} \right) + 2 \right)` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-1, 1]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = \sum_{i = 1}^D x_i^6 \left( \sin \left( \frac{1}{x_i} \right) + 2 \right)$ + + Equation: + \begin{equation} f(\textbf{x}) = \sum_{i = 1}^D x_i^6 \left( \sin \left( \frac{1}{x_i} \right) + 2 \right) \end{equation} + + Domain: + $-1 \leq x_i \leq 1$ + + Reference: + http://infinity77.net/global_optimization/test_functions_nd_I.html#go_benchmark.Infinity + + """ + + Name = ["Infinity"] + + def __init__(self, Lower=-1.0, Upper=1.0): + r"""The initialization of Infinity benchmark. - Date: 2018 + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - Author: Klemen Berkovič + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - License: MIT + """ - Function: - **Infinity Function** + Benchmark.__init__(self, Lower, Upper) - :math:`f(\textbf{x}) = \sum_{i = 1}^D x_i^6 \left( \sin \left( \frac{1}{x_i} \right) + 2 \right)` + @staticmethod + def latex_code(): + """Return the latex code of the problem. - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-1, 1]`, for all :math:`i = 1, 2,..., D`. + Returns: + [str] -- latex code. - **Global minimum:** - :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + """ - LaTeX formats: - Inline: - $f(\textbf{x}) = \sum_{i = 1}^D x_i^6 \left( \sin \left( \frac{1}{x_i} \right) + 2 \right)$ + return r"""$f(\textbf{x}) = \sum_{i = 1}^D x_i^6 \left( \sin \left( \frac{1}{x_i} \right) + 2 \right)$""" - Equation: - \begin{equation} f(\textbf{x}) = \sum_{i = 1}^D x_i^6 \left( \sin \left( \frac{1}{x_i} \right) + 2 \right) \end{equation} + @classmethod + def function(cls): + """Return benchmark evaluation function. - Domain: - $-1 \leq x_i \leq 1$ + Returns: + [fun] -- Evaluation function. - Reference: - http://infinity77.net/global_optimization/test_functions_nd_I.html#go_benchmark.Infinity - """ - Name = ['Infinity'] + """ - def __init__(self, Lower=-1.0, Upper=1.0): Benchmark.__init__(self, Lower, Upper) + def evaluate(D, sol): + val = 0.0 - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = \sum_{i = 1}^D x_i^6 \left( \sin \left( \frac{1}{x_i} \right) + 2 \right)$''' + for i in range(D): + val += sol[i] ** 6 * (sin(1 / sol[i]) + 2) - @classmethod - def function(cls): - def f(D, X): - val = 0.0 - for i in range(D): val += X[i] ** 6 * (sin(1 / X[i]) + 2) - return val - return f + return val -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/katsuura.py b/NiaPy/benchmarks/katsuura.py index dc167745..b0d162e7 100644 --- a/NiaPy/benchmarks/katsuura.py +++ b/NiaPy/benchmarks/katsuura.py @@ -1,62 +1,94 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, line-too-long, multiple-statements -"""Implementations of Katsuura functions.""" + +"""Implementation of Katsuura benchmark.""" from math import fabs from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Katsuura'] +__all__ = ["Katsuura"] + class Katsuura(Benchmark): - r"""Implementations of Katsuura functions. + r"""Implementations of Katsuura functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **Katsuura Function** + + :math:`f(\textbf{x}) = \frac{10}{D^2} \prod_{i=1}^D \left( 1 + i \sum_{j=1}^{32} \frac{| 2^j x_i - round\left(2^j x_i \right) |}{2^j} \right)^\frac{10}{D^{1.2}} - \frac{10}{D^2}` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = \frac{10}{D^2} \prod_{i=1}^D \left( 1 + i \sum_{j=1}^{32} \frac{| 2^j x_i - round\left(2^j x_i \right) |}{2^j} \right)^\frac{10}{D^{1.2}} - \frac{10}{D^2}$ + + Equation: + \begin{equation} f(\textbf{x}) = \frac{10}{D^2} \prod_{i=1}^D \left( 1 + i \sum_{j=1}^{32} \frac{| 2^j x_i - round\left(2^j x_i \right) |}{2^j} \right)^\frac{10}{D^{1.2}} - \frac{10}{D^2} \end{equation} + + Domain: + $-100 \leq x_i \leq 100$ + + Reference: + http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf + + """ + + Name = ["Katsuura"] + + def __init__(self, Lower=-100.0, Upper=100.0, **kwargs): + r"""The initialization of Katsuura benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Date: 2018 + """ - Author: Klemen Berkovič + Benchmark.__init__(self, Lower, Upper, **kwargs) - License: MIT + @staticmethod + def latex_code(): + """Return the latex code of the problem. - Function: - **Katsuura Function** + Returns: + [str] -- latex code. - :math:`f(\textbf{x}) = \frac{10}{D^2} \prod_{i=1}^D \left( 1 + i \sum_{j=1}^{32} \frac{| 2^j x_i - round\left(2^j x_i \right) |}{2^j} \right)^\frac{10}{D^{1.2}} - \frac{10}{D^2}` + """ - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + return r"""$f(\textbf{x}) = \frac{10}{D^2} \prod_{i=1}^D \left( 1 + i \sum_{j=1}^{32} \frac{| 2^j x_i - round\left(2^j x_i \right) |}{2^j} \right)^\frac{10}{D^{1.2}} - \frac{10}{D^2}$""" - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + @classmethod + def function(cls): + """Return benchmark evaluation function. - LaTeX formats: - Inline: - $f(\textbf{x}) = \frac{10}{D^2} \prod_{i=1}^D \left( 1 + i \sum_{j=1}^{32} \frac{| 2^j x_i - round\left(2^j x_i \right) |}{2^j} \right)^\frac{10}{D^{1.2}} - \frac{10}{D^2}$ + Returns: + [fun] -- Evaluation function. - Equation: - \begin{equation} f(\textbf{x}) = \frac{10}{D^2} \prod_{i=1}^D \left( 1 + i \sum_{j=1}^{32} \frac{| 2^j x_i - round\left(2^j x_i \right) |}{2^j} \right)^\frac{10}{D^{1.2}} - \frac{10}{D^2} \end{equation} + """ - Domain: - $-100 \leq x_i \leq 100$ + def evaluate(D, sol): + val = 1.0 - Reference: - http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - """ - Name = ['Katsuura'] + for i in range(D): + valt = 1.0 - def __init__(self, Lower=-100.0, Upper=100.0, **kwargs): Benchmark.__init__(self, Lower, Upper, **kwargs) + for j in range(1, 33): + valt += fabs(2 ** j * sol[i] - round(2 ** j * sol[i])) / 2 ** j - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = \frac{10}{D^2} \prod_{i=1}^D \left( 1 + i \sum_{j=1}^{32} \frac{| 2^j x_i - round\left(2^j x_i \right) |}{2^j} \right)^\frac{10}{D^{1.2}} - \frac{10}{D^2}$''' + val *= (1 + (i + 1) * valt) ** (10 / D ** 1.2) - (10 / D ** 2) - @classmethod - def function(cls): - def f(D, x): - val = 1.0 - for i in range(D): - valt = 1.0 - for j in range(1, 33): valt += fabs(2 ** j * x[i] - round(2 ** j * x[i])) / 2 ** j - val *= (1 + (i + 1) * valt) ** (10 / D ** 1.2) - (10 / D ** 2) - return 10 / D ** 2 * val - return f + return 10 / D ** 2 * val -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/levy.py b/NiaPy/benchmarks/levy.py index b9d2ffb0..e36e368d 100644 --- a/NiaPy/benchmarks/levy.py +++ b/NiaPy/benchmarks/levy.py @@ -1,61 +1,94 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, multiple-statements, line-too-long -"""Implementations of Levy function.""" + +"""Implementation of Levy benchmark.""" from numpy import sin, pi from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Levy'] +__all__ = ["Levy"] + class Levy(Benchmark): - r"""Implementations of Levy functions. + r"""Implementations of Levy functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **Levy Function** + + :math:`f(\textbf{x}) = \sin^2 (\pi w_1) + \sum_{i = 1}^{D - 1} (w_i - 1)^2 \left( 1 + 10 \sin^2 (\pi w_i + 1) \right) + (w_d - 1)^2 (1 + \sin^2 (2 \pi w_d)) \\ w_i = 1 + \frac{x_i - 1}{4}` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-10, 10]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + :math:`f(\textbf{x}^*) = 0` at :math:`\textbf{x}^* = (1, \cdots, 1)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = \sin^2 (\pi w_1) + \sum_{i = 1}^{D - 1} (w_i - 1)^2 \left( 1 + 10 \sin^2 (\pi w_i + 1) \right) + (w_d - 1)^2 (1 + \sin^2 (2 \pi w_d)) \\ w_i = 1 + \frac{x_i - 1}{4}$ + + Equation: + \begin{equation} f(\textbf{x}) = \sin^2 (\pi w_1) + \sum_{i = 1}^{D - 1} (w_i - 1)^2 \left( 1 + 10 \sin^2 (\pi w_i + 1) \right) + (w_d - 1)^2 (1 + \sin^2 (2 \pi w_d)) \\ w_i = 1 + \frac{x_i - 1}{4} \end{equation} + + Domain: + $-10 \leq x_i \leq 10$ + + Reference: + https://www.sfu.ca/~ssurjano/levy.html + + """ + + Name = ["Levy"] + + def __init__(self, Lower=0.0, Upper=pi): + r"""The initialization of Levy benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Date: 2018 + """ - Author: Klemen Berkovič + Benchmark.__init__(self, Lower, Upper) - License: MIT + @staticmethod + def latex_code(): + """Return the latex code of the problem. - Function: - **Levy Function** + Returns: + [str] -- latex code. - :math:`f(\textbf{x}) = \sin^2 (\pi w_1) + \sum_{i = 1}^{D - 1} (w_i - 1)^2 \left( 1 + 10 \sin^2 (\pi w_i + 1) \right) + (w_d - 1)^2 (1 + \sin^2 (2 \pi w_d)) \\ w_i = 1 + \frac{x_i - 1}{4}` + """ - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-10, 10]`, for all :math:`i = 1, 2,..., D`. + return r"""$f(\textbf{x}) = \sin^2 (\pi w_1) + \sum_{i = 1}^{D - 1} (w_i - 1)^2 \left( 1 + 10 \sin^2 (\pi w_i + 1) \right) + (w_d - 1)^2 (1 + \sin^2 (2 \pi w_d)) \\ w_i = 1 + \frac{x_i - 1}{4}$""" - **Global minimum:** - :math:`f(\textbf{x}^*) = 0` at :math:`\textbf{x}^* = (1, \cdots, 1)` + @classmethod + def function(cls): + """Return benchmark evaluation function. - LaTeX formats: - Inline: - $f(\textbf{x}) = \sin^2 (\pi w_1) + \sum_{i = 1}^{D - 1} (w_i - 1)^2 \left( 1 + 10 \sin^2 (\pi w_i + 1) \right) + (w_d - 1)^2 (1 + \sin^2 (2 \pi w_d)) \\ w_i = 1 + \frac{x_i - 1}{4}$ + Returns: + [fun] -- Evaluation function. - Equation: - \begin{equation} f(\textbf{x}) = \sin^2 (\pi w_1) + \sum_{i = 1}^{D - 1} (w_i - 1)^2 \left( 1 + 10 \sin^2 (\pi w_i + 1) \right) + (w_d - 1)^2 (1 + \sin^2 (2 \pi w_d)) \\ w_i = 1 + \frac{x_i - 1}{4} \end{equation} + """ - Domain: - $-10 \leq x_i \leq 10$ + def w(x): + return 1 + (x - 1) / 4 - Reference: - https://www.sfu.ca/~ssurjano/levy.html - """ - Name = ['Levy'] + def evaluate(D, sol): - def __init__(self, Lower=0.0, Upper=pi): Benchmark.__init__(self, Lower, Upper) + v = 0.0 - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = \sin^2 (\pi w_1) + \sum_{i = 1}^{D - 1} (w_i - 1)^2 \left( 1 + 10 \sin^2 (\pi w_i + 1) \right) + (w_d - 1)^2 (1 + \sin^2 (2 \pi w_d)) \\ w_i = 1 + \frac{x_i - 1}{4}$''' + for i in range(D - 1): + v += (w(sol[i]) - 1) ** 2 * (1 + 10 * sin(pi * w(sol[i]) + 1) ** 2) + (w(sol[-1]) - 1) ** 2 * (1 + sin(2 * pi * w(sol[-1]) ** 2)) - @classmethod - def function(cls): - def w(x): return 1 + (x - 1) / 4 - def f(D, X): - v = 0.0 - for i in range(D - 1): v += (w(X[i]) - 1) ** 2 * (1 + 10 * sin(pi * w(X[i]) + 1) ** 2) + (w(X[-1]) - 1) ** 2 * (1 + sin(2 * pi * w(X[-1]) ** 2)) - return sin(pi * w(X[0])) ** 2 + v - return f + return sin(pi * w(sol[0])) ** 2 + v -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/michalewichz.py b/NiaPy/benchmarks/michalewichz.py index 367df0f5..ab94905e 100644 --- a/NiaPy/benchmarks/michalewichz.py +++ b/NiaPy/benchmarks/michalewichz.py @@ -1,64 +1,95 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, multiple-statements -"""Implementations of Michalewichz's function.""" + +"""Implementation of Michalewichz"s benchmark.""" from numpy import sin, pi from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Michalewichz'] +__all__ = ["Michalewichz"] + class Michalewichz(Benchmark): - r"""Implementations of Michalewichz's functions. + r"""Implementations of Michalewichz"s functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **High Conditioned Elliptic Function** + + :math:`f(\textbf{x}) = \sum_{i=1}^D \left( 10^6 \right)^{ \frac{i - 1}{D - 1} } x_i^2` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [0, \pi]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + at :math:`d = 2` :math:`f(\textbf{x}^*) = -1.8013` at :math:`\textbf{x}^* = (2.20, 1.57)` + at :math:`d = 5` :math:`f(\textbf{x}^*) = -4.687658` + at :math:`d = 10` :math:`f(\textbf{x}^*) = -9.66015` + + LaTeX formats: + Inline: + $f(\textbf{x}) = - \sum_{i = 1}^{D} \sin(x_i) \sin\left( \frac{ix_i^2}{\pi} \right)^{2m}$ + + Equation: + \begin{equation} f(\textbf{x}) = - \sum_{i = 1}^{D} \sin(x_i) \sin\left( \frac{ix_i^2}{\pi} \right)^{2m} \end{equation} + + Domain: + $0 \leq x_i \leq \pi$ + + Reference URL: + https://www.sfu.ca/~ssurjano/michal.html + + """ + + Name = ["Michalewichz"] + + def __init__(self, Lower=0.0, Upper=pi, m=10): + r"""The initialization of Alpine1 benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + m (Optional[int]): m attribute. - Date: 2018 + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Author: Klemen Berkovič + """ - License: MIT + Benchmark.__init__(self, Lower, Upper) + self.m = m - Function: - **High Conditioned Elliptic Function** + @staticmethod + def latex_code(): + """Return the latex code of the problem. - :math:`f(\textbf{x}) = \sum_{i=1}^D \left( 10^6 \right)^{ \frac{i - 1}{D - 1} } x_i^2` + Returns: + [str] -- latex code. - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [0, \pi]`, for all :math:`i = 1, 2,..., D`. + """ - **Global minimum:** - at :math:`d = 2` :math:`f(\textbf{x}^*) = -1.8013` at :math:`\textbf{x}^* = (2.20, 1.57)` - at :math:`d = 5` :math:`f(\textbf{x}^*) = -4.687658` - at :math:`d = 10` :math:`f(\textbf{x}^*) = -9.66015` + return r"""$f(\textbf{x}) = - \sum_{i = 1}^{D} \sin(x_i) \sin\left( \frac{ix_i^2}{\pi} \right)^{2m}$""" - LaTeX formats: - Inline: - $f(\textbf{x}) = - \sum_{i = 1}^{D} \sin(x_i) \sin\left( \frac{ix_i^2}{\pi} \right)^{2m}$ + @classmethod + def function(cls): + """Return benchmark evaluation function. - Equation: - \begin{equation} f(\textbf{x}) = - \sum_{i = 1}^{D} \sin(x_i) \sin\left( \frac{ix_i^2}{\pi} \right)^{2m} \end{equation} + Returns: + [fun] -- Evaluation function. - Domain: - $0 \leq x_i \leq \pi$ + """ - Reference URL: - https://www.sfu.ca/~ssurjano/michal.html - """ - Name = ['Michalewichz'] + def evaluate(D, sol): - def __init__(self, Lower=0.0, Upper=pi, m=10): - Benchmark.__init__(self, Lower, Upper) - Michalewichz.m = m + v = 0.0 - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = - \sum_{i = 1}^{D} \sin(x_i) \sin\left( \frac{ix_i^2}{\pi} \right)^{2m}$''' + for i in range(D): + v += sin(sol[i]) * sin(((i + 1) * sol[i] ** 2) / pi) ** (2 * cls.m) - @classmethod - def function(cls): - def evaluate(D, X): - v = 0.0 - for i in range(D): v += sin(X[i]) * sin(((i + 1) * X[i] ** 2) / pi) ** (2 * cls.m) - return -v - return evaluate + return -v -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/perm.py b/NiaPy/benchmarks/perm.py index 6f7bbb83..f738a04a 100644 --- a/NiaPy/benchmarks/perm.py +++ b/NiaPy/benchmarks/perm.py @@ -1,67 +1,98 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, multiple-statements -"""Implementations of Perm function.""" + +"""Implementation of Perm benchmark.""" from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Perm'] +__all__ = ["Perm"] + class Perm(Benchmark): - r"""Implementations of Perm functions. + r"""Implementations of Perm functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Arguments: + beta {real} -- value added to inner sum of funciton + + Function: **Perm Function** + + :math:`f(\textbf{x}) = \sum_{i = 1}^D \left( \sum_{j = 1}^D (j - \beta) \left( x_j^i - \frac{1}{j^i} \right) \right)^2` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-D, D]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + :math:`f(\textbf{x}^*) = 0` at :math:`\textbf{x}^* = (1, \frac{1}{2}, \cdots , \frac{1}{i} , \cdots , \frac{1}{D})` + + LaTeX formats: + Inline: + $f(\textbf{x}) = \sum_{i = 1}^D \left( \sum_{j = 1}^D (j - \beta) \left( x_j^i - \frac{1}{j^i} \right) \right)^2$ + + Equation: + \begin{equation} f(\textbf{x}) = \sum_{i = 1}^D \left( \sum_{j = 1}^D (j - \beta) \left( x_j^i - \frac{1}{j^i} \right) \right)^2 \end{equation} + + Domain: + $-D \leq x_i \leq D$ + + Reference: + https://www.sfu.ca/~ssurjano/perm0db.html + + """ + + Name = ["Perm"] + + def __init__(self, D=10.0, beta=0.5): + """The initialization of Perm benchmark. + + Args: + D [float] -- Dimension on problem. (default: {10.0}) + beta [float] -- beat parameter. (default: {0.5}) - Date: 2018 + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Author: Klemen Berkovič + """ - License: MIT + Benchmark.__init__(self, -D, D) + self.beta = beta - Arguments: - beta {real} -- value added to inner sum of funciton + @staticmethod + def latex_code(): + """Return the latex code of the problem. - Function: - **Perm Function** + Returns: + [str] -- latex code. - :math:`f(\textbf{x}) = \sum_{i = 1}^D \left( \sum_{j = 1}^D (j - \beta) \left( x_j^i - \frac{1}{j^i} \right) \right)^2` + """ - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-D, D]`, for all :math:`i = 1, 2,..., D`. + return r"""$f(\textbf{x}) = \sum_{i = 1}^D \left( \sum_{j = 1}^D (j - \beta) \left( x_j^i - \frac{1}{j^i} \right) \right)^2$""" - **Global minimum:** - :math:`f(\textbf{x}^*) = 0` at :math:`\textbf{x}^* = (1, \frac{1}{2}, \cdots , \frac{1}{i} , \cdots , \frac{1}{D})` + @classmethod + def function(cls): + """Return benchmark evaluation function. - LaTeX formats: - Inline: - $f(\textbf{x}) = \sum_{i = 1}^D \left( \sum_{j = 1}^D (j - \beta) \left( x_j^i - \frac{1}{j^i} \right) \right)^2$ + Returns: + [fun] -- Evaluation function. - Equation: - \begin{equation} f(\textbf{x}) = \sum_{i = 1}^D \left( \sum_{j = 1}^D (j - \beta) \left( x_j^i - \frac{1}{j^i} \right) \right)^2 \end{equation} + """ - Domain: - $-D \leq x_i \leq D$ + def evaluate(D, sol): + v = 0.0 - Reference: - https://www.sfu.ca/~ssurjano/perm0db.html - """ - Name = ['Perm'] + for i in range(1, D + 1): + vv = .0 - def __init__(self, D=10.0, beta=.5): - Benchmark.__init__(self, -D, D) - Perm.beta = beta + for j in range(1, D + 1): + vv += (j + cls.beta) * (sol[j - 1] ** i - 1 / j ** i) - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = \sum_{i = 1}^D \left( \sum_{j = 1}^D (j - \beta) \left( x_j^i - \frac{1}{j^i} \right) \right)^2$''' + v += vv ** 2 - @classmethod - def function(cls): - def f(D, X): - v = .0 - for i in range(1, D + 1): - vv = .0 - for j in range(1, D + 1): vv += (j + cls.beta) * (X[j - 1] ** i - 1 / j ** i) - v += vv ** 2 - return v - return f + return v -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/pinter.py b/NiaPy/benchmarks/pinter.py index d16d15f8..2358736e 100644 --- a/NiaPy/benchmarks/pinter.py +++ b/NiaPy/benchmarks/pinter.py @@ -1,9 +1,11 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Pinter benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Pinter'] +__all__ = ["Pinter"] class Pinter(Benchmark): @@ -51,14 +53,34 @@ class Pinter(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Pinter'] + + Name = ["Pinter"] def __init__(self, Lower=-10.0, Upper=10.0): + r"""The initialization of Pinter benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + return r''' $f(\mathbf{x}) = \sum_{i=1}^D ix_i^2 + \sum_{i=1}^D 20i \sin^2 A + \sum_{i=1}^D i \log_{10} (1 + iB^2); @@ -67,6 +89,13 @@ def latex_code(): @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val1 = 0.0 diff --git a/NiaPy/benchmarks/powell.py b/NiaPy/benchmarks/powell.py index 8b664ec4..1b3d8052 100644 --- a/NiaPy/benchmarks/powell.py +++ b/NiaPy/benchmarks/powell.py @@ -1,59 +1,88 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, multiple-statements, line-too-long -"""Implementations of Levy function.""" + +"""Implementations of Powell benchmark.""" from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Powell'] +__all__ = ["Powell"] + class Powell(Benchmark): - r"""Implementations of Powell functions. + r"""Implementations of Powell functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **Levy Function** + + :math:`f(\textbf{x}) = \sum_{i = 1}^{D / 4} \left( (x_{4 i - 3} + 10 x_{4 i - 2})^2 + 5 (x_{4 i - 1} - x_{4 i})^2 + (x_{4 i - 2} - 2 x_{4 i - 1})^4 + 10 (x_{4 i - 3} - x_{4 i})^4 \right)` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-4, 5]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + :math:`f(\textbf{x}^*) = 0` at :math:`\textbf{x}^* = (0, \cdots, 0)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = \sum_{i = 1}^{D / 4} \left( (x_{4 i - 3} + 10 x_{4 i - 2})^2 + 5 (x_{4 i - 1} - x_{4 i})^2 + (x_{4 i - 2} - 2 x_{4 i - 1})^4 + 10 (x_{4 i - 3} - x_{4 i})^4 \right)$ + + Equation: + \begin{equation} f(\textbf{x}) = \sum_{i = 1}^{D / 4} \left( (x_{4 i - 3} + 10 x_{4 i - 2})^2 + 5 (x_{4 i - 1} - x_{4 i})^2 + (x_{4 i - 2} - 2 x_{4 i - 1})^4 + 10 (x_{4 i - 3} - x_{4 i})^4 \right) \end{equation} + + Domain: + $-4 \leq x_i \leq 5$ + + Reference: + https://www.sfu.ca/~ssurjano/levy.html + + """ + + Name = ["Powell"] - Date: 2018 + def __init__(self, Lower=-4.0, Upper=5.0): + r"""The initialization of Powell benchmark. - Author: Klemen Berkovič + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - License: MIT + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Function: - **Levy Function** + """ - :math:`f(\textbf{x}) = \sum_{i = 1}^{D / 4} \left( (x_{4 i - 3} + 10 x_{4 i - 2})^2 + 5 (x_{4 i - 1} - x_{4 i})^2 + (x_{4 i - 2} - 2 x_{4 i - 1})^4 + 10 (x_{4 i - 3} - x_{4 i})^4 \right)` + Benchmark.__init__(self, Lower, Upper) - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-4, 5]`, for all :math:`i = 1, 2,..., D`. + @staticmethod + def latex_code(): + """Return the latex code of the problem. - **Global minimum:** - :math:`f(\textbf{x}^*) = 0` at :math:`\textbf{x}^* = (0, \cdots, 0)` + Returns: + [str] -- latex code. - LaTeX formats: - Inline: - $f(\textbf{x}) = \sum_{i = 1}^{D / 4} \left( (x_{4 i - 3} + 10 x_{4 i - 2})^2 + 5 (x_{4 i - 1} - x_{4 i})^2 + (x_{4 i - 2} - 2 x_{4 i - 1})^4 + 10 (x_{4 i - 3} - x_{4 i})^4 \right)$ + """ - Equation: - \begin{equation} f(\textbf{x}) = \sum_{i = 1}^{D / 4} \left( (x_{4 i - 3} + 10 x_{4 i - 2})^2 + 5 (x_{4 i - 1} - x_{4 i})^2 + (x_{4 i - 2} - 2 x_{4 i - 1})^4 + 10 (x_{4 i - 3} - x_{4 i})^4 \right) \end{equation} + return r"""$f(\textbf{x}) = \sum_{i = 1}^{D / 4} \left( (x_{4 i - 3} + 10 x_{4 i - 2})^2 + 5 (x_{4 i - 1} - x_{4 i})^2 + (x_{4 i - 2} - 2 x_{4 i - 1})^4 + 10 (x_{4 i - 3} - x_{4 i})^4 \right)$""" - Domain: - $-4 \leq x_i \leq 5$ + @classmethod + def function(cls): + """Return benchmark evaluation function. - Reference: - https://www.sfu.ca/~ssurjano/levy.html - """ - Name = ['Powell'] + Returns: + [fun] -- Evaluation function. - def __init__(self, Lower=-4.0, Upper=5.0): Benchmark.__init__(self, Lower, Upper) + """ - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = \sum_{i = 1}^{D / 4} \left( (x_{4 i - 3} + 10 x_{4 i - 2})^2 + 5 (x_{4 i - 1} - x_{4 i})^2 + (x_{4 i - 2} - 2 x_{4 i - 1})^4 + 10 (x_{4 i - 3} - x_{4 i})^4 \right)$''' + def evaluate(D, sol): + v = 0.0 - @classmethod - def function(cls): - def f(D, X): - v = 0.0 - for i in range(1, (D // 4) + 1): v += (X[4 * i - 4] + 10 * X[4 * i - 3]) ** 2 + 5 * (X[4 * i - 2] - X[4 * i - 1]) ** 2 + (X[4 * i - 3] - 2 * X[4 * i - 2]) ** 4 + 10 * (X[4 * i - 4] - X[4 * i - 1]) ** 4 - return v - return f + for i in range(1, (D // 4) + 1): + v += (sol[4 * i - 4] + 10 * sol[4 * i - 3]) ** 2 + 5 * (sol[4 * i - 2] - sol[4 * i - 1]) ** 2 + (sol[4 * i - 3] - 2 * sol[4 * i - 2]) ** 4 + 10 * (sol[4 * i - 4] - sol[4 * i - 1]) ** 4 -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return v + return evaluate diff --git a/NiaPy/benchmarks/qing.py b/NiaPy/benchmarks/qing.py index ed11aaa8..17eceef3 100644 --- a/NiaPy/benchmarks/qing.py +++ b/NiaPy/benchmarks/qing.py @@ -1,9 +1,12 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Quing benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Qing'] +__all__ = ["Qing"] + class Qing(Benchmark): r"""Implementation of Qing function. @@ -40,18 +43,45 @@ class Qing(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Qing'] + + Name = ["Qing"] def __init__(self, Lower=-500.0, Upper=500.0): + """The initialization of Quing benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + return r'''$f(\mathbf{x}) = \sum_{i=1}^D \left (x_i^2 - i\right)^2$''' @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/quintic.py b/NiaPy/benchmarks/quintic.py index 3786c441..9cecd31c 100644 --- a/NiaPy/benchmarks/quintic.py +++ b/NiaPy/benchmarks/quintic.py @@ -1,9 +1,11 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Quintic benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Quintic'] +__all__ = ["Quintic"] class Quintic(Benchmark): @@ -44,26 +46,53 @@ class Quintic(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Quintic'] + + Name = ["Quintic"] def __init__(self, Lower=-10.0, Upper=10.0): + """The initialization of Quintic benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + return r'''$f(\mathbf{x}) = \sum_{i=1}^D \left| x_i^5 - 3x_i^4 + 4x_i^3 + 2x_i^2 - 10x_i - 4\right|$''' @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 for i in range(D): - val += abs(math.pow(sol[i], 5) - 3.0 * math.pow(sol[i], 4) + 4.0 * - math.pow(sol[i], 3) + 2.0 * math.pow(sol[i], 2) - 10.0 * sol[i] - 4) + val += abs( + math.pow(sol[i], 5) - 3.0 * math.pow(sol[i], 4) + 4.0 * math.pow(sol[i], 3) + 2.0 * math.pow(sol[i], 2) - 10.0 * sol[i] - 4) return val diff --git a/NiaPy/benchmarks/rastrigin.py b/NiaPy/benchmarks/rastrigin.py index a3595b5b..1f1eae66 100644 --- a/NiaPy/benchmarks/rastrigin.py +++ b/NiaPy/benchmarks/rastrigin.py @@ -1,9 +1,11 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implemenatation of Rastrigin benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Rastrigin'] +__all__ = ["Rastrigin"] class Rastrigin(Benchmark): @@ -38,18 +40,44 @@ class Rastrigin(Benchmark): $-5.12 \leq x_i \leq 5.12$ Reference: https://www.sfu.ca/~ssurjano/rastr.html + """ + Name = ['Rastrigin'] def __init__(self, Lower=-5.12, Upper=5.12): + """The initialization of Rastrigin benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ return r'''$f(\mathbf{x}) = 10D + \sum_{i=1}^D \left(x_i^2 -10\cos(2\pi x_i)\right)$''' @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/ridge.py b/NiaPy/benchmarks/ridge.py index 425aa15b..5bc278f5 100644 --- a/NiaPy/benchmarks/ridge.py +++ b/NiaPy/benchmarks/ridge.py @@ -1,9 +1,11 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Ridge benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Ridge'] +__all__ = ["Ridge"] class Ridge(Benchmark): @@ -37,18 +39,45 @@ class Ridge(Benchmark): $-64 \leq x_i \leq 64$ Reference: http://www.cs.unm.edu/~neal.holts/dga/benchmarkFunction/ridge.html + """ + Name = ['Ridge'] def __init__(self, Lower=-64.0, Upper=64.0): + """The initialization of Ridge benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + return r'''$f(\mathbf{x}) = \sum_{i=1}^D (\sum_{j=1}^i x_j)^2 $''' @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/rosenbrock.py b/NiaPy/benchmarks/rosenbrock.py index bbf0e505..1d20a804 100644 --- a/NiaPy/benchmarks/rosenbrock.py +++ b/NiaPy/benchmarks/rosenbrock.py @@ -1,9 +1,11 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Rosenbrock benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Rosenbrock'] +__all__ = ["Rosenbrock"] class Rosenbrock(Benchmark): @@ -42,18 +44,45 @@ class Rosenbrock(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Rosenbrock'] + + Name = ["Rosenbrock"] def __init__(self, Lower=-30.0, Upper=30.0): + """The initialization of Rosenbrock benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + return r'''$f(\mathbf{x}) = \sum_{i=1}^{D-1} (100 (x_{i+1} - x_i^2)^2 + (x_i - 1)^2)$''' @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/salomon.py b/NiaPy/benchmarks/salomon.py index cab386bc..576c74d7 100644 --- a/NiaPy/benchmarks/salomon.py +++ b/NiaPy/benchmarks/salomon.py @@ -1,9 +1,11 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Salomon benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Salomon'] +__all__ = ["Salomon"] class Salomon(Benchmark): @@ -44,19 +46,46 @@ class Salomon(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Salomon'] + + Name = ["Salomon"] def __init__(self, Lower=-100.0, Upper=100.0): + """The initialization of Salomon benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + return r'''$f(\mathbf{x}) = 1 - \cos\left(2\pi\sqrt{\sum_{i=1}^D x_i^2} \right)+ 0.1 \sqrt{\sum_{i=1}^D x_i^2}$''' @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/schaffer.py b/NiaPy/benchmarks/schaffer.py index 3136f607..2cd2bfe7 100644 --- a/NiaPy/benchmarks/schaffer.py +++ b/NiaPy/benchmarks/schaffer.py @@ -1,149 +1,242 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string, mixed-indentation, multiple-statements, line-too-long, no-else-return, unused-argument -"""Implementations of Schwefels functions.""" + +"""Implementations of Schaffer benchmarks.""" from math import sin, cos, sqrt from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['SchafferN2', 'SchafferN4', 'ExpandedSchaffer'] +__all__ = ["SchafferN2", "SchafferN4", "ExpandedSchaffer"] + class SchafferN2(Benchmark): - r"""Implementations of Schaffer N. 2 functions. + r"""Implementations of Schaffer N. 2 functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **Schaffer N. 2 Function** + + :math:`f(\textbf{x}) = 0.5 + \frac{ \sin^2 \left( x_1^2 - x_2^2 \right) - 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 }` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = 0.5 + \frac{ \sin^2 \left( x_1^2 - x_2^2 \right) - 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 }$ + + Equation: + \begin{equation} f(\textbf{x}) = 0.5 + \frac{ \sin^2 \left( x_1^2 - x_2^2 \right) - 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 } \end{equation} + + Domain: + $-100 \leq x_i \leq 100$ - Date: 2018 + Reference: + http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf + """ - Author: Klemen Berkovič + Name = ["SchafferN2"] - License: MIT + def __init__(self, Lower=-100.0, Upper=100.0): + r"""The initialization of Schaffer N. 2 benchmark. - Function: - **Schaffer N. 2 Function** - :math:`f(\textbf{x}) = 0.5 + \frac{ \sin^2 \left( x_1^2 - x_2^2 \right) - 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 }` + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + """ - LaTeX formats: - Inline: - $f(\textbf{x}) = 0.5 + \frac{ \sin^2 \left( x_1^2 - x_2^2 \right) - 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 }$ + Benchmark.__init__(self, Lower, Upper) - Equation: - \begin{equation} f(\textbf{x}) = 0.5 + \frac{ \sin^2 \left( x_1^2 - x_2^2 \right) - 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 } \end{equation} + @staticmethod + def latex_code(): + """Return the latex code of the problem. - Domain: - $-100 \leq x_i \leq 100$ + Returns: + [str] -- latex code. - Reference: - http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - """ - Name = ['SchafferN2'] + """ - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower, Upper) + return r"""$f(\textbf{x}) = 0.5 + \frac{ \sin^2 \left( x_1^2 - x_2^2 \right) - 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 }$""" - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = 0.5 + \frac{ \sin^2 \left( x_1^2 - x_2^2 \right) - 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 }$''' + @classmethod + def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + + def evaluate(D, sol): + return 0.5 + (sin(sol[0] ** 2 - sol[1] ** 2) ** 2 - 0.5) / (1 + 0.001 * (sol[0] ** 2 + sol[1] ** 2)) ** 2 + + return evaluate - @classmethod - def function(cls): - def f(D, x): return 0.5 + (sin(x[0] ** 2 - x[1] ** 2) ** 2 - 0.5) / (1 + 0.001 * (x[0] ** 2 + x[1] ** 2)) ** 2 - return f class SchafferN4(Benchmark): - r"""Implementations of Schaffer N. 2 functions. + r"""Implementations of Schaffer N. 4 functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **Schaffer N. 4 Function** + + :math:`f(\textbf{x}) = 0.5 + \frac{ \cos^2 \left( \sin \left( x_1^2 - x_2^2 \right) \right)- 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 }` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` - Date: 2018 + LaTeX formats: + Inline: + $f(\textbf{x}) = 0.5 + \frac{ \cos^2 \left( \sin \left( x_1^2 - x_2^2 \right) \right)- 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 }$ - Author: Klemen Berkovič + Equation: + \begin{equation} f(\textbf{x}) = 0.5 + \frac{ \cos^2 \left( \sin \left( x_1^2 - x_2^2 \right) \right)- 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 } \end{equation} - License: MIT + Domain: + $-100 \leq x_i \leq 100$ - Function: - **Schaffer N. 2 Function** - :math:`f(\textbf{x}) = 0.5 + \frac{ \cos^2 \left( \sin \left( x_1^2 - x_2^2 \right) \right)- 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 }` + Reference: + http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + """ - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + Name = ["SchafferN4"] - LaTeX formats: - Inline: - $f(\textbf{x}) = 0.5 + \frac{ \cos^2 \left( \sin \left( x_1^2 - x_2^2 \right) \right)- 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 }$ + def __init__(self, Lower=-100.0, Upper=100.0): + r"""The initialization of Schaffer N. 4 benchmark. - Equation: - \begin{equation} f(\textbf{x}) = 0.5 + \frac{ \cos^2 \left( \sin \left( x_1^2 - x_2^2 \right) \right)- 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 } \end{equation} + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - Domain: - $-100 \leq x_i \leq 100$ + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Reference: - http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - """ - Name = ['SchafferN4'] + """ - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower, Upper) + Benchmark.__init__(self, Lower, Upper) - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = 0.5 + \frac{ \cos^2 \left( \sin \left( x_1^2 - x_2^2 \right) \right)- 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 }$''' + @staticmethod + def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + + return r"""$f(\textbf{x}) = 0.5 + \frac{ \cos^2 \left( \sin \left( x_1^2 - x_2^2 \right) \right)- 0.5 }{ \left( 1 + 0.001 \left( x_1^2 + x_2^2 \right) \right)^2 }$""" + + @classmethod + def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + + def evaluate(D, sol): + return 0.5 + (cos(sin(sol[0] ** 2 - sol[1] ** 2)) ** 2 - 0.5) / (1 + 0.001 * (sol[0] ** 2 + sol[1] ** 2)) ** 2 + + return evaluate - @classmethod - def function(cls): - def f(D, x): return 0.5 + (cos(sin(x[0] ** 2 - x[1] ** 2)) ** 2 - 0.5) / (1 + 0.001 * (x[0] ** 2 + x[1] ** 2)) ** 2 - return f class ExpandedSchaffer(Benchmark): - r"""Implementations of Expanded Schaffer functions. + r"""Implementations of Expanded Schaffer functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **Expanded Schaffer Function** + + :math:`f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2$ + + Equation: + \begin{equation} f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2 \end{equation} + + Domain: + $-100 \leq x_i \leq 100$ + + Reference: + http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf + """ + + Name = ["ExpandedSchaffer"] + + def __init__(self, Lower=-100.0, Upper=100.0): + r"""The initialization of Expanded Schaffer benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Date: 2018 + """ - Author: Klemen Berkovič + Benchmark.__init__(self, Lower, Upper) - License: MIT + @staticmethod + def latex_code(): + """Return the latex code of the problem. - Function: - **Expanded Schaffer Function** - :math:`f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2` + Returns: + [str] -- latex code. - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + """ - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + return r"""$f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2$""" - LaTeX formats: - Inline: - $f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2$ + @classmethod + def function(cls): + """Return benchmark evaluation function. - Equation: - \begin{equation} f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2 \end{equation} + Returns: + [fun] -- Evaluation function. - Domain: - $-100 \leq x_i \leq 100$ + """ - Reference: - http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - """ - Name = ['ExpandedSchaffer'] + def g(x, y): + return 0.5 + (sin(sqrt(x ** 2 + y ** 2)) ** 2 - 0.5) / (1 + 0.001 * (x ** 2 + y ** 2)) ** 2 - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower, Upper) + def evaluate(D, sol): - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2$''' + val = 0.0 - @classmethod - def function(cls): - def g(x, y): return 0.5 + (sin(sqrt(x ** 2 + y ** 2)) ** 2 - 0.5) / (1 + 0.001 * (x ** 2 + y ** 2)) ** 2 - def f(D, x): - val = 0.0 - for i in range(1, D): val += g(x[i - 1], x[i]) - return g(x[D - 1], x[0]) + val - return f + for i in range(1, D): + val += g(sol[i - 1], sol[i]) -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return g(sol[D - 1], sol[0]) + val + return evaluate diff --git a/NiaPy/benchmarks/schumerSteiglitz.py b/NiaPy/benchmarks/schumerSteiglitz.py index cc973613..1169193d 100644 --- a/NiaPy/benchmarks/schumerSteiglitz.py +++ b/NiaPy/benchmarks/schumerSteiglitz.py @@ -1,9 +1,11 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Schumer Steiglitz benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['SchumerSteiglitz'] +__all__ = ["SchumerSteiglitz"] class SchumerSteiglitz(Benchmark): @@ -40,18 +42,45 @@ class SchumerSteiglitz(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['SchumerSteiglitz'] + + Name = ["SchumerSteiglitz"] def __init__(self, Lower=-100.0, Upper=100.0): + r"""The initialization of Schumer Steiglitz benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): - return r'''$f(\mathbf{x}) = \sum_{i=1}^D x_i^4$''' + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + + return r"""$f(\mathbf{x}) = \sum_{i=1}^D x_i^4$""" @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/schwefel.py b/NiaPy/benchmarks/schwefel.py index 458c2669..b43a27c6 100644 --- a/NiaPy/benchmarks/schwefel.py +++ b/NiaPy/benchmarks/schwefel.py @@ -1,271 +1,425 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string, mixed-indentation, multiple-statements, line-too-long, no-else-return -"""Implementations of Schwefels functions.""" + +"""Implementations of Schwefels benchmarks.""" from math import sin, fmod, fabs, sqrt from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Schwefel', 'Schwefel221', 'Schwefel222', 'ModifiedSchwefel'] +__all__ = ["Schwefel", "Schwefel221", "Schwefel222", "ModifiedSchwefel"] + class Schwefel(Benchmark): - r"""Implementation of Schewel function. + r"""Implementation of Schewel function. + + Date: 2018 + + Author: Lucija Brezočnik + + License: MIT + + Function: **Schwefel function** + + :math:`f(\textbf{x}) = 418.9829d - \sum_{i=1}^{D} x_i \sin(\sqrt{|x_i|})` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-500, 500]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` - Date: 2018 + LaTeX formats: + Inline: + $f(\textbf{x}) = 418.9829d - \sum_{i=1}^{D} x_i \sin(\sqrt{|x_i|})$ - Author: Lucija Brezočnik + Equation: + \begin{equation} f(\textbf{x}) = 418.9829d - \sum_{i=1}^{D} x_i + \sin(\sqrt{|x_i|}) \end{equation} - License: MIT + Domain: + $-500 \leq x_i \leq 500$ - Function: **Schwefel function** + Reference: https://www.sfu.ca/~ssurjano/schwef.html - :math:`f(\textbf{x}) = 418.9829d - \sum_{i=1}^{D} x_i \sin(\sqrt{|x_i|})` + """ - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-500, 500]`, for all :math:`i = 1, 2,..., D`. + Name = ["Schwefel"] - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + def __init__(self, Lower=-500.0, Upper=500.0): + """The initialization of Schewefel benchmark. - LaTeX formats: - Inline: - $f(\textbf{x}) = 418.9829d - \sum_{i=1}^{D} x_i \sin(\sqrt{|x_i|})$ + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - Equation: - \begin{equation} f(\textbf{x}) = 418.9829d - \sum_{i=1}^{D} x_i - \sin(\sqrt{|x_i|}) \end{equation} + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Domain: - $-500 \leq x_i \leq 500$ + """ - Reference: https://www.sfu.ca/~ssurjano/schwef.html - """ - Name = ['Schwefel'] + Benchmark.__init__(self, Lower, Upper) - def __init__(self, Lower=-500.0, Upper=500.0): Benchmark.__init__(self, Lower, Upper) + @staticmethod + def latex_code(): + """Return the latex code of the problem. - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = 418.9829d - \sum_{i=1}^{D} x_i \sin(\sqrt{|x_i|})$''' + Returns: + [str] -- latex code. + + """ + + return r"""$f(\textbf{x}) = 418.9829d - \sum_{i=1}^{D} x_i \sin(\sqrt{|x_i|})$""" + + @classmethod + def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + + def evaluate(D, sol): + val = 0.0 + for i in range(D): + val += (sol[i] * sin(sqrt(abs(sol[i])))) + return 418.9829 * D - val + return evaluate - @classmethod - def function(cls): - def evaluate(D, sol): - val = 0.0 - for i in range(D): - val += (sol[i] * sin(sqrt(abs(sol[i])))) - return 418.9829 * D - val - return evaluate class Schwefel221(Benchmark): - r"""Schwefel 2.21 function implementation. + r"""Schwefel 2.21 function implementation. + + Date: 2018 + + Author: Grega Vrbančič + + Licence: MIT - Date: 2018 + Function: **Schwefel 2.21 function** - Author: Grega Vrbančič + :math:`f(\mathbf{x})=\max_{i=1,...,D}|x_i|` - Licence: MIT + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. - Function: **Schwefel 2.21 function** + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (0,...,0)` - :math:`f(\mathbf{x})=\max_{i=1,...,D}|x_i|` + LaTeX formats: + Inline: + $f(\mathbf{x})=\max_{i=1,...,D}|x_i|$ - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + Equation: + \begin{equation}f(\mathbf{x}) = \max_{i=1,...,D}|x_i| \end{equation} - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (0,...,0)` + Domain: + $-100 \leq x_i \leq 100$ - LaTeX formats: - Inline: - $f(\mathbf{x})=\max_{i=1,...,D}|x_i|$ + Reference paper: + Jamil, M., and Yang, X. S. (2013). + A literature survey of benchmark functions for global optimisation problems. + International Journal of Mathematical Modelling and Numerical Optimisation, + 4(2), 150-194. - Equation: - \begin{equation}f(\mathbf{x}) = \max_{i=1,...,D}|x_i| \end{equation} + """ - Domain: - $-100 \leq x_i \leq 100$ + Name = ["Schwefel221"] - Reference paper: - Jamil, M., and Yang, X. S. (2013). - A literature survey of benchmark functions for global optimisation problems. - International Journal of Mathematical Modelling and Numerical Optimisation, - 4(2), 150-194. - """ - Name = ['Schwefel221'] + def __init__(self, Lower=-100.0, Upper=100.0): + """The initialization of Schwefel221 benchmark. - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower, Upper) + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - @staticmethod - def latex_code(): - return r'''$f(\mathbf{x})=\max_{i=1,...,D}|x_i|$''' + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + + Benchmark.__init__(self, Lower, Upper) + + @staticmethod + def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + return r'''$f(\mathbf{x})=\max_{i=1,...,D}|x_i|$''' + + @classmethod + def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + + def evaluate(D, sol): + maximum = 0.0 + for i in range(D): + if abs(sol[i]) > maximum: + maximum = abs(sol[i]) + return maximum + return evaluate - @classmethod - def function(cls): - def evaluate(D, sol): - maximum = 0.0 - for i in range(D): - if abs(sol[i]) > maximum: - maximum = abs(sol[i]) - return maximum - return evaluate class Schwefel222(Benchmark): - r"""Schwefel 2.22 function implementation. + r"""Schwefel 2.22 function implementation. + + Date: 2018 + + Author: Grega Vrbančič + + Licence: MIT + + Function: **Schwefel 2.22 function** + + :math:`f(\mathbf{x})=\sum_{i=1}^{D}|x_i|+\prod_{i=1}^{D}|x_i|` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (0,...,0)` + + LaTeX formats: + Inline: + $f(\mathbf{x})=\sum_{i=1}^{D}|x_i|+\prod_{i=1}^{D}|x_i|$ - Date: 2018 + Equation: + \begin{equation}f(\mathbf{x}) = \sum_{i=1}^{D}|x_i| + + \prod_{i=1}^{D}|x_i| \end{equation} - Author: Grega Vrbančič + Domain: + $-100 \leq x_i \leq 100$ - Licence: MIT + Reference paper: + Jamil, M., and Yang, X. S. (2013). + A literature survey of benchmark functions for global optimisation problems. + International Journal of Mathematical Modelling and Numerical Optimisation, + 4(2), 150-194. - Function: **Schwefel 2.22 function** + """ - :math:`f(\mathbf{x})=\sum_{i=1}^{D}|x_i|+\prod_{i=1}^{D}|x_i|` + Name = ["Schwefel222"] - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + def __init__(self, Lower=-100.0, Upper=100.0): + """The initialization of Schwefel222 benchmark. - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (0,...,0)` + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - LaTeX formats: - Inline: - $f(\mathbf{x})=\sum_{i=1}^{D}|x_i|+\prod_{i=1}^{D}|x_i|$ + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Equation: - \begin{equation}f(\mathbf{x}) = \sum_{i=1}^{D}|x_i| + - \prod_{i=1}^{D}|x_i| \end{equation} + """ - Domain: - $-100 \leq x_i \leq 100$ + Benchmark.__init__(self, Lower, Upper) - Reference paper: - Jamil, M., and Yang, X. S. (2013). - A literature survey of benchmark functions for global optimisation problems. - International Journal of Mathematical Modelling and Numerical Optimisation, - 4(2), 150-194. - """ - Name = ['Schwefel222'] + @staticmethod + def latex_code(): + """Return the latex code of the problem. - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower, Upper) + Returns: + [str] -- latex code. - @staticmethod - def latex_code(): - return r'''$f(\mathbf{x})=\sum_{i=1}^{D}|x_i|+\prod_{i=1}^{D}|x_i|$''' + """ + + return r"""$f(\mathbf{x})=\sum_{i=1}^{D}|x_i|+\prod_{i=1}^{D}|x_i|$""" + + @classmethod + def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + + def evaluate(D, sol): + part1 = 0.0 + part2 = 1.0 + for i in range(D): + part1 += abs(sol[i]) + part2 *= abs(sol[i]) + return part1 + part2 + return evaluate - @classmethod - def function(cls): - def evaluate(D, sol): - part1 = 0.0 - part2 = 1.0 - for i in range(D): - part1 += abs(sol[i]) - part2 *= abs(sol[i]) - return part1 + part2 - return evaluate class ModifiedSchwefel(Benchmark): - r"""Implementations of Modified Schwefel functions. + r"""Implementations of Modified Schwefel functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: + **Modified Schwefel Function** + + :math:`f(\textbf{x}) = 418.9829 \cdot D - \sum_{i=1}^D h(x_i) \\ h(x) = g(x + 420.9687462275036) \\ g(z) = \begin{cases} z \sin \left( | z |^{\frac{1}{2}} \right) &\quad | z | \leq 500 \\ \left( 500 - \mod (z, 500) \right) \sin \left( \sqrt{| 500 - \mod (z, 500) |} \right) - \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z > 500 \\ \left( \mod (| z |, 500) - 500 \right) \sin \left( \sqrt{| \mod (|z|, 500) - 500 |} \right) + \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z < -500\end{cases}` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = 418.9829 \cdot D - \sum_{i=1}^D h(x_i) \\ h(x) = g(x + 420.9687462275036) \\ g(z) = \begin{cases} z \sin \left( | z |^{\frac{1}{2}} \right) &\quad | z | \leq 500 \\ \left( 500 - \mod (z, 500) \right) \sin \left( \sqrt{| 500 - \mod (z, 500) |} \right) - \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z > 500 \\ \left( \mod (| z |, 500) - 500 \right) \sin \left( \sqrt{| \mod (|z|, 500) - 500 |} \right) + \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z < -500\end{cases}$ + + Equation: + \begin{equation} f(\textbf{x}) = 418.9829 \cdot D - \sum_{i=1}^D h(x_i) \\ h(x) = g(x + 420.9687462275036) \\ g(z) = \begin{cases} z \sin \left( | z |^{\frac{1}{2}} \right) &\quad | z | \leq 500 \\ \left( 500 - \mod (z, 500) \right) \sin \left( \sqrt{| 500 - \mod (z, 500) |} \right) - \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z > 500 \\ \left( \mod (| z |, 500) - 500 \right) \sin \left( \sqrt{| \mod (|z|, 500) - 500 |} \right) + \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z < -500\end{cases} \end{equation} + + Domain: + $-100 \leq x_i \leq 100$ + + Reference: + http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf + + """ + + Name = ["ModifiedSchwefel"] - Date: 2018 + def __init__(self, Lower=-100.0, Upper=100.0): + """The initialization of Modified Schwefel benchmark. - Author: Klemen Berkovič + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - License: MIT + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Function: - **Modified Schwefel Function** + """ - :math:`f(\textbf{x}) = 418.9829 \cdot D - \sum_{i=1}^D h(x_i) \\ h(x) = g(x + 420.9687462275036) \\ g(z) = \begin{cases} z \sin \left( | z |^{\frac{1}{2}} \right) &\quad | z | \leq 500 \\ \left( 500 - \mod (z, 500) \right) \sin \left( \sqrt{| 500 - \mod (z, 500) |} \right) - \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z > 500 \\ \left( \mod (| z |, 500) - 500 \right) \sin \left( \sqrt{| \mod (|z|, 500) - 500 |} \right) + \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z < -500\end{cases}` + Benchmark.__init__(self, Lower, Upper) - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + @staticmethod + def latex_code(): + """Return the latex code of the problem. - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + Returns: + [str] -- latex code. - LaTeX formats: - Inline: - $f(\textbf{x}) = 418.9829 \cdot D - \sum_{i=1}^D h(x_i) \\ h(x) = g(x + 420.9687462275036) \\ g(z) = \begin{cases} z \sin \left( | z |^{\frac{1}{2}} \right) &\quad | z | \leq 500 \\ \left( 500 - \mod (z, 500) \right) \sin \left( \sqrt{| 500 - \mod (z, 500) |} \right) - \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z > 500 \\ \left( \mod (| z |, 500) - 500 \right) \sin \left( \sqrt{| \mod (|z|, 500) - 500 |} \right) + \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z < -500\end{cases}$ + """ - Equation: - \begin{equation} f(\textbf{x}) = 418.9829 \cdot D - \sum_{i=1}^D h(x_i) \\ h(x) = g(x + 420.9687462275036) \\ g(z) = \begin{cases} z \sin \left( | z |^{\frac{1}{2}} \right) &\quad | z | \leq 500 \\ \left( 500 - \mod (z, 500) \right) \sin \left( \sqrt{| 500 - \mod (z, 500) |} \right) - \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z > 500 \\ \left( \mod (| z |, 500) - 500 \right) \sin \left( \sqrt{| \mod (|z|, 500) - 500 |} \right) + \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z < -500\end{cases} \end{equation} + return r"""$f(\textbf{x}) = 418.9829 \cdot D - \sum_{i=1}^D h(x_i) \\ h(x) = g(x + 420.9687462275036) \\ g(z) = \begin{cases} z \sin \left( | z |^{\frac{1}{2}} \right) &\quad | z | \leq 500 \\ \left( 500 - \mod (z, 500) \right) \sin \left( \sqrt{| 500 - \mod (z, 500) |} \right) - \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z > 500 \\ \left( \mod (| z |, 500) - 500 \right) \sin \left( \sqrt{| \mod (|z|, 500) - 500 |} \right) + \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z < -500\end{cases}$""" - Domain: - $-100 \leq x_i \leq 100$ + @classmethod + def function(cls): + """Return benchmark evaluation function. - Reference: - http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - """ - Name = ['ModifiedSchwefel'] + Returns: + [fun] -- Evaluation function. - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower, Upper) + """ - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = 418.9829 \cdot D - \sum_{i=1}^D h(x_i) \\ h(x) = g(x + 420.9687462275036) \\ g(z) = \begin{cases} z \sin \left( | z |^{\frac{1}{2}} \right) &\quad | z | \leq 500 \\ \left( 500 - \mod (z, 500) \right) \sin \left( \sqrt{| 500 - \mod (z, 500) |} \right) - \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z > 500 \\ \left( \mod (| z |, 500) - 500 \right) \sin \left( \sqrt{| \mod (|z|, 500) - 500 |} \right) + \frac{ \left( z - 500 \right)^2 }{ 10000 D } &\quad z < -500\end{cases}$''' + def g(z, D): + if z > 500: + return (500 - fmod(z, 500)) * sin(sqrt(fabs(500 - fmod(z, 500)))) - (z - 500) ** 2 / (10000 * D) + elif z < -500: + return (fmod(z, 500) - 500) * sin(sqrt(fabs(fmod(z, 500) - 500))) + (z - 500) ** 2 / (10000 * D) + return z * sin(fabs(z) ** (1 / 2)) + + def h(x, D): + return g(x + 420.9687462275036, D) + + def evaluate(D, sol): + val = 0.0 + for i in range(D): + val += h(sol[i], D) + return 418.9829 * D - val + return evaluate - @classmethod - def function(cls): - def g(z, D): - if z > 500: return (500 - fmod(z, 500)) * sin(sqrt(fabs(500 - fmod(z, 500)))) - (z - 500) ** 2 / (10000 * D) - elif z < -500: return (fmod(z, 500) - 500) * sin(sqrt(fabs(fmod(z, 500) - 500))) + (z - 500) ** 2 / (10000 * D) - return z * sin(fabs(z) ** (1 / 2)) - def h(x, D): return g(x + 420.9687462275036, D) - def f(D, sol): - val = 0.0 - for i in range(D): val += h(sol[i], D) - return 418.9829 * D - val - return f class ExpandedScaffer(Benchmark): - r"""Implementations of High Conditioned Elliptic functions. + r"""Implementation of High Conditioned Elliptic functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: + **High Conditioned Elliptic Function** + + :math:`f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2$ + + Equation: + \begin{equation} f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2 \end{equation} + + Domain: + $-100 \leq x_i \leq 100$ + + Reference: + http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf + + """ + + Name = ["ExpandedScaffer"] + + def __init__(self, Lower=-100.0, Upper=100.0): + """The initialization of Expanded Scaffer benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - Date: 2018 + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Author: Klemen Berkovič + """ - License: MIT + Benchmark.__init__(self, Lower=Lower, Upper=Lower) - Function: - **High Conditioned Elliptic Function** + @staticmethod + def latex_code(): + """Return latex code of the problem. - :math:`f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2` + Returns: + [str] -- latex code. - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + """ - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + return r"""$f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2$""" - LaTeX formats: - Inline: - $f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2$ + @classmethod + def function(cls): + """Return benchmark evaluation function. - Equation: - \begin{equation} f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2 \end{equation} + Returns: + [fun] -- Evaluation function. - Domain: - $-100 \leq x_i \leq 100$ + """ - Reference: - http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - """ - Name = ['ExpandedScaffer'] + def g(x, y): + return 0.5 + (sin(sqrt(x ** 2 + y ** 2)) ** 2 - 0.5) / (1 + 0.001 * (x ** 2 + y ** 2)) ** 2 - def __init__(self, Lower=-100.0, Upper=100.0): Benchmark.__init__(self, Lower=Lower, Upper=Lower) + def evaluate(D, x): + val = 0.0 - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = g(x_D, x_1) + \sum_{i=2}^D g(x_{i - 1}, x_i) \\ g(x, y) = 0.5 + \frac{\sin \left(\sqrt{x^2 + y^2} \right)^2 - 0.5}{\left( 1 + 0.001 (x^2 + y^2) \right)}^2$''' + for i in range(1, D): + val += g(x[i - 1], x[i]) - @classmethod - def function(cls): - def g(x, y): return 0.5 + (sin(sqrt(x ** 2 + y ** 2)) ** 2 - 0.5) / (1 + 0.001 * (x ** 2 + y ** 2)) ** 2 - def f(D, x): - val = 0.0 - for i in range(1, D): val += g(x[i - 1], x[i]) - return g(x[D - 1], x[0]) + val - return f + return g(x[D - 1], x[0]) + val -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/sphere.py b/NiaPy/benchmarks/sphere.py index 006d0c90..78e05982 100644 --- a/NiaPy/benchmarks/sphere.py +++ b/NiaPy/benchmarks/sphere.py @@ -1,159 +1,258 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string, mixed-indentation, redefined-builtin, multiple-statements + +"""Implementations of Sphere benchmarks.""" from numpy import abs from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Sphere', 'Sphere2', 'Sphere3'] +__all__ = ["Sphere", "Sphere2", "Sphere3"] + class Sphere(Benchmark): - r"""Implementation of Sphere functions. + r"""Implementation of Sphere functions. + + Date: 2018 + + Authors: Iztok Fister Jr. + + License: MIT + + Function: **Sphere function** + + :math:`f(\mathbf{x}) = \sum_{i=1}^D x_i^2` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [0, 10]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (0,...,0)` + + LaTeX formats: + Inline: + $f(\mathbf{x}) = \sum_{i=1}^D x_i^2$ + + Equation: + \begin{equation}f(\mathbf{x}) = \sum_{i=1}^D x_i^2 \end{equation} + + Domain: + $0 \leq x_i \leq 10$ + + Reference paper: + Jamil, M., and Yang, X. S. (2013). + A literature survey of benchmark functions for global optimisation problems. + International Journal of Mathematical Modelling and Numerical Optimisation, + 4(2), 150-194. - Date: 2018 + """ - Authors: Iztok Fister Jr. + Name = ["Sphere"] - License: MIT + def __init__(self, Lower=-5.12, Upper=5.12): + r"""The initialization of Sphere benchmark. - Function: **Sphere function** + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - :math:`f(\mathbf{x}) = \sum_{i=1}^D x_i^2` + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [0, 10]`, for all :math:`i = 1, 2,..., D`. + """ - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (0,...,0)` + Benchmark.__init__(self, Lower, Upper) - LaTeX formats: - Inline: - $f(\mathbf{x}) = \sum_{i=1}^D x_i^2$ + @staticmethod + def latex_code(): + """Return the latex code of the problem. - Equation: - \begin{equation}f(\mathbf{x}) = \sum_{i=1}^D x_i^2 \end{equation} + Returns: + [str] -- latex code. - Domain: - $0 \leq x_i \leq 10$ + """ - Reference paper: - Jamil, M., and Yang, X. S. (2013). - A literature survey of benchmark functions for global optimisation problems. - International Journal of Mathematical Modelling and Numerical Optimisation, - 4(2), 150-194. - """ - Name = ['Sphere'] + return r"""$f(\mathbf{x}) = \sum_{i=1}^D x_i^2$""" - def __init__(self, Lower=-5.12, Upper=5.12): Benchmark.__init__(self, Lower, Upper) + @classmethod + def function(cls): + """Return benchmark evaluation function. - @staticmethod - def latex_code(): - return r'''$f(\mathbf{x}) = \sum_{i=1}^D x_i^2$''' + Returns: + [fun] -- Evaluation function. + + """ + + def evaluate(D, sol): + val = 0.0 + + for i in range(D): + val += sol[i] ** 2 + + return val + + return evaluate - @classmethod - def function(cls): - def evaluate(D, sol): - val = 0.0 - for i in range(D): val += sol[i] ** 2 - return val - return evaluate class Sphere2(Benchmark): - r"""Implementation of Sphere with different powers function. + r"""Implementation of Sphere with different powers function. + + Date: 2018 + + Authors: Klemen Berkovič + + License: MIT + + Function: **Sun of different powers function** + + :math:`f(\textbf{x}) = \sum_{i = 1}^D | x_i |^{i + 1}` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-1, 1]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (0,...,0)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = \sum_{i = 1}^D | x_i |^{i + 1}$ - Date: 2018 + Equation: + \begin{equation} f(\textbf{x}) = \sum_{i = 1}^D | x_i |^{i + 1} \end{equation} - Authors: Klemen Berkovič + Domain: + $-1 \leq x_i \leq 1$ - License: MIT + Reference URL: https://www.sfu.ca/~ssurjano/sumpow.html - Function: **Sun of different powers function** + """ - :math:`f(\textbf{x}) = \sum_{i = 1}^D | x_i |^{i + 1}` + Name = ["Sphere2"] - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-1, 1]`, for all :math:`i = 1, 2,..., D`. + def __init__(self, Lower=-1.0, Upper=1.0): + r"""The initialization of Sphere benchmark. - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (0,...,0)` + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - LaTeX formats: - Inline: - $f(\textbf{x}) = \sum_{i = 1}^D | x_i |^{i + 1}$ + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Equation: - \begin{equation} f(\textbf{x}) = \sum_{i = 1}^D | x_i |^{i + 1} \end{equation} + """ - Domain: - $-1 \leq x_i \leq 1$ + Benchmark.__init__(self, Lower, Upper) - Reference URL: - https://www.sfu.ca/~ssurjano/sumpow.html - """ - Name = ['Sphere2'] + @staticmethod + def latex_code(): + """Return the latex code of the problem. - def __init__(self, Lower=-1., Upper=1.): Benchmark.__init__(self, Lower, Upper) + Returns: + [str] -- latex code. - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = \sum_{i = 1}^D | x_i |^{i + 1}$''' + """ + + return r"""$f(\textbf{x}) = \sum_{i = 1}^D | x_i |^{i + 1}$""" + + @classmethod + def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + + def evaluate(D, sol): + val = 0.0 + + for i in range(D): + val += abs(sol[i]) ** (i + 2) + + return val + + return evaluate - @classmethod - def function(cls): - def evaluate(D, sol): - val = 0.0 - for i in range(D): val += abs(sol[i]) ** (i + 2) - return val - return evaluate class Sphere3(Benchmark): - r"""Implementation of rotated hyper-ellipsoid function. + r"""Implementation of rotated hyper-ellipsoid function. + + Date: 2018 + + Authors: Klemen Berkovič + + License: MIT + + Function: **Sun of rotated hyper-elliposid function** + + :math:`f(\textbf{x}) = \sum_{i = 1}^D \sum_{j = 1}^i x_j^2` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-65.536, 65.536]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (0,...,0)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = \sum_{i = 1}^D \sum_{j = 1}^i x_j^2$ + + Equation: + \begin{equation} f(\textbf{x}) = \sum_{i = 1}^D \sum_{j = 1}^i x_j^2 \end{equation} + + Domain: + $-65.536 \leq x_i \leq 65.536$ + + Reference URL: https://www.sfu.ca/~ssurjano/rothyp.html + + """ + + Name = ["Sphere3"] + + def __init__(self, Lower=-65.536, Upper=65.536): + r"""The initialization of Sphere3 benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ - Date: 2018 + Benchmark.__init__(self, Lower, Upper) - Authors: Klemen Berkovič + @staticmethod + def latex_code(): + """Return the latex code of the problem. - License: MIT + Returns: + [str] -- latex code. - Function: **Sun of rotated hyper-elliposid function** + """ - :math:`f(\textbf{x}) = \sum_{i = 1}^D \sum_{j = 1}^i x_j^2` + return r"""$f(\textbf{x}) = \sum_{i = 1}^D \sum_{j = 1}^i x_j^2$""" - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-65.536, 65.536]`, for all :math:`i = 1, 2,..., D`. + @classmethod + def function(cls): + """Return benchmark evaluation function. - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (0,...,0)` + Returns: + [fun] -- Evaluation function. - LaTeX formats: - Inline: - $f(\textbf{x}) = \sum_{i = 1}^D \sum_{j = 1}^i x_j^2$ + """ - Equation: - \begin{equation} f(\textbf{x}) = \sum_{i = 1}^D \sum_{j = 1}^i x_j^2 \end{equation} + def evaluate(D, sol): - Domain: - $-65.536 \leq x_i \leq 65.536$ + val = 0.0 - Reference URL: - https://www.sfu.ca/~ssurjano/rothyp.html - """ - Name = ['Sphere3'] + for i in range(D): + v = 0.0 - def __init__(self, Lower=-65.536, Upper=65.536): Benchmark.__init__(self, Lower, Upper) + for j in range(i + 1): + val += abs(sol[j]) ** 2 - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = \sum_{i = 1}^D \sum_{j = 1}^i x_j^2$''' + val += v - @classmethod - def function(cls): - def evaluate(D, sol): - val = 0.0 - for i in range(D): - v = .0 - for j in range(i + 1): val += abs(sol[j]) ** 2 - val += v - return val - return evaluate + return val -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/step.py b/NiaPy/benchmarks/step.py index 9cfbc980..1d3dd279 100644 --- a/NiaPy/benchmarks/step.py +++ b/NiaPy/benchmarks/step.py @@ -1,11 +1,12 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string -"""Implementations of Step functions.""" + +"""Implementations of Step benchmarks.""" import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Step', 'Step2', 'Step3'] +__all__ = ["Step", "Step2", "Step3"] + class Step(Benchmark): r"""Implementation of Step function. @@ -44,19 +45,46 @@ class Step(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Step'] + + Name = ["Step"] def __init__(self, Lower=-100.0, Upper=100.0): + r"""The initialization of Step benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): - return r'''$f(\mathbf{x}) = \sum_{i=1}^D \left( \lfloor \left | - x_i \right | \rfloor \right)$''' + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + + return r"""$f(\mathbf{x}) = \sum_{i=1}^D \left( \lfloor \left | + x_i \right | \rfloor \right)$""" @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 @@ -104,18 +132,45 @@ class Step2(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Step2'] + + Name = ["Step2"] def __init__(self, Lower=-100.0, Upper=100.0): + r"""The initialization of Step2 benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): - return r'''$f(\mathbf{x}) = \sum_{i=1}^D \left( \lfloor x_i + 0.5 \rfloor \right)^2$''' + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + + return r"""$f(\mathbf{x}) = \sum_{i=1}^D \left( \lfloor x_i + 0.5 \rfloor \right)^2$""" @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 @@ -163,18 +218,45 @@ class Step3(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Step3'] + + Name = ["Step3"] def __init__(self, Lower=-100.0, Upper=100.0): + r"""The initialization of Alpine1 benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): - return r'''$f(\mathbf{x}) = \sum_{i=1}^D \left( \lfloor x_i^2 \rfloor \right)$''' + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + + return r"""$f(\mathbf{x}) = \sum_{i=1}^D \left( \lfloor x_i^2 \rfloor \right)$""" @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/stepint.py b/NiaPy/benchmarks/stepint.py index 711e9045..d9514e34 100644 --- a/NiaPy/benchmarks/stepint.py +++ b/NiaPy/benchmarks/stepint.py @@ -1,9 +1,12 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Stepint benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Stepint'] +__all__ = ["Stepint"] + class Stepint(Benchmark): r"""Implementation of Stepint functions. @@ -39,18 +42,45 @@ class Stepint(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Stepint'] + + Name = ["Stepint"] def __init__(self, Lower=-5.12, Upper=5.12): + """The initialization of Stepint benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + return r'''$f(\mathbf{x}) = \sum_{i=1}^D x_i^2$''' @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/styblinskiTang.py b/NiaPy/benchmarks/styblinskiTang.py index 9287b6d9..edf0e529 100644 --- a/NiaPy/benchmarks/styblinskiTang.py +++ b/NiaPy/benchmarks/styblinskiTang.py @@ -1,9 +1,12 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Styblinski Tang benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['StyblinskiTang'] +__all__ = ["StyblinskiTang"] + class StyblinskiTang(Benchmark): r"""Implementation of Styblinski-Tang functions. @@ -42,19 +45,46 @@ class StyblinskiTang(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['StyblinskiTang'] + + Name = ["StyblinskiTang"] def __init__(self, Lower=-5.0, Upper=5.0): + r"""The initialization of Styblinski Tang benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): - return r'''$f(\mathbf{x}) = \frac{1}{2} \sum_{i=1}^D \left( - x_i^4 - 16x_i^2 + 5x_i \right) $''' + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + + return r"""$f(\mathbf{x}) = \frac{1}{2} \sum_{i=1}^D \left( + x_i^4 - 16x_i^2 + 5x_i \right) $""" @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/sumSquares.py b/NiaPy/benchmarks/sumSquares.py index 6f937842..c7cd3658 100644 --- a/NiaPy/benchmarks/sumSquares.py +++ b/NiaPy/benchmarks/sumSquares.py @@ -1,9 +1,12 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Sum Squares benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['SumSquares'] +__all__ = ["SumSquares"] + class SumSquares(Benchmark): r"""Implementation of Sum Squares functions. @@ -39,18 +42,45 @@ class SumSquares(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['SumSquares'] + + Name = ["SumSquares"] def __init__(self, Lower=-10.0, Upper=10.0): + """The initialization of Sum Squares benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): - return r'''$f(\mathbf{x}) = \sum_{i=1}^D i x_i^2$''' + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + + return r"""$f(\mathbf{x}) = \sum_{i=1}^D i x_i^2$""" @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/trid.py b/NiaPy/benchmarks/trid.py index 1ba5e46d..7eef9dfa 100644 --- a/NiaPy/benchmarks/trid.py +++ b/NiaPy/benchmarks/trid.py @@ -4,57 +4,86 @@ from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Trid'] +__all__ = ["Trid"] + class Trid(Benchmark): - r"""Implementations of Trid functions. + r"""Implementations of Trid functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **Levy Function** + + :math:`f(\textbf{x}) = \sum_{i = 1}^D \left( x_i - 1 \right)^2 - \sum_{i = 2}^D x_i x_{i - 1}` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-D^2, D^2]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + :math:`f(\textbf{x}^*) = \frac{-D(D + 4)(D - 1)}{6}` at :math:`\textbf{x}^* = (1 (D + 1 - 1), \cdots , i (D + 1 - i) , \cdots , D (D + 1 - D))` + + LaTeX formats: + Inline: + $f(\textbf{x}) = \sum_{i = 1}^D \left( x_i - 1 \right)^2 - \sum_{i = 2}^D x_i x_{i - 1}$ + + Equation: + \begin{equation} f(\textbf{x}) = \sum_{i = 1}^D \left( x_i - 1 \right)^2 - \sum_{i = 2}^D x_i x_{i - 1} \end{equation} + + Domain: + $-D^2 \leq x_i \leq D^2$ + + Reference: https://www.sfu.ca/~ssurjano/trid.html + + """ + + Name = ["Trid"] + + def __init__(self, D=2): + r"""The initialization of Trid benchmark. - Date: 2018 + Args: + D (Optional[int]): Dimension of problem. - Author: Klemen Berkovič + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - License: MIT + """ - Function: - **Levy Function** + Benchmark.__init__(self, -(D ** 2), D ** 2) - :math:`f(\textbf{x}) = \sum_{i = 1}^D \left( x_i - 1 \right)^2 - \sum_{i = 2}^D x_i x_{i - 1}` + @staticmethod + def latex_code(): + """Return the latex code of the problem. - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-D^2, D^2]`, for all :math:`i = 1, 2,..., D`. + Returns: + [str] -- latex code. - **Global minimum:** - :math:`f(\textbf{x}^*) = \frac{-D(D + 4)(D - 1)}{6}` at :math:`\textbf{x}^* = (1 (D + 1 - 1), \cdots , i (D + 1 - i) , \cdots , D (D + 1 - D))` + """ - LaTeX formats: - Inline: - $f(\textbf{x}) = \sum_{i = 1}^D \left( x_i - 1 \right)^2 - \sum_{i = 2}^D x_i x_{i - 1}$ + return r"""$f(\textbf{x}) = \sum_{i = 1}^D \left( x_i - 1 \right)^2 - \sum_{i = 2}^D x_i x_{i - 1}$""" - Equation: - \begin{equation} f(\textbf{x}) = \sum_{i = 1}^D \left( x_i - 1 \right)^2 - \sum_{i = 2}^D x_i x_{i - 1} \end{equation} + @classmethod + def function(cls): + """Return benchmark evaluation function. - Domain: - $-D^2 \leq x_i \leq D^2$ + Returns: + [fun] -- Evaluation function. - Reference: - https://www.sfu.ca/~ssurjano/trid.html - """ - Name = ['Trid'] + """ - def __init__(self, D=2): Benchmark.__init__(self, -(D ** 2), D ** 2) + def evaluate(D, sol): + v1, v2 = 0.0, 0.0 - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = \sum_{i = 1}^D \left( x_i - 1 \right)^2 - \sum_{i = 2}^D x_i x_{i - 1}$''' + for i in range(D): + v1 += (sol[i] - 1) ** 2 + for i in range(1, D): + v2 += sol[i] * sol[i - 1] - @classmethod - def function(cls): - def f(D, X): - v1, v2 = 0.0, 0.0 - for i in range(D): v1 += (X[i] - 1) ** 2 - for i in range(1, D): v2 += X[i] * X[i - 1] - return v1 - v2 - return f + return v1 - v2 -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/weierstrass.py b/NiaPy/benchmarks/weierstrass.py index 7b709190..25217f30 100644 --- a/NiaPy/benchmarks/weierstrass.py +++ b/NiaPy/benchmarks/weierstrass.py @@ -1,68 +1,101 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, line-too-long, multiple-statements + """Implementations of Weierstrass functions.""" from math import pi, cos from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Weierstrass'] +__all__ = ["Weierstrass"] + class Weierstrass(Benchmark): - r"""Implementations of Weierstrass functions. + r"""Implementations of Weierstrass functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: **Weierstass Function** + + :math:`f(\textbf{x}) = \sum_{i=1}^D \left( \sum_{k=0}^{k_{max}} a^k \cos\left( 2 \pi b^k ( x_i + 0.5) \right) \right) - D \sum_{k=0}^{k_{max}} a^k \cos \left( 2 \pi b^k \cdot 0.5 \right)` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. + Default value of a = 0.5, b = 3 and k_max = 20. + + **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + + LaTeX formats: + Inline: + $$f(\textbf{x}) = \sum_{i=1}^D \left( \sum_{k=0}^{k_{max}} a^k \cos\left( 2 \pi b^k ( x_i + 0.5) \right) \right) - D \sum_{k=0}^{k_{max}} a^k \cos \left( 2 \pi b^k \cdot 0.5 \right) + + Equation: + \begin{equation} f(\textbf{x}) = \sum_{i=1}^D \left( \sum_{k=0}^{k_{max}} a^k \cos\left( 2 \pi b^k ( x_i + 0.5) \right) \right) - D \sum_{k=0}^{k_{max}} a^k \cos \left( 2 \pi b^k \cdot 0.5 \right) \end{equation} + + Domain: + $-100 \leq x_i \leq 100$ + + Reference: + http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf + """ + + Name = ["Weierstrass"] + + def __init__(self, Lower=-100.0, Upper=100.0, a=0.5, b=3, k_max=20): + """The initialization of Weierstrass benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + a (Optional[float]) -- a value. (default: {0.5}) + b (Optional[int]) -- b value. (default: {3}) + k_max (Optional[int]) -- k_max value. (default: {20}) + """ + + Benchmark.__init__(self, Lower, Upper) + self.a = a + self.b = b + self.k_max = k_max - Date: 2018 + @staticmethod + def latex_code(): + """Return the latex code of the problem. - Author: Klemen Berkovič + Returns: + [str] -- latex code. - License: MIT + """ - Function: - **Weierstass Function** + return r"""$$f(\textbf{x}) = \sum_{i=1}^D \left( \sum_{k=0}^{k_{max}} a^k \cos\left( 2 \pi b^k ( x_i + 0.5) \right) \right) - D \sum_{k=0}^{k_{max}} a^k \cos \left( 2 \pi b^k \cdot 0.5 \right)""" - :math:`f(\textbf{x}) = \sum_{i=1}^D \left( \sum_{k=0}^{k_{max}} a^k \cos\left( 2 \pi b^k ( x_i + 0.5) \right) \right) - D \sum_{k=0}^{k_{max}} a^k \cos \left( 2 \pi b^k \cdot 0.5 \right)` + @classmethod + def function(cls): + """Return benchmark evaluation function. - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-100, 100]`, for all :math:`i = 1, 2,..., D`. - Default value of a = 0.5, b = 3 and k_max = 20. + Returns: + [fun] -- Evaluation function. - **Global minimum:** :math:`f(x^*) = 0`, at :math:`x^* = (420.968746,...,420.968746)` + """ - LaTeX formats: - Inline: - $$f(\textbf{x}) = \sum_{i=1}^D \left( \sum_{k=0}^{k_{max}} a^k \cos\left( 2 \pi b^k ( x_i + 0.5) \right) \right) - D \sum_{k=0}^{k_{max}} a^k \cos \left( 2 \pi b^k \cdot 0.5 \right) + def evaluate(D, sol, a=cls.a, b=cls.b, k_max=cls.k_max): - Equation: - \begin{equation} f(\textbf{x}) = \sum_{i=1}^D \left( \sum_{k=0}^{k_{max}} a^k \cos\left( 2 \pi b^k ( x_i + 0.5) \right) \right) - D \sum_{k=0}^{k_{max}} a^k \cos \left( 2 \pi b^k \cdot 0.5 \right) \end{equation} + val1 = 0.0 - Domain: - $-100 \leq x_i \leq 100$ + for i in range(D): + val = 0.0 - Reference: - http://www5.zzu.edu.cn/__local/A/69/BC/D3B5DFE94CD2574B38AD7CD1D12_C802DAFE_BC0C0.pdf - """ - Name = ['Weierstrass'] - a, b, k_max = 0.5, 3, 20 + for k in range(k_max): + val += a ** k * cos(2 * pi * b ** k * (sol[i] + 0.5)) - def __init__(self, Lower=-100.0, Upper=100.0, a=0.5, b=3, k_max=20): - Benchmark.__init__(self, Lower, Upper) - Weierstrass.a, Weierstrass.b, Weierstrass.k_max = a, b, k_max + val1 += val + val2 = 0.0 - @staticmethod - def latex_code(): - return r'''$$f(\textbf{x}) = \sum_{i=1}^D \left( \sum_{k=0}^{k_{max}} a^k \cos\left( 2 \pi b^k ( x_i + 0.5) \right) \right) - D \sum_{k=0}^{k_{max}} a^k \cos \left( 2 \pi b^k \cdot 0.5 \right)''' + for k in range(k_max): + val2 += a ** k * cos(2 * pi * b ** k * 0.5) - @classmethod - def function(cls): - def f(D, sol, a=cls.a, b=cls.b, k_max=cls.k_max): - val1 = 0.0 - for i in range(D): - val = 0.0 - for k in range(k_max): val += a ** k * cos(2 * pi * b ** k * (sol[i] + 0.5)) - val1 += val - val2 = 0.0 - for k in range(k_max): val2 += a ** k * cos(2 * pi * b ** k * 0.5) - return val1 - D * val2 - return f + return val1 - D * val2 -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/NiaPy/benchmarks/whitley.py b/NiaPy/benchmarks/whitley.py index d6423fb5..23d4f3b8 100644 --- a/NiaPy/benchmarks/whitley.py +++ b/NiaPy/benchmarks/whitley.py @@ -1,9 +1,12 @@ # encoding=utf8 -# pylint: disable=anomalous-backslash-in-string + +"""Implementation of Whitley benchmark.""" + import math from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Whitley'] +__all__ = ["Whitley"] + class Whitley(Benchmark): r"""Implementation of Whitley function. @@ -46,20 +49,47 @@ class Whitley(Benchmark): A literature survey of benchmark functions for global optimisation problems. International Journal of Mathematical Modelling and Numerical Optimisation, 4(2), 150-194. + """ - Name = ['Whitley'] + + Name = ["Whitley"] def __init__(self, Lower=-10.24, Upper=10.24): + """The initialization of Whitley benchmark. + + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. + + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` + + """ + Benchmark.__init__(self, Lower, Upper) @staticmethod def latex_code(): + """Return the latex code of the problem. + + Returns: + [str] -- latex code. + + """ + return r'''$f(\mathbf{x}) = \sum_{i=1}^D \sum_{j=1}^D \left(\frac{(100(x_i^2-x_j)^2 + (1-x_j)^2)^2}{4000} - \cos(100(x_i^2-x_j)^2 + (1-x_j)^2)+1\right)$''' @classmethod def function(cls): + """Return benchmark evaluation function. + + Returns: + [fun] -- Evaluation function. + + """ + def evaluate(D, sol): val = 0.0 diff --git a/NiaPy/benchmarks/zakharov.py b/NiaPy/benchmarks/zakharov.py index ad9b367e..cacb684a 100644 --- a/NiaPy/benchmarks/zakharov.py +++ b/NiaPy/benchmarks/zakharov.py @@ -1,59 +1,88 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, multiple-statements, line-too-long + """Implementations of Zakharov function.""" from NiaPy.benchmarks.benchmark import Benchmark -__all__ = ['Zakharov'] +__all__ = ["Zakharov"] + class Zakharov(Benchmark): - r"""Implementations of Zakharov functions. + r"""Implementations of Zakharov functions. + + Date: 2018 + + Author: Klemen Berkovič + + License: MIT + + Function: + **Levy Function** + + :math:`f(\textbf{x}) = \sum_{i = 1}^D x_i^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^4` + + **Input domain:** + The function can be defined on any input domain but it is usually + evaluated on the hypercube :math:`x_i ∈ [-5, 10]`, for all :math:`i = 1, 2,..., D`. + + **Global minimum:** + :math:`f(\textbf{x}^*) = 0` at :math:`\textbf{x}^* = (0, \cdots, 0)` + + LaTeX formats: + Inline: + $f(\textbf{x}) = \sum_{i = 1}^D x_i^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^4$ + + Equation: + \begin{equation} f(\textbf{x}) = \sum_{i = 1}^D x_i^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^4 \end{equation} + + Domain: + $-5 \leq x_i \leq 10$ + + Reference: https://www.sfu.ca/~ssurjano/levy.html + + """ + + Name = ["Zakharov"] - Date: 2018 + def __init__(self, Lower=-5.0, Upper=10.0): + r"""The initialization of Zakharov benchmark. - Author: Klemen Berkovič + Args: + Lower (Optional[float]): Lower bound of problem. + Upper (Optional[float]): Upper bound of problem. - License: MIT + See Also: + :func:`NiaPy.benchmarks.Benchmark.__init__` - Function: - **Levy Function** + """ + Benchmark.__init__(self, Lower, Upper) - :math:`f(\textbf{x}) = \sum_{i = 1}^D x_i^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^4` + @staticmethod + def latex_code(): + """Return the latex code of the problem. - **Input domain:** - The function can be defined on any input domain but it is usually - evaluated on the hypercube :math:`x_i ∈ [-5, 10]`, for all :math:`i = 1, 2,..., D`. + Returns: + [str] -- latex code. - **Global minimum:** - :math:`f(\textbf{x}^*) = 0` at :math:`\textbf{x}^* = (0, \cdots, 0)` + """ - LaTeX formats: - Inline: - $f(\textbf{x}) = \sum_{i = 1}^D x_i^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^4$ + return r"""$f(\textbf{x}) = \sum_{i = 1}^D x_i^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^4$""" - Equation: - \begin{equation} f(\textbf{x}) = \sum_{i = 1}^D x_i^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^4 \end{equation} + @classmethod + def function(cls): + """Return benchmark evaluation function. - Domain: - $-5 \leq x_i \leq 10$ + Returns: + [fun] -- Evaluation function. - Reference: - https://www.sfu.ca/~ssurjano/levy.html - """ - Name = ['Zakharov'] + """ - def __init__(self, Lower=-5.0, Upper=10.0): Benchmark.__init__(self, Lower, Upper) + def evaluate(D, sol): + v1, v2 = 0.0, 0.0 - @staticmethod - def latex_code(): - return r'''$f(\textbf{x}) = \sum_{i = 1}^D x_i^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^2 + \left( \sum_{i = 1}^D 0.5 i x_i \right)^4$''' + for i in range(D): + v1, v2 = v1 + sol[i] ** 2, v2 + 0.5 * (i + 1) * sol[i] - @classmethod - def function(cls): - def f(D, X): - v1, v2 = 0.0, 0.0 - for i in range(D): v1, v2 = v1 + X[i] ** 2, v2 + 0.5 * (i + 1) * X[i] - return v1 + v2 ** 2 + v2 ** 4 - return f + return v1 + v2 ** 2 + v2 ** 4 -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + return evaluate diff --git a/Pipfile b/Pipfile index bb47ae1a..2414056d 100644 --- a/Pipfile +++ b/Pipfile @@ -9,35 +9,35 @@ scipy = ">=1.2.1" enum34 = {version = ">=1.1.6",markers = "python_version < '3.4'"} XlsxWriter = ">=1.1.5" matplotlib = ">=2.2.4" -flake8 = "*" [dev-packages] -pylint = ">=1.9.3" -pycodestyle = "*" -pydocstyle = "*" -pytest = "~=3.3" -pytest-describe = "*" -pytest-expecter = "*" -pytest-random = "*" -pytest-cov = "*" -freezegun = "*" -coverage-space = "*" -docutils = "*" -"pathlib2" = "*" -wheel = "*" -twine = "*" -sniffer = "*" -singledispatch = "*" -configparser = "*" -sphinx-rtd-theme = "*" -funcsigs = "*" -futures = "==3.1.1" -"autopep8" = "*" -sphinx-autobuild = "*" -scandir = "*" -Pygments = "*" -"backports.functools_lru_cache" = "*" -Sphinx = "*" -MacFSEvents = {version = "*",sys_platform = "== 'darwin'"} -pep8 = "*" -flake8-docstrings = "*" +flake8 = "~=3.7.7" +flake8-docstrings = "~=1.3.0" +flake8-rst-docstrings = ">=0.0.8" +flake8-bugbear = "~=19.3.0" +flake8-bandit = "~=2.1.0" +pycodestyle = "~=2.5.0" +pydocstyle = "~=3.0.0" +pytest = "~=4.4.0" +pytest-describe = "~=0.12.0" +pytest-expecter = "~=1.3" +pytest-random = "~=0.02" +pytest-cov = "~=2.6.1" +sniffer = "~=0.4.0" +freezegun = "~=0.3.11" +coverage-space = "~=1.0.2" +docutils = "~=0.14" +scandir = "~=1.10.0" +pathlib2 = "~=2.3.3" +wheel = "~=0.33.1" +twine = "~=1.13.0" +singledispatch = "~=3.4.0.3" +configparser = "~=3.7.4" +funcsigs = "~=1.0.2" +futures = ">=3.1.1" +Pygments = "~=2.3.1" +"backports.functools_lru_cache" = "~=1.5" +MacFSEvents = {version = "~=0.8.1",sys_platform = "== 'darwin'"} +Sphinx = "~=2.0.1" +sphinx-rtd-theme = "~=0.4.3" +sphinx-autobuild = "~=0.7.1" diff --git a/codemeta.json b/codemeta.json deleted file mode 100644 index 8d97ed68..00000000 --- a/codemeta.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "@context": "https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld", - "@type": "Code", - "identifier": "", - "codeRepository": "https://github.com/NiaOrg/NiaPy", - "datePublished": "2018-02-28", - "dateModified": "2018-02-28", - "dateCreated": "2018-02-28", - "description": "Python micro framework for building nature-inspired algorithms.", - "keywords": "nature-inspired algorithms, microframework", - "license": "MIT", - "title": "NiaPy", - "version": "1.0.1" -} \ No newline at end of file diff --git a/gen-codemeta b/gen-codemeta deleted file mode 100755 index 768139d2..00000000 --- a/gen-codemeta +++ /dev/null @@ -1,146 +0,0 @@ -#!/usr/bin/ruby - -# For an OO language, this is distinctly procedural. Should probably fix that. -require 'json' - -details = Hash.new({}) - -capture_params = [ - { :name => "title", :message => "Enter project name." }, - { :name => "url", :message => "Enter the URL of the project repository." }, - { :name => "description", :message => "Enter the (short) project description." }, - { :name => "license", :message => "Enter the license this software shared under. (hit enter to skip)\nFor example MIT, BSD, GPL v3.0, Apache 2.0" }, - { :name => "doi", :message => "Enter the DOI of the archived version of this code. (hit enter to skip)\nFor example http://dx.doi.org/10.6084/m9.figshare.828487" }, - { :name => "keywords", :message => "Enter keywords that should be associated with this project (hit enter to skip)\nComma-separated, for example: turkey, chicken, pot pie" }, - { :name => "version", :message => "Enter the version of your software (hit enter to skip)\nSEMVER preferred: http://semver.org e.g. v1.0.0" } -] - -puts "I'm going to try and help you prepare some things for your JOSS submission" -puts "If all goes well then we'll have a nice codemeta.json file soon..." -puts "" -puts "************************************" -puts "* First, some basic details *" -puts "************************************" -puts "" - -# Loop through the desired captures and print out for clarity -capture_params.each do |param| - puts param[:message] - print "> " - input = gets - - details[param[:name]] = input.chomp - - puts "" - puts "OK, your project has #{param[:name]}: #{input}" - puts "" -end - -puts "" -puts "************************************" -puts "* Experimental stuff *" -puts "************************************" -puts "" - -puts "Would you like me to try and build a list of authors for you?" -puts "(You need to be running this script in a git repository for this to work)" -print "> (Y/N)" -answer = gets.chomp - -case answer.downcase -when "y", "yes" - - # Use git shortlog to extract a list of author names and commit counts. - # Note we don't extract emails here as there's often different emails for - # each user. Instead we capture emails at the end. - - git_log = `git shortlog --summary --numbered --no-merges` - - # ["252\tMichael Jackson", "151\tMC Hammer"] - authors_and_counts = git_log.split("\n").map(&:strip) - - authors_and_counts.each do |author_count| - count, author = author_count.split("\t").map(&:strip) - - puts "Looks like #{author} made #{count} commits" - puts "Add them to the output?" - print "> (Y/N)" - answer = gets.chomp - - # If a user chooses to add this author to the output then we ask for some - # additional information including their email, ORCID and affiliation. - case answer.downcase - when "y", "yes" - puts "What is #{author}'s email address? (hit enter to skip)" - print "> " - email = gets.chomp - - puts "What is #{author}'s ORCID? (hit enter to skip)" - puts "For example: http://orcid.org/0000-0000-0000-0000" - print "> " - orcid = gets.chomp - - puts "What is #{author}'s affiliation? (hit enter to skip)" - print "> " - affiliation = gets.chomp - - - details['authors'].merge!(author => { 'commits' => count, - 'email' => email, - 'orcid' => orcid, - 'affiliation' => affiliation }) - - when "n", "no" - puts "OK boss..." - puts "" - end - end -when "n", "no" - puts "OK boss..." - puts "" -end - -puts "Reticulating splines" - -5.times do - print "." - sleep 0.5 -end - -puts "" -puts "Generating some JSON goodness..." - -# TODO: work out how to use some kind of JSON template here. -# Build the output list of authors from the inputs we've collected. -output_authors = [] - -details['authors'].each do |author_name, values| - entry = { - "@id" => values['orcid'], - "@type" => "Person", - "email" => values['email'], - "name" => author_name, - "affiliation" => values['affiliation'] - } - output_authors << entry -end - -# TODO: this is currently a static template (written out here). It would be good -# to do something smarter here. -output = { - "@context" => "https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld", - "@type" => "Code", - "author" => output_authors, - "identifier" => details['doi'], - "codeRepository" => details['url'], - "datePublished" => Time.now.strftime("%Y-%m-%d"), - "dateModified" => Time.now.strftime("%Y-%m-%d"), - "dateCreated" => Time.now.strftime("%Y-%m-%d"), - "description" => details['description'], - "keywords" => details['keywords'], - "license" => details['license'], - "title" => details['title'], - "version" => details['version'] -} - -File.open('codemeta.json', 'w') {|f| f.write(JSON.pretty_generate(output)) } \ No newline at end of file diff --git a/setup.py b/setup.py index 2231db2a..36d0f186 100644 --- a/setup.py +++ b/setup.py @@ -2,6 +2,17 @@ """Setup script for the package.""" +from __future__ import ( + division, + absolute_import, + with_statement, + print_function, + unicode_literals, + generator_stop, + nested_scopes, + generators +) + import os import sys import logging diff --git a/tests/__init__.py b/tests/__init__.py index a916f18f..4d3e2474 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1 +1,12 @@ """Integration tests for the package.""" + +from __future__ import ( + division, + absolute_import, + with_statement, + print_function, + unicode_literals, + generator_stop, + nested_scopes, + generators +) diff --git a/tests/conftest.py b/tests/conftest.py index 394865cb..69729907 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,16 @@ """Integration tests configuration file.""" +from __future__ import ( + division, + absolute_import, + with_statement, + print_function, + unicode_literals, + generator_stop, + nested_scopes, + generators +) + from NiaPy.tests.conftest import pytest_configure __all__ = ["pytest_configure"] From 5f41a60a3463d49d6da384d76431257a772b20fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grega=20Vrban=C4=8Di=C4=8D?= Date: Fri, 12 Apr 2019 15:20:16 +0200 Subject: [PATCH 13/24] replace pylint with flake8 due to the problems with backward compatibility of newer releases of package. --- NiaPy/benchmarks/ackley.py | 4 ++-- NiaPy/benchmarks/benchmark.py | 2 +- NiaPy/benchmarks/happyCat.py | 2 +- Pipfile | 1 + 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/NiaPy/benchmarks/ackley.py b/NiaPy/benchmarks/ackley.py index 01fd3903..2347db63 100644 --- a/NiaPy/benchmarks/ackley.py +++ b/NiaPy/benchmarks/ackley.py @@ -1,5 +1,4 @@ # encoding=utf8 - """The module implementing Ackley benchmark.""" from numpy import exp, pi, cos, sqrt @@ -8,8 +7,9 @@ __all__ = ["Ackley"] + class Ackley(Benchmark): - r"""Implementation of Ackley function. + ur"""Implementation of Ackley function. Date: 2018 diff --git a/NiaPy/benchmarks/benchmark.py b/NiaPy/benchmarks/benchmark.py index 4a5b4bd3..28e97c00 100644 --- a/NiaPy/benchmarks/benchmark.py +++ b/NiaPy/benchmarks/benchmark.py @@ -14,6 +14,7 @@ __all__ = ["Benchmark"] + class Benchmark: """Base Benchmark interface class.""" @@ -25,7 +26,6 @@ def __init__(self, Lower, Upper, **kwargs): Arguments: Lower {[type]} -- Lower bound. Upper {[type]} -- Upper bound. - """ self.Lower = Lower diff --git a/NiaPy/benchmarks/happyCat.py b/NiaPy/benchmarks/happyCat.py index 23ac8464..54d92203 100644 --- a/NiaPy/benchmarks/happyCat.py +++ b/NiaPy/benchmarks/happyCat.py @@ -9,7 +9,7 @@ class HappyCat(Benchmark): - r"""Implementation of Happy cat function. + ur"""Implementation of Happy cat function. Date: 2018 diff --git a/Pipfile b/Pipfile index 2414056d..440bc9f0 100644 --- a/Pipfile +++ b/Pipfile @@ -9,6 +9,7 @@ scipy = ">=1.2.1" enum34 = {version = ">=1.1.6",markers = "python_version < '3.4'"} XlsxWriter = ">=1.1.5" matplotlib = ">=2.2.4" +flake8 = "*" [dev-packages] flake8 = "~=3.7.7" From 6267ee25f8c04ca1aae32e398904278aef5c498d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grega=20Vrban=C4=8Di=C4=8D?= Date: Sat, 13 Apr 2019 23:39:08 +0200 Subject: [PATCH 14/24] small fix --- NiaPy/benchmarks/ackley.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NiaPy/benchmarks/ackley.py b/NiaPy/benchmarks/ackley.py index 2347db63..c6f9a9b1 100644 --- a/NiaPy/benchmarks/ackley.py +++ b/NiaPy/benchmarks/ackley.py @@ -9,7 +9,7 @@ class Ackley(Benchmark): - ur"""Implementation of Ackley function. + r"""Implementation of Ackley function. Date: 2018 From 2a70c9109c54204d457ec8933569adceecf8c7ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grega=20Vrban=C4=8Di=C4=8D?= Date: Mon, 15 Apr 2019 06:15:38 +0200 Subject: [PATCH 15/24] fixes codestyle of some tests. --- NiaPy/benchmarks/ackley.py | 1 - NiaPy/benchmarks/benchmark.py | 1 - NiaPy/benchmarks/happyCat.py | 2 +- NiaPy/tests/conftest.py | 1 + NiaPy/tests/test_algorithm.py | 192 +++--- NiaPy/tests/test_ba.py | 8 +- NiaPy/tests/test_benchmark_functions.py | 751 ++++++++++++++---------- 7 files changed, 548 insertions(+), 408 deletions(-) diff --git a/NiaPy/benchmarks/ackley.py b/NiaPy/benchmarks/ackley.py index c6f9a9b1..4c5563e9 100644 --- a/NiaPy/benchmarks/ackley.py +++ b/NiaPy/benchmarks/ackley.py @@ -7,7 +7,6 @@ __all__ = ["Ackley"] - class Ackley(Benchmark): r"""Implementation of Ackley function. diff --git a/NiaPy/benchmarks/benchmark.py b/NiaPy/benchmarks/benchmark.py index 28e97c00..6e41a699 100644 --- a/NiaPy/benchmarks/benchmark.py +++ b/NiaPy/benchmarks/benchmark.py @@ -14,7 +14,6 @@ __all__ = ["Benchmark"] - class Benchmark: """Base Benchmark interface class.""" diff --git a/NiaPy/benchmarks/happyCat.py b/NiaPy/benchmarks/happyCat.py index 54d92203..23ac8464 100644 --- a/NiaPy/benchmarks/happyCat.py +++ b/NiaPy/benchmarks/happyCat.py @@ -9,7 +9,7 @@ class HappyCat(Benchmark): - ur"""Implementation of Happy cat function. + r"""Implementation of Happy cat function. Date: 2018 diff --git a/NiaPy/tests/conftest.py b/NiaPy/tests/conftest.py index 4b86be49..e6ccfbe3 100644 --- a/NiaPy/tests/conftest.py +++ b/NiaPy/tests/conftest.py @@ -2,6 +2,7 @@ import logging + def pytest_configure(config): """Disable verbose output when running tests.""" logging.basicConfig(level=logging.DEBUG) diff --git a/NiaPy/tests/test_algorithm.py b/NiaPy/tests/test_algorithm.py index 33767985..df4e7c1d 100644 --- a/NiaPy/tests/test_algorithm.py +++ b/NiaPy/tests/test_algorithm.py @@ -1,5 +1,5 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, function-redefined, multiple-statements, function-redefined, unsubscriptable-object, no-member, line-too-long, logging-not-lazy + import logging from unittest import TestCase from numpy import random as rnd, full, inf, array_equal @@ -10,109 +10,121 @@ logger = logging.getLogger('NiaPy.test') logger.setLevel('INFO') + class MyBenchmark: - def __init__(self): - self.Lower = -5.12 - self.Upper = 5.12 - self.optType = OptimizationType.MINIMIZATION - - @classmethod - def function(cls): - def evaluate(D, sol): - val = 0.0 - for i in range(D): val = val + sol[i] * sol[i] - return val - return evaluate + """Custom benchmark.""" + + def __init__(self): + """The initialization of custom benchmark.""" + + self.Lower = -5.12 + self.Upper = 5.12 + self.optType = OptimizationType.MINIMIZATION + + @classmethod + def function(cls): + """The evaluation function of benchmark.""" + def evaluate(D, sol): + val = 0.0 + for i in range(D): + val = val + sol[i] * sol[i] + return val + return evaluate + class IndividualTestCase(TestCase): - def setUp(self): - self.D = 20 - self.x, self.task = rnd.uniform(-100, 100, self.D), StoppingTask(D=self.D, nFES=230, nGEN=inf, benchmark=MyBenchmark()) - self.s1, self.s2, self.s3 = Individual(x=self.x, e=False), Individual(task=self.task, rand=rnd), Individual(task=self.task) + """Test the individual.""" + + def setUp(self): + self.D = 20 + self.x, self.task = rnd.uniform(-100, 100, self.D), StoppingTask(D=self.D, nFES=230, nGEN=inf, benchmark=MyBenchmark()) + self.s1, self.s2, self.s3 = Individual(x=self.x, e=False), Individual(task=self.task, rand=rnd), Individual(task=self.task) + + def test_x_fine(self): + self.assertTrue(array_equal(self.x, self.s1.x)) - def test_x_fine(self): - self.assertTrue(array_equal(self.x, self.s1.x)) + def test_generateSolutin_fine(self): + self.assertTrue(self.task.isFeasible(self.s2)) + self.assertTrue(self.task.isFeasible(self.s3)) - def test_generateSolutin_fine(self): - self.assertTrue(self.task.isFeasible(self.s2)) - self.assertTrue(self.task.isFeasible(self.s3)) + def test_evaluate_fine(self): + self.s1.evaluate(self.task) + self.assertAlmostEqual(self.s1.f, self.task.eval(self.x)) - def test_evaluate_fine(self): - self.s1.evaluate(self.task) - self.assertAlmostEqual(self.s1.f, self.task.eval(self.x)) + def test_repair_fine(self): + s = Individual(x=full(self.D, 100)) + self.assertFalse(self.task.isFeasible(s.x)) - def test_repair_fine(self): - s = Individual(x=full(self.D, 100)) - self.assertFalse(self.task.isFeasible(s.x)) + def test_eq_fine(self): + self.assertFalse(self.s1 == self.s2) + self.assertTrue(self.s1 == self.s1) + s = Individual(x=self.s1.x) + self.assertTrue(s == self.s1) - def test_eq_fine(self): - self.assertFalse(self.s1 == self.s2) - self.assertTrue(self.s1 == self.s1) - s = Individual(x=self.s1.x) - self.assertTrue(s == self.s1) + def test_str_fine(self): + self.assertEqual(str(self.s1), '%s -> %s' % (self.x, inf)) - def test_str_fine(self): - self.assertEqual(str(self.s1), '%s -> %s' % (self.x, inf)) + def test_getitem_fine(self): + for i in range(self.D): + self.assertEqual(self.s1[i], self.x[i]) - def test_getitem_fine(self): - for i in range(self.D): self.assertEqual(self.s1[i], self.x[i]) + def test_len_fine(self): + self.assertEqual(len(self.s1), len(self.x)) - def test_len_fine(self): - self.assertEqual(len(self.s1), len(self.x)) class AlgorithBaseTestCase(TestCase): - def setUp(self): - self.a = Algorithm() - - def test_randint(self): - o = self.a.randint(Nmax=20, Nmin=10, D=[10, 10]) - self.assertEqual(o.shape, (10, 10)) - o = self.a.randint(Nmax=20, Nmin=10, D=(10, 5)) - self.assertEqual(o.shape, (10, 5)) - o = self.a.randint(Nmax=20, Nmin=10, D=10) - self.assertEqual(o.shape, (10,)) - - def test_setParameters(self): - self.a.setParameters(t=None, a=20) - self.assertRaises(AttributeError, lambda: self.assertEqual(self.a.a, None)) - - def test_randn(self): - a = self.a.randn([1, 2]) - self.assertEqual(a.shape, (1, 2)) - a = self.a.randn(1) - self.assertEqual(len(a), 1) - a = self.a.randn(2) - self.assertEqual(len(a), 2) - a = self.a.randn() - self.assertIsInstance(a, float) + def setUp(self): + self.a = Algorithm() + + def test_randint(self): + o = self.a.randint(Nmax=20, Nmin=10, D=[10, 10]) + self.assertEqual(o.shape, (10, 10)) + o = self.a.randint(Nmax=20, Nmin=10, D=(10, 5)) + self.assertEqual(o.shape, (10, 5)) + o = self.a.randint(Nmax=20, Nmin=10, D=10) + self.assertEqual(o.shape, (10,)) + + def test_setParameters(self): + self.a.setParameters(t=None, a=20) + self.assertRaises(AttributeError, lambda: self.assertEqual(self.a.a, None)) + + def test_randn(self): + a = self.a.randn([1, 2]) + self.assertEqual(a.shape, (1, 2)) + a = self.a.randn(1) + self.assertEqual(len(a), 1) + a = self.a.randn(2) + self.assertEqual(len(a), 2) + a = self.a.randn() + self.assertIsInstance(a, float) + class TestingTask(StoppingTask, TestCase): - def eval(self, A): - r"""Check if is algorithm trying to evaluate solution out of bounds.""" - self.assertTrue(self.isFeasible(A), 'Solution %s is not in feasible space!!!' % A) - return StoppingTask.eval(self, A) + def eval(self, A): + r"""Check if is algorithm trying to evaluate solution out of bounds.""" + self.assertTrue(self.isFeasible(A), 'Solution %s is not in feasible space!!!' % A) + return StoppingTask.eval(self, A) + class AlgorithmTestCase(TestCase): - def setUp(self): - self.D, self.nGEN, self.nFES, self.seed = 40, 1000, 1000, 1 - - def setUpTasks(self, bech='griewank'): - taskOne, taskTwo = TestingTask(D=self.D, nFES=self.nFES, nGEN=self.nGEN, benchmark=bech), TestingTask(D=self.D, nFES=self.nFES, nGEN=self.nGEN, benchmark=bech) - return taskOne, taskTwo - - def algorithm_run_test(self, a, b, benc='griewank'): - tOne, tTwo = self.setUpTasks(benc) - x = a.run(tOne) - self.assertTrue(x) - logger.info('%s -> %s' % (x[0], x[1])) - y = b.run(tTwo) - self.assertTrue(y) - logger.info('%s -> %s' % (y[0], y[1])) - self.assertTrue(array_equal(x[0], y[0]), 'Results can not be reproduced, check usages of random number generator') - self.assertEqual(x[1], y[1], 'Results can not be reproduced or bad function value') - self.assertTrue(self.nFES >= tOne.Evals) - self.assertEqual(tOne.Evals, tTwo.Evals) - self.assertTrue(self.nGEN >= tOne.Iters) - self.assertEqual(tOne.Iters, tTwo.Iters) - -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + def setUp(self): + self.D, self.nGEN, self.nFES, self.seed = 40, 1000, 1000, 1 + + def setUpTasks(self, bech='griewank'): + taskOne, taskTwo = TestingTask(D=self.D, nFES=self.nFES, nGEN=self.nGEN, benchmark=bech), TestingTask(D=self.D, nFES=self.nFES, nGEN=self.nGEN, benchmark=bech) + return taskOne, taskTwo + + def algorithm_run_test(self, a, b, benc='griewank'): + tOne, tTwo = self.setUpTasks(benc) + x = a.run(tOne) + self.assertTrue(x) + logger.info('%s -> %s' % (x[0], x[1])) + y = b.run(tTwo) + self.assertTrue(y) + logger.info('%s -> %s' % (y[0], y[1])) + self.assertTrue(array_equal(x[0], y[0]), 'Results can not be reproduced, check usages of random number generator') + self.assertEqual(x[1], y[1], 'Results can not be reproduced or bad function value') + self.assertTrue(self.nFES >= tOne.Evals) + self.assertEqual(tOne.Evals, tTwo.Evals) + self.assertTrue(self.nGEN >= tOne.Iters) + self.assertEqual(tOne.Iters, tTwo.Iters) diff --git a/NiaPy/tests/test_ba.py b/NiaPy/tests/test_ba.py index a7b17ef1..9b2910bc 100644 --- a/NiaPy/tests/test_ba.py +++ b/NiaPy/tests/test_ba.py @@ -1,11 +1,13 @@ -# pylint: disable=line-too-long from NiaPy.tests.test_algorithm import AlgorithmTestCase, MyBenchmark from NiaPy.algorithms.basic import BatAlgorithm class BATestCase(AlgorithmTestCase): + """Test Bat algorithm.""" def test_parameter_type(self): + """Test BA parameters.""" + d = BatAlgorithm.typeParameters() self.assertTrue(d['Qmax'](10)) self.assertTrue(d['Qmin'](10)) @@ -22,11 +24,15 @@ def test_parameter_type(self): self.assertFalse(d['Qmax'](None)) def test_custom_works_fine(self): + """Test bat custom parameters.""" + ba_custom = BatAlgorithm(NP=20, A=0.5, r=0.5, Qmin=0.0, Qmax=2.0, seed=self.seed) ba_customc = BatAlgorithm(NP=20, A=0.5, r=0.5, Qmin=0.0, Qmax=2.0, seed=self.seed) AlgorithmTestCase.algorithm_run_test(self, ba_custom, ba_customc, MyBenchmark()) def test_griewank_works_fine(self): + """Test bat against griewank.""" + ba_griewank = BatAlgorithm(NP=10, A=0.5, r=0.5, Qmin=0.0, Qmax=2.0, seed=self.seed) ba_griewankc = BatAlgorithm(NP=10, A=0.5, r=0.5, Qmin=0.0, Qmax=2.0, seed=self.seed) AlgorithmTestCase.algorithm_run_test(self, ba_griewank, ba_griewankc) diff --git a/NiaPy/tests/test_benchmark_functions.py b/NiaPy/tests/test_benchmark_functions.py index afe8d174..8ebedc1a 100644 --- a/NiaPy/tests/test_benchmark_functions.py +++ b/NiaPy/tests/test_benchmark_functions.py @@ -1,321 +1,444 @@ # encoding=utf8 -# pylint: disable=mixed-indentation, redefined-builtin, too-many-instance-attributes,too-many-public-methods, multiple-statements, no-self-use + from math import pow, isnan from unittest import TestCase from numpy import asarray, pi, full from NiaPy.util import Utility + class TestBenchmarkFunctions(TestCase): - def setUp(self): - self.D = 5 - self.array = asarray([0, 0, 0, 0, 0]) - self.array2 = asarray([1, 1, 1, 1, 1]) - self.array3 = asarray([420.968746, 420.968746, 420.968746, 420.968746, 420.968746]) - self.array4 = asarray([-2.903534, -2.903534]) - self.array5 = asarray([-0.5, -0.5, -0.5, -0.5, -0.5]) - self.array6 = asarray([-1, -1, -1, -1, -1]) - self.array7 = asarray([2, 2, 2, 2, 2]) - self.array8 = asarray([7.9170526982459462172, 7.9170526982459462172, 7.9170526982459462172, 7.9170526982459462172, 7.9170526982459462172]) - self.array9 = asarray([-5.12, -5.12, -5.12, -5.12, -5.12]) - self.array10 = asarray([1, 2, 3, 4, 5]) - - def assertBounds(self, bench, l, u): - b = Utility().get_benchmark(bench) - self.assertEqual(b.Lower, l) - self.assertEqual(b.Upper, u) - return b.function() - - def test_rastrigin(self): - rastrigin = Utility().get_benchmark('rastrigin') - fun = rastrigin.function() - self.assertTrue(callable(fun)) - self.assertEqual(fun(self.D, self.array), 0.0) - - def test_rosenbrock(self): - rosenbrock = Utility().get_benchmark('rosenbrock') - fun = rosenbrock.function() - self.assertTrue(callable(fun)) - self.assertEqual(fun(self.D, self.array2), 0.0) - - def test_griewank(self): - griewank = Utility().get_benchmark('griewank') - fun = griewank.function() - self.assertTrue(callable(fun)) - self.assertEqual(fun(self.D, self.array), 0.0) - - def test_sphere(self): - sphere = Utility().get_benchmark('sphere') - fun = sphere.function() - self.assertTrue(callable(fun)) - self.assertEqual(fun(self.D, self.array), 0.0) - - def test_ackley(self): - ackley = Utility().get_benchmark('ackley') - fun = ackley.function() - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(self.D, self.array), 0.0, places=10) - - def test_schwefel(self): - schwefel = Utility().get_benchmark('schwefel') - fun = schwefel.function() - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(self.D, self.array3), 0.0, places=3) - - def test_schwefel221(self): - schwefel221 = Utility().get_benchmark('schwefel221') - fun = schwefel221.function() - self.assertTrue(callable(fun)) - self.assertEqual(fun(self.D, self.array), 0.0) - - def test_schwefel222(self): - schwefel222 = Utility().get_benchmark('schwefel222') - fun = schwefel222.function() - self.assertTrue(callable(fun)) - self.assertEqual(fun(self.D, self.array), 0.0) - - def test_whitley(self): - whitley = Utility().get_benchmark('whitley') - fun = whitley.function() - self.assertTrue(callable(fun)) - self.assertEqual(fun(self.D, self.array2), 0.0) - - def test_styblinskiTang(self): - styblinskiTang = Utility().get_benchmark('styblinskiTang') - fun = styblinskiTang.function() - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(2, self.array4), -78.332, places=3) - - def test_sumSquares(self): - sumSquares = Utility().get_benchmark('sumSquares') - fun = sumSquares.function() - self.assertTrue(callable(fun)) - self.assertEqual(fun(self.D, self.array), 0.0) - - def test_stepint(self): - stepint = Utility().get_benchmark('stepint') - fun = stepint.function() - self.assertTrue(callable(fun)) - self.assertEqual(fun(self.D, self.array9), 25.0 - 6 * self.D) - - def test_step(self): - step = Utility().get_benchmark('step') - fun = step.function() - self.assertTrue(callable(fun)) - self.assertEqual(fun(self.D, self.array), 0.0) - - def test_step2(self): - step2 = Utility().get_benchmark('step2') - fun = step2.function() - self.assertTrue(callable(fun)) - self.assertEqual(fun(self.D, self.array5), 0.0) - - def test_step3(self): - step3 = Utility().get_benchmark('step3') - fun = step3.function() - self.assertTrue(callable(fun)) - self.assertEqual(fun(self.D, self.array), 0.0) - - def test_schumerSteiglitz(self): - fun = self.assertBounds('schumerSteiglitz', -100, 100) - self.assertTrue(callable(fun)) - self.assertEqual(fun(self.D, self.array), 0.0) - - def test_salomon(self): - fun = self.assertBounds('salomon', -100.0, 100.0) - self.assertTrue(callable(fun)) - self.assertEqual(fun(self.D, self.array), 0.0) - - def test_quintic(self): - fun = self.assertBounds('quintic', -10.0, 10.0) - self.assertTrue(callable(fun)) - self.assertEqual(fun(self.D, self.array6), 0.0) - - def test_quintic2(self): - fun = self.assertBounds('quintic', -10.0, 10.0) - self.assertTrue(callable(fun)) - self.assertEqual(fun(self.D, self.array7), 0.0) - - def test_pinter(self): - fun = self.assertBounds('pinter', -10.0, 10.0) - self.assertTrue(callable(fun)) - self.assertEqual(fun(self.D, self.array), 0.0) - - def test_alpine1(self): - fun = self.assertBounds('alpine1', -10.0, 10.0) - self.assertTrue(callable(fun)) - self.assertEqual(fun(self.D, self.array), 0.0) - - def test_alpine2(self): - fun = self.assertBounds('alpine2', 0.0, 10.0) - self.assertTrue(callable(fun)) - self.assertEqual(fun(self.D, self.array8), pow(2.8081311800070053291, self.D)) - - def test_chungReynolds(self): - fun = self.assertBounds('chungReynolds', -100, 100) - self.assertTrue(callable(fun)) - self.assertEqual(fun(self.D, self.array), 0.0) - - def test_csendes(self): - fun = self.assertBounds('csendes', -1.0, 1.0) - self.assertTrue(callable(fun)) - self.assertEqual(fun(self.D, self.array), 0.0) - - def test_bentcigar(self): - fun = self.assertBounds('bentcigar', -100, 100) - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(2, full(2, 0)), 0.0, delta=1e-4) - self.assertAlmostEqual(fun(10, full(10, 0)), 0.0, delta=1e-4) - self.assertAlmostEqual(fun(100, full(100, 0)), 0.0, delta=1e-4) - - def test_discus(self): - fun = self.assertBounds('discus', -100, 100) - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(self.D, self.array10), 1000054.0, delta=1e-4) - - def test_elliptic(self): - fun = self.assertBounds('elliptic', -100, 100) - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(self.D, self.array10), 5129555.351959938, delta=2e6) - - def test_expanded_griewank_plus_rosnbrock(self): - fun = self.assertBounds('expandedgriewankplusrosenbrock', -100, 100) - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(self.D, self.array), 2.2997, delta=1e2) - - def test_expanded_schaffer(self): - fun = self.assertBounds('expandedschaffer', -100, 100) - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(self.D, self.array10), 2.616740208857464, delta=1e-4) - - def test_schaffern2(self): - fun = self.assertBounds('schaffer2', -100, 100) - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(self.D, self.array10), 0.02467, delta=1e-4) - - def test_schaffern4(self): - fun = self.assertBounds('schaffer4', -100, 100) - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(self.D, self.array10), 0.97545, delta=1e-4) - - def test_hgbat(self): - fun = self.assertBounds('hgbat', -100, 100) - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(self.D, self.array10), 61.91502622129181, delta=60) - - def test_katsuura(self): - fun = self.assertBounds('katsuura', -100, 100) - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(self.D, self.array10), 3837.4739882594373, delta=4000) - - def test_modifiedscwefel(self): - fun = self.assertBounds('modifiedscwefel', -100, 100) - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(self.D, self.array10), 6.9448853328785844, delta=350) - - def test_weierstrass(self): - fun = self.assertBounds('weierstrass', -100, 100) - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(self.D, self.array10), 0.0, delta=1e-4) - - def test_happyCat(self): - fun = self.assertBounds('happyCat', -100, 100) - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(self.D, self.array10), 15.1821333, delta=1e-4) - - def test_qing(self): - fun = self.assertBounds('qing', -500, 500) - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(self.D, self.array10), 669.0, delta=1e-4) - - def test_ridge(self): - fun = self.assertBounds('ridge', -64, 64) - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(self.D, self.array10), 371.0, delta=1e-4) - - def test_michalewicz(self): - fun = self.assertBounds('michalewicz', 0, pi) - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(2, asarray([2.20, 1.57])), -1.8013, delta=1e-3) - - def test_levy(self): - fun = self.assertBounds('levy', 0, pi) - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(2, full(2, 1.)), 0.0) - self.assertAlmostEqual(fun(10, full(10, 1.)), 0.0) - self.assertAlmostEqual(fun(100, full(100, 1.)), 0.0) - - def test_sphere2(self): - fun = self.assertBounds('sphere2', -1, 1) - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(2, full(2, 0.)), 0.0) - self.assertAlmostEqual(fun(10, full(10, 0.)), 0.0) - self.assertAlmostEqual(fun(100, full(100, 0.)), 0.0) - - def test_sphere3(self): - fun = self.assertBounds('sphere3', -65.536, 65.536) - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(2, full(2, 0.)), 0.0) - self.assertAlmostEqual(fun(10, full(10, 0.)), 0.0) - self.assertAlmostEqual(fun(100, full(100, 0.)), 0.0) - - def __trid_opt(self, d): return -d * (d + 4) * (d - 1) / 6 - - def __trid_opt_sol(self, d): return asarray([i * (d + 1 - i) for i in range(1, d + 1)]) - - def test_trid(self): - fun = self.assertBounds('trid', -2 ** 2, 2 ** 2) - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(2, self.__trid_opt_sol(2)), self.__trid_opt(2)) - self.assertAlmostEqual(fun(10, self.__trid_opt_sol(10)), self.__trid_opt(10)) - self.assertAlmostEqual(fun(100, self.__trid_opt_sol(100)), self.__trid_opt(100)) - - def __perm_opt_sol(self, d): return asarray([1 / i for i in range(1, d + 1)]) - - def test_perm(self): - fun = self.assertBounds('perm', -10, 10) - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(2, self.__perm_opt_sol(2)), .0) - self.assertAlmostEqual(fun(10, self.__perm_opt_sol(10)), .0) - self.assertAlmostEqual(fun(100, self.__perm_opt_sol(100)), .0) - - def test_zakharov(self): - fun = self.assertBounds('zakharov', -5, 10) - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(2, full(2, .0)), .0) - self.assertAlmostEqual(fun(10, full(10, .0)), .0) - self.assertAlmostEqual(fun(100, full(100, .0)), .0) - - def __dixonprice_opt_sol(self, d): return asarray([2 ** (-(2 ** i - 2) / 2 ** i) for i in range(1, d + 1)]) - - def test_dixonprice(self): - fun = self.assertBounds('dixonprice', -10, 10) - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(2, self.__dixonprice_opt_sol(2)), .0) - self.assertAlmostEqual(fun(10, self.__dixonprice_opt_sol(10)), .0) - self.assertAlmostEqual(fun(100, self.__dixonprice_opt_sol(100)), .0) - - def test_powell(self): - fun = self.assertBounds('powell', -4, 5) - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(2, full(2, .0)), .0) - self.assertAlmostEqual(fun(10, full(10, .0)), .0) - self.assertAlmostEqual(fun(100, full(100, .0)), .0) - - def test_cosinemixture(self): - fun = self.assertBounds('cosinemixture', -1, 1) - self.assertTrue(callable(fun)) - self.assertAlmostEqual(fun(2, full(2, .0)), -.1 * 2) - self.assertAlmostEqual(fun(10, full(10, .0)), -.1 * 10) - self.assertAlmostEqual(fun(100, full(100, .0)), -.1 * 100) - - def test_infinity(self): - fun = self.assertBounds('infinity', -1, 1) - self.assertTrue(callable(fun)) - self.assertTrue(isnan(fun(2, full(2, .0)))) - self.assertTrue(isnan(fun(10, full(10, .0)))) - self.assertTrue(isnan(fun(100, full(100, .0)))) - self.assertAlmostEqual(fun(2, full(2, 1e-4)), .0) - self.assertAlmostEqual(fun(10, full(10, 1e-4)), .0) - self.assertAlmostEqual(fun(100, full(100, 1e-4)), .0) - -# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3 + """Testing the benchmarks.""" + + def setUp(self): + """Set up the tests.""" + + self.D = 5 + self.array = asarray([0, 0, 0, 0, 0]) + self.array2 = asarray([1, 1, 1, 1, 1]) + self.array3 = asarray([420.968746, 420.968746, 420.968746, 420.968746, 420.968746]) + self.array4 = asarray([-2.903534, -2.903534]) + self.array5 = asarray([-0.5, -0.5, -0.5, -0.5, -0.5]) + self.array6 = asarray([-1, -1, -1, -1, -1]) + self.array7 = asarray([2, 2, 2, 2, 2]) + self.array8 = asarray([7.9170526982459462172, 7.9170526982459462172, 7.9170526982459462172, 7.9170526982459462172, 7.9170526982459462172]) + self.array9 = asarray([-5.12, -5.12, -5.12, -5.12, -5.12]) + self.array10 = asarray([1, 2, 3, 4, 5]) + + def assertBounds(self, bench, lower, upper): + """Checking the bounds. + + Arguments: + bench [Benchmark]: Benchmark to test. + lower [float]: Lower bound. + upper [type]: Upper bound. + + Returns: + [fun]: Returns benchmarks evaluation function. + """ + + b = Utility().get_benchmark(bench) + self.assertEqual(b.Lower, lower) + self.assertEqual(b.Upper, upper) + return b.function() + + def test_rastrigin(self): + """Test the rastrigin benchmark.""" + + rastrigin = Utility().get_benchmark('rastrigin') + fun = rastrigin.function() + self.assertTrue(callable(fun)) + self.assertEqual(fun(self.D, self.array), 0.0) + + def test_rosenbrock(self): + """Test the rosenbrock benchmark.""" + + rosenbrock = Utility().get_benchmark('rosenbrock') + fun = rosenbrock.function() + self.assertTrue(callable(fun)) + self.assertEqual(fun(self.D, self.array2), 0.0) + + def test_griewank(self): + """Test the griewank benchmark.""" + + griewank = Utility().get_benchmark('griewank') + fun = griewank.function() + self.assertTrue(callable(fun)) + self.assertEqual(fun(self.D, self.array), 0.0) + + def test_sphere(self): + """Test the sphere benchmark.""" + + sphere = Utility().get_benchmark('sphere') + fun = sphere.function() + self.assertTrue(callable(fun)) + self.assertEqual(fun(self.D, self.array), 0.0) + + def test_ackley(self): + """Test the ackley benchmark.""" + + ackley = Utility().get_benchmark('ackley') + fun = ackley.function() + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(self.D, self.array), 0.0, places=10) + + def test_schwefel(self): + """Test the schwefel benchmark.""" + + schwefel = Utility().get_benchmark('schwefel') + fun = schwefel.function() + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(self.D, self.array3), 0.0, places=3) + + def test_schwefel221(self): + """Test the schwefel 221 benchmark.""" + + schwefel221 = Utility().get_benchmark('schwefel221') + fun = schwefel221.function() + self.assertTrue(callable(fun)) + self.assertEqual(fun(self.D, self.array), 0.0) + + def test_schwefel222(self): + """Test the schwefel 222 benchmark.""" + + schwefel222 = Utility().get_benchmark('schwefel222') + fun = schwefel222.function() + self.assertTrue(callable(fun)) + self.assertEqual(fun(self.D, self.array), 0.0) + + def test_whitley(self): + """Test the whitley benchmark.""" + + whitley = Utility().get_benchmark('whitley') + fun = whitley.function() + self.assertTrue(callable(fun)) + self.assertEqual(fun(self.D, self.array2), 0.0) + + def test_styblinskiTang(self): + """Test the styblinski tang benchmark.""" + + styblinskiTang = Utility().get_benchmark('styblinskiTang') + fun = styblinskiTang.function() + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(2, self.array4), -78.332, places=3) + + def test_sumSquares(self): + """Test the sum squares benchmark.""" + + sumSquares = Utility().get_benchmark('sumSquares') + fun = sumSquares.function() + self.assertTrue(callable(fun)) + self.assertEqual(fun(self.D, self.array), 0.0) + + def test_stepint(self): + """Test the stepint benchmark.""" + + stepint = Utility().get_benchmark('stepint') + fun = stepint.function() + self.assertTrue(callable(fun)) + self.assertEqual(fun(self.D, self.array9), 25.0 - 6 * self.D) + + def test_step(self): + """Test the step benchmark.""" + + step = Utility().get_benchmark('step') + fun = step.function() + self.assertTrue(callable(fun)) + self.assertEqual(fun(self.D, self.array), 0.0) + + def test_step2(self): + """Test the step 2 benchmark.""" + + step2 = Utility().get_benchmark('step2') + fun = step2.function() + self.assertTrue(callable(fun)) + self.assertEqual(fun(self.D, self.array5), 0.0) + + def test_step3(self): + """Test the step3 benchmark.""" + + step3 = Utility().get_benchmark('step3') + fun = step3.function() + self.assertTrue(callable(fun)) + self.assertEqual(fun(self.D, self.array), 0.0) + + def test_schumerSteiglitz(self): + """Test the schumer steiglitz benchmark.""" + + fun = self.assertBounds('schumerSteiglitz', -100, 100) + self.assertTrue(callable(fun)) + self.assertEqual(fun(self.D, self.array), 0.0) + + def test_salomon(self): + """Test the salomon benchmark.""" + + fun = self.assertBounds('salomon', -100.0, 100.0) + self.assertTrue(callable(fun)) + self.assertEqual(fun(self.D, self.array), 0.0) + + def test_quintic(self): + """Test the quintic benchmark.""" + + fun = self.assertBounds('quintic', -10.0, 10.0) + self.assertTrue(callable(fun)) + self.assertEqual(fun(self.D, self.array6), 0.0) + + def test_quintic2(self): + """Test the quintic benchmark.""" + + fun = self.assertBounds('quintic', -10.0, 10.0) + self.assertTrue(callable(fun)) + self.assertEqual(fun(self.D, self.array7), 0.0) + + def test_pinter(self): + """Test the pinter benchmark.""" + + fun = self.assertBounds('pinter', -10.0, 10.0) + self.assertTrue(callable(fun)) + self.assertEqual(fun(self.D, self.array), 0.0) + + def test_alpine1(self): + """Test the alpine 1 benchmark.""" + + fun = self.assertBounds('alpine1', -10.0, 10.0) + self.assertTrue(callable(fun)) + self.assertEqual(fun(self.D, self.array), 0.0) + + def test_alpine2(self): + """Test the apline 2 benchmark.""" + + fun = self.assertBounds('alpine2', 0.0, 10.0) + self.assertTrue(callable(fun)) + self.assertEqual(fun(self.D, self.array8), pow(2.8081311800070053291, self.D)) + + def test_chungReynolds(self): + """Test the chung reynolds benchmark.""" + + fun = self.assertBounds('chungReynolds', -100, 100) + self.assertTrue(callable(fun)) + self.assertEqual(fun(self.D, self.array), 0.0) + + def test_csendes(self): + """Test the csendes benchmark.""" + + fun = self.assertBounds('csendes', -1.0, 1.0) + self.assertTrue(callable(fun)) + self.assertEqual(fun(self.D, self.array), 0.0) + + def test_bentcigar(self): + """Test the bent cigar benchmark.""" + + fun = self.assertBounds('bentcigar', -100, 100) + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(2, full(2, 0)), 0.0, delta=1e-4) + self.assertAlmostEqual(fun(10, full(10, 0)), 0.0, delta=1e-4) + self.assertAlmostEqual(fun(100, full(100, 0)), 0.0, delta=1e-4) + + def test_discus(self): + """Test the discus benchmark.""" + + fun = self.assertBounds('discus', -100, 100) + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(self.D, self.array10), 1000054.0, delta=1e-4) + + def test_elliptic(self): + """Test the elliptic benchmark.""" + + fun = self.assertBounds('elliptic', -100, 100) + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(self.D, self.array10), 5129555.351959938, delta=2e6) + + def test_expanded_griewank_plus_rosenbrock(self): + """Test the expanded griewank plus rosenbrock benchmark.""" + + fun = self.assertBounds('expandedgriewankplusrosenbrock', -100, 100) + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(self.D, self.array), 2.2997, delta=1e2) + + def test_expanded_schaffer(self): + """Test the expanded schaffer benchmark.""" + + fun = self.assertBounds('expandedschaffer', -100, 100) + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(self.D, self.array10), 2.616740208857464, delta=1e-4) + + def test_schaffern2(self): + """Test the schaffer n. 2 benchmark.""" + + fun = self.assertBounds('schaffer2', -100, 100) + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(self.D, self.array10), 0.02467, delta=1e-4) + + def test_schaffern4(self): + """Test the schaffer n. 4 benchmark.""" + + fun = self.assertBounds('schaffer4', -100, 100) + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(self.D, self.array10), 0.97545, delta=1e-4) + + def test_hgbat(self): + """Test the hgbat benchmark.""" + + fun = self.assertBounds('hgbat', -100, 100) + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(self.D, self.array10), 61.91502622129181, delta=60) + + def test_katsuura(self): + """Test the katsuura benchmark.""" + + fun = self.assertBounds('katsuura', -100, 100) + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(self.D, self.array10), 3837.4739882594373, delta=4000) + + def test_modifiedscwefel(self): + """Test the modified scwefel benchmark.""" + + fun = self.assertBounds('modifiedscwefel', -100, 100) + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(self.D, self.array10), 6.9448853328785844, delta=350) + + def test_weierstrass(self): + """Test the weierstrass benchmark.""" + + fun = self.assertBounds('weierstrass', -100, 100) + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(self.D, self.array10), 0.0, delta=1e-4) + + def test_happyCat(self): + """Test the happy cat benchmark.""" + + fun = self.assertBounds('happyCat', -100, 100) + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(self.D, self.array10), 15.1821333, delta=1e-4) + + def test_qing(self): + """Test the quing benchmark.""" + + fun = self.assertBounds('qing', -500, 500) + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(self.D, self.array10), 669.0, delta=1e-4) + + def test_ridge(self): + """Test the ridge benchmark.""" + + fun = self.assertBounds('ridge', -64, 64) + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(self.D, self.array10), 371.0, delta=1e-4) + + def test_michalewicz(self): + """Test the michalewicz benchmark.""" + + fun = self.assertBounds('michalewicz', 0, pi) + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(2, asarray([2.20, 1.57])), -1.8013, delta=1e-3) + + def test_levy(self): + """Test the levy benchmark.""" + + fun = self.assertBounds('levy', 0, pi) + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(2, full(2, 1.)), 0.0) + self.assertAlmostEqual(fun(10, full(10, 1.)), 0.0) + self.assertAlmostEqual(fun(100, full(100, 1.)), 0.0) + + def test_sphere2(self): + """Test the sphere 2 benchmark.""" + + fun = self.assertBounds('sphere2', -1, 1) + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(2, full(2, 0.)), 0.0) + self.assertAlmostEqual(fun(10, full(10, 0.)), 0.0) + self.assertAlmostEqual(fun(100, full(100, 0.)), 0.0) + + def test_sphere3(self): + """Test the sphere 3 benchmark.""" + + fun = self.assertBounds('sphere3', -65.536, 65.536) + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(2, full(2, 0.)), 0.0) + self.assertAlmostEqual(fun(10, full(10, 0.)), 0.0) + self.assertAlmostEqual(fun(100, full(100, 0.)), 0.0) + + def __trid_opt(self, d): + """Trid benchmark optimum.""" + + return -d * (d + 4) * (d - 1) / 6 + + def __trid_opt_sol(self, d): + """Trid optimal solution.""" + + return asarray([i * (d + 1 - i) for i in range(1, d + 1)]) + + def test_trid(self): + """Test the trid benchmark.""" + + fun = self.assertBounds('trid', -2 ** 2, 2 ** 2) + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(2, self.__trid_opt_sol(2)), self.__trid_opt(2)) + self.assertAlmostEqual(fun(10, self.__trid_opt_sol(10)), self.__trid_opt(10)) + self.assertAlmostEqual(fun(100, self.__trid_opt_sol(100)), self.__trid_opt(100)) + + def __perm_opt_sol(self, d): + """The perm optimal solution.""" + + return asarray([1 / i for i in range(1, d + 1)]) + + def test_perm(self): + """Test the perm bencmark.""" + + fun = self.assertBounds('perm', -10, 10) + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(2, self.__perm_opt_sol(2)), .0) + self.assertAlmostEqual(fun(10, self.__perm_opt_sol(10)), .0) + self.assertAlmostEqual(fun(100, self.__perm_opt_sol(100)), .0) + + def test_zakharov(self): + """Test the zakharov benchmark.""" + + fun = self.assertBounds('zakharov', -5, 10) + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(2, full(2, .0)), .0) + self.assertAlmostEqual(fun(10, full(10, .0)), .0) + self.assertAlmostEqual(fun(100, full(100, .0)), .0) + + def __dixonprice_opt_sol(self, d): + """The dixon price optimal solution.""" + return asarray([2 ** (-(2 ** i - 2) / 2 ** i) for i in range(1, d + 1)]) + + def test_dixonprice(self): + """Test the dixon price benchmark.""" + + fun = self.assertBounds('dixonprice', -10, 10) + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(2, self.__dixonprice_opt_sol(2)), .0) + self.assertAlmostEqual(fun(10, self.__dixonprice_opt_sol(10)), .0) + self.assertAlmostEqual(fun(100, self.__dixonprice_opt_sol(100)), .0) + + def test_powell(self): + """Tests the powell benchmark.""" + + fun = self.assertBounds('powell', -4, 5) + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(2, full(2, .0)), .0) + self.assertAlmostEqual(fun(10, full(10, .0)), .0) + self.assertAlmostEqual(fun(100, full(100, .0)), .0) + + def test_cosinemixture(self): + """Test the cosine mixture benchmark.""" + + fun = self.assertBounds('cosinemixture', -1, 1) + self.assertTrue(callable(fun)) + self.assertAlmostEqual(fun(2, full(2, .0)), -.1 * 2) + self.assertAlmostEqual(fun(10, full(10, .0)), -.1 * 10) + self.assertAlmostEqual(fun(100, full(100, .0)), -.1 * 100) + + def test_infinity(self): + """Test the infinity benchmark.""" + + fun = self.assertBounds('infinity', -1, 1) + self.assertTrue(callable(fun)) + self.assertTrue(isnan(fun(2, full(2, .0)))) + self.assertTrue(isnan(fun(10, full(10, .0)))) + self.assertTrue(isnan(fun(100, full(100, .0)))) + self.assertAlmostEqual(fun(2, full(2, 1e-4)), .0) + self.assertAlmostEqual(fun(10, full(10, 1e-4)), .0) + self.assertAlmostEqual(fun(100, full(100, 1e-4)), .0) From 5abc1147921440852ef3ef8a78607abf773e33a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grega=20Vrban=C4=8Di=C4=8D?= Date: Mon, 15 Apr 2019 06:16:02 +0200 Subject: [PATCH 16/24] Pipfile.lock --- Pipfile.lock | 930 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 930 insertions(+) create mode 100644 Pipfile.lock diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 00000000..12ee8208 --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,930 @@ +{ + "_meta": { + "hash": { + "sha256": "ae1a70f45af0be4100c51eeb592f530cd308f7e8968c6ca03ab164714fed99a1" + }, + "pipfile-spec": 6, + "requires": {}, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.python.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "cycler": { + "hashes": [ + "sha256:1d8a5ae1ff6c5cf9b93e8811e581232ad8920aeec647c37316ceac982b08cb2d", + "sha256:cd7b2d1018258d7247a71425e9f26463dfb444d411c39569972f4ce586b0c9d8" + ], + "version": "==0.10.0" + }, + "entrypoints": { + "hashes": [ + "sha256:589f874b313739ad35be6e0cd7efde2a4e9b6fea91edcc34e58ecbb8dbe56d19", + "sha256:c70dd71abe5a8c85e55e12c19bd91ccfeec11a6e99044204511f9ed547d48451" + ], + "version": "==0.3" + }, + "enum34": { + "hashes": [ + "sha256:2d81cbbe0e73112bdfe6ef8576f2238f2ba27dd0d55752a776c41d38b7da2850", + "sha256:644837f692e5f550741432dd3f223bbb9852018674981b1664e5dc339387588a", + "sha256:6bd0f6ad48ec2aa117d3d141940d484deccda84d4fcd884f5c3d93c23ecd8c79", + "sha256:8ad8c4783bf61ded74527bffb48ed9b54166685e4230386a9ed9b1279e2df5b1" + ], + "index": "pypi", + "markers": "python_version < '3.4'", + "version": "==1.1.6" + }, + "flake8": { + "hashes": [ + "sha256:859996073f341f2670741b51ec1e67a01da142831aa1fdc6242dbf88dffbe661", + "sha256:a796a115208f5c03b18f332f7c11729812c8c3ded6c46319c59b53efd3819da8" + ], + "index": "pypi", + "version": "==3.7.7" + }, + "kiwisolver": { + "hashes": [ + "sha256:0ee4ed8b3ae8f5f712b0aa9ebd2858b5b232f1b9a96b0943dceb34df2a223bc3", + "sha256:0f7f532f3c94e99545a29f4c3f05637f4d2713e7fd91b4dd8abfc18340b86cd5", + "sha256:1a078f5dd7e99317098f0e0d490257fd0349d79363e8c923d5bb76428f318421", + "sha256:1aa0b55a0eb1bd3fa82e704f44fb8f16e26702af1a073cc5030eea399e617b56", + "sha256:2874060b91e131ceeff00574b7c2140749c9355817a4ed498e82a4ffa308ecbc", + "sha256:379d97783ba8d2934d52221c833407f20ca287b36d949b4bba6c75274bcf6363", + "sha256:3b791ddf2aefc56382aadc26ea5b352e86a2921e4e85c31c1f770f527eb06ce4", + "sha256:4329008a167fac233e398e8a600d1b91539dc33c5a3eadee84c0d4b04d4494fa", + "sha256:45813e0873bbb679334a161b28cb9606d9665e70561fd6caa8863e279b5e464b", + "sha256:53a5b27e6b5717bdc0125338a822605084054c80f382051fb945d2c0e6899a20", + "sha256:574f24b9805cb1c72d02b9f7749aa0cc0b81aa82571be5201aa1453190390ae5", + "sha256:66f82819ff47fa67a11540da96966fb9245504b7f496034f534b81cacf333861", + "sha256:79e5fe3ccd5144ae80777e12973027bd2f4f5e3ae8eb286cabe787bed9780138", + "sha256:83410258eb886f3456714eea4d4304db3a1fc8624623fc3f38a487ab36c0f653", + "sha256:8b6a7b596ce1d2a6d93c3562f1178ebd3b7bb445b3b0dd33b09f9255e312a965", + "sha256:9576cb63897fbfa69df60f994082c3f4b8e6adb49cccb60efb2a80a208e6f996", + "sha256:95a25d9f3449046ecbe9065be8f8380c03c56081bc5d41fe0fb964aaa30b2195", + "sha256:a424f048bebc4476620e77f3e4d1f282920cef9bc376ba16d0b8fe97eec87cde", + "sha256:aaec1cfd94f4f3e9a25e144d5b0ed1eb8a9596ec36d7318a504d813412563a85", + "sha256:acb673eecbae089ea3be3dcf75bfe45fc8d4dcdc951e27d8691887963cf421c7", + "sha256:b15bc8d2c2848a4a7c04f76c9b3dc3561e95d4dabc6b4f24bfabe5fd81a0b14f", + "sha256:b1c240d565e977d80c0083404c01e4d59c5772c977fae2c483f100567f50847b", + "sha256:c595693de998461bcd49b8d20568c8870b3209b8ea323b2a7b0ea86d85864694", + "sha256:ce3be5d520b4d2c3e5eeb4cd2ef62b9b9ab8ac6b6fedbaa0e39cdb6f50644278", + "sha256:e0f910f84b35c36a3513b96d816e6442ae138862257ae18a0019d2fc67b041dc", + "sha256:ea36e19ac0a483eea239320aef0bd40702404ff8c7e42179a2d9d36c5afcb55c", + "sha256:efabbcd4f406b532206b8801058c8bab9e79645b9880329253ae3322b7b02cd5", + "sha256:f923406e6b32c86309261b8195e24e18b6a8801df0cfc7814ac44017bfcb3939" + ], + "version": "==1.0.1" + }, + "matplotlib": { + "hashes": [ + "sha256:1ae6549976b6ceb6ee426272a28c0fc9715b3e3669694d560c8f661c5b39e2c5", + "sha256:4d4250bf508dd07cca3b43888097f873cadb66eec6ac63dbbfb798798ec07af2", + "sha256:53af2e01d7f1700ed2b64a9091bc865360c9c4032f625451c4589a826854c787", + "sha256:63e498067d32d627111cd1162cae1621f1221f9d4c6a9745dd7233f29de581b6", + "sha256:7169a34971e398dd58e87e173f97366fd88a3fa80852704530433eb224a8ca57", + "sha256:91c54d6bb9eeaaff965656c5ea6cbdcbf780bad8462ac99b30b451548194746f", + "sha256:aeef177647bb3fccfe09065481989d7dfc5ac59e9367d6a00a3481062cf651e4", + "sha256:cf8ae10559a78aee0409ede1e9d4fda03895433eeafe609dd9ed67e45f552db0", + "sha256:d51d0889d1c4d51c51a9822265c0494ea3e70a52bdd88358e0863daca46fa23a", + "sha256:de5ccd3500247f85fe4f9fad90f80a8bd397e4f110a4c33fabf95f07403e8372", + "sha256:e1d33589e32f482d0a7d1957bf473d43341115d40d33f578dad44432e47df7b7", + "sha256:e8d1939262aa6b36d0c51f50a50a43a04b9618d20db31e6c0192b1463067aeef", + "sha256:e918d51b1fda82a65fdf52d2f3914b2246481cc2a9cd10e223e6be6078916ff3" + ], + "index": "pypi", + "version": "==3.0.3" + }, + "mccabe": { + "hashes": [ + "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", + "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f" + ], + "version": "==0.6.1" + }, + "numpy": { + "hashes": [ + "sha256:1980f8d84548d74921685f68096911585fee393975f53797614b34d4f409b6da", + "sha256:22752cd809272671b273bb86df0f505f505a12368a3a5fc0aa811c7ece4dfd5c", + "sha256:23cc40313036cffd5d1873ef3ce2e949bdee0646c5d6f375bf7ee4f368db2511", + "sha256:2b0b118ff547fecabc247a2668f48f48b3b1f7d63676ebc5be7352a5fd9e85a5", + "sha256:3a0bd1edf64f6a911427b608a894111f9fcdb25284f724016f34a84c9a3a6ea9", + "sha256:3f25f6c7b0d000017e5ac55977a3999b0b1a74491eacb3c1aa716f0e01f6dcd1", + "sha256:4061c79ac2230594a7419151028e808239450e676c39e58302ad296232e3c2e8", + "sha256:560ceaa24f971ab37dede7ba030fc5d8fa173305d94365f814d9523ffd5d5916", + "sha256:62be044cd58da2a947b7e7b2252a10b42920df9520fc3d39f5c4c70d5460b8ba", + "sha256:6c692e3879dde0b67a9dc78f9bfb6f61c666b4562fd8619632d7043fb5b691b0", + "sha256:6f65e37b5a331df950ef6ff03bd4136b3c0bbcf44d4b8e99135d68a537711b5a", + "sha256:7a78cc4ddb253a55971115f8320a7ce28fd23a065fc33166d601f51760eecfa9", + "sha256:80a41edf64a3626e729a62df7dd278474fc1726836552b67a8c6396fd7e86760", + "sha256:893f4d75255f25a7b8516feb5766c6b63c54780323b9bd4bc51cdd7efc943c73", + "sha256:972ea92f9c1b54cc1c1a3d8508e326c0114aaf0f34996772a30f3f52b73b942f", + "sha256:9f1d4865436f794accdabadc57a8395bd3faa755449b4f65b88b7df65ae05f89", + "sha256:9f4cd7832b35e736b739be03b55875706c8c3e5fe334a06210f1a61e5c2c8ca5", + "sha256:adab43bf657488300d3aeeb8030d7f024fcc86e3a9b8848741ea2ea903e56610", + "sha256:bd2834d496ba9b1bdda3a6cf3de4dc0d4a0e7be306335940402ec95132ad063d", + "sha256:d20c0360940f30003a23c0adae2fe50a0a04f3e48dc05c298493b51fd6280197", + "sha256:d3b3ed87061d2314ff3659bb73896e622252da52558f2380f12c421fbdee3d89", + "sha256:dc235bf29a406dfda5790d01b998a1c01d7d37f449128c0b1b7d1c89a84fae8b", + "sha256:fb3c83554f39f48f3fa3123b9c24aecf681b1c289f9334f8215c1d3c8e2f6e5b" + ], + "index": "pypi", + "version": "==1.16.2" + }, + "pycodestyle": { + "hashes": [ + "sha256:95a2219d12372f05704562a14ec30bc76b05a5b297b21a5dfe3f6fac3491ae56", + "sha256:e40a936c9a450ad81df37f549d676d127b1b66000a6c500caa2b085bc0ca976c" + ], + "version": "==2.5.0" + }, + "pyflakes": { + "hashes": [ + "sha256:17dbeb2e3f4d772725c777fabc446d5634d1038f234e77343108ce445ea69ce0", + "sha256:d976835886f8c5b31d47970ed689944a0262b5f3afa00a5a7b4dc81e5449f8a2" + ], + "version": "==2.1.1" + }, + "pyparsing": { + "hashes": [ + "sha256:1873c03321fc118f4e9746baf201ff990ceb915f433f23b395f5580d1840cb2a", + "sha256:9b6323ef4ab914af344ba97510e966d64ba91055d6b9afa6b30799340e89cc03" + ], + "version": "==2.4.0" + }, + "python-dateutil": { + "hashes": [ + "sha256:7e6584c74aeed623791615e26efd690f29817a27c73085b78e4bad02493df2fb", + "sha256:c89805f6f4d64db21ed966fda138f8a5ed7a4fdbc1a8ee329ce1b74e3c74da9e" + ], + "version": "==2.8.0" + }, + "scipy": { + "hashes": [ + "sha256:014cb900c003b5ac81a53f2403294e8ecf37aedc315b59a6b9370dce0aa7627a", + "sha256:281a34da34a5e0de42d26aed692ab710141cad9d5d218b20643a9cb538ace976", + "sha256:588f9cc4bfab04c45fbd19c1354b5ade377a8124d6151d511c83730a9b6b2338", + "sha256:5a10661accd36b6e2e8855addcf3d675d6222006a15795420a39c040362def66", + "sha256:628f60be272512ca1123524969649a8cb5ae8b31cca349f7c6f8903daf9034d7", + "sha256:6dcc43a88e25b815c2dea1c6fac7339779fc988f5df8396e1de01610604a7c38", + "sha256:70e37cec0ac0fe95c85b74ca4e0620169590fd5d3f44765f3c3a532cedb0e5fd", + "sha256:7274735fb6fb5d67d3789ddec2cd53ed6362539b41aa6cc0d33a06c003aaa390", + "sha256:78e12972e144da47326958ac40c2bd1c1cca908edc8b01c26a36f9ffd3dce466", + "sha256:790cbd3c8d09f3a6d9c47c4558841e25bac34eb7a0864a9def8f26be0b8706af", + "sha256:79792c8fe8e9d06ebc50fe23266522c8c89f20aa94ac8e80472917ecdce1e5ba", + "sha256:865afedf35aaef6df6344bee0de391ee5e99d6e802950a237f9fb9b13e441f91", + "sha256:870fd401ec7b64a895cff8e206ee16569158db00254b2f7157b4c9a5db72c722", + "sha256:963815c226b29b0176d5e3d37fc9de46e2778ce4636a5a7af11a48122ef2577c", + "sha256:9726791484f08e394af0b59eb80489ad94d0a53bbb58ab1837dcad4d58489863", + "sha256:9de84a71bb7979aa8c089c4fb0ea0e2ed3917df3fb2a287a41aaea54bbad7f5d", + "sha256:b2c324ddc5d6dbd3f13680ad16a29425841876a84a1de23a984236d1afff4fa6", + "sha256:b86ae13c597fca087cb8c193870507c8916cefb21e52e1897da320b5a35075e5", + "sha256:ba0488d4dbba2af5bf9596b849873102d612e49a118c512d9d302ceafa36e01a", + "sha256:d78702af4102a3a4e23bb7372cec283e78f32f5573d92091aa6aaba870370fe1", + "sha256:def0e5d681dd3eb562b059d355ae8bebe27f5cc455ab7c2b6655586b63d3a8ea", + "sha256:e085d1babcb419bbe58e2e805ac61924dac4ca45a07c9fa081144739e500aa3c", + "sha256:e2cfcbab37c082a5087aba5ff00209999053260441caadd4f0e8f4c2d6b72088", + "sha256:e742f1f5dcaf222e8471c37ee3d1fd561568a16bb52e031c25674ff1cf9702d5", + "sha256:f06819b028b8ef9010281e74c59cb35483933583043091ed6b261bb1540f11cc", + "sha256:f15f2d60a11c306de7700ee9f65df7e9e463848dbea9c8051e293b704038da60", + "sha256:f31338ee269d201abe76083a990905473987371ff6f3fdb76a3f9073a361cf37", + "sha256:f6b88c8d302c3dac8dff7766955e38d670c82e0d79edfc7eae47d6bb2c186594" + ], + "index": "pypi", + "version": "==1.2.1" + }, + "six": { + "hashes": [ + "sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", + "sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73" + ], + "version": "==1.12.0" + }, + "xlsxwriter": { + "hashes": [ + "sha256:3a4e4a24a6753f046dc5a5e5bc5f443fce6a18988486885a258db6963eb54163", + "sha256:92a2ba339ca939815f0e125fcde728e94ccdb3e97e1acd3275ecf25a3cacfdc6" + ], + "index": "pypi", + "version": "==1.1.6" + } + }, + "develop": { + "alabaster": { + "hashes": [ + "sha256:446438bdcca0e05bd45ea2de1668c1d9b032e1a9154c2c259092d77031ddd359", + "sha256:a661d72d58e6ea8a57f7a86e37d86716863ee5e92788398526d58b26a4e4dc02" + ], + "version": "==0.7.12" + }, + "argh": { + "hashes": [ + "sha256:a9b3aaa1904eeb78e32394cd46c6f37ac0fb4af6dc488daa58971bdc7d7fcaf3", + "sha256:e9535b8c84dc9571a48999094fda7f33e63c3f1b74f3e5f3ac0105a58405bb65" + ], + "version": "==0.26.2" + }, + "atomicwrites": { + "hashes": [ + "sha256:03472c30eb2c5d1ba9227e4c2ca66ab8287fbfbbda3888aa93dc2e28fc6811b4", + "sha256:75a9445bac02d8d058d5e1fe689654ba5a6556a1dfd8ce6ec55a0ed79866cfa6" + ], + "version": "==1.3.0" + }, + "attrs": { + "hashes": [ + "sha256:69c0dbf2ed392de1cb5ec704444b08a5ef81680a61cb899dc08127123af36a79", + "sha256:f0b870f674851ecbfbbbd364d6b5cbdff9dcedbc7f3f5e18a6891057f21fe399" + ], + "version": "==19.1.0" + }, + "babel": { + "hashes": [ + "sha256:6778d85147d5d85345c14a26aada5e478ab04e39b078b0745ee6870c2b5cf669", + "sha256:8cba50f48c529ca3fa18cf81fa9403be176d374ac4d60738b839122dfaaa3d23" + ], + "version": "==2.6.0" + }, + "backports.functools-lru-cache": { + "hashes": [ + "sha256:9d98697f088eb1b0fa451391f91afb5e3ebde16bbdb272819fd091151fda4f1a", + "sha256:f0b0e4eba956de51238e17573b7087e852dfe9854afd2e9c873f73fc0ca0a6dd" + ], + "index": "pypi", + "version": "==1.5" + }, + "backports.shutil-get-terminal-size": { + "hashes": [ + "sha256:0975ba55054c15e346944b38956a4c9cbee9009391e41b86c68990effb8c1f64", + "sha256:713e7a8228ae80341c70586d1cc0a8caa5207346927e23d09dcbcaf18eadec80" + ], + "version": "==1.0.0" + }, + "bandit": { + "hashes": [ + "sha256:6102b5d6afd9d966df5054e0bdfc2e73a24d0fea400ec25f2e54c134412158d7", + "sha256:9413facfe9de1e1bd291d525c784e1beb1a55c9916b51dae12979af63a69ba4c" + ], + "version": "==1.5.1" + }, + "bleach": { + "hashes": [ + "sha256:213336e49e102af26d9cde77dd2d0397afabc5a6bf2fed985dc35b5d1e285a16", + "sha256:3fdf7f77adcf649c9911387df51254b813185e32b2c6619f690b593a617e19fa" + ], + "version": "==3.1.0" + }, + "certifi": { + "hashes": [ + "sha256:59b7658e26ca9c7339e00f8f4636cdfe59d34fa37b9b04f6f9e9926b3cece1a5", + "sha256:b26104d6835d1f5e49452a26eb2ff87fe7090b89dfcaee5ea2212697e1e1d7ae" + ], + "version": "==2019.3.9" + }, + "chardet": { + "hashes": [ + "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", + "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" + ], + "version": "==3.0.4" + }, + "colorama": { + "hashes": [ + "sha256:05eed71e2e327246ad6b38c540c4a3117230b19679b875190486ddd2d721422d", + "sha256:f8ac84de7840f5b9c4e3347b3c1eaa50f7e49c2b07596221daec5edaabbd7c48" + ], + "version": "==0.4.1" + }, + "configparser": { + "hashes": [ + "sha256:8be81d89d6e7b4c0d4e44bcc525845f6da25821de80cb5e06e7e0238a2899e32", + "sha256:da60d0014fd8c55eb48c1c5354352e363e2d30bbf7057e5e171a468390184c75" + ], + "index": "pypi", + "version": "==3.7.4" + }, + "coverage": { + "hashes": [ + "sha256:3684fabf6b87a369017756b551cef29e505cb155ddb892a7a29277b978da88b9", + "sha256:39e088da9b284f1bd17c750ac672103779f7954ce6125fd4382134ac8d152d74", + "sha256:3c205bc11cc4fcc57b761c2da73b9b72a59f8d5ca89979afb0c1c6f9e53c7390", + "sha256:465ce53a8c0f3a7950dfb836438442f833cf6663d407f37d8c52fe7b6e56d7e8", + "sha256:48020e343fc40f72a442c8a1334284620f81295256a6b6ca6d8aa1350c763bbe", + "sha256:5296fc86ab612ec12394565c500b412a43b328b3907c0d14358950d06fd83baf", + "sha256:5f61bed2f7d9b6a9ab935150a6b23d7f84b8055524e7be7715b6513f3328138e", + "sha256:68a43a9f9f83693ce0414d17e019daee7ab3f7113a70c79a3dd4c2f704e4d741", + "sha256:6b8033d47fe22506856fe450470ccb1d8ba1ffb8463494a15cfc96392a288c09", + "sha256:7ad7536066b28863e5835e8cfeaa794b7fe352d99a8cded9f43d1161be8e9fbd", + "sha256:7bacb89ccf4bedb30b277e96e4cc68cd1369ca6841bde7b005191b54d3dd1034", + "sha256:839dc7c36501254e14331bcb98b27002aa415e4af7ea039d9009409b9d2d5420", + "sha256:8f9a95b66969cdea53ec992ecea5406c5bd99c9221f539bca1e8406b200ae98c", + "sha256:932c03d2d565f75961ba1d3cec41ddde00e162c5b46d03f7423edcb807734eab", + "sha256:988529edadc49039d205e0aa6ce049c5ccda4acb2d6c3c5c550c17e8c02c05ba", + "sha256:998d7e73548fe395eeb294495a04d38942edb66d1fa61eb70418871bc621227e", + "sha256:9de60893fb447d1e797f6bf08fdf0dbcda0c1e34c1b06c92bd3a363c0ea8c609", + "sha256:9e80d45d0c7fcee54e22771db7f1b0b126fb4a6c0a2e5afa72f66827207ff2f2", + "sha256:a545a3dfe5082dc8e8c3eb7f8a2cf4f2870902ff1860bd99b6198cfd1f9d1f49", + "sha256:a5d8f29e5ec661143621a8f4de51adfb300d7a476224156a39a392254f70687b", + "sha256:aca06bfba4759bbdb09bf52ebb15ae20268ee1f6747417837926fae990ebc41d", + "sha256:bb23b7a6fd666e551a3094ab896a57809e010059540ad20acbeec03a154224ce", + "sha256:bfd1d0ae7e292105f29d7deaa9d8f2916ed8553ab9d5f39ec65bcf5deadff3f9", + "sha256:c62ca0a38958f541a73cf86acdab020c2091631c137bd359c4f5bddde7b75fd4", + "sha256:c709d8bda72cf4cd348ccec2a4881f2c5848fd72903c185f363d361b2737f773", + "sha256:c968a6aa7e0b56ecbd28531ddf439c2ec103610d3e2bf3b75b813304f8cb7723", + "sha256:df785d8cb80539d0b55fd47183264b7002077859028dfe3070cf6359bf8b2d9c", + "sha256:f406628ca51e0ae90ae76ea8398677a921b36f0bd71aab2099dfed08abd0322f", + "sha256:f46087bbd95ebae244a0eda01a618aff11ec7a069b15a3ef8f6b520db523dcf1", + "sha256:f8019c5279eb32360ca03e9fac40a12667715546eed5c5eb59eb381f2f501260", + "sha256:fc5f4d209733750afd2714e9109816a29500718b32dd9a5db01c0cb3a019b96a" + ], + "version": "==4.5.3" + }, + "coverage-space": { + "hashes": [ + "sha256:37e38169bceffe8fe836670203e4dc49e6d21cba66a6e77521b7dbe2821d9704", + "sha256:b9dde0f5a06433bc22a3f7457fc3cb292b4e8a763ba90644baf6230cb8fe1997" + ], + "index": "pypi", + "version": "==1.0.2.post1" + }, + "docopt": { + "hashes": [ + "sha256:49b3a825280bd66b3aa83585ef59c4a8c82f2c8a522dbe754a8bc8d08c85c491" + ], + "version": "==0.6.2" + }, + "docutils": { + "hashes": [ + "sha256:02aec4bd92ab067f6ff27a38a38a41173bf01bed8f89157768c1573f53e474a6", + "sha256:51e64ef2ebfb29cae1faa133b3710143496eca21c530f3f71424d77687764274", + "sha256:7a4bd47eaf6596e1295ecb11361139febe29b084a87bf005bf899f9a42edc3c6" + ], + "index": "pypi", + "version": "==0.14" + }, + "entrypoints": { + "hashes": [ + "sha256:589f874b313739ad35be6e0cd7efde2a4e9b6fea91edcc34e58ecbb8dbe56d19", + "sha256:c70dd71abe5a8c85e55e12c19bd91ccfeec11a6e99044204511f9ed547d48451" + ], + "version": "==0.3" + }, + "flake8": { + "hashes": [ + "sha256:859996073f341f2670741b51ec1e67a01da142831aa1fdc6242dbf88dffbe661", + "sha256:a796a115208f5c03b18f332f7c11729812c8c3ded6c46319c59b53efd3819da8" + ], + "index": "pypi", + "version": "==3.7.7" + }, + "flake8-bandit": { + "hashes": [ + "sha256:5eac24fa9fef532e4e4ce599c5b3c5248c5cc435d2927537b529b0a7bcb72467", + "sha256:be5840923ccf06cac6a8893a2f0abc17f03b6b9fdb5284d796f722b69c8f840b" + ], + "index": "pypi", + "version": "==2.1.0" + }, + "flake8-bugbear": { + "hashes": [ + "sha256:5070774b668be92c4312e5ca82748ddf4ecaa7a24ff062662681bb745c7896eb", + "sha256:fef9c9826d14ec23187ae1edeb3c6513c4e46bf0e70d86bac38f7d9aabae113d" + ], + "index": "pypi", + "version": "==19.3.0" + }, + "flake8-docstrings": { + "hashes": [ + "sha256:4e0ce1476b64e6291520e5570cf12b05016dd4e8ae454b8a8a9a48bc5f84e1cd", + "sha256:8436396b5ecad51a122a2c99ba26e5b4e623bf6e913b0fea0cb6c2c4050f91eb" + ], + "index": "pypi", + "version": "==1.3.0" + }, + "flake8-polyfill": { + "hashes": [ + "sha256:12be6a34ee3ab795b19ca73505e7b55826d5f6ad7230d31b18e106400169b9e9", + "sha256:e44b087597f6da52ec6393a709e7108b2905317d0c0b744cdca6208e670d8eda" + ], + "version": "==1.0.2" + }, + "flake8-rst-docstrings": { + "hashes": [ + "sha256:3a5b92b40e87006f8e95bfc5082577414cd387ca24def37ecf1fcd9b3ce7273c" + ], + "index": "pypi", + "version": "==0.0.8" + }, + "freezegun": { + "hashes": [ + "sha256:6cb82b276f83f2acce67f121dc2656f4df26c71e32238334eb071170b892a278", + "sha256:e839b43bfbe8158b4d62bb97e6313d39f3586daf48e1314fb1083d2ef17700da" + ], + "index": "pypi", + "version": "==0.3.11" + }, + "funcsigs": { + "hashes": [ + "sha256:330cc27ccbf7f1e992e69fef78261dc7c6569012cf397db8d3de0234e6c937ca", + "sha256:a7bb0f2cf3a3fd1ab2732cb49eba4252c2af4240442415b4abce3b87022a8f50" + ], + "index": "pypi", + "version": "==1.0.2" + }, + "futures": { + "hashes": [ + "sha256:51ecb45f0add83c806c68e4b06106f90db260585b25ef2abfcda0bd95c0132fd", + "sha256:c4884a65654a7c45435063e14ae85280eb1f111d94e542396717ba9828c4337f" + ], + "index": "pypi", + "version": "==3.1.1" + }, + "gitdb2": { + "hashes": [ + "sha256:83361131a1836661a155172932a13c08bda2db3674e4caa32368aa6eb02f38c2", + "sha256:e3a0141c5f2a3f635c7209d56c496ebe1ad35da82fe4d3ec4aaa36278d70648a" + ], + "version": "==2.0.5" + }, + "gitpython": { + "hashes": [ + "sha256:563221e5a44369c6b79172f455584c9ebbb122a13368cc82cb4b5addff788f82", + "sha256:8237dc5bfd6f1366abeee5624111b9d6879393d84745a507de0fda86043b65a8" + ], + "version": "==2.1.11" + }, + "idna": { + "hashes": [ + "sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407", + "sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c" + ], + "version": "==2.8" + }, + "imagesize": { + "hashes": [ + "sha256:3f349de3eb99145973fefb7dbe38554414e5c30abd0c8e4b970a7c9d09f3a1d8", + "sha256:f3832918bc3c66617f92e35f5d70729187676313caa60c187eb0f28b8fe5e3b5" + ], + "version": "==1.1.0" + }, + "jinja2": { + "hashes": [ + "sha256:065c4f02ebe7f7cf559e49ee5a95fb800a9e4528727aec6f24402a5374c65013", + "sha256:14dd6caf1527abb21f08f86c784eac40853ba93edb79552aa1e4b8aef1b61c7b" + ], + "version": "==2.10.1" + }, + "livereload": { + "hashes": [ + "sha256:29cadfabcedd12eed792e0131991235b9d4764d4474bed75cf525f57109ec0a2", + "sha256:e632a6cd1d349155c1d7f13a65be873b38f43ef02961804a1bba8d817fa649a7" + ], + "version": "==2.6.0" + }, + "macfsevents": { + "hashes": [ + "sha256:1324b66b356051de662ba87d84f73ada062acd42b047ed1246e60a449f833e10" + ], + "index": "pypi", + "markers": "sys_platform == 'darwin'", + "version": "==0.8.1" + }, + "markupsafe": { + "hashes": [ + "sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473", + "sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161", + "sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235", + "sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5", + "sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff", + "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b", + "sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1", + "sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e", + "sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183", + "sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66", + "sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1", + "sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1", + "sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e", + "sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b", + "sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905", + "sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735", + "sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d", + "sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e", + "sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d", + "sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c", + "sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21", + "sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2", + "sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5", + "sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b", + "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6", + "sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f", + "sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f", + "sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7" + ], + "version": "==1.1.1" + }, + "mccabe": { + "hashes": [ + "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", + "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f" + ], + "version": "==0.6.1" + }, + "more-itertools": { + "hashes": [ + "sha256:2112d2ca570bb7c3e53ea1a35cd5df42bb0fd10c45f0fb97178679c3c03d64c7", + "sha256:c3e4748ba1aad8dba30a4886b0b1a2004f9a863837b8654e7059eebf727afa5a" + ], + "markers": "python_version > '2.7'", + "version": "==7.0.0" + }, + "nose": { + "hashes": [ + "sha256:9ff7c6cc443f8c51994b34a667bbcf45afd6d945be7477b52e97516fd17c53ac", + "sha256:dadcddc0aefbf99eea214e0f1232b94f2fa9bd98fa8353711dacb112bfcbbb2a", + "sha256:f1bffef9cbc82628f6e7d7b40d7e255aefaa1adb6a1b1d26c69a8b79e6208a98" + ], + "version": "==1.3.7" + }, + "packaging": { + "hashes": [ + "sha256:0c98a5d0be38ed775798ece1b9727178c4469d9c3b4ada66e8e6b7849f8732af", + "sha256:9e1cbf8c12b1f1ce0bb5344b8d7ecf66a6f8a6e91bcb0c84593ed6d3ab5c4ab3" + ], + "version": "==19.0" + }, + "pathlib2": { + "hashes": [ + "sha256:25199318e8cc3c25dcb45cbe084cc061051336d5a9ea2a12448d3d8cb748f742", + "sha256:5887121d7f7df3603bca2f710e7219f3eca0eb69e0b7cc6e0a022e155ac931a7" + ], + "index": "pypi", + "version": "==2.3.3" + }, + "pathtools": { + "hashes": [ + "sha256:7c35c5421a39bb82e58018febd90e3b6e5db34c5443aaaf742b3f33d4655f1c0" + ], + "version": "==0.1.2" + }, + "pbr": { + "hashes": [ + "sha256:8257baf496c8522437e8a6cfe0f15e00aedc6c0e0e7c9d55eeeeab31e0853843", + "sha256:8c361cc353d988e4f5b998555c88098b9d5964c2e11acf7b0d21925a66bb5824" + ], + "version": "==5.1.3" + }, + "pkginfo": { + "hashes": [ + "sha256:7424f2c8511c186cd5424bbf31045b77435b37a8d604990b79d4e70d741148bb", + "sha256:a6d9e40ca61ad3ebd0b72fbadd4fba16e4c0e4df0428c041e01e06eb6ee71f32" + ], + "version": "==1.5.0.1" + }, + "pluggy": { + "hashes": [ + "sha256:19ecf9ce9db2fce065a7a0586e07cfb4ac8614fe96edf628a264b1c70116cf8f", + "sha256:84d306a647cc805219916e62aab89caa97a33a1dd8c342e87a37f91073cd4746" + ], + "version": "==0.9.0" + }, + "port-for": { + "hashes": [ + "sha256:b16a84bb29c2954db44c29be38b17c659c9c27e33918dec16b90d375cc596f1c" + ], + "version": "==0.3.1" + }, + "py": { + "hashes": [ + "sha256:64f65755aee5b381cea27766a3a147c3f15b9b6b9ac88676de66ba2ae36793fa", + "sha256:dc639b046a6e2cff5bbe40194ad65936d6ba360b52b3c3fe1d08a82dd50b5e53" + ], + "version": "==1.8.0" + }, + "pycodestyle": { + "hashes": [ + "sha256:95a2219d12372f05704562a14ec30bc76b05a5b297b21a5dfe3f6fac3491ae56", + "sha256:e40a936c9a450ad81df37f549d676d127b1b66000a6c500caa2b085bc0ca976c" + ], + "version": "==2.5.0" + }, + "pydocstyle": { + "hashes": [ + "sha256:2258f9b0df68b97bf3a6c29003edc5238ff8879f1efb6f1999988d934e432bd8", + "sha256:5741c85e408f9e0ddf873611085e819b809fca90b619f5fd7f34bd4959da3dd4", + "sha256:ed79d4ec5e92655eccc21eb0c6cf512e69512b4a97d215ace46d17e4990f2039" + ], + "index": "pypi", + "version": "==3.0.0" + }, + "pyflakes": { + "hashes": [ + "sha256:17dbeb2e3f4d772725c777fabc446d5634d1038f234e77343108ce445ea69ce0", + "sha256:d976835886f8c5b31d47970ed689944a0262b5f3afa00a5a7b4dc81e5449f8a2" + ], + "version": "==2.1.1" + }, + "pygments": { + "hashes": [ + "sha256:5ffada19f6203563680669ee7f53b64dabbeb100eb51b61996085e99c03b284a", + "sha256:e8218dd399a61674745138520d0d4cf2621d7e032439341bc3f647bff125818d" + ], + "index": "pypi", + "version": "==2.3.1" + }, + "pyparsing": { + "hashes": [ + "sha256:1873c03321fc118f4e9746baf201ff990ceb915f433f23b395f5580d1840cb2a", + "sha256:9b6323ef4ab914af344ba97510e966d64ba91055d6b9afa6b30799340e89cc03" + ], + "version": "==2.4.0" + }, + "pytest": { + "hashes": [ + "sha256:13c5e9fb5ec5179995e9357111ab089af350d788cbc944c628f3cde72285809b", + "sha256:f21d2f1fb8200830dcbb5d8ec466a9c9120e20d8b53c7585d180125cce1d297a" + ], + "index": "pypi", + "version": "==4.4.0" + }, + "pytest-cov": { + "hashes": [ + "sha256:0ab664b25c6aa9716cbf203b17ddb301932383046082c081b9848a0edf5add33", + "sha256:230ef817450ab0699c6cc3c9c8f7a829c34674456f2ed8df1fe1d39780f7c87f" + ], + "index": "pypi", + "version": "==2.6.1" + }, + "pytest-describe": { + "hashes": [ + "sha256:569bda96401fe512f4f345f33fd23fa4d718639d42afac62bc03254b5f2b3fdf" + ], + "index": "pypi", + "version": "==0.12.0" + }, + "pytest-expecter": { + "hashes": [ + "sha256:1c8e9ab98ddd576436b61a7ba61ea11cfa5a3fc6b00288ce9e91e9dd770daf19", + "sha256:27c93dfe87e2f4d28c525031be68d3f89457e3315241d97ee15f7689544e0e37" + ], + "index": "pypi", + "version": "==1.3" + }, + "pytest-random": { + "hashes": [ + "sha256:92f25db8c5d9ffc20d90b51997b914372d6955cb9cf1f6ead45b90514fc0eddd" + ], + "index": "pypi", + "version": "==0.2" + }, + "python-dateutil": { + "hashes": [ + "sha256:7e6584c74aeed623791615e26efd690f29817a27c73085b78e4bad02493df2fb", + "sha256:c89805f6f4d64db21ed966fda138f8a5ed7a4fdbc1a8ee329ce1b74e3c74da9e" + ], + "version": "==2.8.0" + }, + "python-termstyle": { + "hashes": [ + "sha256:6faf42ba42f2826c38cf70dacb3ac51f248a418e48afc0e36593df11cf3ab1d2", + "sha256:f42a6bb16fbfc5e2c66d553e7ad46524ea833872f75ee5d827c15115fafc94e2" + ], + "version": "==0.1.10" + }, + "pytz": { + "hashes": [ + "sha256:303879e36b721603cc54604edcac9d20401bdbe31e1e4fdee5b9f98d5d31dfda", + "sha256:d747dd3d23d77ef44c6a3526e274af6efeb0a6f1afd5a69ba4d5be4098c8e141" + ], + "version": "==2019.1" + }, + "pyyaml": { + "hashes": [ + "sha256:1adecc22f88d38052fb787d959f003811ca858b799590a5eaa70e63dca50308c", + "sha256:436bc774ecf7c103814098159fbb84c2715d25980175292c648f2da143909f95", + "sha256:460a5a4248763f6f37ea225d19d5c205677d8d525f6a83357ca622ed541830c2", + "sha256:5a22a9c84653debfbf198d02fe592c176ea548cccce47553f35f466e15cf2fd4", + "sha256:7a5d3f26b89d688db27822343dfa25c599627bc92093e788956372285c6298ad", + "sha256:9372b04a02080752d9e6f990179a4ab840227c6e2ce15b95e1278456664cf2ba", + "sha256:a5dcbebee834eaddf3fa7366316b880ff4062e4bcc9787b78c7fbb4a26ff2dd1", + "sha256:aee5bab92a176e7cd034e57f46e9df9a9862a71f8f37cad167c6fc74c65f5b4e", + "sha256:c51f642898c0bacd335fc119da60baae0824f2cde95b0330b56c0553439f0673", + "sha256:c68ea4d3ba1705da1e0d85da6684ac657912679a649e8868bd850d2c299cce13", + "sha256:e23d0cc5299223dcc37885dae624f382297717e459ea24053709675a976a3e19" + ], + "version": "==5.1" + }, + "readme-renderer": { + "hashes": [ + "sha256:bb16f55b259f27f75f640acf5e00cf897845a8b3e4731b5c1a436e4b8529202f", + "sha256:c8532b79afc0375a85f10433eca157d6b50f7d6990f337fa498c96cd4bfc203d" + ], + "version": "==24.0" + }, + "requests": { + "hashes": [ + "sha256:502a824f31acdacb3a35b6690b5fbf0bc41d63a24a45c4004352b0242707598e", + "sha256:7bf2a778576d825600030a110f3c0e3e8edc51dfaafe1c146e39a2027784957b" + ], + "version": "==2.21.0" + }, + "requests-toolbelt": { + "hashes": [ + "sha256:380606e1d10dc85c3bd47bf5a6095f815ec007be7a8b69c878507068df059e6f", + "sha256:968089d4584ad4ad7c171454f0a5c6dac23971e9472521ea3b6d49d610aa6fc0" + ], + "version": "==0.9.1" + }, + "restructuredtext-lint": { + "hashes": [ + "sha256:97b3da356d5b3a8514d8f1f9098febd8b41463bed6a1d9f126cf0a048b6fd908" + ], + "version": "==1.3.0" + }, + "scandir": { + "hashes": [ + "sha256:2586c94e907d99617887daed6c1d102b5ca28f1085f90446554abf1faf73123e", + "sha256:2ae41f43797ca0c11591c0c35f2f5875fa99f8797cb1a1fd440497ec0ae4b022", + "sha256:2b8e3888b11abb2217a32af0766bc06b65cc4a928d8727828ee68af5a967fa6f", + "sha256:2c712840c2e2ee8dfaf36034080108d30060d759c7b73a01a52251cc8989f11f", + "sha256:4d4631f6062e658e9007ab3149a9b914f3548cb38bfb021c64f39a025ce578ae", + "sha256:67f15b6f83e6507fdc6fca22fedf6ef8b334b399ca27c6b568cbfaa82a364173", + "sha256:7d2d7a06a252764061a020407b997dd036f7bd6a175a5ba2b345f0a357f0b3f4", + "sha256:8c5922863e44ffc00c5c693190648daa6d15e7c1207ed02d6f46a8dcc2869d32", + "sha256:92c85ac42f41ffdc35b6da57ed991575bdbe69db895507af88b9f499b701c188", + "sha256:b24086f2375c4a094a6b51e78b4cf7ca16c721dcee2eddd7aa6494b42d6d519d", + "sha256:cb925555f43060a1745d0a321cca94bcea927c50114b623d73179189a4e100ac" + ], + "index": "pypi", + "version": "==1.10.0" + }, + "singledispatch": { + "hashes": [ + "sha256:5b06af87df13818d14f08a028e42f566640aef80805c3b50c5056b086e3c2b9c", + "sha256:833b46966687b3de7f438c761ac475213e53b306740f1abfaa86e1d1aae56aa8" + ], + "index": "pypi", + "version": "==3.4.0.3" + }, + "six": { + "hashes": [ + "sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", + "sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73" + ], + "version": "==1.12.0" + }, + "smmap2": { + "hashes": [ + "sha256:0555a7bf4df71d1ef4218e4807bbf9b201f910174e6e08af2e138d4e517b4dde", + "sha256:29a9ffa0497e7f2be94ca0ed1ca1aa3cd4cf25a1f6b4f5f87f74b46ed91d609a" + ], + "version": "==2.0.5" + }, + "sniffer": { + "hashes": [ + "sha256:e8a0daa4c51dff3d00482b45dc9b978159100a8d5a7df327c28ed96586559970", + "sha256:e90c1ad4bd3c31a5fad8e03d45dfc83377b31420aa0779f17280c817ce0c9dd8" + ], + "index": "pypi", + "version": "==0.4.0" + }, + "snowballstemmer": { + "hashes": [ + "sha256:919f26a68b2c17a7634da993d91339e288964f93c274f1343e3bbbe2096e1128", + "sha256:9f3bcd3c401c3e862ec0ebe6d2c069ebc012ce142cce209c098ccb5b09136e89" + ], + "version": "==1.2.1" + }, + "sphinx": { + "hashes": [ + "sha256:423280646fb37944dd3c85c58fb92a20d745793a9f6c511f59da82fa97cd404b", + "sha256:de930f42600a4fef993587633984cc5027dedba2464bcf00ddace26b40f8d9ce" + ], + "index": "pypi", + "version": "==2.0.1" + }, + "sphinx-autobuild": { + "hashes": [ + "sha256:66388f81884666e3821edbe05dd53a0cfb68093873d17320d0610de8db28c74e", + "sha256:e60aea0789cab02fa32ee63c7acae5ef41c06f1434d9fd0a74250a61f5994692" + ], + "index": "pypi", + "version": "==0.7.1" + }, + "sphinx-rtd-theme": { + "hashes": [ + "sha256:00cf895504a7895ee433807c62094cf1e95f065843bf3acd17037c3e9a2becd4", + "sha256:728607e34d60456d736cc7991fd236afb828b21b82f956c5ea75f94c8414040a" + ], + "index": "pypi", + "version": "==0.4.3" + }, + "sphinxcontrib-applehelp": { + "hashes": [ + "sha256:edaa0ab2b2bc74403149cb0209d6775c96de797dfd5b5e2a71981309efab3897", + "sha256:fb8dee85af95e5c30c91f10e7eb3c8967308518e0f7488a2828ef7bc191d0d5d" + ], + "version": "==1.0.1" + }, + "sphinxcontrib-devhelp": { + "hashes": [ + "sha256:6c64b077937330a9128a4da74586e8c2130262f014689b4b89e2d08ee7294a34", + "sha256:9512ecb00a2b0821a146736b39f7aeb90759834b07e81e8cc23a9c70bacb9981" + ], + "version": "==1.0.1" + }, + "sphinxcontrib-htmlhelp": { + "hashes": [ + "sha256:4670f99f8951bd78cd4ad2ab962f798f5618b17675c35c5ac3b2132a14ea8422", + "sha256:d4fd39a65a625c9df86d7fa8a2d9f3cd8299a3a4b15db63b50aac9e161d8eff7" + ], + "version": "==1.0.2" + }, + "sphinxcontrib-jsmath": { + "hashes": [ + "sha256:2ec2eaebfb78f3f2078e73666b1415417a116cc848b72e5172e596c871103178", + "sha256:a9925e4a4587247ed2191a22df5f6970656cb8ca2bd6284309578f2153e0c4b8" + ], + "version": "==1.0.1" + }, + "sphinxcontrib-qthelp": { + "hashes": [ + "sha256:513049b93031beb1f57d4daea74068a4feb77aa5630f856fcff2e50de14e9a20", + "sha256:79465ce11ae5694ff165becda529a600c754f4bc459778778c7017374d4d406f" + ], + "version": "==1.0.2" + }, + "sphinxcontrib-serializinghtml": { + "hashes": [ + "sha256:c0efb33f8052c04fd7a26c0a07f1678e8512e0faec19f4aa8f2473a8b81d5227", + "sha256:db6615af393650bf1151a6cd39120c29abaf93cc60db8c48eb2dddbfdc3a9768" + ], + "version": "==1.1.3" + }, + "stevedore": { + "hashes": [ + "sha256:7be098ff53d87f23d798a7ce7ae5c31f094f3deb92ba18059b1aeb1ca9fec0a0", + "sha256:7d1ce610a87d26f53c087da61f06f9b7f7e552efad2a7f6d2322632b5f932ea2" + ], + "version": "==1.30.1" + }, + "tornado": { + "hashes": [ + "sha256:1174dcb84d08887b55defb2cda1986faeeea715fff189ef3dc44cce99f5fca6b", + "sha256:2613fab506bd2aedb3722c8c64c17f8f74f4070afed6eea17f20b2115e445aec", + "sha256:44b82bc1146a24e5b9853d04c142576b4e8fa7a92f2e30bc364a85d1f75c4de2", + "sha256:457fcbee4df737d2defc181b9073758d73f54a6cfc1f280533ff48831b39f4a8", + "sha256:49603e1a6e24104961497ad0c07c799aec1caac7400a6762b687e74c8206677d", + "sha256:8c2f40b99a8153893793559919a355d7b74649a11e59f411b0b0a1793e160bc0", + "sha256:e1d897889c3b5a829426b7d52828fb37b28bc181cd598624e65c8be40ee3f7fa" + ], + "version": "==6.0.2" + }, + "tqdm": { + "hashes": [ + "sha256:d385c95361699e5cf7622485d9b9eae2d4864b21cd5a2374a9c381ffed701021", + "sha256:e22977e3ebe961f72362f6ddfb9197cc531c9737aaf5f607ef09740c849ecd05" + ], + "version": "==4.31.1" + }, + "twine": { + "hashes": [ + "sha256:0fb0bfa3df4f62076cab5def36b1a71a2e4acb4d1fa5c97475b048117b1a6446", + "sha256:d6c29c933ecfc74e9b1d9fa13aa1f87c5d5770e119f5a4ce032092f0ff5b14dc" + ], + "index": "pypi", + "version": "==1.13.0" + }, + "urllib3": { + "hashes": [ + "sha256:61bf29cada3fc2fbefad4fdf059ea4bd1b4a86d2b6d15e1c7c0b582b9752fe39", + "sha256:de9529817c93f27c8ccbfead6985011db27bd0ddfcdb2d86f3f663385c6a9c22" + ], + "version": "==1.24.1" + }, + "watchdog": { + "hashes": [ + "sha256:965f658d0732de3188211932aeb0bb457587f04f63ab4c1e33eab878e9de961d" + ], + "version": "==0.9.0" + }, + "webencodings": { + "hashes": [ + "sha256:a0af1213f3c2226497a97e2b3aa01a7e4bee4f403f95be16fc9acd2947514a78", + "sha256:b36a1c245f2d304965eb4e0a82848379241dc04b865afcc4aab16748587e1923" + ], + "version": "==0.5.1" + }, + "wheel": { + "hashes": [ + "sha256:66a8fd76f28977bb664b098372daef2b27f60dc4d1688cfab7b37a09448f0e9d", + "sha256:8eb4a788b3aec8abf5ff68d4165441bc57420c9f64ca5f471f58c3969fe08668" + ], + "index": "pypi", + "version": "==0.33.1" + } + } +} From 5d7de460b87b60d1362a904f2f45d113a384369e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grega=20Vrban=C4=8Di=C4=8D?= Date: Mon, 15 Apr 2019 06:19:10 +0200 Subject: [PATCH 17/24] fix flake8-bugbear plugin version for python 2.7 --- Pipfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Pipfile b/Pipfile index 440bc9f0..620dadc1 100644 --- a/Pipfile +++ b/Pipfile @@ -9,13 +9,12 @@ scipy = ">=1.2.1" enum34 = {version = ">=1.1.6",markers = "python_version < '3.4'"} XlsxWriter = ">=1.1.5" matplotlib = ">=2.2.4" -flake8 = "*" [dev-packages] flake8 = "~=3.7.7" flake8-docstrings = "~=1.3.0" flake8-rst-docstrings = ">=0.0.8" -flake8-bugbear = "~=19.3.0" +flake8-bugbear = ">=17.12.0" flake8-bandit = "~=2.1.0" pycodestyle = "~=2.5.0" pydocstyle = "~=3.0.0" From 413e1de9d846b9f103ec104ae570ec47ff6e87ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grega=20Vrban=C4=8Di=C4=8D?= Date: Mon, 15 Apr 2019 06:35:22 +0200 Subject: [PATCH 18/24] fix happy cat benchmark code style. --- .flake8 | 5 ++++- NiaPy/benchmarks/happyCat.py | 2 +- NiaPy/tests/test_benchmark_functions.py | 4 ++-- Pipfile.lock | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.flake8 b/.flake8 index f23a525c..9f85ea11 100644 --- a/.flake8 +++ b/.flake8 @@ -7,4 +7,7 @@ exclude = old, build, dist, - scent.py \ No newline at end of file + scent.py +per-file-ignores = + NiaPy/tests/*:B007,D100,D101,D102,D107,D208,D211,D413,E117,E302,E701,E704,F841,S110,W191,W293 + diff --git a/NiaPy/benchmarks/happyCat.py b/NiaPy/benchmarks/happyCat.py index 54d92203..23ac8464 100644 --- a/NiaPy/benchmarks/happyCat.py +++ b/NiaPy/benchmarks/happyCat.py @@ -9,7 +9,7 @@ class HappyCat(Benchmark): - ur"""Implementation of Happy cat function. + r"""Implementation of Happy cat function. Date: 2018 diff --git a/NiaPy/tests/test_benchmark_functions.py b/NiaPy/tests/test_benchmark_functions.py index 8ebedc1a..bf47d8b4 100644 --- a/NiaPy/tests/test_benchmark_functions.py +++ b/NiaPy/tests/test_benchmark_functions.py @@ -26,12 +26,12 @@ def setUp(self): def assertBounds(self, bench, lower, upper): """Checking the bounds. - + Arguments: bench [Benchmark]: Benchmark to test. lower [float]: Lower bound. upper [type]: Upper bound. - + Returns: [fun]: Returns benchmarks evaluation function. """ diff --git a/Pipfile.lock b/Pipfile.lock index 12ee8208..8f6db60e 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "ae1a70f45af0be4100c51eeb592f530cd308f7e8968c6ca03ab164714fed99a1" + "sha256": "b4e120b3b43eb1e70f4bfceb8efdd777626474d994eac14ceb400d2e563b42d1" }, "pipfile-spec": 6, "requires": {}, From 0e198b81bc2bea099a02cd0802e0bbcc45a1389a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grega=20Vrban=C4=8Di=C4=8D?= Date: Mon, 15 Apr 2019 08:17:24 +0200 Subject: [PATCH 19/24] fix D401 error in benchmarks. --- .flake8 | 6 ++++-- NiaPy/benchmarks/ackley.py | 2 +- NiaPy/benchmarks/alpine.py | 4 ++-- NiaPy/benchmarks/benchmark.py | 4 ++-- NiaPy/benchmarks/bentcigar.py | 2 +- NiaPy/benchmarks/chungReynolds.py | 2 +- NiaPy/benchmarks/cosinemixture.py | 2 +- NiaPy/benchmarks/csendes.py | 2 +- NiaPy/benchmarks/discus.py | 2 +- NiaPy/benchmarks/dixonprice.py | 2 +- NiaPy/benchmarks/elliptic.py | 2 +- NiaPy/benchmarks/griewank.py | 4 ++-- NiaPy/benchmarks/happyCat.py | 2 +- NiaPy/benchmarks/hgbat.py | 2 +- NiaPy/benchmarks/infinity.py | 2 +- NiaPy/benchmarks/katsuura.py | 2 +- NiaPy/benchmarks/levy.py | 2 +- NiaPy/benchmarks/michalewichz.py | 2 +- NiaPy/benchmarks/perm.py | 2 +- NiaPy/benchmarks/pinter.py | 2 +- NiaPy/benchmarks/powell.py | 2 +- NiaPy/benchmarks/qing.py | 2 +- NiaPy/benchmarks/quintic.py | 2 +- NiaPy/benchmarks/rastrigin.py | 2 +- NiaPy/benchmarks/ridge.py | 4 ++-- NiaPy/benchmarks/rosenbrock.py | 2 +- NiaPy/benchmarks/salomon.py | 2 +- NiaPy/benchmarks/schaffer.py | 6 +++--- NiaPy/benchmarks/schumerSteiglitz.py | 2 +- NiaPy/benchmarks/schwefel.py | 10 +++++----- NiaPy/benchmarks/sphere.py | 6 +++--- NiaPy/benchmarks/step.py | 6 +++--- NiaPy/benchmarks/stepint.py | 2 +- NiaPy/benchmarks/styblinskiTang.py | 2 +- NiaPy/benchmarks/sumSquares.py | 2 +- NiaPy/benchmarks/trid.py | 2 +- NiaPy/benchmarks/weierstrass.py | 2 +- NiaPy/benchmarks/whitley.py | 2 +- NiaPy/benchmarks/zakharov.py | 2 +- 39 files changed, 56 insertions(+), 54 deletions(-) diff --git a/.flake8 b/.flake8 index 9f85ea11..764182f0 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,5 @@ [flake8] -ignore = E203, E266, E501, W503, D401, D202, RST299, RST304, RST399, FI +ignore = E203,E266,E501,W503,D401,D202,RST299,RST304,RST399,FI exclude = .git, __pycache__, @@ -10,4 +10,6 @@ exclude = scent.py per-file-ignores = NiaPy/tests/*:B007,D100,D101,D102,D107,D208,D211,D413,E117,E302,E701,E704,F841,S110,W191,W293 - + NiaPy/algorithms/*:B305,B007,D100,D101,D104,D102,D107,D204,D206,D413,E101,E117,E126,E302,E305,E701,E704,E711,E741,RST201,RST203,RST204,RST210,RST301,W191 + NiaPy/__init__.py:D100,D204,D206,D413,E101,E117,E242,E302,E701,E702,E704,E711,RST201,W191 + NiaPy/util/*:D100,D101,D104,D107,D204,D413,E117,E242,E302,E305,E701,E704,F104,RST201,RST203,RST210,W191 diff --git a/NiaPy/benchmarks/ackley.py b/NiaPy/benchmarks/ackley.py index 4c5563e9..5a9c99cb 100644 --- a/NiaPy/benchmarks/ackley.py +++ b/NiaPy/benchmarks/ackley.py @@ -48,7 +48,7 @@ class Ackley(Benchmark): Name = ["Ackley"] def __init__(self, Lower=-32.768, Upper=32.768): - """The initialization of Ackley benchmark. + """Initialize Ackley benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/alpine.py b/NiaPy/benchmarks/alpine.py index a5c8e056..5c986609 100644 --- a/NiaPy/benchmarks/alpine.py +++ b/NiaPy/benchmarks/alpine.py @@ -48,7 +48,7 @@ class Alpine1(Benchmark): Name = ["Alpine1"] def __init__(self, Lower=-10.0, Upper=10.0): - r"""The initialization of Alpine1 benchmark. + r"""Initialize of Alpine1 benchmark. Args: Lower (Optional[float]): Lower bound of problem. @@ -134,7 +134,7 @@ class Alpine2(Benchmark): Name = ["Alpine2"] def __init__(self, Lower=0.0, Upper=10.0): - r"""The initialization of Alpine2 benchmark. + r"""Initialize Alpine2 benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/benchmark.py b/NiaPy/benchmarks/benchmark.py index 6e41a699..19d2d64c 100644 --- a/NiaPy/benchmarks/benchmark.py +++ b/NiaPy/benchmarks/benchmark.py @@ -20,7 +20,7 @@ class Benchmark: Name = ["Benchmark", "BBB"] def __init__(self, Lower, Upper, **kwargs): - r"""Initialization of Benchmark object. + r"""Initialize base Benchmark. Arguments: Lower {[type]} -- Lower bound. @@ -39,7 +39,7 @@ def function(self): """ def evaluate(D, sol): - """The implementation on evaluation function. + """Implement the evaluation function. Arguments: D [int]} -- Dimension of the problem. diff --git a/NiaPy/benchmarks/bentcigar.py b/NiaPy/benchmarks/bentcigar.py index e2e7c01d..5fdea74c 100644 --- a/NiaPy/benchmarks/bentcigar.py +++ b/NiaPy/benchmarks/bentcigar.py @@ -45,7 +45,7 @@ class BentCigar(Benchmark): Name = ["BentCigar"] def __init__(self, Lower=-100.0, Upper=100.0): - r"""The initialization of Bent Cigar benchmark. + r"""Initialize Bent Cigar benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/chungReynolds.py b/NiaPy/benchmarks/chungReynolds.py index e6137361..7dc4f53e 100644 --- a/NiaPy/benchmarks/chungReynolds.py +++ b/NiaPy/benchmarks/chungReynolds.py @@ -48,7 +48,7 @@ class ChungReynolds(Benchmark): Name = ["ChungReynolds"] def __init__(self, Lower=-100.0, Upper=100.0): - """The initialization of Chung Reynolds benchmark. + """Initialize Chung Reynolds benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/cosinemixture.py b/NiaPy/benchmarks/cosinemixture.py index c0117348..6ea4ea74 100644 --- a/NiaPy/benchmarks/cosinemixture.py +++ b/NiaPy/benchmarks/cosinemixture.py @@ -47,7 +47,7 @@ class CosineMixture(Benchmark): Name = ["CosineMixture"] def __init__(self, Lower=-1.0, Upper=1.0): - r"""The initialization of Cosine mixture benchmark. + r"""Initialize Cosine mixture benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/csendes.py b/NiaPy/benchmarks/csendes.py index 966249e3..a1faaeed 100644 --- a/NiaPy/benchmarks/csendes.py +++ b/NiaPy/benchmarks/csendes.py @@ -49,7 +49,7 @@ class Csendes(Benchmark): Name = ["Csendes"] def __init__(self, Lower=-1.0, Upper=1.0): - r"""The initialization of Csendes benchmark. + r"""Initialize Csendes benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/discus.py b/NiaPy/benchmarks/discus.py index ae5dcbf2..aadc40c2 100644 --- a/NiaPy/benchmarks/discus.py +++ b/NiaPy/benchmarks/discus.py @@ -46,7 +46,7 @@ class Discus(Benchmark): Name = ["Discus"] def __init__(self, Lower=-100.0, Upper=100.0): - r"""The initialization of Alpine1 benchmark. + r"""Initialize Alpine1 benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/dixonprice.py b/NiaPy/benchmarks/dixonprice.py index 9c0a5a79..20cb4c5a 100644 --- a/NiaPy/benchmarks/dixonprice.py +++ b/NiaPy/benchmarks/dixonprice.py @@ -45,7 +45,7 @@ class DixonPrice(Benchmark): Name = ["DixonPrice"] def __init__(self, Lower=-10.0, Upper=10): - r"""The initialization of Dixon Price benchmark. + r"""Initialize of Dixon Price benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/elliptic.py b/NiaPy/benchmarks/elliptic.py index 1a4abafa..f21036fc 100644 --- a/NiaPy/benchmarks/elliptic.py +++ b/NiaPy/benchmarks/elliptic.py @@ -45,7 +45,7 @@ class Elliptic(Benchmark): Name = ["Elliptic"] def __init__(self, Lower=-100.0, Upper=100.0): - r"""The initialization of Elliptic benchmark. + r"""Initialize Elliptic benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/griewank.py b/NiaPy/benchmarks/griewank.py index bf5cf862..8460d4ab 100644 --- a/NiaPy/benchmarks/griewank.py +++ b/NiaPy/benchmarks/griewank.py @@ -50,7 +50,7 @@ class Griewank(Benchmark): Name = ["Griewank"] def __init__(self, Lower=-100.0, Upper=100.0): - """The initialization of Griewank benchmark. + """Initialize Griewank benchmark. Args: Lower (Optional[float]): Lower bound of problem. @@ -134,7 +134,7 @@ class ExpandedGriewankPlusRosenbrock(Benchmark): Name = ["ExpandedGriewankPlusRosenbrock"] def __init__(self, Lower=-100.0, Upper=100.0): - """The initialization of Expanded Griewank Plus Rosenbrock benchmark. + """Initialize Expanded Griewank Plus Rosenbrock benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/happyCat.py b/NiaPy/benchmarks/happyCat.py index 23ac8464..2b7f097e 100644 --- a/NiaPy/benchmarks/happyCat.py +++ b/NiaPy/benchmarks/happyCat.py @@ -50,7 +50,7 @@ class HappyCat(Benchmark): Name = ["HappyCat"] def __init__(self, Lower=-100.0, Upper=100.0): - """The initialization of Happy Cat benchmark. + """Initialize Happy Cat benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/hgbat.py b/NiaPy/benchmarks/hgbat.py index fd0f8e90..6f231606 100644 --- a/NiaPy/benchmarks/hgbat.py +++ b/NiaPy/benchmarks/hgbat.py @@ -45,7 +45,7 @@ class HGBat(Benchmark): Name = ["HGBat"] def __init__(self, Lower=-100.0, Upper=100.0): - r"""The initialization of HGBat benchmark. + r"""Initialize HGBat benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/infinity.py b/NiaPy/benchmarks/infinity.py index a7b7e1f1..6519bb4a 100644 --- a/NiaPy/benchmarks/infinity.py +++ b/NiaPy/benchmarks/infinity.py @@ -46,7 +46,7 @@ class Infinity(Benchmark): Name = ["Infinity"] def __init__(self, Lower=-1.0, Upper=1.0): - r"""The initialization of Infinity benchmark. + r"""Initialize Infinity benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/katsuura.py b/NiaPy/benchmarks/katsuura.py index b0d162e7..4b6988db 100644 --- a/NiaPy/benchmarks/katsuura.py +++ b/NiaPy/benchmarks/katsuura.py @@ -45,7 +45,7 @@ class Katsuura(Benchmark): Name = ["Katsuura"] def __init__(self, Lower=-100.0, Upper=100.0, **kwargs): - r"""The initialization of Katsuura benchmark. + r"""Initialize Katsuura benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/levy.py b/NiaPy/benchmarks/levy.py index e36e368d..0919261b 100644 --- a/NiaPy/benchmarks/levy.py +++ b/NiaPy/benchmarks/levy.py @@ -46,7 +46,7 @@ class Levy(Benchmark): Name = ["Levy"] def __init__(self, Lower=0.0, Upper=pi): - r"""The initialization of Levy benchmark. + r"""Initialize Levy benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/michalewichz.py b/NiaPy/benchmarks/michalewichz.py index ab94905e..045ffc7e 100644 --- a/NiaPy/benchmarks/michalewichz.py +++ b/NiaPy/benchmarks/michalewichz.py @@ -48,7 +48,7 @@ class Michalewichz(Benchmark): Name = ["Michalewichz"] def __init__(self, Lower=0.0, Upper=pi, m=10): - r"""The initialization of Alpine1 benchmark. + r"""Initialize Michalewichz benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/perm.py b/NiaPy/benchmarks/perm.py index f738a04a..fd3aa11d 100644 --- a/NiaPy/benchmarks/perm.py +++ b/NiaPy/benchmarks/perm.py @@ -48,7 +48,7 @@ class Perm(Benchmark): Name = ["Perm"] def __init__(self, D=10.0, beta=0.5): - """The initialization of Perm benchmark. + """Initialize Perm benchmark. Args: D [float] -- Dimension on problem. (default: {10.0}) diff --git a/NiaPy/benchmarks/pinter.py b/NiaPy/benchmarks/pinter.py index 2358736e..9716d5c7 100644 --- a/NiaPy/benchmarks/pinter.py +++ b/NiaPy/benchmarks/pinter.py @@ -59,7 +59,7 @@ class Pinter(Benchmark): Name = ["Pinter"] def __init__(self, Lower=-10.0, Upper=10.0): - r"""The initialization of Pinter benchmark. + r"""Initialize Pinter benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/powell.py b/NiaPy/benchmarks/powell.py index 1b3d8052..d12b4ad0 100644 --- a/NiaPy/benchmarks/powell.py +++ b/NiaPy/benchmarks/powell.py @@ -45,7 +45,7 @@ class Powell(Benchmark): Name = ["Powell"] def __init__(self, Lower=-4.0, Upper=5.0): - r"""The initialization of Powell benchmark. + r"""Initialize Powell benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/qing.py b/NiaPy/benchmarks/qing.py index 17eceef3..e4f24652 100644 --- a/NiaPy/benchmarks/qing.py +++ b/NiaPy/benchmarks/qing.py @@ -49,7 +49,7 @@ class Qing(Benchmark): Name = ["Qing"] def __init__(self, Lower=-500.0, Upper=500.0): - """The initialization of Quing benchmark. + """Initialize Quing benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/quintic.py b/NiaPy/benchmarks/quintic.py index 9cecd31c..eaa74e43 100644 --- a/NiaPy/benchmarks/quintic.py +++ b/NiaPy/benchmarks/quintic.py @@ -52,7 +52,7 @@ class Quintic(Benchmark): Name = ["Quintic"] def __init__(self, Lower=-10.0, Upper=10.0): - """The initialization of Quintic benchmark. + """Initialize Quintic benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/rastrigin.py b/NiaPy/benchmarks/rastrigin.py index 1f1eae66..44fcaa96 100644 --- a/NiaPy/benchmarks/rastrigin.py +++ b/NiaPy/benchmarks/rastrigin.py @@ -46,7 +46,7 @@ class Rastrigin(Benchmark): Name = ['Rastrigin'] def __init__(self, Lower=-5.12, Upper=5.12): - """The initialization of Rastrigin benchmark. + """Initialize Rastrigin benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/ridge.py b/NiaPy/benchmarks/ridge.py index 5bc278f5..f7295bce 100644 --- a/NiaPy/benchmarks/ridge.py +++ b/NiaPy/benchmarks/ridge.py @@ -42,10 +42,10 @@ class Ridge(Benchmark): """ - Name = ['Ridge'] + Name = ["Ridge"] def __init__(self, Lower=-64.0, Upper=64.0): - """The initialization of Ridge benchmark. + """Initialize Ridge benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/rosenbrock.py b/NiaPy/benchmarks/rosenbrock.py index 1d20a804..16e5e18d 100644 --- a/NiaPy/benchmarks/rosenbrock.py +++ b/NiaPy/benchmarks/rosenbrock.py @@ -50,7 +50,7 @@ class Rosenbrock(Benchmark): Name = ["Rosenbrock"] def __init__(self, Lower=-30.0, Upper=30.0): - """The initialization of Rosenbrock benchmark. + """Initialize Rosenbrock benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/salomon.py b/NiaPy/benchmarks/salomon.py index 576c74d7..a133d259 100644 --- a/NiaPy/benchmarks/salomon.py +++ b/NiaPy/benchmarks/salomon.py @@ -52,7 +52,7 @@ class Salomon(Benchmark): Name = ["Salomon"] def __init__(self, Lower=-100.0, Upper=100.0): - """The initialization of Salomon benchmark. + """Initialize Salomon benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/schaffer.py b/NiaPy/benchmarks/schaffer.py index 2cd2bfe7..53f379e8 100644 --- a/NiaPy/benchmarks/schaffer.py +++ b/NiaPy/benchmarks/schaffer.py @@ -44,7 +44,7 @@ class SchafferN2(Benchmark): Name = ["SchafferN2"] def __init__(self, Lower=-100.0, Upper=100.0): - r"""The initialization of Schaffer N. 2 benchmark. + r"""Initialize Schaffer N. 2 benchmark. Args: Lower (Optional[float]): Lower bound of problem. @@ -120,7 +120,7 @@ class SchafferN4(Benchmark): Name = ["SchafferN4"] def __init__(self, Lower=-100.0, Upper=100.0): - r"""The initialization of Schaffer N. 4 benchmark. + r"""Initialize Schaffer N. 4 benchmark. Args: Lower (Optional[float]): Lower bound of problem. @@ -195,7 +195,7 @@ class ExpandedSchaffer(Benchmark): Name = ["ExpandedSchaffer"] def __init__(self, Lower=-100.0, Upper=100.0): - r"""The initialization of Expanded Schaffer benchmark. + r"""Initialize Expanded Schaffer benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/schumerSteiglitz.py b/NiaPy/benchmarks/schumerSteiglitz.py index 1169193d..b7218edd 100644 --- a/NiaPy/benchmarks/schumerSteiglitz.py +++ b/NiaPy/benchmarks/schumerSteiglitz.py @@ -48,7 +48,7 @@ class SchumerSteiglitz(Benchmark): Name = ["SchumerSteiglitz"] def __init__(self, Lower=-100.0, Upper=100.0): - r"""The initialization of Schumer Steiglitz benchmark. + r"""Initialize Schumer Steiglitz benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/schwefel.py b/NiaPy/benchmarks/schwefel.py index b43a27c6..81b664c3 100644 --- a/NiaPy/benchmarks/schwefel.py +++ b/NiaPy/benchmarks/schwefel.py @@ -45,7 +45,7 @@ class Schwefel(Benchmark): Name = ["Schwefel"] def __init__(self, Lower=-500.0, Upper=500.0): - """The initialization of Schewefel benchmark. + """Initialize Schewefel benchmark. Args: Lower (Optional[float]): Lower bound of problem. @@ -126,7 +126,7 @@ class Schwefel221(Benchmark): Name = ["Schwefel221"] def __init__(self, Lower=-100.0, Upper=100.0): - """The initialization of Schwefel221 benchmark. + """Initialize Schwefel221 benchmark. Args: Lower (Optional[float]): Lower bound of problem. @@ -208,7 +208,7 @@ class Schwefel222(Benchmark): Name = ["Schwefel222"] def __init__(self, Lower=-100.0, Upper=100.0): - """The initialization of Schwefel222 benchmark. + """Initialize Schwefel222 benchmark. Args: Lower (Optional[float]): Lower bound of problem. @@ -289,7 +289,7 @@ class ModifiedSchwefel(Benchmark): Name = ["ModifiedSchwefel"] def __init__(self, Lower=-100.0, Upper=100.0): - """The initialization of Modified Schwefel benchmark. + """Initialize Modified Schwefel benchmark. Args: Lower (Optional[float]): Lower bound of problem. @@ -378,7 +378,7 @@ class ExpandedScaffer(Benchmark): Name = ["ExpandedScaffer"] def __init__(self, Lower=-100.0, Upper=100.0): - """The initialization of Expanded Scaffer benchmark. + """Initialize Expanded Scaffer benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/sphere.py b/NiaPy/benchmarks/sphere.py index 78e05982..d6005aff 100644 --- a/NiaPy/benchmarks/sphere.py +++ b/NiaPy/benchmarks/sphere.py @@ -48,7 +48,7 @@ class Sphere(Benchmark): Name = ["Sphere"] def __init__(self, Lower=-5.12, Upper=5.12): - r"""The initialization of Sphere benchmark. + r"""Initialize Sphere benchmark. Args: Lower (Optional[float]): Lower bound of problem. @@ -128,7 +128,7 @@ class Sphere2(Benchmark): Name = ["Sphere2"] def __init__(self, Lower=-1.0, Upper=1.0): - r"""The initialization of Sphere benchmark. + r"""Initialize Sphere benchmark. Args: Lower (Optional[float]): Lower bound of problem. @@ -208,7 +208,7 @@ class Sphere3(Benchmark): Name = ["Sphere3"] def __init__(self, Lower=-65.536, Upper=65.536): - r"""The initialization of Sphere3 benchmark. + r"""Initialize Sphere3 benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/step.py b/NiaPy/benchmarks/step.py index 1d3dd279..ce40ce71 100644 --- a/NiaPy/benchmarks/step.py +++ b/NiaPy/benchmarks/step.py @@ -51,7 +51,7 @@ class Step(Benchmark): Name = ["Step"] def __init__(self, Lower=-100.0, Upper=100.0): - r"""The initialization of Step benchmark. + r"""Initialize Step benchmark. Args: Lower (Optional[float]): Lower bound of problem. @@ -138,7 +138,7 @@ class Step2(Benchmark): Name = ["Step2"] def __init__(self, Lower=-100.0, Upper=100.0): - r"""The initialization of Step2 benchmark. + r"""Initialize Step2 benchmark. Args: Lower (Optional[float]): Lower bound of problem. @@ -224,7 +224,7 @@ class Step3(Benchmark): Name = ["Step3"] def __init__(self, Lower=-100.0, Upper=100.0): - r"""The initialization of Alpine1 benchmark. + r"""Initialize Step3 benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/stepint.py b/NiaPy/benchmarks/stepint.py index d9514e34..1e1315c4 100644 --- a/NiaPy/benchmarks/stepint.py +++ b/NiaPy/benchmarks/stepint.py @@ -48,7 +48,7 @@ class Stepint(Benchmark): Name = ["Stepint"] def __init__(self, Lower=-5.12, Upper=5.12): - """The initialization of Stepint benchmark. + """Initialize Stepint benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/styblinskiTang.py b/NiaPy/benchmarks/styblinskiTang.py index edf0e529..7ab54fdc 100644 --- a/NiaPy/benchmarks/styblinskiTang.py +++ b/NiaPy/benchmarks/styblinskiTang.py @@ -51,7 +51,7 @@ class StyblinskiTang(Benchmark): Name = ["StyblinskiTang"] def __init__(self, Lower=-5.0, Upper=5.0): - r"""The initialization of Styblinski Tang benchmark. + r"""Initialize Styblinski Tang benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/sumSquares.py b/NiaPy/benchmarks/sumSquares.py index c7cd3658..5dda0443 100644 --- a/NiaPy/benchmarks/sumSquares.py +++ b/NiaPy/benchmarks/sumSquares.py @@ -48,7 +48,7 @@ class SumSquares(Benchmark): Name = ["SumSquares"] def __init__(self, Lower=-10.0, Upper=10.0): - """The initialization of Sum Squares benchmark. + """Initialize Sum Squares benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/trid.py b/NiaPy/benchmarks/trid.py index 7eef9dfa..aab20fd6 100644 --- a/NiaPy/benchmarks/trid.py +++ b/NiaPy/benchmarks/trid.py @@ -44,7 +44,7 @@ class Trid(Benchmark): Name = ["Trid"] def __init__(self, D=2): - r"""The initialization of Trid benchmark. + r"""Initialize Trid benchmark. Args: D (Optional[int]): Dimension of problem. diff --git a/NiaPy/benchmarks/weierstrass.py b/NiaPy/benchmarks/weierstrass.py index 25217f30..7de07ae7 100644 --- a/NiaPy/benchmarks/weierstrass.py +++ b/NiaPy/benchmarks/weierstrass.py @@ -45,7 +45,7 @@ class Weierstrass(Benchmark): Name = ["Weierstrass"] def __init__(self, Lower=-100.0, Upper=100.0, a=0.5, b=3, k_max=20): - """The initialization of Weierstrass benchmark. + """Initialize Weierstrass benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/whitley.py b/NiaPy/benchmarks/whitley.py index 23d4f3b8..cdccfff3 100644 --- a/NiaPy/benchmarks/whitley.py +++ b/NiaPy/benchmarks/whitley.py @@ -55,7 +55,7 @@ class Whitley(Benchmark): Name = ["Whitley"] def __init__(self, Lower=-10.24, Upper=10.24): - """The initialization of Whitley benchmark. + """Initialize Whitley benchmark. Args: Lower (Optional[float]): Lower bound of problem. diff --git a/NiaPy/benchmarks/zakharov.py b/NiaPy/benchmarks/zakharov.py index cacb684a..28f8cf68 100644 --- a/NiaPy/benchmarks/zakharov.py +++ b/NiaPy/benchmarks/zakharov.py @@ -45,7 +45,7 @@ class Zakharov(Benchmark): Name = ["Zakharov"] def __init__(self, Lower=-5.0, Upper=10.0): - r"""The initialization of Zakharov benchmark. + r"""Initialize Zakharov benchmark. Args: Lower (Optional[float]): Lower bound of problem. From ff46a82e8cc05a0ecb7dfabb3fdf58b621684c4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grega=20Vrban=C4=8Di=C4=8D?= Date: Mon, 15 Apr 2019 09:28:08 +0200 Subject: [PATCH 20/24] Python 2.7 fixes --- Pipfile | 4 +- Pipfile.lock | 208 ++++++++++++++++++++++++++++++--------------------- setup.py | 3 +- 3 files changed, 127 insertions(+), 88 deletions(-) diff --git a/Pipfile b/Pipfile index c9691b1c..1c19547e 100644 --- a/Pipfile +++ b/Pipfile @@ -15,7 +15,7 @@ flake8 = "*" flake8 = "~=3.7.7" flake8-docstrings = "~=1.3.0" flake8-rst-docstrings = ">=0.0.8" -flake8-bugbear = ">=17.12.0" +#flake8-bugbear = ">=17.12.0" flake8-bandit = "~=2.1.0" pycodestyle = "~=2.5.0" pydocstyle = "~=3.0.0" @@ -39,6 +39,6 @@ futures = ">=3.1.1" Pygments = "~=2.3.1" "backports.functools_lru_cache" = "~=1.5" MacFSEvents = {version = "~=0.8.1",sys_platform = "== 'darwin'"} -Sphinx = "~=2.0.1" +Sphinx = "~=1.8.0b1" sphinx-rtd-theme = "~=0.4.3" sphinx-autobuild = "~=0.7.1" diff --git a/Pipfile.lock b/Pipfile.lock index 8f6db60e..a96b69dc 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "b4e120b3b43eb1e70f4bfceb8efdd777626474d994eac14ceb400d2e563b42d1" + "sha256": "706d7b1fe6c61c4944d969aac34e381dbded3be11bad4440b65a412d03cdd8ae" }, "pipfile-spec": 6, "requires": {}, @@ -14,6 +14,21 @@ ] }, "default": { + "backports.functools-lru-cache": { + "hashes": [ + "sha256:9d98697f088eb1b0fa451391f91afb5e3ebde16bbdb272819fd091151fda4f1a", + "sha256:f0b0e4eba956de51238e17573b7087e852dfe9854afd2e9c873f73fc0ca0a6dd" + ], + "version": "==1.5" + }, + "configparser": { + "hashes": [ + "sha256:8be81d89d6e7b4c0d4e44bcc525845f6da25821de80cb5e06e7e0238a2899e32", + "sha256:da60d0014fd8c55eb48c1c5354352e363e2d30bbf7057e5e171a468390184c75" + ], + "markers": "python_version == '2.7'", + "version": "==3.7.4" + }, "cycler": { "hashes": [ "sha256:1d8a5ae1ff6c5cf9b93e8811e581232ad8920aeec647c37316ceac982b08cb2d", @@ -47,6 +62,14 @@ "index": "pypi", "version": "==3.7.7" }, + "functools32": { + "hashes": [ + "sha256:89d824aa6c358c421a234d7f9ee0bd75933a67c29588ce50aaa3acdf4d403fa0", + "sha256:f6253dfbe0538ad2e387bd8fdfd9293c925d63553f5813c4e587745416501e6d" + ], + "markers": "python_version < '3.2'", + "version": "==3.2.3.post2" + }, "kiwisolver": { "hashes": [ "sha256:0ee4ed8b3ae8f5f712b0aa9ebd2858b5b232f1b9a96b0943dceb34df2a223bc3", @@ -82,22 +105,31 @@ }, "matplotlib": { "hashes": [ - "sha256:1ae6549976b6ceb6ee426272a28c0fc9715b3e3669694d560c8f661c5b39e2c5", - "sha256:4d4250bf508dd07cca3b43888097f873cadb66eec6ac63dbbfb798798ec07af2", - "sha256:53af2e01d7f1700ed2b64a9091bc865360c9c4032f625451c4589a826854c787", - "sha256:63e498067d32d627111cd1162cae1621f1221f9d4c6a9745dd7233f29de581b6", - "sha256:7169a34971e398dd58e87e173f97366fd88a3fa80852704530433eb224a8ca57", - "sha256:91c54d6bb9eeaaff965656c5ea6cbdcbf780bad8462ac99b30b451548194746f", - "sha256:aeef177647bb3fccfe09065481989d7dfc5ac59e9367d6a00a3481062cf651e4", - "sha256:cf8ae10559a78aee0409ede1e9d4fda03895433eeafe609dd9ed67e45f552db0", - "sha256:d51d0889d1c4d51c51a9822265c0494ea3e70a52bdd88358e0863daca46fa23a", - "sha256:de5ccd3500247f85fe4f9fad90f80a8bd397e4f110a4c33fabf95f07403e8372", - "sha256:e1d33589e32f482d0a7d1957bf473d43341115d40d33f578dad44432e47df7b7", - "sha256:e8d1939262aa6b36d0c51f50a50a43a04b9618d20db31e6c0192b1463067aeef", - "sha256:e918d51b1fda82a65fdf52d2f3914b2246481cc2a9cd10e223e6be6078916ff3" - ], - "index": "pypi", - "version": "==3.0.3" + "sha256:029620799e581802961ac1dcff5cb5d3ee2f602e0db9c0f202a90495b37d2126", + "sha256:2308f67e085735ed580fcace652339cb517f059cdc9ee8a418c1b55746dbffcb", + "sha256:280aebaec25575e35bf7d1b3ebb2d8ae7e839edb5a403f1a121b7271744b1ef9", + "sha256:295099acb5a8a1148d1b4693ad1a93479a20836cd8b7eb38183a98c84cdcb2f1", + "sha256:75d44c55eb87af653afc3d0a37ab62ab4784c752be0e7c96622713d88ed57e64", + "sha256:95d9d7c2d7f0c7a4317acbcf1a81efa0a2ce5cb5ddfad606ae4c25a783431f0a", + "sha256:9703ffc3e7e369f3ab31d0032719710876cb341eb618e1a8a54447e1946a9f0a", + "sha256:9ff80541d5676207c6e829632b28e22d9875ecaae54eab7a7f8fd82a6552e5e9", + "sha256:a6a04ebd81b3183e7882c9047a9514b7f547b2bae5e4f61a02eaaa6b446bde54", + "sha256:b22b0d3b8d8f769c6ac559f6761878d660bd23d67b36430f07161caf1505c29c", + "sha256:b464d598e36e13f7d798443805f2ba6b4af3d26fc1652c51c77a7847cf665813", + "sha256:c0fa162920185d5d74e6fdf52c1f8cca0fbf897025a9dd81e030cf08a915865a", + "sha256:c452b7aff0a9e4612670a4590e6efc30929dad620a121d423c8f3d0bd93715e2", + "sha256:c90fc796e97815ea3bbbdea63c1e4edf75336361a49b945fdbc2aff1c76008c6", + "sha256:cc1d376963ea9c97338582f3f9d64757c51e71cf2655efe363a3f2414d84aac2", + "sha256:d3f5dfaa345539599308bd83826db242e424e3f4e9657952f8738ce1b5b90e8a", + "sha256:d9e80ba0ffdb0daacaf49e561474d5c5c153d6db853478cf90c8cba5ed8b72b1", + "sha256:daac44fc77cf36ff01953e2acc57a843fb1f6572eb5bf0af10a2930fa7407715", + "sha256:de43c85335d71094a254e8538719752e30db3305005dae8dcb3097b72587ed07", + "sha256:e4621af28a2444f93b5b6d3d60f54767df8ac6daa510a98f68c34377cb474869", + "sha256:f3755a52aae7fb640f5f57b7b63eb5d65688c84931d7833dbc7d03959cd4f8ce", + "sha256:f99c43df8ed2b9d1c95a042f3cacf017f9690092feba0b4292eaa6713f92de97" + ], + "index": "pypi", + "version": "==2.2.4" }, "mccabe": { "hashes": [ @@ -163,6 +195,13 @@ ], "version": "==2.8.0" }, + "pytz": { + "hashes": [ + "sha256:303879e36b721603cc54604edcac9d20401bdbe31e1e4fdee5b9f98d5d31dfda", + "sha256:d747dd3d23d77ef44c6a3526e274af6efeb0a6f1afd5a69ba4d5be4098c8e141" + ], + "version": "==2019.1" + }, "scipy": { "hashes": [ "sha256:014cb900c003b5ac81a53f2403294e8ecf37aedc315b59a6b9370dce0aa7627a", @@ -204,6 +243,22 @@ ], "version": "==1.12.0" }, + "subprocess32": { + "hashes": [ + "sha256:24a7f627ef7a5695138601b665057ad131fa26e80d49d5ffa6b4fdb2357a80d3", + "sha256:6bc82992316eef3ccff319b5033809801c0c3372709c5f6985299c88ac7225c3" + ], + "version": "==3.5.3" + }, + "typing": { + "hashes": [ + "sha256:4027c5f6127a6267a435201981ba156de91ad0d1d98e9ddc2aa173453453492d", + "sha256:57dcf675a99b74d64dacf6fba08fb17cf7e3d5fdff53d4a30ea2a5e7e52543d4", + "sha256:a4c8473ce11a65999c8f59cb093e70686b6c84c98df58c1dae9b3b196089858a" + ], + "markers": "python_version < '3.5'", + "version": "==3.6.6" + }, "xlsxwriter": { "hashes": [ "sha256:3a4e4a24a6753f046dc5a5e5bc5f443fce6a18988486885a258db6963eb54163", @@ -254,7 +309,6 @@ "sha256:9d98697f088eb1b0fa451391f91afb5e3ebde16bbdb272819fd091151fda4f1a", "sha256:f0b0e4eba956de51238e17573b7087e852dfe9854afd2e9c873f73fc0ca0a6dd" ], - "index": "pypi", "version": "==1.5" }, "backports.shutil-get-terminal-size": { @@ -304,7 +358,7 @@ "sha256:8be81d89d6e7b4c0d4e44bcc525845f6da25821de80cb5e06e7e0238a2899e32", "sha256:da60d0014fd8c55eb48c1c5354352e363e2d30bbf7057e5e171a468390184c75" ], - "index": "pypi", + "markers": "python_version == '2.7'", "version": "==3.7.4" }, "coverage": { @@ -373,6 +427,17 @@ ], "version": "==0.3" }, + "enum34": { + "hashes": [ + "sha256:2d81cbbe0e73112bdfe6ef8576f2238f2ba27dd0d55752a776c41d38b7da2850", + "sha256:644837f692e5f550741432dd3f223bbb9852018674981b1664e5dc339387588a", + "sha256:6bd0f6ad48ec2aa117d3d141940d484deccda84d4fcd884f5c3d93c23ecd8c79", + "sha256:8ad8c4783bf61ded74527bffb48ed9b54166685e4230386a9ed9b1279e2df5b1" + ], + "index": "pypi", + "markers": "python_version < '3.4'", + "version": "==1.1.6" + }, "flake8": { "hashes": [ "sha256:859996073f341f2670741b51ec1e67a01da142831aa1fdc6242dbf88dffbe661", @@ -389,14 +454,6 @@ "index": "pypi", "version": "==2.1.0" }, - "flake8-bugbear": { - "hashes": [ - "sha256:5070774b668be92c4312e5ca82748ddf4ecaa7a24ff062662681bb745c7896eb", - "sha256:fef9c9826d14ec23187ae1edeb3c6513c4e46bf0e70d86bac38f7d9aabae113d" - ], - "index": "pypi", - "version": "==19.3.0" - }, "flake8-docstrings": { "hashes": [ "sha256:4e0ce1476b64e6291520e5570cf12b05016dd4e8ae454b8a8a9a48bc5f84e1cd", @@ -435,13 +492,21 @@ "index": "pypi", "version": "==1.0.2" }, + "functools32": { + "hashes": [ + "sha256:89d824aa6c358c421a234d7f9ee0bd75933a67c29588ce50aaa3acdf4d403fa0", + "sha256:f6253dfbe0538ad2e387bd8fdfd9293c925d63553f5813c4e587745416501e6d" + ], + "markers": "python_version < '3.2'", + "version": "==3.2.3.post2" + }, "futures": { "hashes": [ - "sha256:51ecb45f0add83c806c68e4b06106f90db260585b25ef2abfcda0bd95c0132fd", - "sha256:c4884a65654a7c45435063e14ae85280eb1f111d94e542396717ba9828c4337f" + "sha256:9ec02aa7d674acb8618afb127e27fde7fc68994c0437ad759fa094a574adb265", + "sha256:ec0a6cb848cc212002b9828c3e34c675e0c9ff6741dc445cab6fdd4e1085d1f1" ], "index": "pypi", - "version": "==3.1.1" + "version": "==3.2.0" }, "gitdb2": { "hashes": [ @@ -535,11 +600,12 @@ }, "more-itertools": { "hashes": [ - "sha256:2112d2ca570bb7c3e53ea1a35cd5df42bb0fd10c45f0fb97178679c3c03d64c7", - "sha256:c3e4748ba1aad8dba30a4886b0b1a2004f9a863837b8654e7059eebf727afa5a" + "sha256:38a936c0a6d98a38bcc2d03fdaaedaba9f412879461dd2ceff8d37564d6522e4", + "sha256:c0a5785b1109a6bd7fac76d6837fd1feca158e54e521ccd2ae8bfe393cc9d4fc", + "sha256:fe7a7cae1ccb57d33952113ff4fa1bc5f879963600ed74918f1236e212ee50b9" ], - "markers": "python_version > '2.7'", - "version": "==7.0.0" + "markers": "python_version <= '2.7'", + "version": "==5.0.0" }, "nose": { "hashes": [ @@ -800,11 +866,11 @@ }, "sphinx": { "hashes": [ - "sha256:423280646fb37944dd3c85c58fb92a20d745793a9f6c511f59da82fa97cd404b", - "sha256:de930f42600a4fef993587633984cc5027dedba2464bcf00ddace26b40f8d9ce" + "sha256:95acd6648902333647a0e0564abdb28a74b0a76d2333148aa35e5ed1f56d3c4b", + "sha256:c091dbdd5cc5aac6eb95d591a819fd18bccec90ffb048ec465b165a48b839b45" ], "index": "pypi", - "version": "==2.0.1" + "version": "==1.8.0" }, "sphinx-autobuild": { "hashes": [ @@ -822,47 +888,12 @@ "index": "pypi", "version": "==0.4.3" }, - "sphinxcontrib-applehelp": { - "hashes": [ - "sha256:edaa0ab2b2bc74403149cb0209d6775c96de797dfd5b5e2a71981309efab3897", - "sha256:fb8dee85af95e5c30c91f10e7eb3c8967308518e0f7488a2828ef7bc191d0d5d" - ], - "version": "==1.0.1" - }, - "sphinxcontrib-devhelp": { - "hashes": [ - "sha256:6c64b077937330a9128a4da74586e8c2130262f014689b4b89e2d08ee7294a34", - "sha256:9512ecb00a2b0821a146736b39f7aeb90759834b07e81e8cc23a9c70bacb9981" - ], - "version": "==1.0.1" - }, - "sphinxcontrib-htmlhelp": { - "hashes": [ - "sha256:4670f99f8951bd78cd4ad2ab962f798f5618b17675c35c5ac3b2132a14ea8422", - "sha256:d4fd39a65a625c9df86d7fa8a2d9f3cd8299a3a4b15db63b50aac9e161d8eff7" - ], - "version": "==1.0.2" - }, - "sphinxcontrib-jsmath": { + "sphinxcontrib-websupport": { "hashes": [ - "sha256:2ec2eaebfb78f3f2078e73666b1415417a116cc848b72e5172e596c871103178", - "sha256:a9925e4a4587247ed2191a22df5f6970656cb8ca2bd6284309578f2153e0c4b8" + "sha256:68ca7ff70785cbe1e7bccc71a48b5b6d965d79ca50629606c7861a21b206d9dd", + "sha256:9de47f375baf1ea07cdb3436ff39d7a9c76042c10a769c52353ec46e4e8fc3b9" ], - "version": "==1.0.1" - }, - "sphinxcontrib-qthelp": { - "hashes": [ - "sha256:513049b93031beb1f57d4daea74068a4feb77aa5630f856fcff2e50de14e9a20", - "sha256:79465ce11ae5694ff165becda529a600c754f4bc459778778c7017374d4d406f" - ], - "version": "==1.0.2" - }, - "sphinxcontrib-serializinghtml": { - "hashes": [ - "sha256:c0efb33f8052c04fd7a26c0a07f1678e8512e0faec19f4aa8f2473a8b81d5227", - "sha256:db6615af393650bf1151a6cd39120c29abaf93cc60db8c48eb2dddbfdc3a9768" - ], - "version": "==1.1.3" + "version": "==1.1.0" }, "stevedore": { "hashes": [ @@ -873,15 +904,15 @@ }, "tornado": { "hashes": [ - "sha256:1174dcb84d08887b55defb2cda1986faeeea715fff189ef3dc44cce99f5fca6b", - "sha256:2613fab506bd2aedb3722c8c64c17f8f74f4070afed6eea17f20b2115e445aec", - "sha256:44b82bc1146a24e5b9853d04c142576b4e8fa7a92f2e30bc364a85d1f75c4de2", - "sha256:457fcbee4df737d2defc181b9073758d73f54a6cfc1f280533ff48831b39f4a8", - "sha256:49603e1a6e24104961497ad0c07c799aec1caac7400a6762b687e74c8206677d", - "sha256:8c2f40b99a8153893793559919a355d7b74649a11e59f411b0b0a1793e160bc0", - "sha256:e1d897889c3b5a829426b7d52828fb37b28bc181cd598624e65c8be40ee3f7fa" + "sha256:0662d28b1ca9f67108c7e3b77afabfb9c7e87bde174fbda78186ecedc2499a9d", + "sha256:4e5158d97583502a7e2739951553cbd88a72076f152b4b11b64b9a10c4c49409", + "sha256:732e836008c708de2e89a31cb2fa6c0e5a70cb60492bee6f1ea1047500feaf7f", + "sha256:8154ec22c450df4e06b35f131adc4f2f3a12ec85981a203301d310abf580500f", + "sha256:8e9d728c4579682e837c92fdd98036bd5cdefa1da2aaf6acf26947e6dd0c01c5", + "sha256:d4b3e5329f572f055b587efc57d29bd051589fb5a43ec8898c77a47ec2fa2bbb", + "sha256:e5f2585afccbff22390cddac29849df463b252b711aa2ce7c5f3f342a5b3b444" ], - "version": "==6.0.2" + "version": "==5.1.1" }, "tqdm": { "hashes": [ @@ -898,6 +929,15 @@ "index": "pypi", "version": "==1.13.0" }, + "typing": { + "hashes": [ + "sha256:4027c5f6127a6267a435201981ba156de91ad0d1d98e9ddc2aa173453453492d", + "sha256:57dcf675a99b74d64dacf6fba08fb17cf7e3d5fdff53d4a30ea2a5e7e52543d4", + "sha256:a4c8473ce11a65999c8f59cb093e70686b6c84c98df58c1dae9b3b196089858a" + ], + "markers": "python_version < '3.5'", + "version": "==3.6.6" + }, "urllib3": { "hashes": [ "sha256:61bf29cada3fc2fbefad4fdf059ea4bd1b4a86d2b6d15e1c7c0b582b9752fe39", diff --git a/setup.py b/setup.py index 36d0f186..f8d3770c 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,6 @@ with_statement, print_function, unicode_literals, - generator_stop, nested_scopes, generators ) @@ -87,7 +86,7 @@ def build_description(): ], tests_requires=[ - 'pylint >= 2.1.1', + 'flake8 ~= 3.7.7', 'astroid >= 2.0.4', 'pytest ~= 3.7.1', 'coverage ~= 4.4.2', From f81742f69bb96b5752f99190cb4aca2864d9fe22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grega=20Vrban=C4=8Di=C4=8D?= Date: Mon, 15 Apr 2019 09:36:25 +0200 Subject: [PATCH 21/24] fixes --- .flake8 | 4 ++-- tests/__init__.py | 1 - tests/conftest.py | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.flake8 b/.flake8 index 764182f0..66edf00e 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,5 @@ [flake8] -ignore = E203,E266,E501,W503,D401,D202,RST299,RST304,RST399,FI +ignore = E203,E266,E501,W503,D302,D401,D202,RST299,RST304,RST399,FI exclude = .git, __pycache__, @@ -10,6 +10,6 @@ exclude = scent.py per-file-ignores = NiaPy/tests/*:B007,D100,D101,D102,D107,D208,D211,D413,E117,E302,E701,E704,F841,S110,W191,W293 - NiaPy/algorithms/*:B305,B007,D100,D101,D104,D102,D107,D204,D206,D413,E101,E117,E126,E302,E305,E701,E704,E711,E741,RST201,RST203,RST204,RST210,RST301,W191 + NiaPy/algorithms/*:B305,B007,D100,D101,D104,D102,D107,D204,D206,D413,E101,E117,E126,E302,E305,E701,E704,E711,E741,F812,RST201,RST203,RST204,RST210,RST301,W191 NiaPy/__init__.py:D100,D204,D206,D413,E101,E117,E242,E302,E701,E702,E704,E711,RST201,W191 NiaPy/util/*:D100,D101,D104,D107,D204,D413,E117,E242,E302,E305,E701,E704,F104,RST201,RST203,RST210,W191 diff --git a/tests/__init__.py b/tests/__init__.py index 4d3e2474..6429bcfe 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -6,7 +6,6 @@ with_statement, print_function, unicode_literals, - generator_stop, nested_scopes, generators ) diff --git a/tests/conftest.py b/tests/conftest.py index 69729907..dd33b831 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -6,7 +6,6 @@ with_statement, print_function, unicode_literals, - generator_stop, nested_scopes, generators ) From 3c9fa2ed4ec2ef004a70a7f2e517de0ac93bf824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grega=20Vrban=C4=8Di=C4=8D?= Date: Mon, 15 Apr 2019 09:41:02 +0200 Subject: [PATCH 22/24] fix --- .gitignore | 1 + Pipfile.lock | 970 --------------------------------------------------- 2 files changed, 1 insertion(+), 970 deletions(-) delete mode 100644 Pipfile.lock diff --git a/.gitignore b/.gitignore index 44fa1a17..531c6d65 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ *.egg-info __pycache__ .ipynb_checkpoints +Pipfile.lock # Temporary OS files Icon* diff --git a/Pipfile.lock b/Pipfile.lock deleted file mode 100644 index a96b69dc..00000000 --- a/Pipfile.lock +++ /dev/null @@ -1,970 +0,0 @@ -{ - "_meta": { - "hash": { - "sha256": "706d7b1fe6c61c4944d969aac34e381dbded3be11bad4440b65a412d03cdd8ae" - }, - "pipfile-spec": 6, - "requires": {}, - "sources": [ - { - "name": "pypi", - "url": "https://pypi.python.org/simple", - "verify_ssl": true - } - ] - }, - "default": { - "backports.functools-lru-cache": { - "hashes": [ - "sha256:9d98697f088eb1b0fa451391f91afb5e3ebde16bbdb272819fd091151fda4f1a", - "sha256:f0b0e4eba956de51238e17573b7087e852dfe9854afd2e9c873f73fc0ca0a6dd" - ], - "version": "==1.5" - }, - "configparser": { - "hashes": [ - "sha256:8be81d89d6e7b4c0d4e44bcc525845f6da25821de80cb5e06e7e0238a2899e32", - "sha256:da60d0014fd8c55eb48c1c5354352e363e2d30bbf7057e5e171a468390184c75" - ], - "markers": "python_version == '2.7'", - "version": "==3.7.4" - }, - "cycler": { - "hashes": [ - "sha256:1d8a5ae1ff6c5cf9b93e8811e581232ad8920aeec647c37316ceac982b08cb2d", - "sha256:cd7b2d1018258d7247a71425e9f26463dfb444d411c39569972f4ce586b0c9d8" - ], - "version": "==0.10.0" - }, - "entrypoints": { - "hashes": [ - "sha256:589f874b313739ad35be6e0cd7efde2a4e9b6fea91edcc34e58ecbb8dbe56d19", - "sha256:c70dd71abe5a8c85e55e12c19bd91ccfeec11a6e99044204511f9ed547d48451" - ], - "version": "==0.3" - }, - "enum34": { - "hashes": [ - "sha256:2d81cbbe0e73112bdfe6ef8576f2238f2ba27dd0d55752a776c41d38b7da2850", - "sha256:644837f692e5f550741432dd3f223bbb9852018674981b1664e5dc339387588a", - "sha256:6bd0f6ad48ec2aa117d3d141940d484deccda84d4fcd884f5c3d93c23ecd8c79", - "sha256:8ad8c4783bf61ded74527bffb48ed9b54166685e4230386a9ed9b1279e2df5b1" - ], - "index": "pypi", - "markers": "python_version < '3.4'", - "version": "==1.1.6" - }, - "flake8": { - "hashes": [ - "sha256:859996073f341f2670741b51ec1e67a01da142831aa1fdc6242dbf88dffbe661", - "sha256:a796a115208f5c03b18f332f7c11729812c8c3ded6c46319c59b53efd3819da8" - ], - "index": "pypi", - "version": "==3.7.7" - }, - "functools32": { - "hashes": [ - "sha256:89d824aa6c358c421a234d7f9ee0bd75933a67c29588ce50aaa3acdf4d403fa0", - "sha256:f6253dfbe0538ad2e387bd8fdfd9293c925d63553f5813c4e587745416501e6d" - ], - "markers": "python_version < '3.2'", - "version": "==3.2.3.post2" - }, - "kiwisolver": { - "hashes": [ - "sha256:0ee4ed8b3ae8f5f712b0aa9ebd2858b5b232f1b9a96b0943dceb34df2a223bc3", - "sha256:0f7f532f3c94e99545a29f4c3f05637f4d2713e7fd91b4dd8abfc18340b86cd5", - "sha256:1a078f5dd7e99317098f0e0d490257fd0349d79363e8c923d5bb76428f318421", - "sha256:1aa0b55a0eb1bd3fa82e704f44fb8f16e26702af1a073cc5030eea399e617b56", - "sha256:2874060b91e131ceeff00574b7c2140749c9355817a4ed498e82a4ffa308ecbc", - "sha256:379d97783ba8d2934d52221c833407f20ca287b36d949b4bba6c75274bcf6363", - "sha256:3b791ddf2aefc56382aadc26ea5b352e86a2921e4e85c31c1f770f527eb06ce4", - "sha256:4329008a167fac233e398e8a600d1b91539dc33c5a3eadee84c0d4b04d4494fa", - "sha256:45813e0873bbb679334a161b28cb9606d9665e70561fd6caa8863e279b5e464b", - "sha256:53a5b27e6b5717bdc0125338a822605084054c80f382051fb945d2c0e6899a20", - "sha256:574f24b9805cb1c72d02b9f7749aa0cc0b81aa82571be5201aa1453190390ae5", - "sha256:66f82819ff47fa67a11540da96966fb9245504b7f496034f534b81cacf333861", - "sha256:79e5fe3ccd5144ae80777e12973027bd2f4f5e3ae8eb286cabe787bed9780138", - "sha256:83410258eb886f3456714eea4d4304db3a1fc8624623fc3f38a487ab36c0f653", - "sha256:8b6a7b596ce1d2a6d93c3562f1178ebd3b7bb445b3b0dd33b09f9255e312a965", - "sha256:9576cb63897fbfa69df60f994082c3f4b8e6adb49cccb60efb2a80a208e6f996", - "sha256:95a25d9f3449046ecbe9065be8f8380c03c56081bc5d41fe0fb964aaa30b2195", - "sha256:a424f048bebc4476620e77f3e4d1f282920cef9bc376ba16d0b8fe97eec87cde", - "sha256:aaec1cfd94f4f3e9a25e144d5b0ed1eb8a9596ec36d7318a504d813412563a85", - "sha256:acb673eecbae089ea3be3dcf75bfe45fc8d4dcdc951e27d8691887963cf421c7", - "sha256:b15bc8d2c2848a4a7c04f76c9b3dc3561e95d4dabc6b4f24bfabe5fd81a0b14f", - "sha256:b1c240d565e977d80c0083404c01e4d59c5772c977fae2c483f100567f50847b", - "sha256:c595693de998461bcd49b8d20568c8870b3209b8ea323b2a7b0ea86d85864694", - "sha256:ce3be5d520b4d2c3e5eeb4cd2ef62b9b9ab8ac6b6fedbaa0e39cdb6f50644278", - "sha256:e0f910f84b35c36a3513b96d816e6442ae138862257ae18a0019d2fc67b041dc", - "sha256:ea36e19ac0a483eea239320aef0bd40702404ff8c7e42179a2d9d36c5afcb55c", - "sha256:efabbcd4f406b532206b8801058c8bab9e79645b9880329253ae3322b7b02cd5", - "sha256:f923406e6b32c86309261b8195e24e18b6a8801df0cfc7814ac44017bfcb3939" - ], - "version": "==1.0.1" - }, - "matplotlib": { - "hashes": [ - "sha256:029620799e581802961ac1dcff5cb5d3ee2f602e0db9c0f202a90495b37d2126", - "sha256:2308f67e085735ed580fcace652339cb517f059cdc9ee8a418c1b55746dbffcb", - "sha256:280aebaec25575e35bf7d1b3ebb2d8ae7e839edb5a403f1a121b7271744b1ef9", - "sha256:295099acb5a8a1148d1b4693ad1a93479a20836cd8b7eb38183a98c84cdcb2f1", - "sha256:75d44c55eb87af653afc3d0a37ab62ab4784c752be0e7c96622713d88ed57e64", - "sha256:95d9d7c2d7f0c7a4317acbcf1a81efa0a2ce5cb5ddfad606ae4c25a783431f0a", - "sha256:9703ffc3e7e369f3ab31d0032719710876cb341eb618e1a8a54447e1946a9f0a", - "sha256:9ff80541d5676207c6e829632b28e22d9875ecaae54eab7a7f8fd82a6552e5e9", - "sha256:a6a04ebd81b3183e7882c9047a9514b7f547b2bae5e4f61a02eaaa6b446bde54", - "sha256:b22b0d3b8d8f769c6ac559f6761878d660bd23d67b36430f07161caf1505c29c", - "sha256:b464d598e36e13f7d798443805f2ba6b4af3d26fc1652c51c77a7847cf665813", - "sha256:c0fa162920185d5d74e6fdf52c1f8cca0fbf897025a9dd81e030cf08a915865a", - "sha256:c452b7aff0a9e4612670a4590e6efc30929dad620a121d423c8f3d0bd93715e2", - "sha256:c90fc796e97815ea3bbbdea63c1e4edf75336361a49b945fdbc2aff1c76008c6", - "sha256:cc1d376963ea9c97338582f3f9d64757c51e71cf2655efe363a3f2414d84aac2", - "sha256:d3f5dfaa345539599308bd83826db242e424e3f4e9657952f8738ce1b5b90e8a", - "sha256:d9e80ba0ffdb0daacaf49e561474d5c5c153d6db853478cf90c8cba5ed8b72b1", - "sha256:daac44fc77cf36ff01953e2acc57a843fb1f6572eb5bf0af10a2930fa7407715", - "sha256:de43c85335d71094a254e8538719752e30db3305005dae8dcb3097b72587ed07", - "sha256:e4621af28a2444f93b5b6d3d60f54767df8ac6daa510a98f68c34377cb474869", - "sha256:f3755a52aae7fb640f5f57b7b63eb5d65688c84931d7833dbc7d03959cd4f8ce", - "sha256:f99c43df8ed2b9d1c95a042f3cacf017f9690092feba0b4292eaa6713f92de97" - ], - "index": "pypi", - "version": "==2.2.4" - }, - "mccabe": { - "hashes": [ - "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", - "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f" - ], - "version": "==0.6.1" - }, - "numpy": { - "hashes": [ - "sha256:1980f8d84548d74921685f68096911585fee393975f53797614b34d4f409b6da", - "sha256:22752cd809272671b273bb86df0f505f505a12368a3a5fc0aa811c7ece4dfd5c", - "sha256:23cc40313036cffd5d1873ef3ce2e949bdee0646c5d6f375bf7ee4f368db2511", - "sha256:2b0b118ff547fecabc247a2668f48f48b3b1f7d63676ebc5be7352a5fd9e85a5", - "sha256:3a0bd1edf64f6a911427b608a894111f9fcdb25284f724016f34a84c9a3a6ea9", - "sha256:3f25f6c7b0d000017e5ac55977a3999b0b1a74491eacb3c1aa716f0e01f6dcd1", - "sha256:4061c79ac2230594a7419151028e808239450e676c39e58302ad296232e3c2e8", - "sha256:560ceaa24f971ab37dede7ba030fc5d8fa173305d94365f814d9523ffd5d5916", - "sha256:62be044cd58da2a947b7e7b2252a10b42920df9520fc3d39f5c4c70d5460b8ba", - "sha256:6c692e3879dde0b67a9dc78f9bfb6f61c666b4562fd8619632d7043fb5b691b0", - "sha256:6f65e37b5a331df950ef6ff03bd4136b3c0bbcf44d4b8e99135d68a537711b5a", - "sha256:7a78cc4ddb253a55971115f8320a7ce28fd23a065fc33166d601f51760eecfa9", - "sha256:80a41edf64a3626e729a62df7dd278474fc1726836552b67a8c6396fd7e86760", - "sha256:893f4d75255f25a7b8516feb5766c6b63c54780323b9bd4bc51cdd7efc943c73", - "sha256:972ea92f9c1b54cc1c1a3d8508e326c0114aaf0f34996772a30f3f52b73b942f", - "sha256:9f1d4865436f794accdabadc57a8395bd3faa755449b4f65b88b7df65ae05f89", - "sha256:9f4cd7832b35e736b739be03b55875706c8c3e5fe334a06210f1a61e5c2c8ca5", - "sha256:adab43bf657488300d3aeeb8030d7f024fcc86e3a9b8848741ea2ea903e56610", - "sha256:bd2834d496ba9b1bdda3a6cf3de4dc0d4a0e7be306335940402ec95132ad063d", - "sha256:d20c0360940f30003a23c0adae2fe50a0a04f3e48dc05c298493b51fd6280197", - "sha256:d3b3ed87061d2314ff3659bb73896e622252da52558f2380f12c421fbdee3d89", - "sha256:dc235bf29a406dfda5790d01b998a1c01d7d37f449128c0b1b7d1c89a84fae8b", - "sha256:fb3c83554f39f48f3fa3123b9c24aecf681b1c289f9334f8215c1d3c8e2f6e5b" - ], - "index": "pypi", - "version": "==1.16.2" - }, - "pycodestyle": { - "hashes": [ - "sha256:95a2219d12372f05704562a14ec30bc76b05a5b297b21a5dfe3f6fac3491ae56", - "sha256:e40a936c9a450ad81df37f549d676d127b1b66000a6c500caa2b085bc0ca976c" - ], - "version": "==2.5.0" - }, - "pyflakes": { - "hashes": [ - "sha256:17dbeb2e3f4d772725c777fabc446d5634d1038f234e77343108ce445ea69ce0", - "sha256:d976835886f8c5b31d47970ed689944a0262b5f3afa00a5a7b4dc81e5449f8a2" - ], - "version": "==2.1.1" - }, - "pyparsing": { - "hashes": [ - "sha256:1873c03321fc118f4e9746baf201ff990ceb915f433f23b395f5580d1840cb2a", - "sha256:9b6323ef4ab914af344ba97510e966d64ba91055d6b9afa6b30799340e89cc03" - ], - "version": "==2.4.0" - }, - "python-dateutil": { - "hashes": [ - "sha256:7e6584c74aeed623791615e26efd690f29817a27c73085b78e4bad02493df2fb", - "sha256:c89805f6f4d64db21ed966fda138f8a5ed7a4fdbc1a8ee329ce1b74e3c74da9e" - ], - "version": "==2.8.0" - }, - "pytz": { - "hashes": [ - "sha256:303879e36b721603cc54604edcac9d20401bdbe31e1e4fdee5b9f98d5d31dfda", - "sha256:d747dd3d23d77ef44c6a3526e274af6efeb0a6f1afd5a69ba4d5be4098c8e141" - ], - "version": "==2019.1" - }, - "scipy": { - "hashes": [ - "sha256:014cb900c003b5ac81a53f2403294e8ecf37aedc315b59a6b9370dce0aa7627a", - "sha256:281a34da34a5e0de42d26aed692ab710141cad9d5d218b20643a9cb538ace976", - "sha256:588f9cc4bfab04c45fbd19c1354b5ade377a8124d6151d511c83730a9b6b2338", - "sha256:5a10661accd36b6e2e8855addcf3d675d6222006a15795420a39c040362def66", - "sha256:628f60be272512ca1123524969649a8cb5ae8b31cca349f7c6f8903daf9034d7", - "sha256:6dcc43a88e25b815c2dea1c6fac7339779fc988f5df8396e1de01610604a7c38", - "sha256:70e37cec0ac0fe95c85b74ca4e0620169590fd5d3f44765f3c3a532cedb0e5fd", - "sha256:7274735fb6fb5d67d3789ddec2cd53ed6362539b41aa6cc0d33a06c003aaa390", - "sha256:78e12972e144da47326958ac40c2bd1c1cca908edc8b01c26a36f9ffd3dce466", - "sha256:790cbd3c8d09f3a6d9c47c4558841e25bac34eb7a0864a9def8f26be0b8706af", - "sha256:79792c8fe8e9d06ebc50fe23266522c8c89f20aa94ac8e80472917ecdce1e5ba", - "sha256:865afedf35aaef6df6344bee0de391ee5e99d6e802950a237f9fb9b13e441f91", - "sha256:870fd401ec7b64a895cff8e206ee16569158db00254b2f7157b4c9a5db72c722", - "sha256:963815c226b29b0176d5e3d37fc9de46e2778ce4636a5a7af11a48122ef2577c", - "sha256:9726791484f08e394af0b59eb80489ad94d0a53bbb58ab1837dcad4d58489863", - "sha256:9de84a71bb7979aa8c089c4fb0ea0e2ed3917df3fb2a287a41aaea54bbad7f5d", - "sha256:b2c324ddc5d6dbd3f13680ad16a29425841876a84a1de23a984236d1afff4fa6", - "sha256:b86ae13c597fca087cb8c193870507c8916cefb21e52e1897da320b5a35075e5", - "sha256:ba0488d4dbba2af5bf9596b849873102d612e49a118c512d9d302ceafa36e01a", - "sha256:d78702af4102a3a4e23bb7372cec283e78f32f5573d92091aa6aaba870370fe1", - "sha256:def0e5d681dd3eb562b059d355ae8bebe27f5cc455ab7c2b6655586b63d3a8ea", - "sha256:e085d1babcb419bbe58e2e805ac61924dac4ca45a07c9fa081144739e500aa3c", - "sha256:e2cfcbab37c082a5087aba5ff00209999053260441caadd4f0e8f4c2d6b72088", - "sha256:e742f1f5dcaf222e8471c37ee3d1fd561568a16bb52e031c25674ff1cf9702d5", - "sha256:f06819b028b8ef9010281e74c59cb35483933583043091ed6b261bb1540f11cc", - "sha256:f15f2d60a11c306de7700ee9f65df7e9e463848dbea9c8051e293b704038da60", - "sha256:f31338ee269d201abe76083a990905473987371ff6f3fdb76a3f9073a361cf37", - "sha256:f6b88c8d302c3dac8dff7766955e38d670c82e0d79edfc7eae47d6bb2c186594" - ], - "index": "pypi", - "version": "==1.2.1" - }, - "six": { - "hashes": [ - "sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", - "sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73" - ], - "version": "==1.12.0" - }, - "subprocess32": { - "hashes": [ - "sha256:24a7f627ef7a5695138601b665057ad131fa26e80d49d5ffa6b4fdb2357a80d3", - "sha256:6bc82992316eef3ccff319b5033809801c0c3372709c5f6985299c88ac7225c3" - ], - "version": "==3.5.3" - }, - "typing": { - "hashes": [ - "sha256:4027c5f6127a6267a435201981ba156de91ad0d1d98e9ddc2aa173453453492d", - "sha256:57dcf675a99b74d64dacf6fba08fb17cf7e3d5fdff53d4a30ea2a5e7e52543d4", - "sha256:a4c8473ce11a65999c8f59cb093e70686b6c84c98df58c1dae9b3b196089858a" - ], - "markers": "python_version < '3.5'", - "version": "==3.6.6" - }, - "xlsxwriter": { - "hashes": [ - "sha256:3a4e4a24a6753f046dc5a5e5bc5f443fce6a18988486885a258db6963eb54163", - "sha256:92a2ba339ca939815f0e125fcde728e94ccdb3e97e1acd3275ecf25a3cacfdc6" - ], - "index": "pypi", - "version": "==1.1.6" - } - }, - "develop": { - "alabaster": { - "hashes": [ - "sha256:446438bdcca0e05bd45ea2de1668c1d9b032e1a9154c2c259092d77031ddd359", - "sha256:a661d72d58e6ea8a57f7a86e37d86716863ee5e92788398526d58b26a4e4dc02" - ], - "version": "==0.7.12" - }, - "argh": { - "hashes": [ - "sha256:a9b3aaa1904eeb78e32394cd46c6f37ac0fb4af6dc488daa58971bdc7d7fcaf3", - "sha256:e9535b8c84dc9571a48999094fda7f33e63c3f1b74f3e5f3ac0105a58405bb65" - ], - "version": "==0.26.2" - }, - "atomicwrites": { - "hashes": [ - "sha256:03472c30eb2c5d1ba9227e4c2ca66ab8287fbfbbda3888aa93dc2e28fc6811b4", - "sha256:75a9445bac02d8d058d5e1fe689654ba5a6556a1dfd8ce6ec55a0ed79866cfa6" - ], - "version": "==1.3.0" - }, - "attrs": { - "hashes": [ - "sha256:69c0dbf2ed392de1cb5ec704444b08a5ef81680a61cb899dc08127123af36a79", - "sha256:f0b870f674851ecbfbbbd364d6b5cbdff9dcedbc7f3f5e18a6891057f21fe399" - ], - "version": "==19.1.0" - }, - "babel": { - "hashes": [ - "sha256:6778d85147d5d85345c14a26aada5e478ab04e39b078b0745ee6870c2b5cf669", - "sha256:8cba50f48c529ca3fa18cf81fa9403be176d374ac4d60738b839122dfaaa3d23" - ], - "version": "==2.6.0" - }, - "backports.functools-lru-cache": { - "hashes": [ - "sha256:9d98697f088eb1b0fa451391f91afb5e3ebde16bbdb272819fd091151fda4f1a", - "sha256:f0b0e4eba956de51238e17573b7087e852dfe9854afd2e9c873f73fc0ca0a6dd" - ], - "version": "==1.5" - }, - "backports.shutil-get-terminal-size": { - "hashes": [ - "sha256:0975ba55054c15e346944b38956a4c9cbee9009391e41b86c68990effb8c1f64", - "sha256:713e7a8228ae80341c70586d1cc0a8caa5207346927e23d09dcbcaf18eadec80" - ], - "version": "==1.0.0" - }, - "bandit": { - "hashes": [ - "sha256:6102b5d6afd9d966df5054e0bdfc2e73a24d0fea400ec25f2e54c134412158d7", - "sha256:9413facfe9de1e1bd291d525c784e1beb1a55c9916b51dae12979af63a69ba4c" - ], - "version": "==1.5.1" - }, - "bleach": { - "hashes": [ - "sha256:213336e49e102af26d9cde77dd2d0397afabc5a6bf2fed985dc35b5d1e285a16", - "sha256:3fdf7f77adcf649c9911387df51254b813185e32b2c6619f690b593a617e19fa" - ], - "version": "==3.1.0" - }, - "certifi": { - "hashes": [ - "sha256:59b7658e26ca9c7339e00f8f4636cdfe59d34fa37b9b04f6f9e9926b3cece1a5", - "sha256:b26104d6835d1f5e49452a26eb2ff87fe7090b89dfcaee5ea2212697e1e1d7ae" - ], - "version": "==2019.3.9" - }, - "chardet": { - "hashes": [ - "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", - "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" - ], - "version": "==3.0.4" - }, - "colorama": { - "hashes": [ - "sha256:05eed71e2e327246ad6b38c540c4a3117230b19679b875190486ddd2d721422d", - "sha256:f8ac84de7840f5b9c4e3347b3c1eaa50f7e49c2b07596221daec5edaabbd7c48" - ], - "version": "==0.4.1" - }, - "configparser": { - "hashes": [ - "sha256:8be81d89d6e7b4c0d4e44bcc525845f6da25821de80cb5e06e7e0238a2899e32", - "sha256:da60d0014fd8c55eb48c1c5354352e363e2d30bbf7057e5e171a468390184c75" - ], - "markers": "python_version == '2.7'", - "version": "==3.7.4" - }, - "coverage": { - "hashes": [ - "sha256:3684fabf6b87a369017756b551cef29e505cb155ddb892a7a29277b978da88b9", - "sha256:39e088da9b284f1bd17c750ac672103779f7954ce6125fd4382134ac8d152d74", - "sha256:3c205bc11cc4fcc57b761c2da73b9b72a59f8d5ca89979afb0c1c6f9e53c7390", - "sha256:465ce53a8c0f3a7950dfb836438442f833cf6663d407f37d8c52fe7b6e56d7e8", - "sha256:48020e343fc40f72a442c8a1334284620f81295256a6b6ca6d8aa1350c763bbe", - "sha256:5296fc86ab612ec12394565c500b412a43b328b3907c0d14358950d06fd83baf", - "sha256:5f61bed2f7d9b6a9ab935150a6b23d7f84b8055524e7be7715b6513f3328138e", - "sha256:68a43a9f9f83693ce0414d17e019daee7ab3f7113a70c79a3dd4c2f704e4d741", - "sha256:6b8033d47fe22506856fe450470ccb1d8ba1ffb8463494a15cfc96392a288c09", - "sha256:7ad7536066b28863e5835e8cfeaa794b7fe352d99a8cded9f43d1161be8e9fbd", - "sha256:7bacb89ccf4bedb30b277e96e4cc68cd1369ca6841bde7b005191b54d3dd1034", - "sha256:839dc7c36501254e14331bcb98b27002aa415e4af7ea039d9009409b9d2d5420", - "sha256:8f9a95b66969cdea53ec992ecea5406c5bd99c9221f539bca1e8406b200ae98c", - "sha256:932c03d2d565f75961ba1d3cec41ddde00e162c5b46d03f7423edcb807734eab", - "sha256:988529edadc49039d205e0aa6ce049c5ccda4acb2d6c3c5c550c17e8c02c05ba", - "sha256:998d7e73548fe395eeb294495a04d38942edb66d1fa61eb70418871bc621227e", - "sha256:9de60893fb447d1e797f6bf08fdf0dbcda0c1e34c1b06c92bd3a363c0ea8c609", - "sha256:9e80d45d0c7fcee54e22771db7f1b0b126fb4a6c0a2e5afa72f66827207ff2f2", - "sha256:a545a3dfe5082dc8e8c3eb7f8a2cf4f2870902ff1860bd99b6198cfd1f9d1f49", - "sha256:a5d8f29e5ec661143621a8f4de51adfb300d7a476224156a39a392254f70687b", - "sha256:aca06bfba4759bbdb09bf52ebb15ae20268ee1f6747417837926fae990ebc41d", - "sha256:bb23b7a6fd666e551a3094ab896a57809e010059540ad20acbeec03a154224ce", - "sha256:bfd1d0ae7e292105f29d7deaa9d8f2916ed8553ab9d5f39ec65bcf5deadff3f9", - "sha256:c62ca0a38958f541a73cf86acdab020c2091631c137bd359c4f5bddde7b75fd4", - "sha256:c709d8bda72cf4cd348ccec2a4881f2c5848fd72903c185f363d361b2737f773", - "sha256:c968a6aa7e0b56ecbd28531ddf439c2ec103610d3e2bf3b75b813304f8cb7723", - "sha256:df785d8cb80539d0b55fd47183264b7002077859028dfe3070cf6359bf8b2d9c", - "sha256:f406628ca51e0ae90ae76ea8398677a921b36f0bd71aab2099dfed08abd0322f", - "sha256:f46087bbd95ebae244a0eda01a618aff11ec7a069b15a3ef8f6b520db523dcf1", - "sha256:f8019c5279eb32360ca03e9fac40a12667715546eed5c5eb59eb381f2f501260", - "sha256:fc5f4d209733750afd2714e9109816a29500718b32dd9a5db01c0cb3a019b96a" - ], - "version": "==4.5.3" - }, - "coverage-space": { - "hashes": [ - "sha256:37e38169bceffe8fe836670203e4dc49e6d21cba66a6e77521b7dbe2821d9704", - "sha256:b9dde0f5a06433bc22a3f7457fc3cb292b4e8a763ba90644baf6230cb8fe1997" - ], - "index": "pypi", - "version": "==1.0.2.post1" - }, - "docopt": { - "hashes": [ - "sha256:49b3a825280bd66b3aa83585ef59c4a8c82f2c8a522dbe754a8bc8d08c85c491" - ], - "version": "==0.6.2" - }, - "docutils": { - "hashes": [ - "sha256:02aec4bd92ab067f6ff27a38a38a41173bf01bed8f89157768c1573f53e474a6", - "sha256:51e64ef2ebfb29cae1faa133b3710143496eca21c530f3f71424d77687764274", - "sha256:7a4bd47eaf6596e1295ecb11361139febe29b084a87bf005bf899f9a42edc3c6" - ], - "index": "pypi", - "version": "==0.14" - }, - "entrypoints": { - "hashes": [ - "sha256:589f874b313739ad35be6e0cd7efde2a4e9b6fea91edcc34e58ecbb8dbe56d19", - "sha256:c70dd71abe5a8c85e55e12c19bd91ccfeec11a6e99044204511f9ed547d48451" - ], - "version": "==0.3" - }, - "enum34": { - "hashes": [ - "sha256:2d81cbbe0e73112bdfe6ef8576f2238f2ba27dd0d55752a776c41d38b7da2850", - "sha256:644837f692e5f550741432dd3f223bbb9852018674981b1664e5dc339387588a", - "sha256:6bd0f6ad48ec2aa117d3d141940d484deccda84d4fcd884f5c3d93c23ecd8c79", - "sha256:8ad8c4783bf61ded74527bffb48ed9b54166685e4230386a9ed9b1279e2df5b1" - ], - "index": "pypi", - "markers": "python_version < '3.4'", - "version": "==1.1.6" - }, - "flake8": { - "hashes": [ - "sha256:859996073f341f2670741b51ec1e67a01da142831aa1fdc6242dbf88dffbe661", - "sha256:a796a115208f5c03b18f332f7c11729812c8c3ded6c46319c59b53efd3819da8" - ], - "index": "pypi", - "version": "==3.7.7" - }, - "flake8-bandit": { - "hashes": [ - "sha256:5eac24fa9fef532e4e4ce599c5b3c5248c5cc435d2927537b529b0a7bcb72467", - "sha256:be5840923ccf06cac6a8893a2f0abc17f03b6b9fdb5284d796f722b69c8f840b" - ], - "index": "pypi", - "version": "==2.1.0" - }, - "flake8-docstrings": { - "hashes": [ - "sha256:4e0ce1476b64e6291520e5570cf12b05016dd4e8ae454b8a8a9a48bc5f84e1cd", - "sha256:8436396b5ecad51a122a2c99ba26e5b4e623bf6e913b0fea0cb6c2c4050f91eb" - ], - "index": "pypi", - "version": "==1.3.0" - }, - "flake8-polyfill": { - "hashes": [ - "sha256:12be6a34ee3ab795b19ca73505e7b55826d5f6ad7230d31b18e106400169b9e9", - "sha256:e44b087597f6da52ec6393a709e7108b2905317d0c0b744cdca6208e670d8eda" - ], - "version": "==1.0.2" - }, - "flake8-rst-docstrings": { - "hashes": [ - "sha256:3a5b92b40e87006f8e95bfc5082577414cd387ca24def37ecf1fcd9b3ce7273c" - ], - "index": "pypi", - "version": "==0.0.8" - }, - "freezegun": { - "hashes": [ - "sha256:6cb82b276f83f2acce67f121dc2656f4df26c71e32238334eb071170b892a278", - "sha256:e839b43bfbe8158b4d62bb97e6313d39f3586daf48e1314fb1083d2ef17700da" - ], - "index": "pypi", - "version": "==0.3.11" - }, - "funcsigs": { - "hashes": [ - "sha256:330cc27ccbf7f1e992e69fef78261dc7c6569012cf397db8d3de0234e6c937ca", - "sha256:a7bb0f2cf3a3fd1ab2732cb49eba4252c2af4240442415b4abce3b87022a8f50" - ], - "index": "pypi", - "version": "==1.0.2" - }, - "functools32": { - "hashes": [ - "sha256:89d824aa6c358c421a234d7f9ee0bd75933a67c29588ce50aaa3acdf4d403fa0", - "sha256:f6253dfbe0538ad2e387bd8fdfd9293c925d63553f5813c4e587745416501e6d" - ], - "markers": "python_version < '3.2'", - "version": "==3.2.3.post2" - }, - "futures": { - "hashes": [ - "sha256:9ec02aa7d674acb8618afb127e27fde7fc68994c0437ad759fa094a574adb265", - "sha256:ec0a6cb848cc212002b9828c3e34c675e0c9ff6741dc445cab6fdd4e1085d1f1" - ], - "index": "pypi", - "version": "==3.2.0" - }, - "gitdb2": { - "hashes": [ - "sha256:83361131a1836661a155172932a13c08bda2db3674e4caa32368aa6eb02f38c2", - "sha256:e3a0141c5f2a3f635c7209d56c496ebe1ad35da82fe4d3ec4aaa36278d70648a" - ], - "version": "==2.0.5" - }, - "gitpython": { - "hashes": [ - "sha256:563221e5a44369c6b79172f455584c9ebbb122a13368cc82cb4b5addff788f82", - "sha256:8237dc5bfd6f1366abeee5624111b9d6879393d84745a507de0fda86043b65a8" - ], - "version": "==2.1.11" - }, - "idna": { - "hashes": [ - "sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407", - "sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c" - ], - "version": "==2.8" - }, - "imagesize": { - "hashes": [ - "sha256:3f349de3eb99145973fefb7dbe38554414e5c30abd0c8e4b970a7c9d09f3a1d8", - "sha256:f3832918bc3c66617f92e35f5d70729187676313caa60c187eb0f28b8fe5e3b5" - ], - "version": "==1.1.0" - }, - "jinja2": { - "hashes": [ - "sha256:065c4f02ebe7f7cf559e49ee5a95fb800a9e4528727aec6f24402a5374c65013", - "sha256:14dd6caf1527abb21f08f86c784eac40853ba93edb79552aa1e4b8aef1b61c7b" - ], - "version": "==2.10.1" - }, - "livereload": { - "hashes": [ - "sha256:29cadfabcedd12eed792e0131991235b9d4764d4474bed75cf525f57109ec0a2", - "sha256:e632a6cd1d349155c1d7f13a65be873b38f43ef02961804a1bba8d817fa649a7" - ], - "version": "==2.6.0" - }, - "macfsevents": { - "hashes": [ - "sha256:1324b66b356051de662ba87d84f73ada062acd42b047ed1246e60a449f833e10" - ], - "index": "pypi", - "markers": "sys_platform == 'darwin'", - "version": "==0.8.1" - }, - "markupsafe": { - "hashes": [ - "sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473", - "sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161", - "sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235", - "sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5", - "sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff", - "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b", - "sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1", - "sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e", - "sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183", - "sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66", - "sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1", - "sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1", - "sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e", - "sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b", - "sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905", - "sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735", - "sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d", - "sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e", - "sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d", - "sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c", - "sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21", - "sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2", - "sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5", - "sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b", - "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6", - "sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f", - "sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f", - "sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7" - ], - "version": "==1.1.1" - }, - "mccabe": { - "hashes": [ - "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", - "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f" - ], - "version": "==0.6.1" - }, - "more-itertools": { - "hashes": [ - "sha256:38a936c0a6d98a38bcc2d03fdaaedaba9f412879461dd2ceff8d37564d6522e4", - "sha256:c0a5785b1109a6bd7fac76d6837fd1feca158e54e521ccd2ae8bfe393cc9d4fc", - "sha256:fe7a7cae1ccb57d33952113ff4fa1bc5f879963600ed74918f1236e212ee50b9" - ], - "markers": "python_version <= '2.7'", - "version": "==5.0.0" - }, - "nose": { - "hashes": [ - "sha256:9ff7c6cc443f8c51994b34a667bbcf45afd6d945be7477b52e97516fd17c53ac", - "sha256:dadcddc0aefbf99eea214e0f1232b94f2fa9bd98fa8353711dacb112bfcbbb2a", - "sha256:f1bffef9cbc82628f6e7d7b40d7e255aefaa1adb6a1b1d26c69a8b79e6208a98" - ], - "version": "==1.3.7" - }, - "packaging": { - "hashes": [ - "sha256:0c98a5d0be38ed775798ece1b9727178c4469d9c3b4ada66e8e6b7849f8732af", - "sha256:9e1cbf8c12b1f1ce0bb5344b8d7ecf66a6f8a6e91bcb0c84593ed6d3ab5c4ab3" - ], - "version": "==19.0" - }, - "pathlib2": { - "hashes": [ - "sha256:25199318e8cc3c25dcb45cbe084cc061051336d5a9ea2a12448d3d8cb748f742", - "sha256:5887121d7f7df3603bca2f710e7219f3eca0eb69e0b7cc6e0a022e155ac931a7" - ], - "index": "pypi", - "version": "==2.3.3" - }, - "pathtools": { - "hashes": [ - "sha256:7c35c5421a39bb82e58018febd90e3b6e5db34c5443aaaf742b3f33d4655f1c0" - ], - "version": "==0.1.2" - }, - "pbr": { - "hashes": [ - "sha256:8257baf496c8522437e8a6cfe0f15e00aedc6c0e0e7c9d55eeeeab31e0853843", - "sha256:8c361cc353d988e4f5b998555c88098b9d5964c2e11acf7b0d21925a66bb5824" - ], - "version": "==5.1.3" - }, - "pkginfo": { - "hashes": [ - "sha256:7424f2c8511c186cd5424bbf31045b77435b37a8d604990b79d4e70d741148bb", - "sha256:a6d9e40ca61ad3ebd0b72fbadd4fba16e4c0e4df0428c041e01e06eb6ee71f32" - ], - "version": "==1.5.0.1" - }, - "pluggy": { - "hashes": [ - "sha256:19ecf9ce9db2fce065a7a0586e07cfb4ac8614fe96edf628a264b1c70116cf8f", - "sha256:84d306a647cc805219916e62aab89caa97a33a1dd8c342e87a37f91073cd4746" - ], - "version": "==0.9.0" - }, - "port-for": { - "hashes": [ - "sha256:b16a84bb29c2954db44c29be38b17c659c9c27e33918dec16b90d375cc596f1c" - ], - "version": "==0.3.1" - }, - "py": { - "hashes": [ - "sha256:64f65755aee5b381cea27766a3a147c3f15b9b6b9ac88676de66ba2ae36793fa", - "sha256:dc639b046a6e2cff5bbe40194ad65936d6ba360b52b3c3fe1d08a82dd50b5e53" - ], - "version": "==1.8.0" - }, - "pycodestyle": { - "hashes": [ - "sha256:95a2219d12372f05704562a14ec30bc76b05a5b297b21a5dfe3f6fac3491ae56", - "sha256:e40a936c9a450ad81df37f549d676d127b1b66000a6c500caa2b085bc0ca976c" - ], - "version": "==2.5.0" - }, - "pydocstyle": { - "hashes": [ - "sha256:2258f9b0df68b97bf3a6c29003edc5238ff8879f1efb6f1999988d934e432bd8", - "sha256:5741c85e408f9e0ddf873611085e819b809fca90b619f5fd7f34bd4959da3dd4", - "sha256:ed79d4ec5e92655eccc21eb0c6cf512e69512b4a97d215ace46d17e4990f2039" - ], - "index": "pypi", - "version": "==3.0.0" - }, - "pyflakes": { - "hashes": [ - "sha256:17dbeb2e3f4d772725c777fabc446d5634d1038f234e77343108ce445ea69ce0", - "sha256:d976835886f8c5b31d47970ed689944a0262b5f3afa00a5a7b4dc81e5449f8a2" - ], - "version": "==2.1.1" - }, - "pygments": { - "hashes": [ - "sha256:5ffada19f6203563680669ee7f53b64dabbeb100eb51b61996085e99c03b284a", - "sha256:e8218dd399a61674745138520d0d4cf2621d7e032439341bc3f647bff125818d" - ], - "index": "pypi", - "version": "==2.3.1" - }, - "pyparsing": { - "hashes": [ - "sha256:1873c03321fc118f4e9746baf201ff990ceb915f433f23b395f5580d1840cb2a", - "sha256:9b6323ef4ab914af344ba97510e966d64ba91055d6b9afa6b30799340e89cc03" - ], - "version": "==2.4.0" - }, - "pytest": { - "hashes": [ - "sha256:13c5e9fb5ec5179995e9357111ab089af350d788cbc944c628f3cde72285809b", - "sha256:f21d2f1fb8200830dcbb5d8ec466a9c9120e20d8b53c7585d180125cce1d297a" - ], - "index": "pypi", - "version": "==4.4.0" - }, - "pytest-cov": { - "hashes": [ - "sha256:0ab664b25c6aa9716cbf203b17ddb301932383046082c081b9848a0edf5add33", - "sha256:230ef817450ab0699c6cc3c9c8f7a829c34674456f2ed8df1fe1d39780f7c87f" - ], - "index": "pypi", - "version": "==2.6.1" - }, - "pytest-describe": { - "hashes": [ - "sha256:569bda96401fe512f4f345f33fd23fa4d718639d42afac62bc03254b5f2b3fdf" - ], - "index": "pypi", - "version": "==0.12.0" - }, - "pytest-expecter": { - "hashes": [ - "sha256:1c8e9ab98ddd576436b61a7ba61ea11cfa5a3fc6b00288ce9e91e9dd770daf19", - "sha256:27c93dfe87e2f4d28c525031be68d3f89457e3315241d97ee15f7689544e0e37" - ], - "index": "pypi", - "version": "==1.3" - }, - "pytest-random": { - "hashes": [ - "sha256:92f25db8c5d9ffc20d90b51997b914372d6955cb9cf1f6ead45b90514fc0eddd" - ], - "index": "pypi", - "version": "==0.2" - }, - "python-dateutil": { - "hashes": [ - "sha256:7e6584c74aeed623791615e26efd690f29817a27c73085b78e4bad02493df2fb", - "sha256:c89805f6f4d64db21ed966fda138f8a5ed7a4fdbc1a8ee329ce1b74e3c74da9e" - ], - "version": "==2.8.0" - }, - "python-termstyle": { - "hashes": [ - "sha256:6faf42ba42f2826c38cf70dacb3ac51f248a418e48afc0e36593df11cf3ab1d2", - "sha256:f42a6bb16fbfc5e2c66d553e7ad46524ea833872f75ee5d827c15115fafc94e2" - ], - "version": "==0.1.10" - }, - "pytz": { - "hashes": [ - "sha256:303879e36b721603cc54604edcac9d20401bdbe31e1e4fdee5b9f98d5d31dfda", - "sha256:d747dd3d23d77ef44c6a3526e274af6efeb0a6f1afd5a69ba4d5be4098c8e141" - ], - "version": "==2019.1" - }, - "pyyaml": { - "hashes": [ - "sha256:1adecc22f88d38052fb787d959f003811ca858b799590a5eaa70e63dca50308c", - "sha256:436bc774ecf7c103814098159fbb84c2715d25980175292c648f2da143909f95", - "sha256:460a5a4248763f6f37ea225d19d5c205677d8d525f6a83357ca622ed541830c2", - "sha256:5a22a9c84653debfbf198d02fe592c176ea548cccce47553f35f466e15cf2fd4", - "sha256:7a5d3f26b89d688db27822343dfa25c599627bc92093e788956372285c6298ad", - "sha256:9372b04a02080752d9e6f990179a4ab840227c6e2ce15b95e1278456664cf2ba", - "sha256:a5dcbebee834eaddf3fa7366316b880ff4062e4bcc9787b78c7fbb4a26ff2dd1", - "sha256:aee5bab92a176e7cd034e57f46e9df9a9862a71f8f37cad167c6fc74c65f5b4e", - "sha256:c51f642898c0bacd335fc119da60baae0824f2cde95b0330b56c0553439f0673", - "sha256:c68ea4d3ba1705da1e0d85da6684ac657912679a649e8868bd850d2c299cce13", - "sha256:e23d0cc5299223dcc37885dae624f382297717e459ea24053709675a976a3e19" - ], - "version": "==5.1" - }, - "readme-renderer": { - "hashes": [ - "sha256:bb16f55b259f27f75f640acf5e00cf897845a8b3e4731b5c1a436e4b8529202f", - "sha256:c8532b79afc0375a85f10433eca157d6b50f7d6990f337fa498c96cd4bfc203d" - ], - "version": "==24.0" - }, - "requests": { - "hashes": [ - "sha256:502a824f31acdacb3a35b6690b5fbf0bc41d63a24a45c4004352b0242707598e", - "sha256:7bf2a778576d825600030a110f3c0e3e8edc51dfaafe1c146e39a2027784957b" - ], - "version": "==2.21.0" - }, - "requests-toolbelt": { - "hashes": [ - "sha256:380606e1d10dc85c3bd47bf5a6095f815ec007be7a8b69c878507068df059e6f", - "sha256:968089d4584ad4ad7c171454f0a5c6dac23971e9472521ea3b6d49d610aa6fc0" - ], - "version": "==0.9.1" - }, - "restructuredtext-lint": { - "hashes": [ - "sha256:97b3da356d5b3a8514d8f1f9098febd8b41463bed6a1d9f126cf0a048b6fd908" - ], - "version": "==1.3.0" - }, - "scandir": { - "hashes": [ - "sha256:2586c94e907d99617887daed6c1d102b5ca28f1085f90446554abf1faf73123e", - "sha256:2ae41f43797ca0c11591c0c35f2f5875fa99f8797cb1a1fd440497ec0ae4b022", - "sha256:2b8e3888b11abb2217a32af0766bc06b65cc4a928d8727828ee68af5a967fa6f", - "sha256:2c712840c2e2ee8dfaf36034080108d30060d759c7b73a01a52251cc8989f11f", - "sha256:4d4631f6062e658e9007ab3149a9b914f3548cb38bfb021c64f39a025ce578ae", - "sha256:67f15b6f83e6507fdc6fca22fedf6ef8b334b399ca27c6b568cbfaa82a364173", - "sha256:7d2d7a06a252764061a020407b997dd036f7bd6a175a5ba2b345f0a357f0b3f4", - "sha256:8c5922863e44ffc00c5c693190648daa6d15e7c1207ed02d6f46a8dcc2869d32", - "sha256:92c85ac42f41ffdc35b6da57ed991575bdbe69db895507af88b9f499b701c188", - "sha256:b24086f2375c4a094a6b51e78b4cf7ca16c721dcee2eddd7aa6494b42d6d519d", - "sha256:cb925555f43060a1745d0a321cca94bcea927c50114b623d73179189a4e100ac" - ], - "index": "pypi", - "version": "==1.10.0" - }, - "singledispatch": { - "hashes": [ - "sha256:5b06af87df13818d14f08a028e42f566640aef80805c3b50c5056b086e3c2b9c", - "sha256:833b46966687b3de7f438c761ac475213e53b306740f1abfaa86e1d1aae56aa8" - ], - "index": "pypi", - "version": "==3.4.0.3" - }, - "six": { - "hashes": [ - "sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", - "sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73" - ], - "version": "==1.12.0" - }, - "smmap2": { - "hashes": [ - "sha256:0555a7bf4df71d1ef4218e4807bbf9b201f910174e6e08af2e138d4e517b4dde", - "sha256:29a9ffa0497e7f2be94ca0ed1ca1aa3cd4cf25a1f6b4f5f87f74b46ed91d609a" - ], - "version": "==2.0.5" - }, - "sniffer": { - "hashes": [ - "sha256:e8a0daa4c51dff3d00482b45dc9b978159100a8d5a7df327c28ed96586559970", - "sha256:e90c1ad4bd3c31a5fad8e03d45dfc83377b31420aa0779f17280c817ce0c9dd8" - ], - "index": "pypi", - "version": "==0.4.0" - }, - "snowballstemmer": { - "hashes": [ - "sha256:919f26a68b2c17a7634da993d91339e288964f93c274f1343e3bbbe2096e1128", - "sha256:9f3bcd3c401c3e862ec0ebe6d2c069ebc012ce142cce209c098ccb5b09136e89" - ], - "version": "==1.2.1" - }, - "sphinx": { - "hashes": [ - "sha256:95acd6648902333647a0e0564abdb28a74b0a76d2333148aa35e5ed1f56d3c4b", - "sha256:c091dbdd5cc5aac6eb95d591a819fd18bccec90ffb048ec465b165a48b839b45" - ], - "index": "pypi", - "version": "==1.8.0" - }, - "sphinx-autobuild": { - "hashes": [ - "sha256:66388f81884666e3821edbe05dd53a0cfb68093873d17320d0610de8db28c74e", - "sha256:e60aea0789cab02fa32ee63c7acae5ef41c06f1434d9fd0a74250a61f5994692" - ], - "index": "pypi", - "version": "==0.7.1" - }, - "sphinx-rtd-theme": { - "hashes": [ - "sha256:00cf895504a7895ee433807c62094cf1e95f065843bf3acd17037c3e9a2becd4", - "sha256:728607e34d60456d736cc7991fd236afb828b21b82f956c5ea75f94c8414040a" - ], - "index": "pypi", - "version": "==0.4.3" - }, - "sphinxcontrib-websupport": { - "hashes": [ - "sha256:68ca7ff70785cbe1e7bccc71a48b5b6d965d79ca50629606c7861a21b206d9dd", - "sha256:9de47f375baf1ea07cdb3436ff39d7a9c76042c10a769c52353ec46e4e8fc3b9" - ], - "version": "==1.1.0" - }, - "stevedore": { - "hashes": [ - "sha256:7be098ff53d87f23d798a7ce7ae5c31f094f3deb92ba18059b1aeb1ca9fec0a0", - "sha256:7d1ce610a87d26f53c087da61f06f9b7f7e552efad2a7f6d2322632b5f932ea2" - ], - "version": "==1.30.1" - }, - "tornado": { - "hashes": [ - "sha256:0662d28b1ca9f67108c7e3b77afabfb9c7e87bde174fbda78186ecedc2499a9d", - "sha256:4e5158d97583502a7e2739951553cbd88a72076f152b4b11b64b9a10c4c49409", - "sha256:732e836008c708de2e89a31cb2fa6c0e5a70cb60492bee6f1ea1047500feaf7f", - "sha256:8154ec22c450df4e06b35f131adc4f2f3a12ec85981a203301d310abf580500f", - "sha256:8e9d728c4579682e837c92fdd98036bd5cdefa1da2aaf6acf26947e6dd0c01c5", - "sha256:d4b3e5329f572f055b587efc57d29bd051589fb5a43ec8898c77a47ec2fa2bbb", - "sha256:e5f2585afccbff22390cddac29849df463b252b711aa2ce7c5f3f342a5b3b444" - ], - "version": "==5.1.1" - }, - "tqdm": { - "hashes": [ - "sha256:d385c95361699e5cf7622485d9b9eae2d4864b21cd5a2374a9c381ffed701021", - "sha256:e22977e3ebe961f72362f6ddfb9197cc531c9737aaf5f607ef09740c849ecd05" - ], - "version": "==4.31.1" - }, - "twine": { - "hashes": [ - "sha256:0fb0bfa3df4f62076cab5def36b1a71a2e4acb4d1fa5c97475b048117b1a6446", - "sha256:d6c29c933ecfc74e9b1d9fa13aa1f87c5d5770e119f5a4ce032092f0ff5b14dc" - ], - "index": "pypi", - "version": "==1.13.0" - }, - "typing": { - "hashes": [ - "sha256:4027c5f6127a6267a435201981ba156de91ad0d1d98e9ddc2aa173453453492d", - "sha256:57dcf675a99b74d64dacf6fba08fb17cf7e3d5fdff53d4a30ea2a5e7e52543d4", - "sha256:a4c8473ce11a65999c8f59cb093e70686b6c84c98df58c1dae9b3b196089858a" - ], - "markers": "python_version < '3.5'", - "version": "==3.6.6" - }, - "urllib3": { - "hashes": [ - "sha256:61bf29cada3fc2fbefad4fdf059ea4bd1b4a86d2b6d15e1c7c0b582b9752fe39", - "sha256:de9529817c93f27c8ccbfead6985011db27bd0ddfcdb2d86f3f663385c6a9c22" - ], - "version": "==1.24.1" - }, - "watchdog": { - "hashes": [ - "sha256:965f658d0732de3188211932aeb0bb457587f04f63ab4c1e33eab878e9de961d" - ], - "version": "==0.9.0" - }, - "webencodings": { - "hashes": [ - "sha256:a0af1213f3c2226497a97e2b3aa01a7e4bee4f403f95be16fc9acd2947514a78", - "sha256:b36a1c245f2d304965eb4e0a82848379241dc04b865afcc4aab16748587e1923" - ], - "version": "==0.5.1" - }, - "wheel": { - "hashes": [ - "sha256:66a8fd76f28977bb664b098372daef2b27f60dc4d1688cfab7b37a09448f0e9d", - "sha256:8eb4a788b3aec8abf5ff68d4165441bc57420c9f64ca5f471f58c3969fe08668" - ], - "index": "pypi", - "version": "==0.33.1" - } - } -} From 2455964fcea467522b3f800aa450c72d8fae8880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grega=20Vrban=C4=8Di=C4=8D?= Date: Mon, 15 Apr 2019 09:47:51 +0200 Subject: [PATCH 23/24] fix --- NiaPy/tests/conftest.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/NiaPy/tests/conftest.py b/NiaPy/tests/conftest.py index e6ccfbe3..a07763af 100644 --- a/NiaPy/tests/conftest.py +++ b/NiaPy/tests/conftest.py @@ -7,16 +7,16 @@ def pytest_configure(config): """Disable verbose output when running tests.""" logging.basicConfig(level=logging.DEBUG) - terminal = config.pluginmanager.getplugin('terminal') - base = terminal.TerminalReporter +# terminal = config.pluginmanager.getplugin('terminal') +# base = terminal.TerminalReporter - class QuietReporter(base): - """Reporter that only shows dots when running tests.""" +# class QuietReporter(base): +# """Reporter that only shows dots when running tests.""" - def __init__(self, *args, **kwargs): - super(QuietReporter, self).__init__(*args, **kwargs) - self.verbosity = 0 - self.showlongtestinfo = False - self.showfspath = False +# def __init__(self, *args, **kwargs): +# super(QuietReporter, self).__init__(*args, **kwargs) +# self.verbosity = 0 +# self.showlongtestinfo = False +# self.showfspath = False - terminal.TerminalReporter = QuietReporter +# terminal.TerminalReporter = QuietReporter From 2347dfd3cb61edc22df2be213b59000a02e0fb35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grega=20Vrban=C4=8Di=C4=8D?= Date: Mon, 15 Apr 2019 10:31:03 +0200 Subject: [PATCH 24/24] unit test fixes --- NiaPy/benchmarks/michalewichz.py | 2 +- NiaPy/benchmarks/perm.py | 4 ++-- NiaPy/benchmarks/weierstrass.py | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/NiaPy/benchmarks/michalewichz.py b/NiaPy/benchmarks/michalewichz.py index 045ffc7e..86aeccf4 100644 --- a/NiaPy/benchmarks/michalewichz.py +++ b/NiaPy/benchmarks/michalewichz.py @@ -61,7 +61,7 @@ def __init__(self, Lower=0.0, Upper=pi, m=10): """ Benchmark.__init__(self, Lower, Upper) - self.m = m + Michalewichz.m = m @staticmethod def latex_code(): diff --git a/NiaPy/benchmarks/perm.py b/NiaPy/benchmarks/perm.py index fd3aa11d..d1be13a6 100644 --- a/NiaPy/benchmarks/perm.py +++ b/NiaPy/benchmarks/perm.py @@ -52,7 +52,7 @@ def __init__(self, D=10.0, beta=0.5): Args: D [float] -- Dimension on problem. (default: {10.0}) - beta [float] -- beat parameter. (default: {0.5}) + beta [float] -- beta parameter. (default: {0.5}) See Also: :func:`NiaPy.benchmarks.Benchmark.__init__` @@ -60,7 +60,7 @@ def __init__(self, D=10.0, beta=0.5): """ Benchmark.__init__(self, -D, D) - self.beta = beta + Perm.beta = beta @staticmethod def latex_code(): diff --git a/NiaPy/benchmarks/weierstrass.py b/NiaPy/benchmarks/weierstrass.py index 7de07ae7..8dfb2df0 100644 --- a/NiaPy/benchmarks/weierstrass.py +++ b/NiaPy/benchmarks/weierstrass.py @@ -56,9 +56,9 @@ def __init__(self, Lower=-100.0, Upper=100.0, a=0.5, b=3, k_max=20): """ Benchmark.__init__(self, Lower, Upper) - self.a = a - self.b = b - self.k_max = k_max + Weierstrass.a = a + Weierstrass.b = b + Weierstrass.k_max = k_max @staticmethod def latex_code():