MTSOS: writing barrier functionsIn order to compile MTSOS, the user must provide a function for calculating the barrier at a given a point . Although it is possible to write the barrier funciton in MATLAB, doing so will incur a significant performance penalty, so users are encouraged to write their barrier function directly in C. A very brief introduction to barrier methodsA very brief introduction to barrier methods will be provided here and we will obscure many of the details to focus on implementation. For more information on barrier functions for interior point methods see Convex Optimization and . As outlined in Minimum-Time Speed Optimization Over a Fixed Path the constraints will have the form . For the purposes of explanation we will consider constraints of the more specific form , where is convex. In a barrier method, we reformulate our constraints as a cost in the objective by adding to the objective, where is the indicator function. If the constraint is satisfied, it will not contribute to the objective at all, while if it is unsatisfied, the objective will be infinite. Therefore, to minimize the objective, the constraints must be satisfied. Unfortunately, the indictaor is not differentiable so we approximate it by , where is a parameter that sets the accuracy of the approximation. As decreases, this approximation approaches the indicator function. Although we strongly encourage the use of the log barrier function, MTSOS is written to allow the use of an alternative barrier function if desired. If you have multiple constraints, say of them at evaluation point , then we evaluate them as . In the barrier function you must calculate , , and as described below. MATLABIf the user must write the barrier function in MATLAB, change the compiler to point to barreir_matlab.c instead of barrier_front.c. This will cause the algorithm to look to barrier_mat.m for the dynamics. The name of this file can be changed in barrier_matlab.c. [H G F] = barrier(S, S_prime, S_dprime, a, b, u,indicator,kappa,variables) Inputs
Outputs
C
InputsNote: these are all constant.
OutputsAllocated, but unitialized, arrays are provided for the user to populate. In particular, if an array needs to be zero, the values must be set to zero, do not assume any values in the arrays.
Tips for writing barrier functionsLog barrier gradients and HessiansSome useful quantities when using the log barrier function, are: where is . This suggests an advantageous structuring of the code for the calculation of the gradient and Hessian of . Example structure
|