Skip to main content

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

sustech_ncs-0.0.5.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sustech_ncs-0.0.5-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

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

Hashes for sustech_ncs-0.0.5.tar.gz
Algorithm Hash digest
SHA256 caa88ea3561f00283d9322cf94ce93930db8564fb33b3f8444112cde9b82d4ff
MD5 f17f9daac9cd9660a8261c1c36f87473
BLAKE2b-256 982a943af7d9a82745e905d18720a08717a99ab694b96dfc273274a1f1422279

See more details on using hashes here.

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

Hashes for sustech_ncs-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d7f95bdb4b428e34f33555c5ebe8677c066cdeea4ed5f285fd8ecbd0250d4c4d
MD5 0d8e4085135479c7446e7f591b9239a7
BLAKE2b-256 03430d0a9e773d0984b026e841f188f079ddfb3562cdd05c33a34d00bf18070d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page