Skip to content

Commit

Permalink
Fix for opt_duration=False errors (#62)
Browse files Browse the repository at this point in the history
* fix for fixing initial time and duration.  externally sourcing these require the set_time_options argument input_initial=True or input_duration=True.  If they are externally sourced, all optimiation-related options to input/duration are irrelevlant.  Options opt_initial/opt_duration are DEPRECATED in favor of fix_initial/fix_duration.

* Updated examples to use time options fix_initial or fix_duration.  Tests for the double integrator are used to test inputting values for initial time and duration, and associated warnings.

* test for deprecation warning if user uses opt_initial or opt_duration in set_time_options

* bumped patch -> 0.9.1

* removed explicit mode in setup to update with current OpenMDAO

* skip unittests that use assertWarns when python version < 3.3
  • Loading branch information
robfalck authored Jul 16, 2018
1 parent cc57e50 commit e471cd9
Show file tree
Hide file tree
Showing 37 changed files with 572 additions and 110 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.9.0
current_version = 0.9.1
commit = False
tag = False

Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
# built documents.
#
# The short X.Y version.
version = u'0.9.0'
version = u'0.9.1'
# The full version, including alpha/beta/rc tags.
release = version

Expand Down
6 changes: 5 additions & 1 deletion docs/source/user_guide/phases/variables.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ In |project|, time is characterized by two variables:
* `t_initial` - The initial time of the phase
* `t_duration` - The duration of the phase

The bounds, scaling, and units of these variables may be set using `set_time_options`.
The bounds, scaling, and units of these variables may be set using `set_time_options`. In addition,
the user can specify that the initial time or duration of a phase is to be connected to some
external output by specifying `input_initial = True` or `input_duration = True`. In the case of
fixed initial time or duration, or input initial time or duration, the optimization-related options
have no effect and a warning will be raised if they are used.

.. embed-options::
dymos.phases.options
Expand Down
2 changes: 1 addition & 1 deletion dymos/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import print_function, division, absolute_import

__version__ = '0.9.0'
__version__ = '0.9.1'

from .ode_options import ODEOptions, declare_time, declare_state, declare_parameter
from .phases.phase_factory import Phase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def ex_aircraft_steady_flight(optimizer='SLSQP', transcription='gauss-lobatto'):

p.model.linear_solver = DirectSolver(assemble_jac=True)

p.setup(mode='fwd')
p.setup()

p['phase0.t_initial'] = 0.0
p['phase0.t_duration'] = 3600.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def setUpClass(cls):
cls.p.model.connect('W_total', 'flight_equilibrium.W_total')
cls.p.model.connect('q', ('aero.q', 'flight_equilibrium.q'))

cls.p.setup(check=True, mode='fwd', force_alloc_complex=True)
cls.p.setup(check=True, force_alloc_complex=True)

cls.p.run_model()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def setUpClass(cls):
cls.p.model.connect('pres', 'propulsion.pres')
cls.p.model.connect('CT', 'propulsion.CT')

cls.p.setup(mode='fwd', force_alloc_complex=True)
cls.p.setup(force_alloc_complex=True)

cls.p.run_model()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_cruise_results(self):
p.model.linear_solver = DirectSolver(assemble_jac=True)
p.model.options['assembled_jac_type'] = 'csc'

p.setup(mode='fwd')
p.setup()

p['phase0.t_initial'] = 0.0
p['phase0.t_duration'] = 1.515132 * 3600.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def setUpClass(cls):
cls.p.model.linear_solver = DirectSolver(assemble_jac=True)
cls.p.model.options['assembled_jac_type'] = 'csc'

cls.p.setup(check=True, mode='fwd')
cls.p.setup(check=True)

cls.p.run_model()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def test_steady_aircraft_for_docs(self):

p.model.linear_solver = DirectSolver(assemble_jac=True)

p.setup(mode='fwd')
p.setup()

p['phase0.t_initial'] = 0.0
p['phase0.t_duration'] = 3600.0
Expand Down
4 changes: 2 additions & 2 deletions dymos/examples/brachistochrone/ex_brachistochrone.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def brachistochrone_min_time(

p.model.add_subsystem('phase0', phase)

phase.set_time_options(opt_initial=False, duration_bounds=(.5, 10))
phase.set_time_options(fix_initial=True, duration_bounds=(.5, 10))

phase.set_state_options('x', fix_initial=True, fix_final=True)
phase.set_state_options('y', fix_initial=True, fix_final=True)
Expand All @@ -56,7 +56,7 @@ def brachistochrone_min_time(

p.model.options['assembled_jac_type'] = top_level_jacobian.lower()
p.model.linear_solver = DirectSolver(assemble_jac=True)
p.setup(mode='fwd', check=True)
p.setup(check=True)

p['phase0.t_initial'] = 0.0
p['phase0.t_duration'] = 2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_brachistochrone_for_docs_gauss_lobatto_simul_derivs(self):
p.model.linear_solver = DirectSolver(assemble_jac=True)
p.model.options['assembled_jac_type'] = 'csc'

p.setup(mode='fwd')
p.setup()

p['phase0.t_initial'] = 0.0
p['phase0.t_duration'] = 2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_brachistochrone_for_docs_gauss_lobatto_without_simul_derivs(self):
p.model.linear_solver = DirectSolver(assemble_jac=True)
p.model.options['assembled_jac_type'] = 'csc'

p.setup(mode='fwd')
p.setup()

p['phase0.t_initial'] = 0.0
p['phase0.t_duration'] = 2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_brachistochrone_for_docs_gauss_lobatto(self):
p.model.linear_solver = DirectSolver(assemble_jac=True)
p.model.options['assembled_jac_type'] = 'csc'

p.setup(mode='rev')
p.setup()

p['phase0.t_initial'] = 0.0
p['phase0.t_duration'] = 2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_brachistochrone_recording_for_docs(self):
p.model.add_recorder(rec)
phase.add_recorder(rec)

p.setup(mode='rev')
p.setup()

p['phase0.t_initial'] = 0.0
p['phase0.t_duration'] = 2.0
Expand Down
8 changes: 4 additions & 4 deletions dymos/examples/brachistochrone/test/test_path_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_control_rate_path_constraint_gl(self):
p.model.linear_solver = DirectSolver(assemble_jac=True)
p.model.options['assembled_jac_type'] = 'csc'

p.setup(mode='fwd')
p.setup()

p['phase0.t_initial'] = 0.0
p['phase0.t_duration'] = 2.0
Expand Down Expand Up @@ -88,7 +88,7 @@ def test_control_rate2_path_constraint_gl(self):
p.model.linear_solver = DirectSolver(assemble_jac=True)
p.model.options['assembled_jac_type'] = 'csc'

p.setup(mode='fwd')
p.setup()

p['phase0.t_initial'] = 0.0
p['phase0.t_duration'] = 2.0
Expand Down Expand Up @@ -138,7 +138,7 @@ def test_control_rate_path_constraint_radau(self):
p.model.linear_solver = DirectSolver(assemble_jac=True)
p.model.options['assembled_jac_type'] = 'csc'

p.setup(mode='fwd')
p.setup()

p['phase0.t_initial'] = 0.0
p['phase0.t_duration'] = 2.0
Expand Down Expand Up @@ -188,7 +188,7 @@ def test_control_rate2_path_constraint_radau(self):
p.model.linear_solver = DirectSolver(assemble_jac=True)
p.model.options['assembled_jac_type'] = 'csc'

p.setup(mode='fwd')
p.setup()

p['phase0.t_initial'] = 0.0
p['phase0.t_duration'] = 2.0
Expand Down
7 changes: 3 additions & 4 deletions dymos/examples/double_integrator/ex_double_integrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def double_integrator_direct_collocation(transcription='gauss-lobatto', top_leve

p.model.add_subsystem('phase0', phase)

phase.set_time_options(initial_bounds=(0, 0), duration_bounds=(1.0, 1.0))
phase.set_time_options(fix_initial=True, fix_duration=True)

phase.set_state_options('x', fix_initial=True)
phase.set_state_options('v', fix_initial=True, fix_final=True)
Expand All @@ -34,7 +34,7 @@ def double_integrator_direct_collocation(transcription='gauss-lobatto', top_leve
p.model.linear_solver = DirectSolver(assemble_jac=True)
p.model.options['assembled_jac_type'] = top_level_jacobian.lower()

p.setup(mode='fwd', check=True)
p.setup(check=True)

p['phase0.t_initial'] = 0.0
p['phase0.t_duration'] = 1.0
Expand All @@ -49,5 +49,4 @@ def double_integrator_direct_collocation(transcription='gauss-lobatto', top_leve


if __name__ == '__main__':
prob = double_integrator_direct_collocation(transcription='radau-ps', optimizer='SLSQP',
compressed=True)
prob = double_integrator_direct_collocation(transcription='radau-ps', compressed=True)
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_double_integrator_for_docs(self):

p.model.linear_solver = DirectSolver(assemble_jac=True)

p.setup(mode='fwd', check=True)
p.setup(check=True)

p['phase0.t_initial'] = 0.0
p['phase0.t_duration'] = 1.0
Expand Down
Loading

0 comments on commit e471cd9

Please sign in to comment.