config
ConvexSolverConfig
dataclass
¶
Source code in openscvx/config.py
__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
|
Source code in openscvx/config.py
DevConfig
dataclass
¶
Source code in openscvx/config.py
__init__(profiling: bool = False, debug: bool = False, printing: bool = True, verbosity: int = 2)
¶
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
|
verbosity
|
int
|
Verbosity level for iteration output. 1 (MINIMAL): Core metrics only (iter, cost, status) 2 (STANDARD): + timing, penalty terms (default) 3 (FULL): + autotuning diagnostics |
2
|
Source code in openscvx/config.py
DiscretizationConfig
dataclass
¶
Source code in openscvx/config.py
__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
|
Source code in openscvx/config.py
PropagationConfig
dataclass
¶
Source code in openscvx/config.py
__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
|
Source code in openscvx/config.py
ScpConfig
dataclass
¶
Source code in openscvx/config.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 | |
autotuner: Optional[AutotuningBase]
property
writable
¶
Return the configured autotuner, defaulting to AugmentedLagrangian.
If no custom autotuner instance has been provided, this property lazily
constructs a default :class:AugmentedLagrangian instance and caches it
on the config object. This keeps the configuration as the single source
of truth for the autotuning strategy while avoiding circular imports by
importing inside the method body.
lam_vc
property
writable
¶
Getter for lam_vc.
__init__(n: Optional[int] = None, n_states: Optional[int] = None, k_max: int = 200, lam_prox: float = 1.0, lam_vc: float = 10.0, lam_cost: float = 0.1, lam_vb: float = 0.0, ep_tr: float = 0.0001, ep_vb: float = 0.0001, ep_vc: float = 1e-08, uniform_time_grid: bool = False, autotuner: Optional[AutotuningBase] = 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. |
lam_prox |
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 |
autotuner |
bool
|
Optional custom autotuner instance. If not provided, defaults
to .. code-block:: python |
Note
Autotuner parameters can be accessed and modified via the autotuner
instance (e.g., problem.algorithm.autotuner.rho_max) after
initialization. Default values are set in the AugmentedLagrangian class.
Source code in openscvx/config.py
SimConfig
dataclass
¶
Source code in openscvx/config.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | |
ctcs_slice
property
¶
Slice for accessing CTCS augmented states.
ctcs_slice_prop
property
¶
Slice for accessing CTCS augmented states in propagation.
time_dilation_slice
property
¶
Slice for accessing time dilation in the control vector.
time_slice
property
¶
Slice for accessing time in the state vector.
true_control_slice
property
¶
Slice for accessing true (non-augmented) controls.
true_state_slice
property
¶
Slice for accessing true (non-augmented) states.
true_state_slice_prop
property
¶
Slice for accessing true (non-augmented) propagation states.
__init__(x: UnifiedState, x_prop: UnifiedState, u: UnifiedControl, total_time: float, save_compiled: bool = False, ctcs_node_intervals: Optional[list] = None, n_states: Optional[int] = None, n_states_prop: Optional[int] = None, n_controls: Optional[int] = 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 |
save_compiled
|
bool
|
If True, save and reuse compiled solver functions. Defaults to False. |
False
|
ctcs_node_intervals
|
list
|
Node intervals for CTCS 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
|
Note
You can specify custom scaling for specific states/controls using
the scaling_min and scaling_max attributes on State, Control, and Time objects.
If not set, the default min/max bounds will be used for scaling.