Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the optimizer available using fpm #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

fedebenelli
Copy link

Hi! I've seen your code and it can be really useful in some of my works. I've did some editions to it to make it able to use it as a dependency with the Fortran Package Manager fpm, this will be helpful for me and other users that want to use your code in their work.

Besides that compatibility, I did some minor changes to make it easier to use in other projects. Now the optimizer routine is included in a module instead of being a main program, and receives the desired fitness function as an argument. An usage example can be seen at the new directory example:

program main
    use fitness_example, only: fitness
    use PSOclassicG, only: pso
    use iso_fortran_env, only: pr => real64

    real(pr) :: x(30), xmin(30), xmax(30)

    xmax = 30
    xmin = -30
    call pso(fitness, x, psize=30, verbose=.true., xmin=xmin, xmax=xmax)
end program main

With fpm installed an user can try this example by running fpm run --example inside the repo folder.

Other way of using it is making a fpm project and including this package as a dependency in the fpm.toml manifest file

[dependencies]
Particle-Swarm-Optimization-Fortran-95 = {git =https://github.com/zaman13/Particle-Swarm-Optimization-Fortran-95 }

Without downloading anything manually now the optimizer can be available to call in another project.

I don't know much details of the algorithm itself, but this could be further improved to have a nice package for other users :)

@fedebenelli
Copy link
Author

More work can be done, but I avoided touching the code as much as I could since I'm not an expert of the algorithm itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant