API for Custom Solver

Main solver API

The main solver functions are in the table below.

Function

Description

void set_default_settings(Workspace* work)

Sets the default settings

void load_data(Workspace* work)

Loads the default problem data

void qoco_custom_solve(Workspace* work)

Solves the problem with qoco_custom

Settings

The settings are defined in the workspace.h file of qoco_custom and are identical to the QOCO settings which are described in settings. To change the settings, directly modify the settings struct as shown in the code snippet in calling.

Solution

The solution struct is within the workspace struct. To see how to access members fo the solution struct refer to the code snippet in calling (for example work.sol.obj returns the objective value). The members of the solution struct are given below.

Member

Description

x

Primal solution

s

Slack variable for conic constraints

y

Dual solution for equality constraints

z

Dual solution for conic constraints

iters

Number of iterations

obj

Objective value

pres

Primal residual

dres

Dual residual

gap

Duality gap

status

Solve status see exitflags

Status Flags

The solution struct contains the solve status flag. The various flags are given in the table below.

Status

Status Code

Value

Solver hasn’t been called

QOCO_CUSTOM_UNSOLVED

0

Solved to desired accuracy

QOCO_CUSTOM_SOLVED

1

Solved to low accuracy

QOCO_CUSTOM_SOLVED_INACCURATE

2

Numerical error or infeasible

QOCO_CUSTOM_NUMERICAL_ERROR

3

Iteration limit reached

QOCO_CUSTOM_MAX_ITER

4

Changing problem instance

Since the custom solvers are generated for a given problem family, users can solve any problem with identical sparsity patterns. This means that users can change the vector data c, b, and h, as well as the nonzero values in P, A, and G. To change the values, the user should directly modify the data within the Workspace struct as shown in calling.