ljvmiranda921 / pyswarms

A research toolkit for particle swarm optimization in Python
https://pyswarms.readthedocs.io/en/latest/
MIT License
1.28k stars 332 forks source link

Mixed Integer and Continuous variables #342

Closed resetscoder closed 5 years ago

resetscoder commented 5 years ago

Is your feature request related to a problem? Please describe. Hi! I am currently working on a plant Layout Optimization Problem, which is in my case a non-convex MINLP - Mixed Integer Non-Linear Programming problem. PSO could be well suited to my problem but I have to work with both integer and continuous variants. Currently PySwarms is implemented with only binary or only continuous variants.

Describe the solution you'd like One of the solution in the literature is to keep the main PSO algorithm and velocity updating process, and at any iteration after finding the new position of particles, appropriate variables can be made discrete by finding the nearest discrete value to the current continuous variable.

May I interact with the swarm array for example in the opt_func ? Or should code my own PSO optimization loop ?

def opt_func(X):
    n_particles = X.shape[0]  # number of particles

    #HERE MODIFY THE SWARM ARRAY X

    #calculate cost
    co = [cout(X[i],CC,CH,dimensions) for i in range(n_particles)]
    return np.array(co)

Thank you !

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

whzup commented 4 years ago

@resetscoder Please see #400