API¶
Warning
This page is still under development .
openscvx.dynamics.Dynamics
dataclass
¶
Dataclass to hold a system dynamics function and (optionally) its gradients.
This class is intended to be instantiated using the dynamics
decorator
wrapped around a function defining the system dynamics. Both the dynamics
and optional gradients should be composed of jax
primitives to enable
efficient computation.
Usage examples:
Or, if a more lambda-function-style is desired, the function can be directly wrapped:
Using Parameters in Dynamics
You can use symbolic Parameter
objects in your dynamics function to
represent tunable or environment-dependent values. The argument names
for parameters must match the parameter name with an underscore suffix
(e.g., I_sp_
for a parameter named I_sp
). This is required for the
parameter mapping to work correctly.
Example (3DoF rocket landing):
from openscvx.backend.parameter import Parameter
import jax.numpy as jnp
I_sp = Parameter("I_sp")
g = Parameter("g")
theta = Parameter("theta")
@dynamics
def rocket_dynamics(x_, u_, I_sp_, g_, theta_):
m = x_[6]
T = u_
r_dot = x_[3:6]
g_vec = jnp.array([0, 0, g_])
v_dot = T/m - g_vec
m_dot = -jnp.linalg.norm(T) / (I_sp_ * 9.807 * jnp.cos(theta_))
t_dot = 1
return jnp.hstack([r_dot, v_dot, m_dot, t_dot])
# Set parameter values before solving
I_sp.value = 225
g.value = 3.7114
theta.value = 27 * jnp.pi / 180
Using Parameters in Nodal Constraints
You can also use symbolic Parameter
objects in nodal constraints. As
with dynamics, the argument names for parameters in the constraint
function must match the parameter name with an underscore suffix
(e.g., g_
for a parameter named g
).
Example:
from openscvx.backend.parameter import Parameter
from openscvx.constraints import nodal
import jax.numpy as jnp
g = Parameter("g")
g.value = 3.7114
@nodal
def terminal_velocity_constraint(x_, u_, g_):
# Enforce a terminal velocity constraint using the gravity parameter
return x_[5] + g_ * x_[7] # e.g., vz + g * t <= 0 at final node
When building your problem, collect all parameters with
Parameter.get_all()
and pass them to your problem setup.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f
|
Callable[[ndarray, ndarray], ndarray]
|
Function defining the continuous time nonlinear system dynamics as x_dot = f(x, u, ...params). - x: 1D array (state at a single node), shape (n_x,) - u: 1D array (control at a single node), shape (n_u,) - Additional parameters: passed as keyword arguments with names matching the parameter name plus an underscore (e.g., g_ for Parameter('g')). If you want to use parameters, include them as extra arguments with the underscore naming convention. If you use vectorized integration or batch evaluation, x and u may be 2D arrays (N, n_x) and (N, n_u). |
required |
A
|
Optional[Callable[[ndarray, ndarray], ndarray]]
|
Jacobian of |
None
|
B
|
Optional[Callable[[ndarray, ndarray], ndarray]]
|
Jacobian of |
None
|
Returns:
Name | Type | Description |
---|---|---|
Dynamics |
A dataclass bundling the system dynamics function and |
|
Jacobians. |
Constraints¶
CTCSConstraint¶
openscvx.constraints.ctcs.CTCSConstraint
dataclass
¶
Dataclass for continuous-time constraint satisfaction (CTCS) constraints over a trajectory interval.
A CTCSConstraint
wraps a residual function func(x, u)
, applies a
pointwise penalty
to its outputs, and accumulates the penalized sum
only within a specified node interval [nodes[0], nodes[1]).
CTCS constraints are used for continuous-time constraints that need to be satisfied over trajectory intervals rather than at specific nodes. The constraint function should return residuals where positive values indicate constraint violations.
Usage examples:
@ctcs(penalty="huber", nodes=(0, 10), idx=2)
def g(x_, u_):
return jnp.sin(x_) + u_ # sin(x) + u <= 0 constraint
@ctcs(penalty="smooth_relu", scaling=0.5)
def g(x_, u_):
return x_[0]**2 + x_[1]**2 - 1.0 # ||x||^2 <= 1 constraint
Or can directly wrap a function if a more lambda-function interface is desired:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func
|
Callable[[ndarray, ndarray], ndarray]
|
Function computing constraint residuals g(x, u). - x: 1D array (state at a single node), shape (n_x,) - u: 1D array (control at a single node), shape (n_u,) - Additional parameters: passed as keyword arguments with names matching the parameter name plus an underscore (e.g., g_ for Parameter('g')). Should return positive values for constraint violations (g(x,u) > 0 indicates violation). If you want to use parameters, include them as extra arguments with the underscore naming convention. |
required |
penalty
|
Callable[[ndarray], ndarray]
|
Penalty function applied elementwise to g's output. Used to calculate and penalize constraint violation during state augmentation. Common penalties include: - "squared_relu": max(0, x)² (default) - "huber": smooth approximation of absolute value - "smooth_relu": differentiable version of ReLU |
required |
nodes
|
Optional[Tuple[int, int]]
|
Half-open interval (start, end) of node indices where this constraint is active. If None, the penalty applies at every node. |
None
|
idx
|
Optional[int]
|
Optional index used to group CTCS constraints. Used during automatic state augmentation.
All CTCS constraints with the same index must be active over the same |
None
|
grad_f_x
|
Optional[Callable[[ndarray, ndarray], ndarray]]
|
User-supplied gradient of |
None
|
grad_f_u
|
Optional[Callable[[ndarray, ndarray], ndarray]]
|
User-supplied gradient of |
None
|
scaling
|
float
|
Scaling factor to apply to the penalized sum. |
1.0
|
NodalConstraint¶
openscvx.constraints.nodal.NodalConstraint
dataclass
¶
Encapsulates a constraint function applied at specific trajectory nodes.
A NodalConstraint
wraps a function g(x, u)
that computes constraint residuals
for given state x
and input u
. It can optionally apply only at
a subset of trajectory nodes, support vectorized evaluation across nodes,
and integrate with convex solvers when convex=True
.
Expected input types:
Case | x, u type/shape |
---|---|
convex=False, vectorized=False | 1D arrays, shape (n_x,), (n_u,) (single node) |
convex=False, vectorized=True | 2D arrays, shape (N, n_x), (N, n_u) (all nodes) |
convex=True, vectorized=False | list of cvxpy variables, one per node |
convex=True, vectorized=True | list of cvxpy variables, one per node |
Expected output:
Case | Output type |
---|---|
convex=False, vectorized=False | float (single node) |
convex=False, vectorized=True | float array (per node) |
convex=True, vectorized=False | cvxpy expression (single node) |
convex=True, vectorized=True | list of cvxpy expressions (one per node) |
Nonconvex examples:
Or can directly wrap a function if a more lambda-function interface is desired:
Convex Examples:
Expected input types:
Case | x, u type/shape |
---|---|
convex=False, vectorized=False | 1D arrays, shape (n_x,), (n_u,) (single node) |
convex=False, vectorized=True | 2D arrays, shape (N, n_x), (N, n_u) (all nodes) |
convex=True, vectorized=False | list of cvxpy variables, one per node |
convex=True, vectorized=True | list of cvxpy variables, one per node |
Expected output:
Case | Output type |
---|---|
convex=False, vectorized=False | float (single node) |
convex=False, vectorized=True | float array (per node) |
convex=True, vectorized=False | cvxpy expression (single node) |
convex=True, vectorized=True | list of cvxpy expressions (one per node) |
Nonconvex examples:
Or can directly wrap a function if a more lambda-function interface is desired:
Convex Examples:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func
|
Callable
|
The user-supplied constraint function. The expected input and output
types depend on the values of Input/Output types: - convex=False, vectorized=False: x,u are 1D arrays (n_x,), (n_u,), returns float - convex=False, vectorized=True: x,u are 2D arrays (N, n_x), (N, n_u), returns float array - convex=True, vectorized=False: x,u are cvxpy variables, returns cvxpy expression - convex=True, vectorized=True: x,u are cvxpy variables, returns list of cvxpy expressions Additional parameters: always passed as keyword arguments with names
matching the parameter name plus an underscore (e.g., |
required |
nodes
|
Optional[List[int]]
|
Specific node indices where this constraint applies. If None, applies at all nodes. |
None
|
convex
|
bool
|
If True, the provided cvxpy.expression is directly passed to the cvxpy.problem. |
False
|
vectorized
|
bool
|
If False, automatically vectorizes |
False
|
grad_g_x
|
Optional[Callable[[ndarray, ndarray], ndarray]]
|
User-supplied gradient of |
None
|
grad_g_u
|
Optional[Callable[[ndarray, ndarray], ndarray]]
|
User-supplied gradient of |
None
|
get_cvxpy_constraints(x, u, *args, **kwargs)
¶
Evaluate the constraint function and always return a flat list of cvxpy constraints.
Integrators¶
RK45Integrator¶
openscvx.integrators.solve_ivp_rk45(f: Callable[[jnp.ndarray, jnp.ndarray, Any], jnp.ndarray], tau_final: float, y_0: jnp.ndarray, args, tau_0: float = 0.0, num_substeps: int = 50, is_not_compiled: bool = False)
¶
Solve an initial-value ODE problem using fixed-step RK45 integration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f
|
Callable[[ndarray, ndarray, Any], ndarray]
|
ODE right-hand side; signature f(t, y, *args) -> dy/dt. |
required |
tau_final
|
float
|
Final integration time. |
required |
y_0
|
ndarray
|
Initial state at tau_0. |
required |
args
|
tuple
|
Extra arguments to pass to |
required |
tau_0
|
float
|
Initial time. Defaults to 0.0. |
0.0
|
num_substeps
|
int
|
Number of output time points. Defaults to 50. |
50
|
is_not_compiled
|
bool
|
If True, use Python loop instead of
JAX |
False
|
Returns:
Type | Description |
---|---|
jnp.ndarray: Array of shape (num_substeps, state_dim) with solution at each time. |
openscvx.integrators.rk45_step(f: Callable[[jnp.ndarray, jnp.ndarray, Any], jnp.ndarray], t: jnp.ndarray, y: jnp.ndarray, h: float, *args) -> jnp.ndarray
¶
Perform a single RK45 (Runge-Kutta-Fehlberg) integration step.
This implements the classic Dorman-Prince coefficients for an explicit 4(5) method, returning the fourth-order estimate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f
|
Callable[[ndarray, ndarray, Any], ndarray]
|
ODE right-hand side; signature f(t, y, *args) -> dy/dt. |
required |
t
|
ndarray
|
Current time. |
required |
y
|
ndarray
|
Current state vector. |
required |
h
|
float
|
Step size. |
required |
*args
|
Additional arguments passed to |
()
|
Returns:
Type | Description |
---|---|
ndarray
|
jnp.ndarray: Next state estimate at t + h. |
Diffrax Integrators¶
openscvx.integrators.solve_ivp_diffrax(f: Callable[[jnp.ndarray, jnp.ndarray, Any], jnp.ndarray], tau_final: float, y_0: jnp.ndarray, args, tau_0: float = 0.0, num_substeps: int = 50, solver_name: str = 'Dopri8', rtol: float = 0.001, atol: float = 1e-06, extra_kwargs=None)
¶
Solve an initial-value ODE problem using a Diffrax adaptive solver.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f
|
Callable[[ndarray, ndarray, Any], ndarray]
|
ODE right-hand side; f(t, y, *args). |
required |
tau_final
|
float
|
Final integration time. |
required |
y_0
|
ndarray
|
Initial state at tau_0. |
required |
args
|
tuple
|
Extra arguments to pass to |
required |
tau_0
|
float
|
Initial time. Defaults to 0.0. |
0.0
|
num_substeps
|
int
|
Number of save points between tau_0 and tau_final. Defaults to 50. |
50
|
solver_name
|
str
|
Key into SOLVER_MAP for the Diffrax solver class. Defaults to "Dopri8". |
'Dopri8'
|
rtol
|
float
|
Relative tolerance for adaptive stepping. Defaults to 1e-3. |
0.001
|
atol
|
float
|
Absolute tolerance for adaptive stepping. Defaults to 1e-6. |
1e-06
|
extra_kwargs
|
dict
|
Additional keyword arguments forwarded to |
None
|
Returns:
Type | Description |
---|---|
jnp.ndarray: Solution states at the requested save points, shape (num_substeps, state_dim). |
Raises:
Type | Description |
---|---|
ValueError
|
If |
openscvx.integrators.solve_ivp_diffrax_prop(f: Callable[[jnp.ndarray, jnp.ndarray, Any], jnp.ndarray], tau_final: float, y_0: jnp.ndarray, args, tau_0: float = 0.0, num_substeps: int = 50, solver_name: str = 'Dopri8', rtol: float = 0.001, atol: float = 1e-06, extra_kwargs=None, save_time: jnp.ndarray = None, mask: jnp.ndarray = None)
¶
Solve an initial-value ODE problem using a Diffrax adaptive solver. This function is specifically designed for use in the context of trajectory optimization and handles the nonlinear single-shot propagation of state variables in undilated time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f
|
Callable[[ndarray, ndarray, Any], ndarray]
|
ODE right-hand side; signature f(t, y, *args) -> dy/dt. |
required |
tau_final
|
float
|
Final integration time. |
required |
y_0
|
ndarray
|
Initial state at tau_0. |
required |
args
|
tuple
|
Extra arguments to pass to |
required |
tau_0
|
float
|
Initial time. Defaults to 0.0. |
0.0
|
num_substeps
|
int
|
Number of save points between tau_0 and tau_final. Defaults to 50. |
50
|
solver_name
|
str
|
Key into SOLVER_MAP for the Diffrax solver class. Defaults to "Dopri8". |
'Dopri8'
|
rtol
|
float
|
Relative tolerance for adaptive stepping. Defaults to 1e-3. |
0.001
|
atol
|
float
|
Absolute tolerance for adaptive stepping. Defaults to 1e-6. |
1e-06
|
extra_kwargs
|
dict
|
Additional keyword arguments forwarded to |
None
|
save_time
|
ndarray
|
Time points at which to evaluate the solution. Must be provided for export compatibility. |
None
|
mask
|
ndarray
|
Boolean mask for the save_time points. |
None
|
Returns:
Type | Description |
---|---|
jnp.ndarray: Solution states at the requested save points, shape (num_substeps, state_dim). |
Raises:
ValueError: If solver_name
is not in SOLVER_MAP or if save_time is not provided.
TrajOptProblem¶
openscvx.trajoptproblem.TrajOptProblem.__init__(dynamics: Dynamics, constraints: List[Union[CTCSConstraint, NodalConstraint]], x: State, u: Control, N: int, idx_time: int, params: Optional[dict] = None, dynamics_prop: Optional[callable] = None, x_prop: State = None, scp: Optional[ScpConfig] = None, dis: Optional[DiscretizationConfig] = None, prp: Optional[PropagationConfig] = None, sim: Optional[SimConfig] = None, dev: Optional[DevConfig] = None, cvx: Optional[ConvexSolverConfig] = None, licq_min=0.0, licq_max=0.0001, time_dilation_factor_min=0.3, time_dilation_factor_max=3.0)
¶
The primary class in charge of compiling and exporting the solvers
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dynamics
|
Dynamics
|
Dynamics function decorated with @dynamics |
required |
constraints
|
List[Union[CTCSConstraint, NodalConstraint]]
|
List of constraints decorated with @ctcs or @nodal |
required |
idx_time
|
int
|
Index of the time variable in the state vector |
required |
N
|
int
|
Number of segments in the trajectory |
required |
time_init
|
float
|
Initial time for the trajectory |
required |
x_guess
|
ndarray
|
Initial guess for the state trajectory |
required |
u_guess
|
ndarray
|
Initial guess for the control trajectory |
required |
initial_state
|
BoundaryConstraint
|
Initial state constraint |
required |
final_state
|
BoundaryConstraint
|
Final state constraint |
required |
x_max
|
ndarray
|
Upper bound on the state variables |
required |
x_min
|
ndarray
|
Lower bound on the state variables |
required |
u_max
|
ndarray
|
Upper bound on the control variables |
required |
u_min
|
ndarray
|
Lower bound on the control variables |
required |
dynamics_prop
|
Optional[callable]
|
Propagation dynamics function decorated with @dynamics |
None
|
initial_state_prop
|
Propagation initial state constraint |
required | |
scp
|
Optional[ScpConfig]
|
SCP configuration object |
None
|
dis
|
Optional[DiscretizationConfig]
|
Discretization configuration object |
None
|
prp
|
Optional[PropagationConfig]
|
Propagation configuration object |
None
|
sim
|
Optional[SimConfig]
|
Simulation configuration object |
None
|
dev
|
Optional[DevConfig]
|
Development configuration object |
None
|
cvx
|
Optional[ConvexSolverConfig]
|
Convex solver configuration object |
None
|
Returns:
Type | Description |
---|---|
None |
ScpConfig¶
openscvx.config.ScpConfig.__init__(n: Optional[int] = None, k_max: int = 200, w_tr: float = 1.0, lam_vc: float = 1.0, ep_tr: float = 0.0001, ep_vb: float = 0.0001, ep_vc: float = 1e-08, lam_cost: float = 0.0, lam_vb: float = 0.0, uniform_time_grid: bool = False, cost_drop: int = -1, cost_relax: float = 1.0, w_tr_adapt: float = 1.0, w_tr_max: Optional[float] = None, w_tr_max_scaling_factor: Optional[float] = None)
¶
Configuration class for Sequential Convex Programming (SCP).
This class defines the parameters used to configure the SCP solver. You will very likely need to modify the weights for your problem. Please refer to my guide here for more information.
Attributes:
Name | Type | Description |
---|---|---|
n |
int
|
The number of discretization nodes. Defaults to |
k_max |
int
|
The maximum number of SCP iterations. Defaults to 200. |
w_tr |
float
|
The trust region weight. Defaults to 1.0. |
lam_vc |
float
|
The penalty weight for virtual control. Defaults to 1.0. |
ep_tr |
float
|
The trust region convergence tolerance. Defaults to 1e-4. |
ep_vb |
float
|
The boundary constraint convergence tolerance. Defaults to 1e-4. |
ep_vc |
float
|
The virtual constraint convergence tolerance. Defaults to 1e-8. |
lam_cost |
float
|
The weight for original cost. Defaults to 0.0. |
lam_vb |
float
|
The weight for virtual buffer. This is only used if there are nonconvex nodal constraints present. Defaults to 0.0. |
uniform_time_grid |
bool
|
Whether to use a uniform time grid.
Defaults to |
cost_drop |
int
|
The number of iterations to allow for cost stagnation before termination. Defaults to -1 (disabled). |
cost_relax |
float
|
The relaxation factor for cost reduction. Defaults to 1.0. |
w_tr_adapt |
float
|
The adaptation factor for the trust region weight. Defaults to 1.0. |
w_tr_max |
float
|
The maximum allowable trust region weight.
Defaults to |
w_tr_max_scaling_factor |
float
|
The scaling factor for the maximum
trust region weight. Defaults to |
DiscretizationConfig¶
openscvx.config.DiscretizationConfig.__init__(dis_type: str = 'FOH', custom_integrator: bool = False, solver: str = 'Tsit5', args: Optional[dict] = None, atol: float = 0.001, rtol: float = 1e-06)
¶
Configuration class for discretization settings.
This class defines the parameters required for discretizing system dynamics.
Main arguments: These are the arguments most commonly used day-to-day.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dis_type
|
str
|
The type of discretization to use (e.g., "FOH" for First-Order Hold). Defaults to "FOH". |
'FOH'
|
custom_integrator
|
bool
|
This enables our custom fixed-step RK45 algorithm. This tends to be faster than Diffrax but unless you're going for speed, it's recommended to stick with Diffrax for robustness and other solver options. Defaults to False. |
False
|
solver
|
str
|
Not used if custom_integrator is enabled. Any choice of solver in Diffrax is valid, please refer here, How to Choose a Solver. Defaults to "Tsit5". |
'Tsit5'
|
Other arguments: These arguments are less frequently used, and for most purposes you shouldn't need to understand these.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args
|
Dict
|
Additional arguments to pass to the solver which can be found here. Defaults to an empty dictionary. |
None
|
atol
|
float
|
Absolute tolerance for the solver. Defaults to 1e-3. |
0.001
|
rtol
|
float
|
Relative tolerance for the solver. Defaults to 1e-6. |
1e-06
|
PropagationConfig¶
openscvx.config.PropagationConfig.__init__(inter_sample: int = 30, dt: float = 0.01, solver: str = 'Dopri8', max_tau_len: int = 1000, args: Optional[dict] = None, atol: float = 0.001, rtol: float = 1e-06)
¶
Configuration class for propagation settings.
This class defines the parameters required for propagating the nonlinear system dynamics using the optimal control sequence.
Main arguments: These are the arguments most commonly used day-to-day.
Other arguments: The solver should likely not be changed as it is a high accuracy 8th-order Runge-Kutta method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inter_sample
|
int
|
How dense the propagation within multishot discretization should be. Defaults to 30. |
30
|
dt
|
float
|
The time step for propagation. Defaults to 0.1. |
0.01
|
solver
|
str
|
The numerical solver to use for propagation (e.g., "Dopri8"). Defaults to "Dopri8". |
'Dopri8'
|
max_tau_len
|
int
|
The maximum length of the time vector for propagation. Defaults to 1000. |
1000
|
args
|
Dict
|
Additional arguments to pass to the solver. Defaults to an empty dictionary. |
None
|
atol
|
float
|
Absolute tolerance for the solver. Defaults to 1e-3. |
0.001
|
rtol
|
float
|
Relative tolerance for the solver. Defaults to 1e-6. |
1e-06
|
SimConfig¶
openscvx.config.SimConfig.__init__(x: State, x_prop: State, u: Control, total_time: float, idx_x_true: slice, idx_x_true_prop: slice, idx_u_true: slice, idx_t: slice, idx_y: slice, idx_y_prop: slice, idx_s: slice, save_compiled: bool = True, ctcs_node_intervals: Optional[list] = None, constraints_ctcs: Optional[list[Callable]] = None, constraints_nodal: Optional[list[Callable]] = None, n_states: Optional[int] = None, n_states_prop: Optional[int] = None, n_controls: Optional[int] = None, scaling_x_overrides: Optional[list] = None, scaling_u_overrides: Optional[list] = None)
¶
Configuration class for simulation settings.
This class defines the parameters required for simulating a trajectory optimization problem.
Main arguments: These are the arguments most commonly used day-to-day.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
State
|
State object, must have .min and .max attributes for bounds. |
required |
x_prop
|
State
|
Propagation state object, must have .min and .max attributes for bounds. |
required |
u
|
Control
|
Control object, must have .min and .max attributes for bounds. |
required |
total_time
|
float
|
The total simulation time. |
required |
idx_x_true
|
slice
|
Slice for true state indices. |
required |
idx_x_true_prop
|
slice
|
Slice for true propagation state indices. |
required |
idx_u_true
|
slice
|
Slice for true control indices. |
required |
idx_t
|
slice
|
Slice for time index. |
required |
idx_y
|
slice
|
Slice for constraint violation indices. |
required |
idx_y_prop
|
slice
|
Slice for propagation constraint violation indices. |
required |
idx_s
|
slice
|
Slice for time dilation index. |
required |
save_compiled
|
bool
|
If True, save and reuse compiled solver functions. Defaults to True. |
True
|
ctcs_node_intervals
|
list
|
Node intervals for CTCS constraints. |
None
|
constraints_ctcs
|
list
|
List of CTCS constraints. |
None
|
constraints_nodal
|
list
|
List of nodal constraints. |
None
|
n_states
|
int
|
The number of state variables. Defaults to
|
None
|
n_states_prop
|
int
|
The number of propagation state
variables. Defaults to |
None
|
n_controls
|
int
|
The number of control variables. Defaults
to |
None
|
scaling_x_overrides
|
list
|
List of (upper_bound, lower_bound, idx) for custom state scaling. Each can be scalar or array, idx can be int, list, or slice. |
None
|
scaling_u_overrides
|
list
|
List of (upper_bound, lower_bound, idx) for custom control scaling. Each can be scalar or array, idx can be int, list, or slice. |
None
|
Note
You can specify custom scaling for specific states/controls using scaling_x_overrides and scaling_u_overrides. Any indices not covered by overrides will use the default min/max bounds.
ConvexSolverConfig¶
openscvx.config.ConvexSolverConfig.__init__(solver: str = 'QOCO', solver_args: Optional[dict] = None, cvxpygen: bool = False, cvxpygen_override: bool = False)
¶
Configuration class for convex solver settings.
This class defines the parameters required for configuring a convex solver.
These are the arguments most commonly used day-to-day. Generally I have found QOCO to be the most performant of the CVXPY solvers for these types of problems (I do have a bias as the author is from my group) and can handle up to SOCP's. CLARABEL is also a great option with feasibility checking and can handle a few more problem types. CVXPYGen is also great if your problem isn't too large. I have found qocogen to be the most performant of the CVXPYGen solvers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
solver
|
str
|
The name of the CVXPY solver to use. A list of options can be found here. Defaults to "QOCO". |
'QOCO'
|
solver_args
|
dict
|
Ensure you are using the correct arguments for your solver as they are not all common. Additional arguments to configure the solver, such as tolerances. Defaults to {"abstol": 1e-6, "reltol": 1e-9}. |
None
|
cvxpygen
|
bool
|
Whether to enable CVXPY code generation for the solver. Defaults to False. |
False
|
DevConfig¶
openscvx.config.DevConfig.__init__(profiling: bool = False, debug: bool = False, printing: bool = True)
¶
Configuration class for development settings.
This class defines the parameters used for development and debugging purposes.
Main arguments: These are the arguments most commonly used day-to-day.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
profiling
|
bool
|
Whether to enable profiling for performance analysis. Defaults to False. |
False
|
debug
|
bool
|
Disables all precompilation so you can place breakpoints and inspect values. Defaults to False. |
False
|
printing
|
bool
|
Whether to enable printing during development. Defaults to True. |
True
|