ootk 3.0.0 → 4.0.0-1

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.
Files changed (357) hide show
  1. package/CHANGELOG.md +235 -10
  2. package/README.md +27 -40
  3. package/dist/coordinate/Hill.d.ts +49 -0
  4. package/dist/coordinate/Hill.js +222 -0
  5. package/dist/coordinate/Hill.js.map +1 -0
  6. package/dist/coordinate/index.d.ts +1 -0
  7. package/dist/coordinate/index.js +2 -0
  8. package/dist/coordinate/index.js.map +1 -0
  9. package/dist/covariance/CovarianceSample.d.ts +43 -0
  10. package/dist/covariance/CovarianceSample.js +147 -0
  11. package/dist/covariance/CovarianceSample.js.map +1 -0
  12. package/dist/covariance/StateCovariance.d.ts +42 -0
  13. package/dist/covariance/StateCovariance.js +65 -0
  14. package/dist/covariance/StateCovariance.js.map +1 -0
  15. package/dist/force/AtmosphericDrag.d.ts +31 -0
  16. package/dist/force/AtmosphericDrag.js +73 -0
  17. package/dist/force/AtmosphericDrag.js.map +1 -0
  18. package/dist/force/EarthGravity.d.ts +27 -0
  19. package/dist/force/EarthGravity.js +117 -0
  20. package/dist/force/EarthGravity.js.map +1 -0
  21. package/{lib/ootk.d.ts → dist/force/Force.d.ts} +12 -11
  22. package/dist/force/Force.js +31 -0
  23. package/dist/force/Force.js.map +1 -0
  24. package/dist/force/ForceModel.d.ts +37 -0
  25. package/dist/force/ForceModel.js +75 -0
  26. package/dist/force/ForceModel.js.map +1 -0
  27. package/dist/force/Gravity.d.ts +38 -0
  28. package/dist/force/Gravity.js +47 -0
  29. package/dist/force/Gravity.js.map +1 -0
  30. package/dist/{ootk.d.ts → force/SolarRadiationPressure.d.ts} +12 -11
  31. package/dist/force/SolarRadiationPressure.js +44 -0
  32. package/dist/force/SolarRadiationPressure.js.map +1 -0
  33. package/dist/force/ThirdBodyGravity.d.ts +26 -0
  34. package/dist/force/ThirdBodyGravity.js +57 -0
  35. package/dist/force/ThirdBodyGravity.js.map +1 -0
  36. package/dist/force/Thrust.d.ts +34 -0
  37. package/dist/force/Thrust.js +58 -0
  38. package/dist/force/Thrust.js.map +1 -0
  39. package/dist/interfaces/RfSensorParams.d.ts +28 -0
  40. package/dist/interfaces/RfSensorParams.js +24 -0
  41. package/dist/interfaces/RfSensorParams.js.map +1 -0
  42. package/dist/interfaces/index.d.ts +1 -0
  43. package/dist/interfaces/index.js +2 -0
  44. package/dist/interfaces/index.js.map +1 -0
  45. package/dist/interpolator/ChebyshevCoefficients.d.ts +50 -0
  46. package/dist/interpolator/ChebyshevCoefficients.js +94 -0
  47. package/dist/interpolator/ChebyshevCoefficients.js.map +1 -0
  48. package/dist/interpolator/ChebyshevInterpolator.d.ts +38 -0
  49. package/dist/interpolator/ChebyshevInterpolator.js +71 -0
  50. package/dist/interpolator/ChebyshevInterpolator.js.map +1 -0
  51. package/dist/interpolator/CubicSpline.d.ts +35 -0
  52. package/dist/interpolator/CubicSpline.js +69 -0
  53. package/dist/interpolator/CubicSpline.js.map +1 -0
  54. package/dist/interpolator/CubicSplineInterpolator.d.ts +36 -0
  55. package/dist/interpolator/CubicSplineInterpolator.js +80 -0
  56. package/dist/interpolator/CubicSplineInterpolator.js.map +1 -0
  57. package/dist/interpolator/FieldInterpolator.d.ts +28 -0
  58. package/dist/interpolator/FieldInterpolator.js +34 -0
  59. package/dist/interpolator/FieldInterpolator.js.map +1 -0
  60. package/dist/interpolator/Interpolator.d.ts +22 -0
  61. package/dist/interpolator/Interpolator.js +47 -0
  62. package/dist/interpolator/Interpolator.js.map +1 -0
  63. package/dist/interpolator/LagrangeInterpolator.d.ts +40 -0
  64. package/dist/interpolator/LagrangeInterpolator.js +159 -0
  65. package/dist/interpolator/LagrangeInterpolator.js.map +1 -0
  66. package/dist/interpolator/StateInterpolator.d.ts +27 -0
  67. package/dist/interpolator/StateInterpolator.js +35 -0
  68. package/dist/interpolator/StateInterpolator.js.map +1 -0
  69. package/dist/interpolator/VerletBlendInterpolator.d.ts +43 -0
  70. package/dist/interpolator/VerletBlendInterpolator.js +118 -0
  71. package/dist/interpolator/VerletBlendInterpolator.js.map +1 -0
  72. package/{lib/ootk.js → dist/main.d.ts} +13 -10
  73. package/dist/{objects/space-object.d.ts → main.js} +17 -23
  74. package/dist/main.js.map +1 -0
  75. package/dist/maneuver/TwoBurnOrbitTransfer.d.ts +41 -0
  76. package/dist/maneuver/TwoBurnOrbitTransfer.js +65 -0
  77. package/dist/maneuver/TwoBurnOrbitTransfer.js.map +1 -0
  78. package/dist/maneuver/Waypoint.d.ts +91 -0
  79. package/dist/maneuver/Waypoint.js +179 -0
  80. package/dist/maneuver/Waypoint.js.map +1 -0
  81. package/{lib/objects/detailed-sat.d.ts → dist/objects/DetailedSatellite.d.ts} +40 -36
  82. package/dist/objects/DetailedSatellite.js +136 -0
  83. package/dist/objects/DetailedSatellite.js.map +1 -0
  84. package/dist/objects/DetailedSensor.d.ts +42 -0
  85. package/dist/objects/DetailedSensor.js +65 -0
  86. package/dist/objects/DetailedSensor.js.map +1 -0
  87. package/dist/objects/LandObject.d.ts +33 -0
  88. package/dist/objects/LandObject.js +34 -0
  89. package/dist/objects/LandObject.js.map +1 -0
  90. package/dist/objects/Marker.d.ts +20 -0
  91. package/dist/objects/Marker.js +24 -0
  92. package/dist/objects/Marker.js.map +1 -0
  93. package/dist/objects/RfSensor.d.ts +41 -0
  94. package/dist/objects/RfSensor.js +67 -0
  95. package/dist/objects/RfSensor.js.map +1 -0
  96. package/dist/objects/index.d.ts +5 -4
  97. package/dist/objects/index.js +6 -0
  98. package/dist/objects/index.js.map +1 -0
  99. package/dist/observation/Observation.d.ts +89 -0
  100. package/dist/observation/Observation.js +102 -0
  101. package/dist/observation/Observation.js.map +1 -0
  102. package/dist/observation/ObservationOptical.d.ts +48 -0
  103. package/dist/observation/ObservationOptical.js +105 -0
  104. package/dist/observation/ObservationOptical.js.map +1 -0
  105. package/dist/observation/ObservationRadar.d.ts +46 -0
  106. package/dist/observation/ObservationRadar.js +96 -0
  107. package/dist/observation/ObservationRadar.js.map +1 -0
  108. package/dist/observation/ObservationUtils.d.ts +20 -0
  109. package/dist/observation/ObservationUtils.js +32 -0
  110. package/dist/observation/ObservationUtils.js.map +1 -0
  111. package/dist/observation/PropagatorPairs.d.ts +32 -0
  112. package/dist/observation/PropagatorPairs.js +43 -0
  113. package/dist/observation/PropagatorPairs.js.map +1 -0
  114. package/dist/operations/BoxMuller.d.ts +46 -0
  115. package/dist/operations/BoxMuller.js +77 -0
  116. package/dist/operations/BoxMuller.js.map +1 -0
  117. package/dist/operations/EulerAngles.d.ts +105 -0
  118. package/dist/operations/EulerAngles.js +161 -0
  119. package/dist/operations/EulerAngles.js.map +1 -0
  120. package/dist/operations/Quaternion.d.ts +56 -0
  121. package/dist/operations/Quaternion.js +167 -0
  122. package/dist/operations/Quaternion.js.map +1 -0
  123. package/dist/operations/RandomGaussianSource.d.ts +24 -0
  124. package/dist/operations/RandomGaussianSource.js +43 -0
  125. package/dist/operations/RandomGaussianSource.js.map +1 -0
  126. package/dist/operations/index.d.ts +4 -0
  127. package/dist/operations/index.js +5 -0
  128. package/dist/operations/index.js.map +1 -0
  129. package/dist/optimize/ChebyshevCompressor.d.ts +32 -0
  130. package/dist/optimize/ChebyshevCompressor.js +83 -0
  131. package/dist/optimize/ChebyshevCompressor.js.map +1 -0
  132. package/dist/optimize/DownhillSimplex.d.ts +64 -0
  133. package/dist/optimize/DownhillSimplex.js +182 -0
  134. package/dist/optimize/DownhillSimplex.js.map +1 -0
  135. package/dist/optimize/GoldenSection.d.ts +39 -0
  136. package/dist/optimize/GoldenSection.js +55 -0
  137. package/dist/optimize/GoldenSection.js.map +1 -0
  138. package/dist/optimize/PolynomialRegression.d.ts +49 -0
  139. package/dist/optimize/PolynomialRegression.js +83 -0
  140. package/dist/optimize/PolynomialRegression.js.map +1 -0
  141. package/dist/optimize/PolynomicalRegressionResult.d.ts +31 -0
  142. package/dist/optimize/PolynomicalRegressionResult.js +38 -0
  143. package/dist/optimize/PolynomicalRegressionResult.js.map +1 -0
  144. package/dist/optimize/SimpleLinearRegression.d.ts +44 -0
  145. package/dist/optimize/SimpleLinearRegression.js +112 -0
  146. package/dist/optimize/SimpleLinearRegression.js.map +1 -0
  147. package/dist/optimize/SimplexEntry.d.ts +32 -0
  148. package/dist/optimize/SimplexEntry.js +42 -0
  149. package/dist/optimize/SimplexEntry.js.map +1 -0
  150. package/dist/orbit_determination/BatchLeastSquaresOD.d.ts +65 -0
  151. package/dist/orbit_determination/BatchLeastSquaresOD.js +143 -0
  152. package/dist/orbit_determination/BatchLeastSquaresOD.js.map +1 -0
  153. package/dist/orbit_determination/BatchLeastSquaresResult.d.ts +31 -0
  154. package/{lib/objects/space-object.d.ts → dist/orbit_determination/BatchLeastSquaresResult.js} +21 -23
  155. package/dist/orbit_determination/BatchLeastSquaresResult.js.map +1 -0
  156. package/dist/orbit_determination/GibbsIOD.d.ts +38 -0
  157. package/dist/orbit_determination/GibbsIOD.js +76 -0
  158. package/dist/orbit_determination/GibbsIOD.js.map +1 -0
  159. package/dist/orbit_determination/GoodingIOD.d.ts +51 -0
  160. package/dist/orbit_determination/GoodingIOD.js +247 -0
  161. package/dist/orbit_determination/GoodingIOD.js.map +1 -0
  162. package/dist/orbit_determination/HerrickGibbsIOD.d.ts +33 -0
  163. package/dist/orbit_determination/HerrickGibbsIOD.js +50 -0
  164. package/dist/orbit_determination/HerrickGibbsIOD.js.map +1 -0
  165. package/dist/orbit_determination/LambertIOD.d.ts +59 -0
  166. package/dist/orbit_determination/LambertIOD.js +213 -0
  167. package/dist/orbit_determination/LambertIOD.js.map +1 -0
  168. package/dist/orbit_determination/ModifiedGoodingIOD.d.ts +40 -0
  169. package/dist/orbit_determination/ModifiedGoodingIOD.js +83 -0
  170. package/dist/orbit_determination/ModifiedGoodingIOD.js.map +1 -0
  171. package/dist/propagator/DormandPrince54Propagator.d.ts +28 -0
  172. package/dist/propagator/DormandPrince54Propagator.js +64 -0
  173. package/dist/propagator/DormandPrince54Propagator.js.map +1 -0
  174. package/dist/propagator/KeplerPropagator.d.ts +35 -0
  175. package/dist/propagator/KeplerPropagator.js +84 -0
  176. package/dist/propagator/KeplerPropagator.js.map +1 -0
  177. package/dist/propagator/Propagator.d.ts +34 -0
  178. package/dist/propagator/Propagator.js +162 -0
  179. package/dist/propagator/Propagator.js.map +1 -0
  180. package/dist/propagator/RkCheckpoint.d.ts +22 -0
  181. package/dist/propagator/RkCheckpoint.js +27 -0
  182. package/dist/propagator/RkCheckpoint.js.map +1 -0
  183. package/dist/propagator/RkResult.d.ts +23 -0
  184. package/dist/propagator/RkResult.js +30 -0
  185. package/dist/propagator/RkResult.js.map +1 -0
  186. package/dist/propagator/RungeKutta4Propagator.d.ts +50 -0
  187. package/dist/propagator/RungeKutta4Propagator.js +141 -0
  188. package/dist/propagator/RungeKutta4Propagator.js.map +1 -0
  189. package/dist/propagator/RungeKutta89Propagator.d.ts +28 -0
  190. package/dist/propagator/RungeKutta89Propagator.js +126 -0
  191. package/dist/propagator/RungeKutta89Propagator.js.map +1 -0
  192. package/dist/propagator/RungeKuttaAdaptive.d.ts +54 -0
  193. package/dist/propagator/RungeKuttaAdaptive.js +159 -0
  194. package/dist/propagator/RungeKuttaAdaptive.js.map +1 -0
  195. package/dist/propagator/Sgp4Propagator.d.ts +34 -0
  196. package/dist/propagator/Sgp4Propagator.js +56 -0
  197. package/dist/propagator/Sgp4Propagator.js.map +1 -0
  198. package/dist/smoothing/ExponentialSmoothing.d.ts +23 -0
  199. package/dist/smoothing/ExponentialSmoothing.js +81 -0
  200. package/dist/smoothing/ExponentialSmoothing.js.map +1 -0
  201. package/dist/transforms/index.d.ts +1 -0
  202. package/dist/transforms/index.js +2 -0
  203. package/dist/transforms/index.js.map +1 -0
  204. package/dist/transforms/transforms.d.ts +56 -92
  205. package/dist/transforms/transforms.js +94 -0
  206. package/dist/transforms/transforms.js.map +1 -0
  207. package/dist/types/types.d.ts +105 -584
  208. package/dist/types/types.js +23 -0
  209. package/dist/types/types.js.map +1 -0
  210. package/dist/utils/index.d.ts +1 -0
  211. package/dist/utils/index.js +2 -0
  212. package/dist/utils/index.js.map +1 -0
  213. package/dist/utils/jacobian.d.ts +11 -0
  214. package/dist/utils/jacobian.js +29 -0
  215. package/dist/utils/jacobian.js.map +1 -0
  216. package/package.json +34 -42
  217. package/src/coordinate/Hill.ts +326 -0
  218. package/src/coordinate/index.ts +1 -0
  219. package/src/covariance/CovarianceSample.ts +194 -0
  220. package/src/covariance/StateCovariance.ts +69 -0
  221. package/src/force/AtmosphericDrag.ts +101 -0
  222. package/src/force/EarthGravity.ts +157 -0
  223. package/src/force/Force.ts +33 -0
  224. package/src/force/ForceModel.ts +91 -0
  225. package/src/force/Gravity.ts +53 -0
  226. package/src/force/SolarRadiationPressure.ts +42 -0
  227. package/src/force/ThirdBodyGravity.ts +62 -0
  228. package/src/force/Thrust.ts +83 -0
  229. package/src/interfaces/RfSensorParams.ts +30 -0
  230. package/src/interfaces/index.ts +1 -0
  231. package/src/interpolator/ChebyshevCoefficients.ts +109 -0
  232. package/src/interpolator/ChebyshevInterpolator.ts +87 -0
  233. package/src/interpolator/CubicSpline.ts +72 -0
  234. package/src/interpolator/CubicSplineInterpolator.ts +90 -0
  235. package/src/interpolator/FieldInterpolator.ts +37 -0
  236. package/src/interpolator/Interpolator.ts +56 -0
  237. package/src/interpolator/LagrangeInterpolator.ts +192 -0
  238. package/src/interpolator/StateInterpolator.ts +39 -0
  239. package/src/interpolator/VerletBlendInterpolator.ts +146 -0
  240. package/src/main.ts +32 -0
  241. package/src/maneuver/TwoBurnOrbitTransfer.ts +79 -0
  242. package/src/maneuver/Waypoint.ts +267 -0
  243. package/src/objects/DetailedSatellite.ts +159 -0
  244. package/src/objects/DetailedSensor.ts +68 -0
  245. package/src/objects/LandObject.ts +46 -0
  246. package/src/objects/Marker.ts +25 -0
  247. package/src/objects/RfSensor.ts +78 -0
  248. package/src/objects/index.ts +5 -0
  249. package/src/observation/Observation.ts +125 -0
  250. package/src/observation/ObservationOptical.ts +146 -0
  251. package/src/observation/ObservationRadar.ts +131 -0
  252. package/src/observation/ObservationUtils.ts +40 -0
  253. package/src/observation/PropagatorPairs.ts +45 -0
  254. package/src/operations/BoxMuller.ts +87 -0
  255. package/src/operations/EulerAngles.ts +183 -0
  256. package/src/operations/Quaternion.ts +222 -0
  257. package/src/operations/RandomGaussianSource.ts +51 -0
  258. package/src/operations/index.ts +4 -0
  259. package/src/optimize/ChebyshevCompressor.ts +96 -0
  260. package/src/optimize/DownhillSimplex.ts +212 -0
  261. package/src/optimize/GoldenSection.ts +71 -0
  262. package/src/optimize/PolynomialRegression.ts +109 -0
  263. package/src/optimize/PolynomicalRegressionResult.ts +32 -0
  264. package/src/optimize/SimpleLinearRegression.ts +127 -0
  265. package/src/optimize/SimplexEntry.ts +50 -0
  266. package/src/orbit_determination/BatchLeastSquaresOD.ts +174 -0
  267. package/src/orbit_determination/BatchLeastSquaresResult.ts +33 -0
  268. package/src/orbit_determination/GibbsIOD.ts +95 -0
  269. package/src/orbit_determination/GoodingIOD.ts +380 -0
  270. package/src/orbit_determination/HerrickGibbsIOD.ts +51 -0
  271. package/src/orbit_determination/LambertIOD.ts +260 -0
  272. package/src/orbit_determination/ModifiedGoodingIOD.ts +133 -0
  273. package/src/propagator/DormandPrince54Propagator.ts +73 -0
  274. package/src/propagator/KeplerPropagator.ts +102 -0
  275. package/src/propagator/Propagator.ts +253 -0
  276. package/src/propagator/RkCheckpoint.ts +25 -0
  277. package/src/propagator/RkResult.ts +26 -0
  278. package/src/propagator/RungeKutta4Propagator.ts +179 -0
  279. package/src/propagator/RungeKutta89Propagator.ts +132 -0
  280. package/src/propagator/RungeKuttaAdaptive.ts +232 -0
  281. package/src/propagator/Sgp4Propagator.ts +71 -0
  282. package/src/smoothing/ExponentialSmoothing.ts +90 -0
  283. package/src/transforms/index.ts +1 -0
  284. package/src/transforms/transforms.ts +117 -0
  285. package/src/types/types.ts +135 -0
  286. package/src/utils/index.ts +1 -0
  287. package/src/utils/jacobian.ts +38 -0
  288. package/.eslintrc.json +0 -244
  289. package/.prettierrc +0 -17
  290. package/babel.config.js +0 -16
  291. package/codecov.yml +0 -21
  292. package/dist/objects/base-object.d.ts +0 -40
  293. package/dist/objects/detailed-sat.d.ts +0 -66
  294. package/dist/objects/sat.d.ts +0 -92
  295. package/dist/objects/sensor.d.ts +0 -93
  296. package/dist/objects/star.d.ts +0 -46
  297. package/dist/ootk.js +0 -2
  298. package/dist/ootk.js.LICENSE.txt +0 -77
  299. package/dist/sgp4/sgp4.d.ts +0 -82
  300. package/dist/tle/tle-format-data.d.ts +0 -6
  301. package/dist/tle/tle.d.ts +0 -375
  302. package/dist/utils/constants.d.ts +0 -34
  303. package/dist/utils/moon-math.d.ts +0 -113
  304. package/dist/utils/sun-math.d.ts +0 -230
  305. package/dist/utils/utils.d.ts +0 -39
  306. package/jest.config.ts +0 -30
  307. package/lib/objects/base-object.d.ts +0 -40
  308. package/lib/objects/base-object.js +0 -79
  309. package/lib/objects/base-object.js.map +0 -1
  310. package/lib/objects/detailed-sat.js +0 -149
  311. package/lib/objects/detailed-sat.js.map +0 -1
  312. package/lib/objects/index.d.ts +0 -4
  313. package/lib/objects/index.js +0 -5
  314. package/lib/objects/index.js.map +0 -1
  315. package/lib/objects/sat.d.ts +0 -92
  316. package/lib/objects/sat.js +0 -188
  317. package/lib/objects/sat.js.map +0 -1
  318. package/lib/objects/sensor.d.ts +0 -93
  319. package/lib/objects/sensor.js +0 -273
  320. package/lib/objects/sensor.js.map +0 -1
  321. package/lib/objects/space-object.js +0 -60
  322. package/lib/objects/space-object.js.map +0 -1
  323. package/lib/objects/star.d.ts +0 -46
  324. package/lib/objects/star.js +0 -91
  325. package/lib/objects/star.js.map +0 -1
  326. package/lib/ootk.js.map +0 -1
  327. package/lib/sgp4/sgp4.d.ts +0 -82
  328. package/lib/sgp4/sgp4.js +0 -3262
  329. package/lib/sgp4/sgp4.js.map +0 -1
  330. package/lib/tle/tle-format-data.d.ts +0 -6
  331. package/lib/tle/tle-format-data.js +0 -10
  332. package/lib/tle/tle-format-data.js.map +0 -1
  333. package/lib/tle/tle.d.ts +0 -375
  334. package/lib/tle/tle.js +0 -611
  335. package/lib/tle/tle.js.map +0 -1
  336. package/lib/transforms/transforms.d.ts +0 -94
  337. package/lib/transforms/transforms.js +0 -308
  338. package/lib/transforms/transforms.js.map +0 -1
  339. package/lib/types/types.d.ts +0 -605
  340. package/lib/types/types.js +0 -36
  341. package/lib/types/types.js.map +0 -1
  342. package/lib/utils/constants.d.ts +0 -34
  343. package/lib/utils/constants.js +0 -35
  344. package/lib/utils/constants.js.map +0 -1
  345. package/lib/utils/moon-math.d.ts +0 -113
  346. package/lib/utils/moon-math.js +0 -387
  347. package/lib/utils/moon-math.js.map +0 -1
  348. package/lib/utils/sun-math.d.ts +0 -230
  349. package/lib/utils/sun-math.js +0 -422
  350. package/lib/utils/sun-math.js.map +0 -1
  351. package/lib/utils/utils.d.ts +0 -39
  352. package/lib/utils/utils.js +0 -102
  353. package/lib/utils/utils.js.map +0 -1
  354. package/sandbox.html +0 -8
  355. package/tsconfig.base.json +0 -31
  356. package/tsconfig.build.json +0 -14
  357. /package/{LICENSE.MD → LICENSE.md} +0 -0
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @author @thkruz Theodore Kruczek
3
+ * @license AGPL-3.0-or-later
4
+ * @copyright (c) 2020-2024 Theodore Kruczek
5
+ *
6
+ * Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
7
+ * terms of the GNU Affero General Public License as published by the Free Software
8
+ * Foundation, either version 3 of the License, or (at your option) any later version.
9
+ *
10
+ * Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
+ * See the GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License along with
15
+ * Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+ import { Vector } from 'ootk-core';
18
+ import { BoxMuller } from './BoxMuller';
19
+ export class RandomGaussianSource {
20
+ _boxMuller;
21
+ constructor(seed = 0) {
22
+ this._boxMuller = new BoxMuller(0, 1, seed);
23
+ }
24
+ nextGauss() {
25
+ return this._boxMuller.nextGauss();
26
+ }
27
+ gaussVector(n) {
28
+ if (n < 1) {
29
+ throw new Error('n must be greater than 0');
30
+ }
31
+ const result = new Vector([this.nextGauss()]);
32
+ for (let i = 0; i < n; i++) {
33
+ if (i > 0) {
34
+ result.add(new Vector([this.nextGauss()]));
35
+ }
36
+ }
37
+ return result;
38
+ }
39
+ gaussSphere(radius = 1.0) {
40
+ return this.gaussVector(3).toVector3D(0).normalize().scale(radius);
41
+ }
42
+ }
43
+ //# sourceMappingURL=RandomGaussianSource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RandomGaussianSource.js","sourceRoot":"","sources":["../../src/operations/RandomGaussianSource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,MAAM,EAAY,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,OAAO,oBAAoB;IACvB,UAAU,CAAY;IAE9B,YAAY,IAAI,GAAG,CAAC;QAClB,IAAI,CAAC,UAAU,GAAG,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;IAC9C,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;IACrC,CAAC;IAED,WAAW,CAAC,CAAS;QACnB,IAAI,CAAC,GAAG,CAAC,EAAE;YACT,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;SAC7C;QAED,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QAE9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;YAC1B,IAAI,CAAC,GAAG,CAAC,EAAE;gBACT,MAAM,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;aAC5C;SACF;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,WAAW,CAAC,MAAM,GAAG,GAAG;QACtB,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACrE,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ export { BoxMuller } from './BoxMuller';
2
+ export { EulerAngles } from './EulerAngles';
3
+ export { Quaternion } from './Quaternion';
4
+ export { RandomGaussianSource } from './RandomGaussianSource';
@@ -0,0 +1,5 @@
1
+ export { BoxMuller } from './BoxMuller';
2
+ export { EulerAngles } from './EulerAngles';
3
+ export { Quaternion } from './Quaternion';
4
+ export { RandomGaussianSource } from './RandomGaussianSource';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/operations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @author @thkruz Theodore Kruczek
3
+ * @license AGPL-3.0-or-later
4
+ * @copyright (c) 2020-2024 Theodore Kruczek
5
+ *
6
+ * Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
7
+ * terms of the GNU Affero General Public License as published by the Free Software
8
+ * Foundation, either version 3 of the License, or (at your option) any later version.
9
+ *
10
+ * Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
+ * See the GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License along with
15
+ * Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+ import { StateInterpolator } from '../interpolator/StateInterpolator';
18
+ import { ChebyshevInterpolator } from './../interpolator/ChebyshevInterpolator';
19
+ export declare class ChebyshevCompressor {
20
+ private _interpolator;
21
+ constructor(_interpolator: StateInterpolator);
22
+ private static _cosPi;
23
+ private _fitCoefficient;
24
+ private _fitWindow;
25
+ /**
26
+ * Compress this object's interpolater, using the provided coefficients
27
+ * per revolution [cpr].
28
+ * @param cpr Coefficients per revolution.
29
+ * @returns A new [ChebyshevInterpolator] object.
30
+ */
31
+ compress(cpr?: number): ChebyshevInterpolator;
32
+ }
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @author @thkruz Theodore Kruczek
3
+ * @license AGPL-3.0-or-later
4
+ * @copyright (c) 2020-2024 Theodore Kruczek
5
+ *
6
+ * Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
7
+ * terms of the GNU Affero General Public License as published by the Free Software
8
+ * Foundation, either version 3 of the License, or (at your option) any later version.
9
+ *
10
+ * Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
+ * See the GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License along with
15
+ * Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+ import { EpochUTC, Vector3D } from 'ootk-core';
18
+ import { ChebyshevCoefficients } from './../interpolator/ChebyshevCoefficients';
19
+ import { ChebyshevInterpolator } from './../interpolator/ChebyshevInterpolator';
20
+ // / Ephemeris compressor.
21
+ export class ChebyshevCompressor {
22
+ _interpolator;
23
+ // / Create a new [ChebyshevCompressor] object from an [Interpolator].
24
+ constructor(_interpolator) {
25
+ this._interpolator = _interpolator;
26
+ // Do nothing.
27
+ }
28
+ // / Return the cosine of π times [x].
29
+ static _cosPi(x) {
30
+ return Math.cos(Math.PI * x);
31
+ }
32
+ _fitCoefficient(j, n, a, b) {
33
+ let sumX = 0.0;
34
+ let sumY = 0.0;
35
+ let sumZ = 0.0;
36
+ const h = 0.5;
37
+ for (let i = 0; i < n; i++) {
38
+ const x = ChebyshevCompressor._cosPi((i + h) / n);
39
+ const seconds = x * (h * (b - a)) + h * (b + a);
40
+ const state = this._interpolator.interpolate(new EpochUTC(seconds));
41
+ const fx = state.position.x;
42
+ const fy = state.position.y;
43
+ const fz = state.position.z;
44
+ const nFac = ChebyshevCompressor._cosPi((j * (i + h)) / n);
45
+ sumX += fx * nFac;
46
+ sumY += fy * nFac;
47
+ sumZ += fz * nFac;
48
+ }
49
+ return new Vector3D(sumX * (2 / n), sumY * (2 / n), sumZ * (2 / n));
50
+ }
51
+ _fitWindow(coeffs, a, b) {
52
+ const cx = new Float64Array();
53
+ const cy = new Float64Array();
54
+ const cz = new Float64Array();
55
+ for (let j = 0; j < coeffs; j++) {
56
+ const result = this._fitCoefficient(j, coeffs, a, b);
57
+ cx[j] = result.x;
58
+ cy[j] = result.y;
59
+ cz[j] = result.z;
60
+ }
61
+ return new ChebyshevCoefficients(a, b, cx, cy, cz);
62
+ }
63
+ /**
64
+ * Compress this object's interpolater, using the provided coefficients
65
+ * per revolution [cpr].
66
+ * @param cpr Coefficients per revolution.
67
+ * @returns A new [ChebyshevInterpolator] object.
68
+ */
69
+ compress(cpr = 21) {
70
+ const { start, end } = this._interpolator.window();
71
+ const period = this._interpolator.interpolate(start).period;
72
+ const coefficients = [];
73
+ let current = start;
74
+ while (current < end) {
75
+ const step = Math.min(period, end.posix - current.posix);
76
+ const segment = current.roll(step);
77
+ coefficients.push(this._fitWindow(cpr, current.posix, segment.posix));
78
+ current = segment;
79
+ }
80
+ return new ChebyshevInterpolator(coefficients);
81
+ }
82
+ }
83
+ //# sourceMappingURL=ChebyshevCompressor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChebyshevCompressor.js","sourceRoot":"","sources":["../../src/optimize/ChebyshevCompressor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,QAAQ,EAAW,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAEhF,0BAA0B;AAC1B,MAAM,OAAO,mBAAmB;IAEV;IADpB,sEAAsE;IACtE,YAAoB,aAAgC;QAAhC,kBAAa,GAAb,aAAa,CAAmB;QAClD,cAAc;IAChB,CAAC;IAED,sCAAsC;IAC9B,MAAM,CAAC,MAAM,CAAC,CAAS;QAC7B,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IAC/B,CAAC;IAEO,eAAe,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS;QAChE,IAAI,IAAI,GAAG,GAAG,CAAC;QACf,IAAI,IAAI,GAAG,GAAG,CAAC;QACf,IAAI,IAAI,GAAG,GAAG,CAAC;QACf,MAAM,CAAC,GAAG,GAAG,CAAC;QAEd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;YAC1B,MAAM,CAAC,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAClD,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,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,GAAG,MAAM,CAAC,CAAC,CAAC;YACjB,EAAE,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;SAClB;QAED,OAAO,IAAI,qBAAqB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IACrD,CAAC;IAED;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,GAAG,EAAE;QACf,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC;QACnD,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,KAAK,CAAE,CAAC,MAAM,CAAC;QAC7D,MAAM,YAAY,GAA4B,EAAE,CAAC;QACjD,IAAI,OAAO,GAAG,KAAK,CAAC;QAEpB,OAAO,OAAO,GAAG,GAAG,EAAE;YACpB,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAY,CAAC;YACpE,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAEnC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;YACtE,OAAO,GAAG,OAAO,CAAC;SACnB;QAED,OAAO,IAAI,qBAAqB,CAAC,YAAY,CAAC,CAAC;IACjD,CAAC;CACF"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * @author @thkruz Theodore Kruczek
3
+ * @license AGPL-3.0-or-later
4
+ * @copyright (c) 2020-2024 Theodore Kruczek
5
+ *
6
+ * Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
7
+ * terms of the GNU Affero General Public License as published by the Free Software
8
+ * Foundation, either version 3 of the License, or (at your option) any later version.
9
+ *
10
+ * Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
+ * See the GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License along with
15
+ * Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+ import { CostFunction } from './SimplexEntry';
18
+ export declare class DownhillSimplex {
19
+ private constructor();
20
+ /**
21
+ * Compute the centroid from a list of [SimplexEntry] objects, using cost
22
+ * function [f].
23
+ * @param f Cost function
24
+ * @param xss Simplex entries
25
+ * @returns The centroid.
26
+ */
27
+ private static _centroid;
28
+ private static _shrink;
29
+ /**
30
+ * Generate a new simplex from initial guess [x0], and an optional
31
+ * simplex [step] value.
32
+ * @param x0 Initial guess
33
+ * @param step Simplex step
34
+ * @returns The simplex.
35
+ */
36
+ static generateSimplex(x0: Float64Array, step?: number): Float64Array[];
37
+ /**
38
+ * Perform derivative-free Nelder-Mead simplex optimization to minimize the
39
+ * cost function [f] for the initial simplex [xs].
40
+ *
41
+ * Optional arguments:
42
+ * - `xTolerance`: centroid delta termination criteria
43
+ * - `fTolerance`: cost function delta termination criteria
44
+ * - `maxIter`: maximum number of optimization iterations
45
+ * - `adaptive`: use adaptive coefficients if possible
46
+ * - `printIter`: print a debug statement after each iteration
47
+ * @param f Cost function
48
+ * @param xs Initial simplex
49
+ * @param root0 Root0
50
+ * @param root0.xTolerance Root0.xTolerance
51
+ * @param root0.fTolerance Root0.fTolerance
52
+ * @param root0.maxIter Root0.maxIter
53
+ * @param root0.adaptive Root0.adaptive
54
+ * @param root0.printIter Root0.printIter
55
+ * @returns The optimal input value.
56
+ */
57
+ static solveSimplex(f: CostFunction, xs: Float64Array[], { xTolerance, fTolerance, maxIter, adaptive, printIter, }: {
58
+ xTolerance?: number;
59
+ fTolerance?: number;
60
+ maxIter?: number;
61
+ adaptive?: boolean;
62
+ printIter?: boolean;
63
+ }): Float64Array;
64
+ }
@@ -0,0 +1,182 @@
1
+ /**
2
+ * @author @thkruz Theodore Kruczek
3
+ * @license AGPL-3.0-or-later
4
+ * @copyright (c) 2020-2024 Theodore Kruczek
5
+ *
6
+ * Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
7
+ * terms of the GNU Affero General Public License as published by the Free Software
8
+ * Foundation, either version 3 of the License, or (at your option) any later version.
9
+ *
10
+ * Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
+ * See the GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License along with
15
+ * Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+ import { SimplexEntry } from './SimplexEntry';
18
+ // / Derivative-free Nelder-Mead simplex optimizer.
19
+ export class DownhillSimplex {
20
+ constructor() {
21
+ // disable constructor
22
+ }
23
+ /**
24
+ * Compute the centroid from a list of [SimplexEntry] objects, using cost
25
+ * function [f].
26
+ * @param f Cost function
27
+ * @param xss Simplex entries
28
+ * @returns The centroid.
29
+ */
30
+ static _centroid(f, xss) {
31
+ const n = xss[0].points.length;
32
+ const m = xss.length - 1;
33
+ const output = new Float64Array(n);
34
+ for (let i = 0; i < m; i++) {
35
+ for (let j = 0; j < n; j++) {
36
+ output[j] += xss[i].points[j];
37
+ }
38
+ }
39
+ for (let i = 0; i < n; i++) {
40
+ output[i] /= m;
41
+ }
42
+ return new SimplexEntry(f, output);
43
+ }
44
+ static _shrink(s, xss) {
45
+ const x1 = xss[0];
46
+ for (let i = 1; i < xss.length; i++) {
47
+ const xi = xss[i];
48
+ xss[i] = x1.modify(s, xi, x1);
49
+ }
50
+ }
51
+ /**
52
+ * Generate a new simplex from initial guess [x0], and an optional
53
+ * simplex [step] value.
54
+ * @param x0 Initial guess
55
+ * @param step Simplex step
56
+ * @returns The simplex.
57
+ */
58
+ static generateSimplex(x0, step = 0.01) {
59
+ const output = [x0.slice(0)];
60
+ for (let i = 0; i < x0.length; i++) {
61
+ const tmp = x0.slice(0);
62
+ tmp[i] += tmp[i] * step;
63
+ output.push(tmp);
64
+ }
65
+ return output;
66
+ }
67
+ /**
68
+ * Perform derivative-free Nelder-Mead simplex optimization to minimize the
69
+ * cost function [f] for the initial simplex [xs].
70
+ *
71
+ * Optional arguments:
72
+ * - `xTolerance`: centroid delta termination criteria
73
+ * - `fTolerance`: cost function delta termination criteria
74
+ * - `maxIter`: maximum number of optimization iterations
75
+ * - `adaptive`: use adaptive coefficients if possible
76
+ * - `printIter`: print a debug statement after each iteration
77
+ * @param f Cost function
78
+ * @param xs Initial simplex
79
+ * @param root0 Root0
80
+ * @param root0.xTolerance Root0.xTolerance
81
+ * @param root0.fTolerance Root0.fTolerance
82
+ * @param root0.maxIter Root0.maxIter
83
+ * @param root0.adaptive Root0.adaptive
84
+ * @param root0.printIter Root0.printIter
85
+ * @returns The optimal input value.
86
+ */
87
+ static solveSimplex(f, xs, { xTolerance = 1e-12, fTolerance = 1e-12, maxIter = 10000, adaptive = false, printIter = false, }) {
88
+ let a;
89
+ let g;
90
+ let p;
91
+ let s;
92
+ const n = xs.length - 1;
93
+ if (adaptive && n >= 2) {
94
+ a = 1.0;
95
+ g = 1.0 + 2.0 / n;
96
+ p = 0.75 - 1.0 / (2.0 * n);
97
+ s = 1.0 - 1.0 / n;
98
+ }
99
+ else {
100
+ a = 1.0;
101
+ g = 2.0;
102
+ p = 0.5;
103
+ s = 0.5;
104
+ }
105
+ let iter = 0;
106
+ let action = 'init';
107
+ const ordered = [];
108
+ for (const x of xs) {
109
+ ordered.push(new SimplexEntry(f, x));
110
+ }
111
+ // eslint-disable-next-line no-constant-condition
112
+ while (true) {
113
+ ordered.sort((x, y) => x.score - y.score);
114
+ const x0 = DownhillSimplex._centroid(f, ordered);
115
+ // update exit criterea
116
+ let xd = 0.0;
117
+ let fd = 0.0;
118
+ for (let i = 1; i < ordered.length; i++) {
119
+ xd = Math.max(xd, x0.distance(ordered[i]));
120
+ fd = Math.max(fd, Math.abs(x0.score - ordered[i].score));
121
+ }
122
+ if (printIter) {
123
+ // eslint-disable-next-line no-console
124
+ console.log(`${iter}: score=${x0.score} xd=${xd} fd=${fd} [${action}]`);
125
+ }
126
+ if (iter !== 0 && (xd < xTolerance || fd < fTolerance)) {
127
+ return ordered[0].points;
128
+ }
129
+ if (iter >= maxIter) {
130
+ return ordered[0].points;
131
+ }
132
+ iter++;
133
+ // reflection
134
+ const xr = x0.modify(a, x0, ordered[ordered.length - 1]);
135
+ if (ordered[0].score <= xr.score && xr.score < ordered[ordered.length - 2].score) {
136
+ ordered[ordered.length - 1] = xr;
137
+ action = 'reflect';
138
+ continue;
139
+ }
140
+ // expansion
141
+ if (xr.score < ordered[0].score) {
142
+ const xe = x0.modify(g, xr, x0);
143
+ if (xe.score < xr.score) {
144
+ ordered[ordered.length - 1] = xe;
145
+ }
146
+ else {
147
+ ordered[ordered.length - 1] = xr;
148
+ }
149
+ action = 'expand';
150
+ continue;
151
+ }
152
+ // contraction
153
+ if (xr.score < ordered[ordered.length - 1].score) {
154
+ const xc = x0.modify(p, xr, x0);
155
+ if (xc.score < xr.score) {
156
+ ordered[ordered.length - 1] = xc;
157
+ action = 'contract';
158
+ continue;
159
+ }
160
+ else {
161
+ DownhillSimplex._shrink(s, ordered);
162
+ action = 'shrink';
163
+ continue;
164
+ }
165
+ }
166
+ else if (xr.score >= ordered[ordered.length - 1].score) {
167
+ const xc = x0.modify(p, ordered[ordered.length - 1], x0);
168
+ if (xc.score < ordered[ordered.length - 1].score) {
169
+ ordered[ordered.length - 1] = xc;
170
+ action = 'contract';
171
+ continue;
172
+ }
173
+ else {
174
+ DownhillSimplex._shrink(s, ordered);
175
+ action = 'shrink';
176
+ continue;
177
+ }
178
+ }
179
+ }
180
+ }
181
+ }
182
+ //# sourceMappingURL=DownhillSimplex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DownhillSimplex.js","sourceRoot":"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AO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE;gBAChD,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;gBAEhC,IAAI,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC,KAAK,EAAE;oBACvB,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;oBACjC,MAAM,GAAG,UAAU,CAAC;oBACpB,SAAS;iBACV;qBAAM;oBACL,eAAe,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;oBACpC,MAAM,GAAG,QAAQ,CAAC;oBAClB,SAAS;iBACV;aACF;iBAAM,IAAI,EAAE,CAAC,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE;gBACxD,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBAEzD,IAAI,EAAE,CAAC,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE;oBAChD,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;oBACjC,MAAM,GAAG,UAAU,CAAC;oBACpB,SAAS;iBACV;qBAAM;oBACL,eAAe,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;oBACpC,MAAM,GAAG,QAAQ,CAAC;oBAClB,SAAS;iBACV;aACF;SACF;IACH,CAAC;CACF"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @author @thkruz Theodore Kruczek
3
+ * @license AGPL-3.0-or-later
4
+ * @copyright (c) 2020-2024 Theodore Kruczek
5
+ *
6
+ * Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
7
+ * terms of the GNU Affero General Public License as published by the Free Software
8
+ * Foundation, either version 3 of the License, or (at your option) any later version.
9
+ *
10
+ * Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
+ * See the GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License along with
15
+ * Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+ import { DifferentiableFunction } from '../main';
18
+ export declare class GoldenSection {
19
+ private static readonly _grInv;
20
+ private static _check;
21
+ /**
22
+ * Search for an optimal input value for function [f] that minimizes the
23
+ * output value.
24
+ *
25
+ * Takes [lower] and [upper] input search bounds, and an optional
26
+ * search [tolerance].
27
+ * @param f Function to optimize
28
+ * @param lower Lower bound
29
+ * @param upper Upper bound
30
+ * @param root0 Root0
31
+ * @param root0.tolerance Root0.tolerance
32
+ * @param root0.solveMax Root0.solveMax
33
+ * @returns The optimal input value.
34
+ */
35
+ static search(f: DifferentiableFunction, lower: number, upper: number, { tolerance, solveMax, }: {
36
+ tolerance?: number;
37
+ solveMax?: boolean;
38
+ }): number;
39
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @author @thkruz Theodore Kruczek
3
+ * @license AGPL-3.0-or-later
4
+ * @copyright (c) 2020-2024 Theodore Kruczek
5
+ *
6
+ * Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
7
+ * terms of the GNU Affero General Public License as published by the Free Software
8
+ * Foundation, either version 3 of the License, or (at your option) any later version.
9
+ *
10
+ * Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
+ * See the GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License along with
15
+ * Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+ // / Golden Section bounded single value optimizer.
18
+ export class GoldenSection {
19
+ static _grInv = 1.0 / (0.5 * (Math.sqrt(5) + 1));
20
+ static _check(fc, fd, solveMax) {
21
+ return solveMax ? fc > fd : fc < fd;
22
+ }
23
+ /**
24
+ * Search for an optimal input value for function [f] that minimizes the
25
+ * output value.
26
+ *
27
+ * Takes [lower] and [upper] input search bounds, and an optional
28
+ * search [tolerance].
29
+ * @param f Function to optimize
30
+ * @param lower Lower bound
31
+ * @param upper Upper bound
32
+ * @param root0 Root0
33
+ * @param root0.tolerance Root0.tolerance
34
+ * @param root0.solveMax Root0.solveMax
35
+ * @returns The optimal input value.
36
+ */
37
+ static search(f, lower, upper, { tolerance = 1e-5, solveMax = false, }) {
38
+ let a = lower;
39
+ let b = upper;
40
+ let c = b - (b - a) * GoldenSection._grInv;
41
+ let d = a + (b - a) * GoldenSection._grInv;
42
+ while (Math.abs(b - a) > tolerance) {
43
+ if (GoldenSection._check(f(c), f(d), solveMax)) {
44
+ b = d;
45
+ }
46
+ else {
47
+ a = c;
48
+ }
49
+ c = b - (b - a) * GoldenSection._grInv;
50
+ d = a + (b - a) * GoldenSection._grInv;
51
+ }
52
+ return 0.5 * (b + a);
53
+ }
54
+ }
55
+ //# sourceMappingURL=GoldenSection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GoldenSection.js","sourceRoot":"","sources":["../../src/optimize/GoldenSection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,mDAAmD;AACnD,MAAM,OAAO,aAAa;IAChB,MAAM,CAAU,MAAM,GAAW,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAElE,MAAM,CAAC,MAAM,CAAC,EAAU,EAAE,EAAU,EAAE,QAAiB;QAC7D,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC;IACtC,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,MAAM,CACX,CAAyB,EACzB,KAAa,EACb,KAAa,EACb,EACE,SAAS,GAAG,IAAI,EAChB,QAAQ,GAAG,KAAK,GAIjB;QAED,IAAI,CAAC,GAAG,KAAK,CAAC;QACd,IAAI,CAAC,GAAG,KAAK,CAAC;QACd,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC;QAC3C,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC;QAE3C,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS,EAAE;YAClC,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE;gBAC9C,CAAC,GAAG,CAAC,CAAC;aACP;iBAAM;gBACL,CAAC,GAAG,CAAC,CAAC;aACP;YACD,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC;YACvC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC;SACxC;QAED,OAAO,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,CAAC"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @author @thkruz Theodore Kruczek
3
+ * @license AGPL-3.0-or-later
4
+ * @copyright (c) 2020-2024 Theodore Kruczek
5
+ *
6
+ * Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
7
+ * terms of the GNU Affero General Public License as published by the Free Software
8
+ * Foundation, either version 3 of the License, or (at your option) any later version.
9
+ *
10
+ * Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
+ * See the GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License along with
15
+ * Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+ import { PolynomicalRegressionResult } from './PolynomicalRegressionResult';
18
+ export declare class PolynomialRegression {
19
+ private constructor();
20
+ private static _bayesInformationCriterea;
21
+ /**
22
+ * Optimize polynomial coefficients to fit data series [xs] and [ys] for the
23
+ * provided polynomial [order].
24
+ * @param xs x values
25
+ * @param ys y values
26
+ * @param order Polynomial order
27
+ * @param root0 Root0
28
+ * @param root0.printIter Root0.printIter
29
+ * @returns The optimal input value.
30
+ */
31
+ static solve(xs: Float64Array, ys: Float64Array, order: number, { printIter }?: {
32
+ printIter?: boolean;
33
+ }): PolynomicalRegressionResult;
34
+ /**
35
+ * Optimize polynomial coefficients to fit data series [xs] and [ys], and
36
+ * attempt to find an optimal order within the [minOrder] and
37
+ * [maxOrder] bounds.
38
+ * @param xs x values
39
+ * @param ys y values
40
+ * @param minOrder Minimum polynomial order
41
+ * @param maxOrder Maximum polynomial order
42
+ * @param root0 Root0
43
+ * @param root0.printIter Root0.printIter
44
+ * @returns The optimal input value.
45
+ */
46
+ static solveOrder(xs: Float64Array, ys: Float64Array, minOrder: number, maxOrder: number, { printIter }?: {
47
+ printIter?: boolean;
48
+ }): PolynomicalRegressionResult;
49
+ }