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

Constraint aliasing #743

Merged
merged 28 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cbb858c
first try at radau constraint aliasing with test_state_path_constrain…
robfalck Mar 4, 2022
9d1b363
constraint aliasing works for pseudospectral phases
robfalck Mar 9, 2022
3d74a73
Merge branch 'master' of https://github.com/OpenMDAO/dymos into const…
robfalck Mar 17, 2022
a4e993b
path fix for parameter constraints
robfalck Mar 17, 2022
17cef4e
Merge branch 'master' of https://github.com/OpenMDAO/dymos into const…
robfalck Apr 1, 2022
5732f3c
Reworked constraint aliases for path and boundary constraints.
robfalck Apr 1, 2022
961a67f
refactored configuration of boundary constraints. get_boundary_constr…
robfalck Apr 2, 2022
6da7d3c
Fixed indexing for n-dimensional constrained quantities.
robfalck Apr 4, 2022
b52310d
a few more issues with how to address constraints applied to multiple…
robfalck Apr 4, 2022
aabc74e
Still working out the way in which indices are applied to path and bo…
robfalck Apr 5, 2022
78ad3df
Merge branch 'master' of https://github.com/OpenMDAO/dymos into const…
robfalck Apr 6, 2022
ec09d1d
Progress on consraints but still have some failures.
robfalck Apr 19, 2022
cb1d98d
Use openmdao indexer to resolve constraint indices.
robfalck Apr 21, 2022
fd8f73c
Working out constraint linearity.
robfalck Apr 22, 2022
9132f45
Merge branch 'master' of https://github.com/OpenMDAO/dymos into const…
robfalck Apr 25, 2022
4db41aa
The combination of circumstances that can allow for a constraint to b…
robfalck Apr 25, 2022
394282f
Added documentation about constraint aliasing and the linearity of co…
robfalck Apr 25, 2022
e529167
Fixed some missing @require_pyoptsparse tests
robfalck Apr 25, 2022
7bb9184
skip tests regarding openmdao case prefixes until that issue is resolved
robfalck Apr 26, 2022
8f702a3
trouble converging a partial FD example
robfalck Apr 26, 2022
33989d8
updated a problematic notebook example with better IPOPT settings
robfalck Apr 26, 2022
9fe109a
Added test to verify fix for Issue 733, duplicate constraint creation.
robfalck Apr 27, 2022
5fa5ab6
added test for error message when more than one boundary/path constra…
robfalck Apr 27, 2022
8083fd6
One more fix
robfalck Apr 27, 2022
6399a73
pep8
robfalck Apr 27, 2022
db32bb3
Edits per Bret's review
robfalck May 2, 2022
c1164f3
Changes per Ken's review
robfalck May 2, 2022
c6f87d8
set/list/array issues fixed
robfalck May 2, 2022
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
1 change: 0 additions & 1 deletion .github/workflows/dymos_tests_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ on:
pull_request:
branches: [ master ]
workflow_dispatch:
branches: [ master ]

jobs:

Expand Down
20 changes: 16 additions & 4 deletions docs/dymos_book/faq/use_partial_coloring.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true,
"tags": [
"active-ipynb",
"remove-input",
Expand Down Expand Up @@ -65,6 +66,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true,
"tags": [
"remove-input"
]
Expand Down Expand Up @@ -161,6 +163,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true,
"tags": [
"remove-input",
"remove-output"
Expand Down Expand Up @@ -203,6 +206,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true,
"tags": [
"remove-input",
"hide-output"
Expand All @@ -216,7 +220,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"import os \n",
Expand Down Expand Up @@ -244,9 +250,14 @@
"\n",
" p.driver = om.pyOptSparseDriver()\n",
" p.driver.options['optimizer'] = 'IPOPT'\n",
" p.driver.declare_coloring(tol=1.0E-12)\n",
" p.driver.opt_settings['max_iter'] = 500\n",
" p.driver.opt_settings['alpha_for_y'] = 'safer-min-dual-infeas'\n",
" p.driver.opt_settings['print_level'] = 5\n",
" p.driver.opt_settings['nlp_scaling_method'] = 'gradient-based'\n",
" p.driver.opt_settings['tol'] = 1.0E-7\n",
" p.driver.opt_settings['mu_strategy'] = 'monotone'\n",
" \n",
" p.driver.declare_coloring(tol=1.0E-12)\n",
"\n",
" #\n",
" # Instantiate the trajectory and phase\n",
Expand Down Expand Up @@ -350,6 +361,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true,
"tags": [
"remove-input",
"remove-output"
Expand Down Expand Up @@ -398,7 +410,7 @@
}
},
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -412,7 +424,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.9.7"
}
},
"nbformat": 4,
Expand Down
36 changes: 32 additions & 4 deletions docs/dymos_book/features/phases/constraints.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@
" 'please install them and restart this notebook\\'s runtime: {\",\".join(missing_packages)}')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -132,9 +139,30 @@
"``` \n",
"\n",
"Phases also support the `add_path_constraint` method, which imposes path constraints as constraints in the NLP problem.\n",
"As with `add_bound_constraint`, the `add_path_constraint` method is the only option for path constraining an output of the ODE.\n",
"As with `add_boundary_constraint`, the `add_path_constraint` method is the only option for path constraining an output of the ODE.\n",
"\n",
"The downside of path constraints is that they add a considerable number of constraints to the NLP problem and thus may negatively impact performance, although this is generally minor for many problems.\n",
"\n",
"## Implementation Detail - Constraint Aliasing\n",
"\n",
"As of OpenMDAO Version 3.17.0, multiple constraints are allowed to exist on the same output as long as they use different indices and are provided different aliases.\n",
"In Dymos, this allows us to always apply multiple constraints (initial, final, or path constraints) to the timeseries outputs of the phase.\n",
"To allow boundary and path constraints to potentially be applied to the same timeseries outputs, they are provided the following aliases:\n",
"\n",
"An initial boundary constraint on the name `'alpha'` will be given the alias `f'{path_to_phase}.initial_boundary_constraints->alpha`. \n",
"\n",
"A final boundary constraint on the name `'alpha'` will be given the alias `f'{path_to_phase}.final_boundary_constraints->alpha`.\n",
"\n",
"A path constraint on the name `'alpha'` will be given the alias `f'{path_to_phase}.path_constraints->alpha`. \n",
"\n",
"The use of the `->` in this case is intended to remind the user that this is not the actual path to the variable being constrained.\n",
"\n",
"## Constraint Linearity\n",
"\n",
"The downside of path constraints is that they add a considerable number of constraints to the NLP problem and thus may negatively impact performance, although this is generally minor for many problems.\n"
"OpenMDAO will treat all boundary and path consraints as nonlinear unless the user provides the argument `linear=True` to `add_boundary_constraint` or `add_path_constraint`.\n",
"Note that it is the responsibility of the user to understand the inner workings of Dymos and their model well enough to know if the constraint may be treated as linear.\n",
"Specifying an output that is actually a nonlinear function of the design variables as a linear constraint will almost certainly result of the failure of the optimization due to incorrect derivatives.\n",
"The derivatives of linear constraints are computed once and cached by OpenMDAO for the remainder of the optimization.\n"
]
}
],
Expand All @@ -148,7 +176,7 @@
}
},
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -162,7 +190,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.1"
"version": "3.9.7"
}
},
"nbformat": 4,
Expand Down
4 changes: 1 addition & 3 deletions dymos/examples/brachistochrone/test/ex_brachistochrone.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ def brachistochrone_min_time(transcription='gauss-lobatto', num_segments=8, tran
p.model.add_subsystem('traj0', traj)
traj.add_phase('phase0', phase)

# p.model.add_subsystem('traj0', traj)

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

phase.add_state('x', fix_initial=True, fix_final=False, solve_segments=solve_segments)
Expand Down Expand Up @@ -81,6 +79,6 @@ def brachistochrone_min_time(transcription='gauss-lobatto', num_segments=8, tran


if __name__ == '__main__':
p = brachistochrone_min_time(transcription='radau-ps', num_segments=3, run_driver=True,
p = brachistochrone_min_time(transcription='radau-ps', num_segments=20, run_driver=True,
transcription_order=5, compressed=False, optimizer='SNOPT',
solve_segments=False, force_alloc_complex=True)
Loading