Solving Dynamic Optimization Problems by PSOPT Solver in C++
In my previous articles, I displayed nature-based algorithms to solve optimization problems both in engineering and robotics domains. Since these algorithms solve optimization problems as required however there is often a need for parameter tuning.
In this article, I would like to present and recommend a PSOPT soler using pseudospectral methods for finding optimal solutions (advantages of pseudospectral methods).
PSOPT (PSOPT on GitHub) was pioneered by Victor M. Becerra from the University of Portsmouth, UK.
PSOPT is an open-source software developed for optimum control and employs direct collocation techniques like pseudospectral and local discretizations. PSOPT was written in C++, and it is extremely fast.
As it was depicted above the PSOPT uses pseudospectral methods to find solutions for optimization problems. Under the hood, the PSOPT in optimal control problems uses global polynomials like Legendre or Chebyshev functions to approximate the time-dependent variables.
Local discretization techniques, which implement implicit Runge-Kutta integrators, use local splines to approximate the time-dependent functions.
The problem’s integrals, continuous constraints, and differential equations are discretized over a grid of nodes using both global and local approaches. The next step is to locate regionally ideal solutions using sparse nonlinear programming.
Installation for Linux users is straightforward. You will find details in Github. Besides the outstanding performance of PSOPT, the author of the following article was impressed by brilliant documentation and remarkable examples which can be compiled out of the box.
Optimal Rocket Time Problem
In order to learn this PSOPT I solved the optimal rocket time problem depicted in the thesis, Open-Source Software for Nonlinear Constrained Optimization of Dynamic Systems.
The source code for this problem you will find on my Github.
//simply clone folder to examples
//add to CMakeList.txt
//in psopt folder
cmake -DBUILD_EXAMPLES=ON ..
The challenge defined in the thesis is to minimize the rocket's travel time while ensuring that the rocket reaches its destination with zero velocity. There exist imposed constraints on the rocket’s positive and negative acceleration as well as maximum velocity. The author took also fuel usage into account.
The problem is specified as follows,
In order to decompose the above problem into the PSOPT interface data structure I followed paragraph 2.1 in the documentation.
endpoint_cost () — specify your objective function
dea() — differential-algebraic system of equations — define your differential equations. In the discussed example, we have to define altitude, velocity, and mass as variables.
events() — here we specify a vector containing the initial and final conditions of the rocket (consider problem equations for t0 and tf) — without values only events.
In main() function we have to specify the problem bounds information.
You can also modify the parameter of the solver (number of iterations, the parameter for polynomial, tolerance, etc).
The solution for the discussed problem can be depicted as follows.
Thank you for reading.