【发布时间】:2020-05-22 20:27:32
【问题描述】:
我正在尝试通过 OpenMDAO 的 pyoptsparse 驱动程序使用 NSGA2 优化器时修改 GA 人口大小。
我尝试使用opt_settings 字典从pyNSGA2.py 访问PopSize,如下所示:
prob.driver = om.pyOptSparseDriver(optimizer='NSGA2')
prob.driver.opt_settings["PopSize"] = 150
但是,这会导致分段错误,消息如下:
[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.
是否有其他方法可以访问 NSGA2 优化器的选项而不是 opt_settings 字典?我对 Python 比较陌生,所以我也怀疑我的语法也可能不正确。
更新:
对于更多的上下文,我尝试在没有 PETSC 的情况下运行。优化成功,无需尝试更改 PopSize,但在尝试更改 PopSize 时,它仅因 Segmentation fault 而崩溃。跟踪错误,我相信分段错误的根源在pyoptsparse/pyNSGA2/source/crossover.c,根据下面的消息
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];
我还尝试在一台新机器上全新安装 PETSC,但这让我又回到了同样的错误。
【问题讨论】:
-
我对 NSGAII 包装器没有太多经验,所以帮不上什么忙。但是,您的语法对我来说看起来不错。看起来你编译 petsc 和 MPI 的方式有问题
-
@JustinGray 我尝试在新机器上全新安装 petsc 和 MPI 并遇到相同的错误(请参阅上面的更新)。如果我设法在 petsc/MPI 中找到问题,我将发布另一个更新