Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added require_pyoptsparse to all tests that use pyOptSparseDriver #624

Merged
merged 1 commit into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
plt.style.use('ggplot')

from dymos.utils.doc_utils import save_for_docs
from openmdao.utils.testing_utils import use_tempdirs
from openmdao.utils.testing_utils import use_tempdirs, require_pyoptsparse


@use_tempdirs
class TestSteadyAircraftFlightForDocs(unittest.TestCase):

@save_for_docs
@require_pyoptsparse(optimizer='SLSQP')
def test_steady_aircraft_for_docs(self):
import matplotlib.pyplot as plt

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

import openmdao.api as om
from openmdao.utils.assert_utils import assert_near_equal
from openmdao.utils.testing_utils import use_tempdirs
from openmdao.utils.testing_utils import use_tempdirs, require_pyoptsparse

import dymos as dm
from dymos.utils.lgl import lgl
from dymos.examples.aircraft_steady_flight.aircraft_ode import AircraftODE


@require_pyoptsparse(optimizer='SLSQP')
def ex_aircraft_steady_flight(optimizer='SLSQP', solve_segments=False,
use_boundary_constraints=False, compressed=False):
p = om.Problem(model=om.Group())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import openmdao.api as om
from openmdao.utils.assert_utils import assert_near_equal
from openmdao.utils.testing_utils import use_tempdirs
from openmdao.utils.testing_utils import use_tempdirs, require_pyoptsparse

import dymos as dm
from dymos.examples.battery_multibranch.battery_multibranch_ode import BatteryODE
Expand All @@ -23,6 +23,7 @@ def setUp(self):
def tearDown(self):
dm.options['include_check_partials'] = False

@require_pyoptsparse(optimizer='SLSQP')
def test_optimizer_defects(self):

prob = om.Problem()
Expand Down Expand Up @@ -278,6 +279,7 @@ def test_solver_defects_reverse_propagation(self):
soc1 = prob['traj.phase1.states:state_of_charge']
assert_near_equal(soc1[-1], 1.0, 1e-6)

@require_pyoptsparse(optimizer='SLSQP')
def test_optimizer_segments_direct_connections(self):
prob = om.Problem()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
import openmdao.api as om
from dymos.utils.doc_utils import save_for_docs
from openmdao.utils.testing_utils import use_tempdirs
from openmdao.utils.testing_utils import use_tempdirs, require_pyoptsparse


class BrachistochroneArclengthODE(om.ExplicitComponent):
Expand Down Expand Up @@ -48,6 +48,7 @@ def compute_partials(self, inputs, jacobian):
class TestBrachistochroneTandemPhases(unittest.TestCase):

@save_for_docs
@require_pyoptsparse(optimizer='SLSQP')
def test_brachistochrone_tandem_phases(self):
from dymos.examples.brachistochrone.brachistochrone_ode import BrachistochroneODE

Expand Down
2 changes: 2 additions & 0 deletions dymos/examples/brachistochrone/test/ex_brachistochrone.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import matplotlib.pyplot as plt

import openmdao.api as om
from openmdao.utils.testing_utils import require_pyoptsparse

import dymos as dm
from dymos.examples.brachistochrone.brachistochrone_ode import BrachistochroneODE

SHOW_PLOTS = True


@require_pyoptsparse(optimizer='SLSQP')
def brachistochrone_min_time(transcription='gauss-lobatto', num_segments=8, transcription_order=3,
compressed=True, optimizer='SLSQP', run_driver=True, force_alloc_complex=False,
solve_segments=False):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

import numpy as np
import openmdao.api as om
from openmdao.utils.testing_utils import use_tempdirs
from openmdao.utils.testing_utils import use_tempdirs, require_pyoptsparse
from openmdao.utils.assert_utils import assert_near_equal
import dymos as dm


@use_tempdirs
class TestBrachExecCompODE(unittest.TestCase):

@require_pyoptsparse(optimizer='SLSQP')
def _make_problem(self, transcription='gauss-lobatto', num_segments=8, transcription_order=3,
compressed=True, optimizer='SLSQP', run_driver=True, force_alloc_complex=False,
solve_segments=False):
Expand Down Expand Up @@ -132,7 +133,7 @@ def test_ex_brachistochrone_gl_uncompressed(self):

@use_tempdirs
class TestInvalidCallableODEClass(unittest.TestCase):

@require_pyoptsparse(optimizer='SLSQP')
def test_invalid_callable(self):
num_segments = 10
transcription_order = 3
Expand Down Expand Up @@ -232,6 +233,7 @@ class TestBrachCallableODE(unittest.TestCase):
def setUp(self):
self.ode = CallableBrachistochroneODE(num_nodes=1)

@require_pyoptsparse(optimizer='SLSQP')
def _make_problem(self, transcription='gauss-lobatto', num_segments=8, transcription_order=3,
compressed=True, optimizer='SLSQP', run_driver=True,
force_alloc_complex=False,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import openmdao.api as om
from dymos.utils.testing_utils import assert_timeseries_near_equal
from openmdao.utils.testing_utils import use_tempdirs
from openmdao.utils.testing_utils import use_tempdirs, require_pyoptsparse


class BrachistochroneODE(om.ExplicitComponent):
Expand Down Expand Up @@ -88,6 +88,7 @@ def tearDownClass(cls):
if os.path.exists(filename):
os.remove(filename)

@require_pyoptsparse(optimizer='SLSQP')
def test_brachistochrone_integrated_param_gauss_lobatto(self):
import numpy as np
import openmdao.api as om
Expand Down Expand Up @@ -157,6 +158,7 @@ def test_brachistochrone_integrated_param_gauss_lobatto(self):
assert_timeseries_near_equal(t_sol, v_sol, t_sim, v_sim, tolerance=5.0E-3)
assert_timeseries_near_equal(t_sol, theta_sol, t_sim, theta_sim, tolerance=5.0E-3)

@require_pyoptsparse(optimizer='SLSQP')
def test_brachistochrone_integrated_parameter_radau_ps(self):
import numpy as np
import openmdao.api as om
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
import dymos.examples.brachistochrone.test.ex_brachistochrone_vector_states as ex_brachistochrone_vs
import dymos.examples.brachistochrone.test.ex_brachistochrone as ex_brachistochrone
from dymos.examples.brachistochrone.brachistochrone_ode import BrachistochroneODE
from openmdao.utils.testing_utils import use_tempdirs
from openmdao.utils.testing_utils import use_tempdirs, require_pyoptsparse

from openmdao.utils.general_utils import set_pyoptsparse_opt

OPT, OPTIMIZER = set_pyoptsparse_opt('SLSQP')


@require_pyoptsparse(optimizer='SLSQP')
def _make_problem(transcription='gauss-lobatto', num_segments=8, transcription_order=3,
compressed=True, optimizer='SLSQP', run_driver=True, force_alloc_complex=False,
solve_segments=False):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from numpy.testing import assert_almost_equal

import openmdao.api as om
from openmdao.utils.testing_utils import use_tempdirs
from openmdao.utils.testing_utils import use_tempdirs, require_pyoptsparse

import dymos as dm
from dymos.examples.brachistochrone.brachistochrone_ode import BrachistochroneODE
Expand All @@ -14,6 +14,7 @@
@use_tempdirs
class TestBrachistochroneVaryingOrderControlSimulation(unittest.TestCase):

@require_pyoptsparse(optimizer='SLSQP')
def test_gauss_lobatto(self):
p = om.Problem(model=om.Group())

Expand Down Expand Up @@ -90,6 +91,7 @@ def test_gauss_lobatto(self):

assert_almost_equal(thetaf, 100.12, decimal=0)

@require_pyoptsparse(optimizer='SLSQP')
def test_radau(self):
p = om.Problem(model=om.Group())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import openmdao.api as om
from openmdao.utils.assert_utils import assert_near_equal
from openmdao.utils.testing_utils import use_tempdirs
from openmdao.utils.testing_utils import use_tempdirs, require_pyoptsparse

import dymos as dm
from dymos.utils.testing_utils import assert_timeseries_near_equal
Expand Down Expand Up @@ -221,6 +221,7 @@ def _test_integrate_control_rate(self, transcription):
assert_timeseries_near_equal(t_sol, int_theta_sol, t_sol, theta_sol, tolerance=1.0E-2)
assert_timeseries_near_equal(t_sim, int_theta_sim, t_sim, theta_sim, tolerance=1.0E-2)

@require_pyoptsparse(optimizer='SLSQP')
def _test_integrate_control_rate2(self, transcription):
#
# Define the OpenMDAO problem
Expand Down Expand Up @@ -564,6 +565,7 @@ def _test_integrate_polynomial_control_rate(self, transcription):
assert_timeseries_near_equal(t_sol, int_theta_sol, t_sol, theta_sol, tolerance=1.0E-3)
# assert_timeseries_near_equal(t_sol, int_theta_sim, t_sol, theta_sim, tolerance=1.0E-3)

@require_pyoptsparse(optimizer='SLSQP')
def _test_integrate_polynomial_control_rate2(self, transcription):
#
# Define the OpenMDAO problem
Expand Down
3 changes: 2 additions & 1 deletion dymos/examples/brachistochrone/test/test_tandem_phases.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import openmdao.api as om
from openmdao.utils.assert_utils import assert_near_equal
from openmdao.utils.testing_utils import use_tempdirs
from openmdao.utils.testing_utils import use_tempdirs, require_pyoptsparse

import dymos as dm
from dymos.examples.brachistochrone.brachistochrone_ode import BrachistochroneODE
Expand Down Expand Up @@ -68,6 +68,7 @@ def make_brachistochrone_phase(transcription='gauss-lobatto', num_segments=8, tr


@use_tempdirs
@require_pyoptsparse(optimizer='SLSQP')
class TestTandemPhases(unittest.TestCase):

def _run_transcription(self, transcription):
Expand Down
3 changes: 2 additions & 1 deletion dymos/examples/brachistochrone/test/test_timeseries_units.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import unittest

import openmdao.api as om
from openmdao.utils.testing_utils import use_tempdirs
from openmdao.utils.testing_utils import use_tempdirs, require_pyoptsparse
from openmdao.utils.assert_utils import assert_near_equal
import dymos as dm


@use_tempdirs
class TestTimeseriesUnits(unittest.TestCase):

@require_pyoptsparse(optimizer='SLSQP')
def _make_problem(self, transcription='gauss-lobatto', num_segments=8, transcription_order=3,
compressed=True, optimizer='SLSQP', run_driver=True, force_alloc_complex=False,
solve_segments=False):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
plt.switch_backend('Agg')

from dymos.utils.doc_utils import save_for_docs
from openmdao.utils.testing_utils import use_tempdirs
from openmdao.utils.testing_utils import use_tempdirs, require_pyoptsparse


@use_tempdirs
class TestTwoPhaseCannonballForDocs(unittest.TestCase):

@save_for_docs
@require_pyoptsparse(optimizer='SLSQP')
def test_two_phase_cannonball_for_docs(self):
import numpy as np
from scipy.interpolate import interp1d
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import unittest
from openmdao.utils.assert_utils import assert_near_equal
from openmdao.utils.testing_utils import use_tempdirs
from openmdao.utils.testing_utils import use_tempdirs, require_pyoptsparse


class ODEComp(om.ExplicitComponent):
Expand All @@ -30,6 +30,7 @@ def compute(self, inputs, outputs):
@use_tempdirs
class TestCannonballMatrixState(unittest.TestCase):
""" Tests to verify that dymos can use matrix-states"""
@require_pyoptsparse(optimizer='SLSQP')
def _make_problem(self, tx):
p = om.Problem()

Expand Down Expand Up @@ -132,6 +133,7 @@ def test_cannonball_matrix_state_gl_solve_segments(self):
@use_tempdirs
class TestCannonballMatrixStateExplicitShape(unittest.TestCase):
""" Tests to verify that dymos can use matrix-states"""
@require_pyoptsparse(optimizer='SLSQP')
def _make_problem(self, tx):
p = om.Problem()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import openmdao
import openmdao.api as om

from openmdao.utils.testing_utils import use_tempdirs
from openmdao.utils.testing_utils import use_tempdirs, require_pyoptsparse

from dymos.examples.cannonball.cannonball_ode import rho_interp

Expand Down Expand Up @@ -82,6 +82,7 @@ class TestConnectControlToParameter(unittest.TestCase):

@unittest.skipIf(om_version < (3, 4, 1) or (om_version == (3, 4, 1) and om_dev_version),
'test requires OpenMDAO >= 3.4.1')
@require_pyoptsparse(optimizer='SLSQP')
def test_connect_control_to_parameter(self):
""" Test that the final value of a control in one phase can be connected as the value
of a parameter in a subsequent phase. """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import matplotlib.pyplot as plt
plt.switch_backend('Agg')
from openmdao.utils.testing_utils import use_tempdirs
from openmdao.utils.testing_utils import use_tempdirs, require_pyoptsparse


@use_tempdirs
class TestTwoPhaseCannonballODEOutputLinkage(unittest.TestCase):

@require_pyoptsparse(optimizer='SLSQP')
def test_link_fixed_states_final_to_initial(self):
""" Test that linking phases with states that are fixed at the linkage point raises an exception. """

Expand Down Expand Up @@ -105,6 +106,7 @@ def test_link_fixed_states_final_to_initial(self):
'value of "gam" in ascent to initial value of "gam" in '
'descent. Values on both sides of the linkage are fixed.')

@require_pyoptsparse(optimizer='SLSQP')
def test_link_fixed_states_final_to_final(self):
""" Test that linking phases with states that are fixed at the linkage point raises an exception. """

Expand Down Expand Up @@ -205,6 +207,7 @@ def test_link_fixed_states_final_to_final(self):
'value of "h" in ascent to final value of "h" in '
'descent. Values on both sides of the linkage are fixed.')

@require_pyoptsparse(optimizer='SLSQP')
def test_link_fixed_states_initial_to_initial(self):
""" Test that linking phases with states that are fixed at the linkage point raises an exception. """

Expand Down Expand Up @@ -305,6 +308,7 @@ def test_link_fixed_states_initial_to_initial(self):
'value of "h" in ascent to initial value of "h" in '
'descent. Values on both sides of the linkage are fixed.')

@require_pyoptsparse(optimizer='SLSQP')
def test_link_fixed_times_final_to_initial(self):
""" Test that linking phases with times that are fixed at the linkage point raises an exception. """

Expand Down Expand Up @@ -401,6 +405,7 @@ def test_link_fixed_times_final_to_initial(self):
'value of "time" in ascent to initial value of "time" in '
'descent. Values on both sides of the linkage are fixed.')

@require_pyoptsparse(optimizer='SLSQP')
def test_link_bounded_times_final_to_initial(self):
""" Test that linking phases with times that are fixed at the linkage point raises an exception. """

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import matplotlib.pyplot as plt
plt.switch_backend('Agg')
from openmdao.utils.testing_utils import use_tempdirs
from openmdao.utils.testing_utils import use_tempdirs, require_pyoptsparse


@use_tempdirs
class TestTwoPhaseCannonballODEOutputLinkage(unittest.TestCase):

@require_pyoptsparse(optimizer='SLSQP')
def test_two_phase_cannonball_ode_output_linkage(self):
import openmdao.api as om
from openmdao.utils.assert_utils import assert_near_equal
Expand Down Expand Up @@ -206,6 +207,7 @@ def test_two_phase_cannonball_ode_output_linkage(self):

plt.show()

@require_pyoptsparse(optimizer='SLSQP')
def test_traj_param_target_none(self):
# Tests a bug where you couldn't specify None as a target for a specific phase.
import openmdao.api as om
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
plt.style.use('ggplot')

from dymos.utils.doc_utils import save_for_docs
from openmdao.utils.testing_utils import use_tempdirs
from openmdao.utils.testing_utils import use_tempdirs, require_pyoptsparse


@use_tempdirs
Expand All @@ -20,6 +20,7 @@ def tearDownClass(cls):
os.remove(filename)

@save_for_docs
@require_pyoptsparse(optimizer='SLSQP')
def test_double_integrator_for_docs(self):
import matplotlib.pyplot as plt
import openmdao.api as om
Expand Down
Loading