Skip to main content

A python impletation of NCS-C.

Project description

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: sustech_ncs-0.0.7.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.7.tar.gz
Algorithm Hash digest
SHA256 dce649841c91a0f379dabfba4eed0e9beb01d905dc5c24f838f66e670b840ec2
MD5 722cc54ead325dae1a6fd2fdf621d365
BLAKE2b-256 37f8bff76f77477a258cf878e32945f673f172480ef07b43a09ed7c2137853c9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sustech_ncs-0.0.7-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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f52597baa91b06ee0fbf9d40b0b8578320275ba95df4004a3d37dae752f76a97
MD5 4403389d28c63eb94a0764ea55428722
BLAKE2b-256 4e9868ed34ba78f365361408de0e8363ba9d459458239483631f1fab709cfe72

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