GithubHelp home page GithubHelp logo

jacobwilliams / pikaia Goto Github PK

View Code? Open in Web Editor NEW
35.0 12.0 13.0 1.52 MB

Modern Fortran Edition of the Pikaia Genetic Algorithm

License: Other

Fortran 100.00%
fortran optimization genetic-algorithm numerical-optimization pikaia fortran-package-manager

pikaia's Introduction

pikaia

Pikaia: Modern Fortran Edition of the PIKAIA Genetic Algorithm

Status

Language GitHub release CI Status codecov last-commit

Overview

This is a refactoring of the PIKAIA unconstrained optimization code from the High Altitude Observatory. The original code is public domain and was written by Paul Charbonneau & Barry Knapp. The new code differs from the old code in the following respects:

  • The original fixed-form source (FORTRAN 77) was converted to free-form source.
  • The code is now object-oriented Fortran 2003/2008. All user interaction is now through the pikaia_class.
  • All real variables are now double precision.
  • The original random number generator was replaced with MT19937-64 (64-bit Mersenne Twister).
  • There are various new options (e.g., a convergence window with a tolerance can be specified as a stopping condition, and the user can specify a subroutine for reporting iterations).
  • Mapping the variables to be between 0 and 1 now occurs internally, rather than requiring the user to do it.
  • Can now include an initial guess in the initial population.
  • Some OpenMP support has been added.

Compiling

The library can be built with the Fortran Package Manager using the provided fpm.toml file like so:

fpm build --release

To use Pikaia within your fpm project, add the following to your fpm.toml file:

[dependencies]
pikaia = { git="https://github.com/jacobwilliams/pikaia.git" }

Or to use a specific version:

[dependencies]
pikaia = { git="https://github.com/jacobwilliams/pikaia.git", tag = "1.0.1" }

The mersenne-twister-fortran library is required to compile Pikaia. FPM will automatically download this library.

Examples

  • An example use of Pikaia can be found here.

Documentation

  • The API documentation for the current master branch can be found here. This is generated by processing the source files with FORD. Note that the shell script will also generate these files automatically in the doc folder, assuming you have FORD installed.
  • The original Pikaia documentation (for v1.2) can be found here.

See also

pikaia's People

Contributors

jacobwilliams avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pikaia's Issues

pikaia with openmp?

Dear Jacob,
many thanks for the updated pikaia code.

I am just playing a bit around with it and trying to start it parallel with openmp by adding
some cpu consuming dummy code in the Rosenbrock function (the plan is to apply pikaia to some "real world problem") and

a) in pikaya subroutine after "!Compute initial (random but bounded) phenotypes" comment line

      !$omp parallel do private(ip)
      do ip=istart,me%np
         do k=1,me%n
            oldph(k,ip)=urand()  !from [0,1] ! urand not thread safe!
         end do
         call me%ff(oldph(:,ip),fitns(ip))
      end do
      !$omp end parallel do

(have also set omp_set_nested(.false.) in the example to avoid splitting k loop... )

b) in newpop after "!replace population" comment line

      !$omp parallel do private(i)
      do i=1,me%np

         oldph(:,i)=newph(:,i)

         !get fitness using caller's fitness function
         call me%ff(oldph(:,i),fitns(i))

      end do
      !$omp end parallel do

It seems to bring something (not much but anyway) but I have got also 3 more questions related to the problem:

  1. Are there any other good places to do openmp threads in the code? (mb I haven't found them?)
  2. Should Fortran built-in random generator and urand() function be parts of private objects for each openmp thread? I.e. do we need to replace this random_number with something more portable and related to OOP ?
  3. I cannot ensure reproducibility of calculation in modified version using openmp threads. This seems to be connected with 2? Or there is some kind of limitation at the algorithm level?

Issue with the tests

I just clone and tested this project using fpm (version 0.4.0), as follows:

fpm build
fpm test

and got the following error:

At line 809 of file ././src/pikaia_module.f90
Fortran runtime error: Index '0' of dimension 1 of array 'stackl' below lower bound of 1

Error termination. Backtrace:
#0  0x7f6f65ab57c2 in ???
#1  0x7f6f65ab6289 in ???
#2  0x7f6f65ab689a in ???
#3  0x40a854 in rqsort
	at ././src/pikaia_module.f90:809
#4  0x406665 in __pikaia_module_MOD_rnkpop
	at ././src/pikaia_module.f90:1243
#5  0x40d6a4 in __pikaia_module_MOD_pikaia
	at ././src/pikaia_module.f90:515
#6  0x40bbfe in __pikaia_module_MOD_solve_with_pikaia
	at ././src/pikaia_module.f90:650
#7  0x401a28 in pikaia_test
	at src/tests/pikaia_test.f90:75
#8  0x403836 in main
	at src/tests/pikaia_test.f90:10
<ERROR> Execution failed for object " pikaia_test "
<ERROR>*cmd_run*:stopping due to failed executions
STOP 1

This happens in the subroutine rqsort, and I am not sure how to solve it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.