A python impletation of NCS-C.
Project description
A python impletation of NCS-C.
参考文献:
K. Tang, P. Yang and X. Yao, "Negatively Correlated Search," in IEEE Journal on Selected Areas in Communications, vol. 34, no. 3, pp. 542-550, March 2016, doi: 10.1109/JSAC.2016.2525458.
算法包sustech_ncs下,NCS是NCS-C的多进程并行加速的实现,NCS_noMul是未进行多进程加速的版本,NCS_asym是加入了非对称优化的实现版本。
使用示例:
import numpy as np
# import optproblems.cec2005 as benchmark
import opfunu.cec_based.cec2005 as benchmark
from sustech_ncs import NCS
if __name__=='__main__':
dimension0=30
pop_size0=10 #
sigma0=0.2 # 注意sigma不能是整数
r0=0.80 #
epoch0=10 #
T0=30000
scope = np.array([[-np.pi, np.pi]] * dimension0)
# 选择测试使用的fitness function
function=benchmark.F122005(ndim=dimension0).evaluate # opfunu
# function=benchmark.F1(num_variables=dimension0) # optproblems
optimizer = NCS(function, dimensions=dimension0, pop_size=pop_size0, sigma=np.full(pop_size0, sigma0), r=r0, epoch=epoch0, T_max=T0 ,scope=scope)
best_solution, best_f_solution = optimizer.NCS_run()
print("Best solution found by NCS:", best_solution)
print("Objective function value:", best_f_solution)
print(f"Function: {optimizer.objective_function_individual}, \n"
f"Dimensions: {optimizer.dimensions}, Population Size: {optimizer.pop_size}, Sigma: {sigma0}, \n"
f"R: {optimizer.r}, Epoch: {optimizer.epoch}, T_max: {optimizer.T_max}, "
f"Scope: {optimizer.scope[0]}")
# # opfunu用法
# dimension = 10
# problem = benchmark.F12005(dimension)
# solution = [0.1] * dimension
# value = problem.evaluate(solution)
# print(value)
# # optproblems用法
# dimension = 10
# problem = benchmark.F1(dimension)
# solution = [0.1] * dimension
# value = problem(solution)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sustech_ncs-0.0.5.tar.gz.
File metadata
- Download URL: sustech_ncs-0.0.5.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
caa88ea3561f00283d9322cf94ce93930db8564fb33b3f8444112cde9b82d4ff
|
|
| MD5 |
f17f9daac9cd9660a8261c1c36f87473
|
|
| BLAKE2b-256 |
982a943af7d9a82745e905d18720a08717a99ab694b96dfc273274a1f1422279
|
File details
Details for the file sustech_ncs-0.0.5-py3-none-any.whl.
File metadata
- Download URL: sustech_ncs-0.0.5-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7f95bdb4b428e34f33555c5ebe8677c066cdeea4ed5f285fd8ecbd0250d4c4d
|
|
| MD5 |
0d8e4085135479c7446e7f591b9239a7
|
|
| BLAKE2b-256 |
03430d0a9e773d0984b026e841f188f079ddfb3562cdd05c33a34d00bf18070d
|