Solver Settings

LinearMPC uses the DAQP solver for solving quadratic programs. You can configure solver settings to adjust tolerances, iteration limits, and other parameters.

Changing Settings

After setting up the MPC controller, you can modify solver settings using DAQP.settings:

using LinearMPC

# Create and setup MPC
mpc = MPC(A, B; Np=10)
set_bounds!(mpc; umin=-1, umax=1)
setup!(mpc)

# Change solver settings
DAQP.settings(mpc.opt_model, Dict(
    :iter_limit => 2000,
    :primal_tol => 1e-8
))

# Compute control with new settings
u = compute_control(mpc, x)

Basic Settings

For full documentation of all DAQP settings, see the DAQP settings reference.

ParameterDescriptionDefault
primal_tolTolerance for primal infeasibility1e-6
dual_tolTolerance for dual infeasibility1e-12
progress_tolMinimum change in objective function to consider it progress1e-6
cycle_tolAllowed number of iterations without progress before terminating10
iter_limitMaximum number of iterations before terminating1000
rho_softWeight used for soft constraints (higher enables more violations)1e-6

Code Generation

When generating C code, you can pass solver settings via the opt_settings argument:

codegen(mpc; opt_settings=Dict(:iter_limit => 500))

These settings will be embedded in the generated C code.