diff --git a/README.md b/README.md index 6085827aa..9d0ad2826 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ ALPSO, CONMIN, IPOPT, NLPQLP, NSGA2, PSQP, SLSQP, ParOpt and SNOPT are currently We do not provide the source code for SNOPT and NLPQLP, due to their restrictive license requirements. Please contact the authors of the respective optimizers if you wish to obtain them. -Furthermore, ParOpt and IPOPT are available as a open source package but must be installed separately. +Furthermore, ParOpt and IPOPT are available as open source packages but must be installed separately. Please see the documentation page of each optimizer for purchase and installation instructions. ## Integration into other frameworks diff --git a/doc/install.rst b/doc/install.rst index 2586af2cd..15e597caf 100644 --- a/doc/install.rst +++ b/doc/install.rst @@ -34,7 +34,6 @@ pyOptSparse has the following dependencies: We recommend ``gcc`` and ``gfortran`` which can be installed via the package manager for your operating system. Please make sure these are installed and available for use. -In order to use NSGA2, SWIG (v1.3+) is also required, which can be installed via the package manager. Python dependencies are automatically handled by ``pip``, so they do not need to be installed separately. .. note:: diff --git a/pyoptsparse/__init__.py b/pyoptsparse/__init__.py index d31584a24..74c88eaa8 100644 --- a/pyoptsparse/__init__.py +++ b/pyoptsparse/__init__.py @@ -1,4 +1,4 @@ -__version__ = "2.13.1" +__version__ = "2.13.2" from .pyOpt_history import History from .pyOpt_variable import Variable diff --git a/pyoptsparse/pyNSGA2/meson.build b/pyoptsparse/pyNSGA2/meson.build index e9cfdcca4..48faac1ae 100644 --- a/pyoptsparse/pyNSGA2/meson.build +++ b/pyoptsparse/pyNSGA2/meson.build @@ -1,40 +1,36 @@ -swig = find_program('swig', required: false) +swig = find_program('swig', required: true) -if swig.found() - nsga2_source = custom_target('nsga2_wrap.c', - input : ['source/swig/nsga2.i'], - output : ['nsga2_wrap.c'], - command: ['swig', '-o', 'pyoptsparse/pyNSGA2/nsga2_wrap.c', '-python', '-interface', 'nsga2', '@INPUT@'] - ) +nsga2_source = custom_target('nsga2_wrap.c', + input : ['source/swig/nsga2.i'], + output : ['nsga2_wrap.c'], + command: ['swig', '-o', 'pyoptsparse/pyNSGA2/nsga2_wrap.c', '-python', '-interface', 'nsga2', '@INPUT@'] + ) - py3_target.extension_module('nsga2', - 'source/allocate.c', - 'source/auxiliary.c', - 'source/crossover.c', - 'source/crowddist.c', - 'source/decode.c', - 'source/dominance.c', - 'source/eval.c', - 'source/fillnds.c', - 'source/initialize.c', - 'source/list.c', - 'source/merge.c', - 'source/mutation.c', - 'source/nsga2.c', - 'source/rand.c', - 'source/rank.c', - 'source/report.c', - 'source/sort.c', - 'source/tourselect.c', - nsga2_source, - include_directories: 'source', - dependencies : py3_dep, - subdir: 'pyoptsparse/pyNSGA2', - link_language: 'c', - install : false) -else - message('SWIG was not found, therefore NSGA2 will not be built.') -endif +py3_target.extension_module('nsga2', + 'source/allocate.c', + 'source/auxiliary.c', + 'source/crossover.c', + 'source/crowddist.c', + 'source/decode.c', + 'source/dominance.c', + 'source/eval.c', + 'source/fillnds.c', + 'source/initialize.c', + 'source/list.c', + 'source/merge.c', + 'source/mutation.c', + 'source/nsga2.c', + 'source/rand.c', + 'source/rank.c', + 'source/report.c', + 'source/sort.c', + 'source/tourselect.c', + nsga2_source, + include_directories: 'source', + dependencies : py3_dep, + subdir: 'pyoptsparse/pyNSGA2', + link_language: 'c', + install : false) #python_sources = [ # '__init__.py', diff --git a/pyoptsparse/pyNSGA2/pyNSGA2.py b/pyoptsparse/pyNSGA2/pyNSGA2.py index 12a0d5987..c83faa187 100644 --- a/pyoptsparse/pyNSGA2/pyNSGA2.py +++ b/pyoptsparse/pyNSGA2/pyNSGA2.py @@ -16,7 +16,7 @@ # import the compiled module THIS_DIR = os.path.dirname(os.path.abspath(__file__)) -nsga2 = try_import_compiled_module_from_path("nsga2", THIS_DIR) +nsga2 = try_import_compiled_module_from_path("nsga2", THIS_DIR, raise_warning=True) class NSGA2(Optimizer): diff --git a/pyproject.toml b/pyproject.toml index e70531965..ce02acea6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,3 @@ [build-system] -requires = ["setuptools>=42", "meson>=0.60.0", "ninja", "numpy>=2.0"] +requires = ["setuptools>=42", "meson>=0.60.0", "ninja", "numpy>=2.0", "swig"] build-backend = "setuptools.build_meta" diff --git a/tests/test_nsga2_multi_objective.py b/tests/test_nsga2_multi_objective.py index b74bab019..7cf0981ee 100644 --- a/tests/test_nsga2_multi_objective.py +++ b/tests/test_nsga2_multi_objective.py @@ -1,4 +1,4 @@ -""" Test NSGA2.""" +"""Test NSGA2.""" # Standard Python modules import unittest @@ -19,13 +19,6 @@ class TestNSGA2(OptTest): optName = "NSGA2" histFileName = None - def setUp(self): - try: - # First party modules - from pyoptsparse.pyNSGA2 import nsga2 # noqa: F401 - except ImportError: - raise unittest.SkipTest("Optimizer not available: NSGA2") - def objfunc(self, xdict): x = xdict["x"] y = xdict["y"] diff --git a/tests/testing_utils.py b/tests/testing_utils.py index b599a7eb8..7fb041b50 100644 --- a/tests/testing_utils.py +++ b/tests/testing_utils.py @@ -59,7 +59,7 @@ def get_dict_distance(d, d2): } # these are optimizers which are installed by default -DEFAULT_OPTIMIZERS = {"SLSQP", "PSQP", "CONMIN", "ALPSO"} +DEFAULT_OPTIMIZERS = {"SLSQP", "PSQP", "CONMIN", "ALPSO", "NSGA2"} # Define gradient-based optimizers GRAD_BASED_OPTIMIZERS = {"CONMIN", "IPOPT", "NLPQLP", "ParOpt", "PSQP", "SLSQP", "SNOPT"}