Once a problem is defined in a problem structure and callback routines, solving the problem is done by calling solveSocsProblem.m.
Purpose
This function solves a previosly defined TOMLAB /SOCS problem by calling
the SOCS optimization software.
Calling Syntax
solution = solveSocsProblem(problem)
Description of Input
| problem | The problem structure containing the problem to solve. All callback functions referred to from the problem structure must be accessible in path. |
Description of Output
| solution | A structure containing the solution if the problem was solved, or if something went wrong, some information about the error. The structure has the same fields in both cases though. |
Upon a succesful solution process, the solution structure contains:
The solution structure does not contain values of the state and control variables at any particular time points. The user has to call evalSocsSolution.m to evaluate the values of the state and control variables at specific time points.
Table 4: TOMLAB /SOCS solution structure
solution structure inform double scalar (integer values) exittext string raw structure cstat double matrix, 1 x ipcph(end) - 1 ipcph double matrix (integer values), 1 x N + 1 dparm double matrix, ipdph(end) - 1 x N ipdph double matrix (integer values), 1 x N + 1 dims double matrix, N x 7 CPUtime double scalar phases array of structures, N time double matrix, 1 x k states double matrix, ns x k controls double matrix, nc x k parameters double matrix, np x k initial_time double scalar final_time double scalar
An integer information flag. This flag can take different values depending on whether an error occurred during solving or not. Inform == 0 means normal termination.
See the error file for a description of a nonzero value of inform.
A text tellin whether the solution process was succesful or not. In case of failure this is usually a text refering to the error file set in problem.options.ErrorFile.
Structure containing raw solution data. The solution generated by SOCS is expressed B-splines. This structure contains the coefficients for the B-splines representation of the solution, and also the values of the parameter variables.
A vector containing the B-spline coefficients. Consult the SOCS manual [2] from The Boeing Company to read about these in more detail.
Vector telling what coefficients in cstat belongs to which phase.
Parameter + free time variable values in the solution for all phases.
Vector telling what columns in dparm belongs to which phase.
Matrix containing the dimensions of the N phases. Each row i contains, for phase i:
[ns nc npcon necon np nodes namax]
Where ns, nc, npcon, necon, np, nodes are described in section 3.3. namax is the maximum number of auxiliary functions that occur for a path constraint in this phase.
The time spent solving the problem expressed in seconds.
An array of N structures. One for each phase. This structure contains, when returned from solveSocsProblem, only the values of initial- and final time and the parameter values.
An ns x k matrix containing the state variable values at the time points given in solution.phases.time.
This vector is empty when returned from solveSocsProblem.m.
An nc x k matrix containing the control variable values at the time points given in soltion.phases.time.
This vector is empty when returned from solveSocsProblem.m.
An np x 1 matrix containing the parameter variable values.
A double scalar containing the initial time value of the phase.
A double scalar containing the final time value of the phase.
One can evaluate the state variables and control variables at any time point within the phase. This is done through function evalSocsSolution.m:
Purpose
evalSocsSolution.m evaluates the values of the states and controls for
a phase at a number of time points. The computed values are added to
the solution structure and the solution structure is returned.
A call to evalSocsSolution.m doesn't remove the previously evaluated
values, but only adds the new ones.
Calling Syntax
solution = evalSocsSolution(solution, phase_number, t)
Description of Input
| solution | The solution structure from the problem to evaluate state and control variables of. |
| phase_number | The number of the phase to evaluate for. |
| t | A vector of time points to evaluate at. |
Description of Output
| solution | Solution with new information added in solution.phases(phase_number).time, solution.phases(phase_number).states and solution.phases(phase_number).controls. |
Example
To evaluate the solution in 50 time points uniformly distributed
between the phase start and end time of phase 1, do:
solution = evalSocsSolution(solution, 1,
linspace(solution.phases(1).initial_time,
solution.phases(1).final_time, 50));