# solveOCP

Solves an instance of the optimal control problem.

## Contents

- Syntax
- Description
- Input Arguments
- Output Arguments
- See Also

## Syntax

sol = solveOCP(obj,y0,x0)

## Description

This function solves the optimal control problem given the initial state x0 of the dynamical system and an initial guess y0 (all optimization variables including the states, control inputs, and slack variables).

## Input Arguments

obj | instance of class optimalControl
y0 | initial guess (double array of dimension [obj.idxVars.nVars, 1])
x0 | initial state of the dynamical system (double array of dimension [obj.nx, 1])

## Output Arguments

sol | solution to the optimal control problem - structure with the following fields
.isFeasible | true, if IPOPT converged to a feasible solution (boolean)
.x | optimal state trajectory (double array of dimension [obj.nx, obj.N+1])
.u | optimal control input trajectory (double array of dimension [obj.nu, obj.N])
.slack_bu | optimal slack variables - softened bounds on the control inputs (double array)

## See Also

-

© 2018-2026 I6 Technische Universität München `•` Website `•` License