# TOMLAB  
# REGISTER (TOMLAB)
# LOGIN  
# myTOMLAB
TOMLAB LOGO

« Previous « Start » Next »

5  Solving a problem

Once a problem is defined in a problem structure and callback routines, solving the problem is done by calling solveSocsProblem.m.

5.1  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

problemThe problem structure containing the problem to solve. All callback functions referred to from the problem structure must be accessible in path.


Description of Output

solutionA 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.


5.2  Solution structure

Upon a succesful solution process, the solution structure contains:

  • an information flag and exit text telling it was succesful,
  • raw solution data, such as B-spline coefficients for the state and control variables, and values of the parameters including variable initial and final times,
  • the amount of time spent on solving the problem,
  • the parameter values, initial and final time values of the solution for all phases in a special array of structures.

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
solutionstructure
    informdouble scalar (integer values)
    exittextstring
  
    rawstructure
       cstatdouble matrix, 1 x ipcph(end) - 1
       ipcphdouble matrix (integer values), 1 x N + 1
       dparmdouble matrix, ipdph(end) - 1 x N
       ipdphdouble matrix (integer values), 1 x N + 1
       dimsdouble matrix, N x 7
  
    CPUtimedouble scalar
  
    phasesarray of structures, N
       timedouble matrix, 1 x k
       statesdouble matrix, ns x k
       controlsdouble matrix, nc x k
       parametersdouble matrix, np x k
       initial_timedouble scalar
       final_timedouble scalar
 

5.2.1  solution.inform

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.

5.2.2  solution.exittext

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.

5.2.3  solution.raw

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.

5.2.4  solution.raw.cstat

A vector containing the B-spline coefficients. Consult the SOCS manual [2] from The Boeing Company to read about these in more detail.

5.2.5  solution.raw.ipcph

Vector telling what coefficients in cstat belongs to which phase.

5.2.6  solution.raw.dparm

Parameter + free time variable values in the solution for all phases.

5.2.7  solution.raw.ipdph

Vector telling what columns in dparm belongs to which phase.

5.2.8  solution.raw.dims

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.

5.2.9  solution.CPUtime

The time spent solving the problem expressed in seconds.

5.2.10  solution.phases

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.

5.2.11  solution.phases.states

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.

5.2.12  solution.phases.controls

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.

5.2.13  solution.phases.parameters

An np x 1 matrix containing the parameter variable values.

5.2.14  solution.phases.initial_time

A double scalar containing the initial time value of the phase.

5.2.15  solution.phases.final_time

A double scalar containing the final time value of the phase.

5.3  Evaluating state and control variables

One can evaluate the state variables and control variables at any time point within the phase. This is done through function evalSocsSolution.m:

5.3.1  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

solutionThe solution structure from the problem to evaluate state and control variables of.
phase_numberThe number of the phase to evaluate for.
tA vector of time points to evaluate at.


Description of Output

solutionSolution 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));


« Previous « Start » Next »