Skip to content

Commit

Permalink
add tests for all optimizers
Browse files Browse the repository at this point in the history
  • Loading branch information
ewu63 committed May 29, 2024
1 parent 4ed7ce9 commit 2d40f7f
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions tests/test_sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@

# First party modules
from pyoptsparse import Optimization
from pyoptsparse.pyOpt_optimizer import Optimizers

# Local modules
from testing_utils import OptTest

ALL_OPTIMIZERS = [e.name for e in Optimizers]


class TestSphere(OptTest):
## Solve unconstrained Sphere problem.
Expand Down Expand Up @@ -40,7 +43,7 @@ class TestSphere(OptTest):
xStar = {"xvars": np.zeros(N)}

# Tolerances
tol = {"ALPSO": 1e-3}
tol = {k: 1e-3 for k in ALL_OPTIMIZERS}

optOptions = {
"ALPSO": { # sphere
Expand All @@ -50,7 +53,14 @@ class TestSphere(OptTest):
"c2": 1.25, # Social Parameter
"stopCriteria": 0, # 0: maxOuterIter, 1: convergence
"seed": 1235,
}
},
"NSGA2": {
"PopSize": 10,
"maxGen": 10,
},
"SNOPT": {
"Major iterations limit": 10,
},
}

def objfunc(self, xdict):
Expand Down Expand Up @@ -85,7 +95,7 @@ def setup_optProb(self):
# Objective
self.optProb.addObj("obj")

@parameterized.expand(["ALPSO"])
@parameterized.expand(ALL_OPTIMIZERS)
def test_optimization(self, optName):
self.optName = optName
self.setup_optProb()
Expand Down

0 comments on commit 2d40f7f

Please sign in to comment.