openscvx 0.3.2.dev170__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of openscvx might be problematic. Click here for more details.

Files changed (79) hide show
  1. openscvx/__init__.py +123 -0
  2. openscvx/_version.py +34 -0
  3. openscvx/algorithms/__init__.py +92 -0
  4. openscvx/algorithms/autotuning.py +24 -0
  5. openscvx/algorithms/base.py +351 -0
  6. openscvx/algorithms/optimization_results.py +215 -0
  7. openscvx/algorithms/penalized_trust_region.py +384 -0
  8. openscvx/config.py +437 -0
  9. openscvx/discretization/__init__.py +47 -0
  10. openscvx/discretization/discretization.py +236 -0
  11. openscvx/expert/__init__.py +23 -0
  12. openscvx/expert/byof.py +326 -0
  13. openscvx/expert/lowering.py +419 -0
  14. openscvx/expert/validation.py +357 -0
  15. openscvx/integrators/__init__.py +48 -0
  16. openscvx/integrators/runge_kutta.py +281 -0
  17. openscvx/lowered/__init__.py +30 -0
  18. openscvx/lowered/cvxpy_constraints.py +23 -0
  19. openscvx/lowered/cvxpy_variables.py +124 -0
  20. openscvx/lowered/dynamics.py +34 -0
  21. openscvx/lowered/jax_constraints.py +133 -0
  22. openscvx/lowered/parameters.py +54 -0
  23. openscvx/lowered/problem.py +70 -0
  24. openscvx/lowered/unified.py +718 -0
  25. openscvx/plotting/__init__.py +63 -0
  26. openscvx/plotting/plotting.py +756 -0
  27. openscvx/plotting/scp_iteration.py +299 -0
  28. openscvx/plotting/viser/__init__.py +126 -0
  29. openscvx/plotting/viser/animated.py +605 -0
  30. openscvx/plotting/viser/plotly_integration.py +333 -0
  31. openscvx/plotting/viser/primitives.py +355 -0
  32. openscvx/plotting/viser/scp.py +459 -0
  33. openscvx/plotting/viser/server.py +112 -0
  34. openscvx/problem.py +734 -0
  35. openscvx/propagation/__init__.py +60 -0
  36. openscvx/propagation/post_processing.py +104 -0
  37. openscvx/propagation/propagation.py +248 -0
  38. openscvx/solvers/__init__.py +51 -0
  39. openscvx/solvers/cvxpy.py +226 -0
  40. openscvx/symbolic/__init__.py +9 -0
  41. openscvx/symbolic/augmentation.py +630 -0
  42. openscvx/symbolic/builder.py +492 -0
  43. openscvx/symbolic/constraint_set.py +92 -0
  44. openscvx/symbolic/expr/__init__.py +222 -0
  45. openscvx/symbolic/expr/arithmetic.py +517 -0
  46. openscvx/symbolic/expr/array.py +632 -0
  47. openscvx/symbolic/expr/constraint.py +796 -0
  48. openscvx/symbolic/expr/control.py +135 -0
  49. openscvx/symbolic/expr/expr.py +720 -0
  50. openscvx/symbolic/expr/lie/__init__.py +87 -0
  51. openscvx/symbolic/expr/lie/adjoint.py +357 -0
  52. openscvx/symbolic/expr/lie/se3.py +172 -0
  53. openscvx/symbolic/expr/lie/so3.py +138 -0
  54. openscvx/symbolic/expr/linalg.py +279 -0
  55. openscvx/symbolic/expr/math.py +699 -0
  56. openscvx/symbolic/expr/spatial.py +209 -0
  57. openscvx/symbolic/expr/state.py +607 -0
  58. openscvx/symbolic/expr/stl.py +136 -0
  59. openscvx/symbolic/expr/variable.py +321 -0
  60. openscvx/symbolic/hashing.py +112 -0
  61. openscvx/symbolic/lower.py +760 -0
  62. openscvx/symbolic/lowerers/__init__.py +106 -0
  63. openscvx/symbolic/lowerers/cvxpy.py +1302 -0
  64. openscvx/symbolic/lowerers/jax.py +1382 -0
  65. openscvx/symbolic/preprocessing.py +757 -0
  66. openscvx/symbolic/problem.py +110 -0
  67. openscvx/symbolic/time.py +116 -0
  68. openscvx/symbolic/unified.py +420 -0
  69. openscvx/utils/__init__.py +20 -0
  70. openscvx/utils/cache.py +131 -0
  71. openscvx/utils/caching.py +210 -0
  72. openscvx/utils/printing.py +301 -0
  73. openscvx/utils/profiling.py +37 -0
  74. openscvx/utils/utils.py +100 -0
  75. openscvx-0.3.2.dev170.dist-info/METADATA +350 -0
  76. openscvx-0.3.2.dev170.dist-info/RECORD +79 -0
  77. openscvx-0.3.2.dev170.dist-info/WHEEL +5 -0
  78. openscvx-0.3.2.dev170.dist-info/licenses/LICENSE +201 -0
  79. openscvx-0.3.2.dev170.dist-info/top_level.txt +1 -0
@@ -0,0 +1,135 @@
1
+ import numpy as np
2
+
3
+ from .variable import Variable
4
+
5
+
6
+ class Control(Variable):
7
+ """Control input variable for trajectory optimization problems.
8
+
9
+ Control represents control input variables (actuator commands) in a trajectory
10
+ optimization problem. Unlike State variables which evolve according to dynamics,
11
+ Controls are direct decision variables that the optimizer can freely adjust
12
+ (within specified bounds) at each time step to influence the system dynamics.
13
+
14
+ Controls are conceptually similar to State variables but simpler - they don't
15
+ have boundary conditions (initial/final specifications) since controls are
16
+ typically not constrained at the endpoints. Like States, Controls support:
17
+
18
+ - Min/max bounds to enforce actuator limits
19
+ - Initial trajectory guesses to help the optimizer converge
20
+
21
+ Common examples of control inputs include:
22
+
23
+ - Thrust magnitude and direction for spacecraft/rockets
24
+ - Throttle settings for engines
25
+ - Steering angles for vehicles
26
+ - Torques for robotic manipulators
27
+ - Force/acceleration commands
28
+
29
+ Attributes:
30
+ name (str): Unique name identifier for this control variable
31
+ _shape (tuple[int, ...]): Shape of the control vector (typically 1D like (3,) for 3D thrust)
32
+ _slice (slice | None): Internal slice information for variable indexing
33
+ _min (np.ndarray | None): Minimum bounds for each element of the control
34
+ _max (np.ndarray | None): Maximum bounds for each element of the control
35
+ _guess (np.ndarray | None): Initial guess for the control trajectory (n_points, n_controls)
36
+
37
+ Example:
38
+ Scalar throttle control bounded [0, 1]:
39
+
40
+ throttle = Control("throttle", shape=(1,))
41
+ throttle.min = [0.0]
42
+ throttle.max = [1.0]
43
+ throttle.guess = np.full((50, 1), 0.5) # Start at 50% throttle
44
+
45
+ 3D thrust vector for spacecraft:
46
+
47
+ thrust = Control("thrust", shape=(3,))
48
+ thrust.min = [-10, -10, 0] # No downward thrust
49
+ thrust.max = [10, 10, 50] # Limited thrust
50
+ thrust.guess = np.zeros((50, 3)) # Initialize with zero thrust
51
+
52
+ 2D steering control (left/right, forward/backward):
53
+
54
+ steer = Control("steer", shape=(2,))
55
+ steer.min = [-1, -1]
56
+ steer.max = [1, 1]
57
+ steer.guess = np.linspace([0, 0], [0, 1], 50) # Gradual acceleration
58
+ """
59
+
60
+ def __init__(self, name, shape):
61
+ """Initialize a Control object.
62
+
63
+ Args:
64
+ name: Name identifier for the control variable
65
+ shape: Shape of the control vector (typically 1D tuple like (3,))
66
+ """
67
+ super().__init__(name, shape)
68
+ self._scaling_min = None
69
+ self._scaling_max = None
70
+
71
+ @property
72
+ def scaling_min(self):
73
+ """Get the scaling minimum bounds for the control variables.
74
+
75
+ Returns:
76
+ Array of scaling minimum values for each control variable element, or None if not set.
77
+ """
78
+ return self._scaling_min
79
+
80
+ @scaling_min.setter
81
+ def scaling_min(self, val):
82
+ """Set the scaling minimum bounds for the control variables.
83
+
84
+ Args:
85
+ val: Array of scaling minimum values, must match the control shape exactly
86
+
87
+ Raises:
88
+ ValueError: If the shape doesn't match the control shape
89
+ """
90
+ if val is None:
91
+ self._scaling_min = None
92
+ return
93
+ val = np.asarray(val, dtype=float)
94
+ if val.shape != self.shape:
95
+ raise ValueError(
96
+ f"Scaling min shape {val.shape} does not match Control shape {self.shape}"
97
+ )
98
+ self._scaling_min = val
99
+
100
+ @property
101
+ def scaling_max(self):
102
+ """Get the scaling maximum bounds for the control variables.
103
+
104
+ Returns:
105
+ Array of scaling maximum values for each control variable element, or None if not set.
106
+ """
107
+ return self._scaling_max
108
+
109
+ @scaling_max.setter
110
+ def scaling_max(self, val):
111
+ """Set the scaling maximum bounds for the control variables.
112
+
113
+ Args:
114
+ val: Array of scaling maximum values, must match the control shape exactly
115
+
116
+ Raises:
117
+ ValueError: If the shape doesn't match the control shape
118
+ """
119
+ if val is None:
120
+ self._scaling_max = None
121
+ return
122
+ val = np.asarray(val, dtype=float)
123
+ if val.shape != self.shape:
124
+ raise ValueError(
125
+ f"Scaling max shape {val.shape} does not match Control shape {self.shape}"
126
+ )
127
+ self._scaling_max = val
128
+
129
+ def __repr__(self):
130
+ """String representation of the Control object.
131
+
132
+ Returns:
133
+ Concise string showing the control name and shape.
134
+ """
135
+ return f"Control('{self.name}', shape={self.shape})"