openmdaopetsc

Accessing NSGA2 population size using pyoptsparse driver with OpenMDAO


I am attempting to modify the GA population size for when using the NSGA2 optimizer through OpenMDAO's pyoptsparse driver.

I tried accessing PopSize from pyNSGA2.py using opt_settings dictionary as follows:

prob.driver = om.pyOptSparseDriver(optimizer='NSGA2')
prob.driver.opt_settings["PopSize"] = 150

However, this results in a segmentation error, message below:

[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range
[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
[0]PETSC ERROR: or see https://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind
[0]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple Mac OS X to find memory corruption errors
[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run 
[0]PETSC ERROR: to get more information on the crash.
--------------------------------------------------------------------------
MPI_ABORT was invoked on rank 0 in communicator MPI_COMM_WORLD
with errorcode 50152059.

NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
You may or may not see output from other processes, depending on
exactly when Open MPI kills them.

Is there a different method to access the options for the NSGA2 optimizer that should be used instead of the opt_settings dictionary? I am relatively new to Python, so I also suspect my syntax could be incorrect as well.

Update: For a bit more context, I attempted running without PETSC. The optimization was successful without trying to change PopSize, however it crashed with just Segmentation fault when trying to change PopSize. Trace the error, I believe the source of the segmentation fault is in pyoptsparse/pyNSGA2/source/crossover.c, per the message below

Program received signal SIGSEGV, Segmentation fault.
0x00007fffbc85747b in realcross (parent1=parent1@entry=0x1864bf0, parent2=parent2@entry=0x186d030, 
    child1=child1@entry=0x1868280, child2=child2@entry=0x18682c0, global=..., nrealcross=<optimized out>)
    at pyoptsparse/pyNSGA2/source/crossover.c:104
104                 child2->xreal[i] = parent2->xreal[i];

I also tried a clean installation of PETSC on a new machine, however that brings me back to the same error.


Solution

  • In looking through the C source code for the NSGA2 optimizer, I found that the issue was not with accessing the population size option, but rather that I was specifying an invalid population size. Per the file header comment of nsga2.c, population size must be a multiple of 4.

    I was able to successfully run the optimization at population size of 160 rather than 150.