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.6.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.6-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file sustech_ncs-0.0.6.tar.gz.

File metadata

  • Download URL: sustech_ncs-0.0.6.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.6.tar.gz
Algorithm Hash digest
SHA256 5bb3ae0dc99150b8cb4acc234dc4b0cfa34097cefa87b83f6813c5629bee0cd0
MD5 09a023899999dece333d5e4fe028cf5a
BLAKE2b-256 2978ec0137ea94d18ea29c36818c3338df5b701a6467d0aa31de2c9734a56024

See more details on using hashes here.

File details

Details for the file sustech_ncs-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: sustech_ncs-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 9.7 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 5356df5ec590155274ba7a42c2009efa8c6671f9402ecb9c9f4382be989a7906
MD5 87471bca52267f6beb86726f2db458ef
BLAKE2b-256 a174ef0d00dcefa0157ed890746ef5b5702ce0e977892ec69d6f2e58fb3de1dc

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