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 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.