openscvx 2.dev1__py3-none-any.whl → 2.dev2__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.
openscvx/_version.py CHANGED
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '2.dev1'
22
- __version_tuple__ = version_tuple = (2, 'dev1')
21
+ __version__ = version = '2.dev2'
22
+ __version_tuple__ = version_tuple = (2, 'dev2')
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -6,8 +6,9 @@ optimization problems through iterative convex approximation.
6
6
 
7
7
  import time
8
8
  import warnings
9
- from typing import TYPE_CHECKING, Callable, Dict, List, Union
9
+ from typing import TYPE_CHECKING, Callable, Dict, List, Tuple, Union
10
10
 
11
+ import jax
11
12
  import numpy as np
12
13
  import numpy.linalg as la
13
14
 
@@ -188,6 +189,11 @@ class PenalizedTrustRegion(Algorithm):
188
189
  return solver.call(*args)
189
190
  return solver(*args)
190
191
 
192
+ @staticmethod
193
+ def _block_until_ready_outputs(outputs: Tuple[object, ...]) -> None:
194
+ """Finish any pending XLA work from discretization exports (warm-up helper)."""
195
+ jax.block_until_ready(outputs)
196
+
191
197
  def _recover_prior_node_from_initial(
192
198
  self,
193
199
  settings: Config,
@@ -286,7 +292,8 @@ class PenalizedTrustRegion(Algorithm):
286
292
  """Initialize PTR algorithm.
287
293
 
288
294
  Stores compiled infrastructure and performs a warm-start solve to
289
- initialize DPP and JAX jacobians.
295
+ initialize DPP and JAX jacobians. Also runs post-subproblem discretization
296
+ on the throwaway CVX solution so XLA/export caches match the first ``step()``.
290
297
 
291
298
  Args:
292
299
  solver: Convex subproblem solver (e.g., CVXPySolver)
@@ -333,7 +340,29 @@ class PenalizedTrustRegion(Algorithm):
333
340
  params,
334
341
  )
335
342
  init_state.add_impulsive_discretization(W_multi_shoot.__array__())
336
- _ = self._subproblem(params, init_state, settings)
343
+ (x_sol, u_sol, *_) = self._subproblem(params, init_state, settings)
344
+
345
+ # Prime the same exported discretization calls used after every subproblem in
346
+ # step() (candidate trajectory). initialize() previously only discretized the
347
+ # initial guess, so the first step() in solve() could still hit an XLA cache_miss
348
+ # on post-CVX (x_sol, u_sol). Running that path here moves compilation into init.
349
+ cont_out = self._invoke_solver(
350
+ self._discretization_solver, x_sol, u_sol.astype(float), params
351
+ )
352
+ x_prop_c = cont_out[3]
353
+ u_candidate = u_sol.astype(float)
354
+ x0_prior_c = self._recover_prior_node_from_initial(settings, x_sol[0])
355
+ x_nodes_prior_c = np.vstack((x0_prior_c, np.asarray(x_prop_c)))
356
+ if self._discretization_solver_impulsive is not None:
357
+ imp_out = self._invoke_solver(
358
+ self._discretization_solver_impulsive,
359
+ x_nodes_prior_c,
360
+ u_candidate,
361
+ params,
362
+ )
363
+ self._block_until_ready_outputs(cont_out + imp_out)
364
+ else:
365
+ self._block_until_ready_outputs(cont_out)
337
366
 
338
367
  def step(
339
368
  self,
@@ -9,16 +9,29 @@ the same structure, the cached compiled artifacts can be reused.
9
9
  """
10
10
 
11
11
  import hashlib
12
+ from importlib.metadata import PackageNotFoundError, version
12
13
  from typing import TYPE_CHECKING
13
14
 
14
15
  import numpy as np
15
16
 
16
- from openscvx._version import __version__
17
-
18
17
  if TYPE_CHECKING:
19
18
  from openscvx.symbolic.problem import SymbolicProblem
20
19
 
21
20
 
21
+ def _openscvx_version() -> str:
22
+ """Package version for cache invalidation; works without generated _version.py."""
23
+ try:
24
+ return version("openscvx")
25
+ except PackageNotFoundError:
26
+ pass
27
+ try:
28
+ from openscvx._version import __version__ as v
29
+
30
+ return v
31
+ except ImportError:
32
+ return "0.0.0"
33
+
34
+
22
35
  def hash_symbolic_problem(problem: "SymbolicProblem") -> str:
23
36
  """Compute a structural hash of a symbolic optimization problem.
24
37
 
@@ -47,7 +60,7 @@ def hash_symbolic_problem(problem: "SymbolicProblem") -> str:
47
60
  hasher = hashlib.sha256()
48
61
 
49
62
  # Include library version to invalidate cache on version changes
50
- hasher.update(f"openscvx:{__version__}:".encode())
63
+ hasher.update(f"openscvx:{_openscvx_version()}:".encode())
51
64
 
52
65
  # Hash the dynamics
53
66
  hasher.update(b"dynamics:")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openscvx
3
- Version: 2.dev1
3
+ Version: 2.dev2
4
4
  Summary: A general Python-based successive convexification implementation which uses a JAX backend.
5
5
  Author-email: Chris Hayner and Griffin Norris <haynec@uw.edu>
6
6
  License: Apache Software License
@@ -1,6 +1,6 @@
1
1
  openscvx/__init__.py,sha256=S-pt3p_BI5aOdOYPLrxKOshOeLEBXmqPoqZfROqq730,3542
2
2
  openscvx/__main__.py,sha256=Hwm7mtVg3tLdvoUPkpcQv8KF3wxl72PNLBp9axFu8GY,2991
3
- openscvx/_version.py,sha256=4w1vpaqG6FPfOy5YFO_ugNNX5OrGGKO6fMH-0ZI5wFs,523
3
+ openscvx/_version.py,sha256=U-q9bAeU59rRgUryJHtruyMJsxMPd7Yq_xsfqRREV4A,523
4
4
  openscvx/config.py,sha256=qfDDYoCe6WqJglKsx5b2W48YOglXenKr-PVRRdCFhYE,9898
5
5
  openscvx/loader.py,sha256=FvKLkkXd4ihd5FqLFF8Cd9VnPbPwTV_azBRnEipi28c,7654
6
6
  openscvx/problem.py,sha256=g-DKsdpZ5rOxEoMVOUj_QwB1L1edN0rgtRn8Z-TjgTI,47177
@@ -9,7 +9,7 @@ openscvx/algorithms/augmented_lagrangian.py,sha256=liEHtqONbpmw7CZJJCkAluPOEbFsl
9
9
  openscvx/algorithms/base.py,sha256=JsaVfS-hyHeGU1GUuQV9i-EpKQ1HBE0RHABIBGrEonM,30205
10
10
  openscvx/algorithms/constant_proximal_weight.py,sha256=UopFJHFHaFRTUnpeBEc_wYsSDvmxS9-bSKpI8JGYQII,2846
11
11
  openscvx/algorithms/optimization_results.py,sha256=Fk7tiW8IuMZa8Ri9-SHq9kmw3BPxXl1mc0yXy11w_-c,13416
12
- openscvx/algorithms/penalized_trust_region.py,sha256=ncM3BczFGIPRBrWXcMp_K-ZbJ1IkMJu7qxzPrmV2ilY,28687
12
+ openscvx/algorithms/penalized_trust_region.py,sha256=2UDZMYshpn0Z52JFjqPji5ececD0SGjZqhSrAT1DbD0,30164
13
13
  openscvx/algorithms/ramp_proximal_weight.py,sha256=19A-oerRMJjajQpHxeUeXdyTV0_Onr9cw1ttlwbY5_w,3383
14
14
  openscvx/algorithms/weights.py,sha256=DQV9NOR_-59lISv6d_el3cpQ-EcFasSGb1oZr4ma-yA,20682
15
15
  openscvx/discretization/__init__.py,sha256=lDMVvJMuaP3s78IqwQ2N-BmPPp7_vnll-TX5cU3ezlo,2799
@@ -61,7 +61,7 @@ openscvx/symbolic/__init__.py,sha256=aBwrKg6OnmbDL9pma9k4G009QWCOjM2Lmt_6MZPF7I4
61
61
  openscvx/symbolic/augmentation.py,sha256=qZWpcFenJawRM_VIRZmoJtYOLErx0jmb8eLvSf_xCvI,29555
62
62
  openscvx/symbolic/builder.py,sha256=ivkPY9tecg6KEgguEuOHknh_FRabWXlCUjXrnWuiwe0,24631
63
63
  openscvx/symbolic/constraint_set.py,sha256=HtLKmXvji9B47l1jzd5fEJSAFAKX93vyzDwux1xxayM,3476
64
- openscvx/symbolic/hashing.py,sha256=u9JJQpAskuC8mPntwdmWIdEtoL0BF96a-zbqkEXJX78,4320
64
+ openscvx/symbolic/hashing.py,sha256=OLSwuqFal9tKKtMxLAM9HBGb1bo5vzo-DG7srSy21lI,4686
65
65
  openscvx/symbolic/lower.py,sha256=zGMVRduOqzC-u3cU3Rw1y61EG-86waHdc-hP0XDh5io,31790
66
66
  openscvx/symbolic/preprocessing.py,sha256=Sqy_i5ntGWXdxcJCvql_034ZWoYU-kBRPEX34wgB344,36318
67
67
  openscvx/symbolic/problem.py,sha256=TblK3Z0orLaI_6_uPBVZP4SMxTSFXnUfNb0SICR-vFg,4853
@@ -137,9 +137,9 @@ openscvx/utils/caching.py,sha256=BPkT_IbmYT-i-BZ-himdWUc_4oBcwXWJxeUMwQWnSNc,934
137
137
  openscvx/utils/printing.py,sha256=zl3IxnKhwITqB5dK0Ru2IlORPqB61Y3DgsTryqMNu9M,13360
138
138
  openscvx/utils/profiling.py,sha256=k2x-i0CpG_kRe6dNcNBGu-ylrOtQw4B4C1UaOTjUMfU,1678
139
139
  openscvx/utils/utils.py,sha256=M25RHE_7DSr3Reaca0xCXnDSY9KHuqYvXdh5m1ZotEc,3047
140
- openscvx-2.dev1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
141
- openscvx-2.dev1.dist-info/METADATA,sha256=pYPpRpTVKMuApseklvwDpBvNFFl_znVuCJw81FQC8_E,10662
142
- openscvx-2.dev1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
143
- openscvx-2.dev1.dist-info/entry_points.txt,sha256=1Oqek8Sy28hmAZFgZXDxFXYVf56YLYWlHjhh9RYJ7wE,52
144
- openscvx-2.dev1.dist-info/top_level.txt,sha256=nUT4Ybefzh40H8tVXqc1RzKESy_MAowElb-CIvAbd4Q,9
145
- openscvx-2.dev1.dist-info/RECORD,,
140
+ openscvx-2.dev2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
141
+ openscvx-2.dev2.dist-info/METADATA,sha256=ZS2YI58BaQKZfK5RsfxJXH8KjaHNtrYDhHk0iJzlNGU,10662
142
+ openscvx-2.dev2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
143
+ openscvx-2.dev2.dist-info/entry_points.txt,sha256=1Oqek8Sy28hmAZFgZXDxFXYVf56YLYWlHjhh9RYJ7wE,52
144
+ openscvx-2.dev2.dist-info/top_level.txt,sha256=nUT4Ybefzh40H8tVXqc1RzKESy_MAowElb-CIvAbd4Q,9
145
+ openscvx-2.dev2.dist-info/RECORD,,