# The Dymos 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 what happens if the grid is not dense enough to accurately capture the physics of the problem. This is the purpose of grid refinement. There have been numerous methods of grid refinment posed for implcit optimal control techniques. In general, they follow the following procedure:

1. Optimize the trajectory
2. Assess errors in the solution
3. Propose a new grid to reduce these errors to an acceptable level.
4. Repeat until the errors are within some acceptable tolerance.

This requires another layer of iteration outside of the OpenMDAO run_driver method. This is the original motivation for Dymos' run_problem function.

dymos.run_problem.run_problem

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')

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.

Arguments:

problem: The OpenMDAO problem object to be run.

refine_method: The choice of refinement algorithm to use for grid refinement

refine_iteration_limit: The number of passes through the grid refinement algorithm to be made.

run_driver: If True, run the driver (optimize the problem), otherwise just run the model one time.

simulate: If True, perform a simulation of Trajectories found in the Problem after the driver has been run and grid refinement is complete.

restart: If not None, the path to a CaseRecorder file used to load in recording from a previous run.

make_plots: If True, automatically generate plots of all timeseries outputs.

solution_record_file: Path to case recorder file use to store results from solution.

simulation_record_file: Path to case recorder file use to store results from simulation.

plot_dir: Path to directory for plot files.