The run_problem function#
In the Brachistochrone example we used two methods on the OpenMDAO Problem class to execute the model.
run_model Takes the current model design variables and runs a single execution of the Problem’s model.
Any iterative systems are converged, but no optimization is performed.
When using dymos with an optimizer-driven implicit transcription, run_model will not produce a physically valid trajectory on output.
If using a solver-driven transcription, the collocation defects will be satisfied (if possible) and the resulting outputs will provide a physically valid trajectory (to the extent possible given the collocation grid).
run_driver runs a driver wrapped around the model (typically done for optimization) and repeatedly executes run_model until the associated optimization problem is satisfied.
This approach will provide a physically valid trajectory, to the extent that the grid is sufficient to accurately model the dynamics.
But commonly, we want to do the following when we run dymos
- Automatically record states, controls, and parameters at the arrived-upon “final” solution. 
- Automatically provide explicit simulation of the solution to verify the accuracy of the collocation. 
- Automatically load in the results from a previous case as the initial guess for an optimization. 
- Iteratively re-optimize the problem with different grid settings to attempt to minimize grid error (i.e. grid refinement). 
To remove the need to repeatedly setup the code to do this, dymos provides a function called run_problem.
- dymos.run_problem(problem, refine_method='hp', refine_iteration_limit=0, run_driver=True, simulate=False, restart=None, solution_record_file='dymos_solution.db', simulation_record_file='dymos_simulation.db', make_plots=False, plot_dir='plots', case_prefix=None, reset_iter_counts=True, simulate_kwargs=None, plot_kwargs=None)[source]
A Dymos-specific interface to execute an OpenMDAO problem containing Dymos Trajectories or Phases. This function can iteratively call run_driver to perform grid refinement, and automatically call simulate following a run to check the validity of a result.
- Parameters:
- problemom.Problem
The OpenMDAO problem object to be run, presumed to contain one or more dymos phases.
- refine_methodString
The choice of refinement algorithm to use for grid refinement. Current options are ‘hp’ for h-then-p adaptive or ‘ph’ for ‘p-then-h’ adaptive.
- refine_iteration_limitint
The maximum number of passes through the grid refinement algorithm to be made.
- run_driverbool
If True, run the driver attached to the problem, otherwise just run the model one time.
- simulatebool
If True, perform a simulation of any Trajectories found in the Problem model after the driver has been run and grid refinement is complete.
- restartstr, Case, or None
If given as a dict returned by om.CaseReader.get_case, automatically load the states, controls, and parameters as given in the provided case as the initial guess for the next run. If given as a string, assume the user is providing the path to a CaseRecorder file that contains a case named “final” that the user wants to use as the guess for the case.
- make_plotsbool
If True, automatically generate plots of all timeseries outputs. These are stored in the reports subdirectory generated by OpenMDAO.
- solution_record_filestr
Path to case recorder file use to store results from solution.
- simulation_record_filestr
Path to case recorder file use to store results from simulation.
- plot_dirstr
Name of the plot directory to be created.
- simulate_kwargsdict
A dictionary of argument: value pairs to be passed to simulate. These are ignored when simulate=False.
- plot_kwargsdict
A dictionary of argument: value pairs that are passed to timeseries_plots. Only used when make_plots=True.
- case_prefixstr or None
Prefix to prepend to coordinates when recording.
- reset_iter_countsbool
If True and model has been run previously, reset all iteration counters.
 
    
  
  
