ootk 2.0.1 → 4.0.0-0
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.
- package/.eslintrc.json +14 -14
- package/CHANGELOG.md +122 -0
- package/README.md +27 -40
- package/jest.config.ts +30 -0
- package/lib/coordinate/Hill.d.ts +50 -0
- package/lib/coordinate/Hill.js +214 -0
- package/lib/coordinate/Hill.js.map +1 -0
- package/lib/coordinate/index.d.ts +1 -0
- package/lib/coordinate/index.js +2 -0
- package/lib/coordinate/index.js.map +1 -0
- package/lib/covariance/CovarianceSample.d.ts +44 -0
- package/lib/covariance/CovarianceSample.js +146 -0
- package/lib/covariance/CovarianceSample.js.map +1 -0
- package/lib/covariance/StateCovariance.d.ts +41 -0
- package/lib/covariance/StateCovariance.js +62 -0
- package/lib/covariance/StateCovariance.js.map +1 -0
- package/lib/force/AtmosphericDrag.d.ts +32 -0
- package/lib/force/AtmosphericDrag.js +66 -0
- package/lib/force/AtmosphericDrag.js.map +1 -0
- package/{dist/ootk.d.ts → lib/force/EarthGravity.d.ts} +13 -11
- package/lib/force/EarthGravity.js +115 -0
- package/lib/force/EarthGravity.js.map +1 -0
- package/lib/force/Force.d.ts +25 -0
- package/lib/force/Force.js +30 -0
- package/lib/force/Force.js.map +1 -0
- package/lib/force/ForceModel.d.ts +38 -0
- package/lib/force/ForceModel.js +71 -0
- package/lib/force/ForceModel.js.map +1 -0
- package/lib/force/Gravity.d.ts +41 -0
- package/lib/force/Gravity.js +48 -0
- package/lib/force/Gravity.js.map +1 -0
- package/lib/force/SolarRadiationPressure.d.ts +27 -0
- package/lib/force/SolarRadiationPressure.js +42 -0
- package/lib/force/SolarRadiationPressure.js.map +1 -0
- package/lib/force/ThirdBodyGravity.d.ts +27 -0
- package/lib/force/ThirdBodyGravity.js +56 -0
- package/lib/force/ThirdBodyGravity.js.map +1 -0
- package/lib/force/Thrust.d.ts +35 -0
- package/lib/force/Thrust.js +53 -0
- package/lib/force/Thrust.js.map +1 -0
- package/lib/interpolator/ChebyshevCoefficients.d.ts +54 -0
- package/lib/interpolator/ChebyshevCoefficients.js +90 -0
- package/lib/interpolator/ChebyshevCoefficients.js.map +1 -0
- package/lib/interpolator/ChebyshevInterpolator.d.ts +39 -0
- package/lib/interpolator/ChebyshevInterpolator.js +71 -0
- package/lib/interpolator/ChebyshevInterpolator.js.map +1 -0
- package/lib/interpolator/CubicSpline.d.ts +36 -0
- package/lib/interpolator/CubicSpline.js +64 -0
- package/lib/interpolator/CubicSpline.js.map +1 -0
- package/lib/interpolator/CubicSplineInterpolator.d.ts +37 -0
- package/lib/interpolator/CubicSplineInterpolator.js +78 -0
- package/lib/interpolator/CubicSplineInterpolator.js.map +1 -0
- package/lib/interpolator/FieldInterpolator.d.ts +26 -0
- package/lib/interpolator/FieldInterpolator.js +31 -0
- package/lib/interpolator/FieldInterpolator.js.map +1 -0
- package/lib/interpolator/Interpolator.d.ts +23 -0
- package/lib/interpolator/Interpolator.js +48 -0
- package/lib/interpolator/Interpolator.js.map +1 -0
- package/lib/interpolator/LagrangeInterpolator.d.ts +42 -0
- package/lib/interpolator/LagrangeInterpolator.js +156 -0
- package/lib/interpolator/LagrangeInterpolator.js.map +1 -0
- package/lib/interpolator/StateInterpolator.d.ts +29 -0
- package/lib/interpolator/StateInterpolator.js +37 -0
- package/lib/interpolator/StateInterpolator.js.map +1 -0
- package/lib/interpolator/VerletBlendInterpolator.d.ts +44 -0
- package/lib/interpolator/VerletBlendInterpolator.js +115 -0
- package/lib/interpolator/VerletBlendInterpolator.js.map +1 -0
- package/lib/maneuver/TwoBurnOrbitTransfer.d.ts +43 -0
- package/lib/maneuver/TwoBurnOrbitTransfer.js +62 -0
- package/lib/maneuver/TwoBurnOrbitTransfer.js.map +1 -0
- package/lib/maneuver/Waypoint.d.ts +66 -0
- package/lib/maneuver/Waypoint.js +152 -0
- package/lib/maneuver/Waypoint.js.map +1 -0
- package/lib/objects/DetailedSatellite.d.ts +94 -0
- package/lib/objects/DetailedSatellite.js +140 -0
- package/lib/objects/DetailedSatellite.js.map +1 -0
- package/lib/objects/DetailedSensor.d.ts +43 -0
- package/lib/objects/DetailedSensor.js +45 -0
- package/lib/objects/DetailedSensor.js.map +1 -0
- package/lib/objects/{space-object.d.ts → LandObject.d.ts} +19 -21
- package/lib/objects/LandObject.js +28 -0
- package/lib/objects/LandObject.js.map +1 -0
- package/lib/objects/Marker.d.ts +21 -0
- package/lib/objects/Marker.js +25 -0
- package/lib/objects/Marker.js.map +1 -0
- package/lib/objects/index.d.ts +5 -4
- package/lib/objects/index.js +5 -4
- package/lib/objects/index.js.map +1 -1
- package/lib/observation/Observation.d.ts +51 -0
- package/lib/observation/Observation.js +71 -0
- package/lib/observation/Observation.js.map +1 -0
- package/lib/observation/ObservationOptical.d.ts +47 -0
- package/lib/observation/ObservationOptical.js +101 -0
- package/lib/observation/ObservationOptical.js.map +1 -0
- package/lib/observation/ObservationRadar.d.ts +43 -0
- package/lib/observation/ObservationRadar.js +90 -0
- package/lib/observation/ObservationRadar.js.map +1 -0
- package/lib/observation/ObservationUtils.d.ts +21 -0
- package/lib/observation/ObservationUtils.js +33 -0
- package/lib/observation/ObservationUtils.js.map +1 -0
- package/lib/observation/PropagatorPairs.d.ts +31 -0
- package/lib/observation/PropagatorPairs.js +40 -0
- package/lib/observation/PropagatorPairs.js.map +1 -0
- package/lib/ootk.d.ts +10 -9
- package/lib/ootk.js +10 -9
- package/lib/ootk.js.map +1 -1
- package/lib/operations/BoxMuller.d.ts +41 -0
- package/lib/operations/BoxMuller.js +66 -0
- package/lib/operations/BoxMuller.js.map +1 -0
- package/lib/operations/EulerAngles.d.ts +50 -0
- package/lib/operations/EulerAngles.js +111 -0
- package/lib/operations/EulerAngles.js.map +1 -0
- package/lib/operations/Quaternion.d.ts +57 -0
- package/lib/operations/Quaternion.js +164 -0
- package/lib/operations/Quaternion.js.map +1 -0
- package/lib/operations/RandomGaussianSource.d.ts +25 -0
- package/lib/operations/RandomGaussianSource.js +43 -0
- package/lib/operations/RandomGaussianSource.js.map +1 -0
- package/lib/operations/index.d.ts +4 -0
- package/lib/operations/index.js +5 -0
- package/lib/operations/index.js.map +1 -0
- package/lib/optimize/ChebyshevCompressor.d.ts +31 -0
- package/lib/optimize/ChebyshevCompressor.js +80 -0
- package/lib/optimize/ChebyshevCompressor.js.map +1 -0
- package/lib/optimize/DownhillSimplex.d.ts +50 -0
- package/lib/optimize/DownhillSimplex.js +168 -0
- package/lib/optimize/DownhillSimplex.js.map +1 -0
- package/lib/optimize/GoldenSection.d.ts +33 -0
- package/lib/optimize/GoldenSection.js +49 -0
- package/lib/optimize/GoldenSection.js.map +1 -0
- package/lib/optimize/PolynomialRegression.d.ts +37 -0
- package/lib/optimize/PolynomialRegression.js +66 -0
- package/lib/optimize/PolynomialRegression.js.map +1 -0
- package/lib/optimize/PolynomicalRegressionResult.d.ts +28 -0
- package/lib/optimize/PolynomicalRegressionResult.js +32 -0
- package/lib/optimize/PolynomicalRegressionResult.js.map +1 -0
- package/lib/optimize/SimpleLinearRegression.d.ts +41 -0
- package/lib/optimize/SimpleLinearRegression.js +107 -0
- package/lib/optimize/SimpleLinearRegression.js.map +1 -0
- package/lib/optimize/SimplexEntry.d.ts +33 -0
- package/lib/optimize/SimplexEntry.js +39 -0
- package/lib/optimize/SimplexEntry.js.map +1 -0
- package/lib/orbit_determination/BatchLeastSquaresOD.d.ts +54 -0
- package/lib/orbit_determination/BatchLeastSquaresOD.js +118 -0
- package/lib/orbit_determination/BatchLeastSquaresOD.js.map +1 -0
- package/lib/orbit_determination/BatchLeastSquaresResult.d.ts +29 -0
- package/lib/orbit_determination/BatchLeastSquaresResult.js +31 -0
- package/lib/orbit_determination/BatchLeastSquaresResult.js.map +1 -0
- package/lib/orbit_determination/GibbsIOD.d.ts +33 -0
- package/lib/orbit_determination/GibbsIOD.js +70 -0
- package/lib/orbit_determination/GibbsIOD.js.map +1 -0
- package/lib/orbit_determination/GoodingIOD.d.ts +52 -0
- package/lib/orbit_determination/GoodingIOD.js +244 -0
- package/lib/orbit_determination/GoodingIOD.js.map +1 -0
- package/{dist/objects/space-object.d.ts → lib/orbit_determination/HerrickGibbsIOD.d.ts} +17 -22
- package/lib/orbit_determination/HerrickGibbsIOD.js +49 -0
- package/lib/orbit_determination/HerrickGibbsIOD.js.map +1 -0
- package/lib/orbit_determination/LambertIOD.d.ts +46 -0
- package/lib/orbit_determination/LambertIOD.js +199 -0
- package/lib/orbit_determination/LambertIOD.js.map +1 -0
- package/lib/orbit_determination/ModifiedGoodingIOD.d.ts +41 -0
- package/lib/orbit_determination/ModifiedGoodingIOD.js +82 -0
- package/lib/orbit_determination/ModifiedGoodingIOD.js.map +1 -0
- package/lib/propagator/DormandPrince54Propagator.d.ts +29 -0
- package/lib/propagator/DormandPrince54Propagator.js +68 -0
- package/lib/propagator/DormandPrince54Propagator.js.map +1 -0
- package/lib/propagator/KeplerPropagator.d.ts +36 -0
- package/lib/propagator/KeplerPropagator.js +81 -0
- package/lib/propagator/KeplerPropagator.js.map +1 -0
- package/lib/propagator/Propagator.d.ts +35 -0
- package/lib/propagator/Propagator.js +163 -0
- package/lib/propagator/Propagator.js.map +1 -0
- package/lib/propagator/RkCheckpoint.d.ts +23 -0
- package/lib/propagator/RkCheckpoint.js +26 -0
- package/lib/propagator/RkCheckpoint.js.map +1 -0
- package/lib/propagator/RkResult.d.ts +24 -0
- package/lib/propagator/RkResult.js +28 -0
- package/lib/propagator/RkResult.js.map +1 -0
- package/lib/propagator/RungeKutta4Propagator.d.ts +46 -0
- package/lib/propagator/RungeKutta4Propagator.js +132 -0
- package/lib/propagator/RungeKutta4Propagator.js.map +1 -0
- package/lib/propagator/RungeKutta89Propagator.d.ts +29 -0
- package/lib/propagator/RungeKutta89Propagator.js +130 -0
- package/lib/propagator/RungeKutta89Propagator.js.map +1 -0
- package/lib/propagator/RungeKuttaAdaptive.d.ts +52 -0
- package/lib/propagator/RungeKuttaAdaptive.js +152 -0
- package/lib/propagator/RungeKuttaAdaptive.js.map +1 -0
- package/lib/propagator/Sgp4Propagator.d.ts +35 -0
- package/lib/propagator/Sgp4Propagator.js +55 -0
- package/lib/propagator/Sgp4Propagator.js.map +1 -0
- package/lib/smoothing/ExponentialSmoothing.d.ts +24 -0
- package/lib/smoothing/ExponentialSmoothing.js +82 -0
- package/lib/smoothing/ExponentialSmoothing.js.map +1 -0
- package/lib/types/types.d.ts +68 -262
- package/lib/types/types.js +23 -33
- package/lib/types/types.js.map +1 -1
- package/package.json +28 -42
- package/codecov.yml +0 -21
- package/dist/objects/base-object.d.ts +0 -40
- package/dist/objects/detailed-sat.d.ts +0 -66
- package/dist/objects/index.d.ts +0 -4
- package/dist/objects/sat.d.ts +0 -92
- package/dist/objects/sensor.d.ts +0 -87
- package/dist/objects/star.d.ts +0 -46
- package/dist/ootk.js +0 -2
- package/dist/ootk.js.LICENSE.txt +0 -77
- package/dist/sgp4/Sgp4Assembly.d.ts +0 -5
- package/dist/sgp4/sgp4.d.ts +0 -82
- package/dist/tle/tle-format-data.d.ts +0 -6
- package/dist/tle/tle.d.ts +0 -374
- package/dist/transforms/transforms.d.ts +0 -55
- package/dist/types/types.d.ts +0 -280
- package/dist/utils/constants.d.ts +0 -34
- package/dist/utils/moon-math.d.ts +0 -113
- package/dist/utils/sun-math.d.ts +0 -230
- package/dist/utils/utils.d.ts +0 -39
- package/lib/objects/base-object.d.ts +0 -40
- package/lib/objects/base-object.js +0 -109
- package/lib/objects/base-object.js.map +0 -1
- package/lib/objects/detailed-sat.d.ts +0 -66
- package/lib/objects/detailed-sat.js +0 -149
- package/lib/objects/detailed-sat.js.map +0 -1
- package/lib/objects/sat.d.ts +0 -92
- package/lib/objects/sat.js +0 -188
- package/lib/objects/sat.js.map +0 -1
- package/lib/objects/sensor.d.ts +0 -87
- package/lib/objects/sensor.js +0 -255
- package/lib/objects/sensor.js.map +0 -1
- package/lib/objects/space-object.js +0 -60
- package/lib/objects/space-object.js.map +0 -1
- package/lib/objects/star.d.ts +0 -46
- package/lib/objects/star.js +0 -91
- package/lib/objects/star.js.map +0 -1
- package/lib/sgp4/Sgp4Assembly.d.ts +0 -5
- package/lib/sgp4/Sgp4Assembly.js +0 -75
- package/lib/sgp4/Sgp4Assembly.js.map +0 -1
- package/lib/sgp4/sgp4.d.ts +0 -82
- package/lib/sgp4/sgp4.js +0 -3274
- package/lib/sgp4/sgp4.js.map +0 -1
- package/lib/tle/tle-format-data.d.ts +0 -6
- package/lib/tle/tle-format-data.js +0 -10
- package/lib/tle/tle-format-data.js.map +0 -1
- package/lib/tle/tle.d.ts +0 -374
- package/lib/tle/tle.js +0 -611
- package/lib/tle/tle.js.map +0 -1
- package/lib/transforms/transforms.d.ts +0 -55
- package/lib/transforms/transforms.js +0 -209
- package/lib/transforms/transforms.js.map +0 -1
- package/lib/utils/constants.d.ts +0 -34
- package/lib/utils/constants.js +0 -35
- package/lib/utils/constants.js.map +0 -1
- package/lib/utils/moon-math.d.ts +0 -113
- package/lib/utils/moon-math.js +0 -387
- package/lib/utils/moon-math.js.map +0 -1
- package/lib/utils/sun-math.d.ts +0 -230
- package/lib/utils/sun-math.js +0 -422
- package/lib/utils/sun-math.js.map +0 -1
- package/lib/utils/utils.d.ts +0 -39
- package/lib/utils/utils.js +0 -100
- package/lib/utils/utils.js.map +0 -1
- package/sandbox.html +0 -8
- /package/{LICENSE.MD → LICENSE.md} +0 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author @thkruz Theodore Kruczek
|
|
3
|
+
*
|
|
4
|
+
* @license AGPL-3.0-or-later
|
|
5
|
+
* @Copyright (c) 2020-2024 Theodore Kruczek
|
|
6
|
+
*
|
|
7
|
+
* Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
|
|
8
|
+
* terms of the GNU Affero General Public License as published by the Free Software
|
|
9
|
+
* Foundation, either version 3 of the License, or (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
12
|
+
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
* See the GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License along with
|
|
16
|
+
* Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
import { EpochUTC, Vector3D } from 'ootk-core';
|
|
19
|
+
import { ChebyshevCoefficients } from './../interpolator/ChebyshevCoefficients';
|
|
20
|
+
import { ChebyshevInterpolator } from './../interpolator/ChebyshevInterpolator';
|
|
21
|
+
// / Ephemeris compressor.
|
|
22
|
+
export class ChebyshevCompressor {
|
|
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 state = this._interpolator.interpolate(new EpochUTC(x * (h * (b - a)) + h * (b + a)));
|
|
40
|
+
const fx = state.position.x;
|
|
41
|
+
const fy = state.position.y;
|
|
42
|
+
const fz = state.position.z;
|
|
43
|
+
const nFac = ChebyshevCompressor._cosPi((j * (i + h)) / n);
|
|
44
|
+
sumX += fx * nFac;
|
|
45
|
+
sumY += fy * nFac;
|
|
46
|
+
sumZ += fz * nFac;
|
|
47
|
+
}
|
|
48
|
+
return new Vector3D(sumX * (2 / n), sumY * (2 / n), sumZ * (2 / n));
|
|
49
|
+
}
|
|
50
|
+
_fitWindow(coeffs, a, b) {
|
|
51
|
+
const cx = new Float64Array();
|
|
52
|
+
const cy = new Float64Array();
|
|
53
|
+
const cz = new Float64Array();
|
|
54
|
+
for (let j = 0; j < coeffs; j++) {
|
|
55
|
+
const result = this._fitCoefficient(j, coeffs, a, b);
|
|
56
|
+
cx[j] = result.x;
|
|
57
|
+
cy[j] = result.y;
|
|
58
|
+
cz[j] = result.z;
|
|
59
|
+
}
|
|
60
|
+
return new ChebyshevCoefficients(a, b, cx, cy, cz);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Compress this object's interpolater, using the provided coefficients
|
|
64
|
+
* per revolution [cpr].
|
|
65
|
+
*/
|
|
66
|
+
compress(cpr = 21) {
|
|
67
|
+
const { start, end } = this._interpolator.window();
|
|
68
|
+
const period = this._interpolator.interpolate(start).period();
|
|
69
|
+
const coefficients = [];
|
|
70
|
+
let current = start;
|
|
71
|
+
while (current < end) {
|
|
72
|
+
const step = Math.min(period, end.posix - current.posix);
|
|
73
|
+
const segment = current.roll(step);
|
|
74
|
+
coefficients.push(this._fitWindow(cpr, current.posix, segment.posix));
|
|
75
|
+
current = segment;
|
|
76
|
+
}
|
|
77
|
+
return new ChebyshevInterpolator(coefficients);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=ChebyshevCompressor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChebyshevCompressor.js","sourceRoot":"","sources":["../../src/optimize/ChebyshevCompressor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAEhF,0BAA0B;AAC1B,MAAM,OAAO,m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AG,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,CAAC,CAAC;YACzD,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,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author @thkruz Theodore Kruczek
|
|
3
|
+
*
|
|
4
|
+
* @license AGPL-3.0-or-later
|
|
5
|
+
* @Copyright (c) 2020-2024 Theodore Kruczek
|
|
6
|
+
*
|
|
7
|
+
* Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
|
|
8
|
+
* terms of the GNU Affero General Public License as published by the Free Software
|
|
9
|
+
* Foundation, either version 3 of the License, or (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
12
|
+
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
* See the GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License along with
|
|
16
|
+
* Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
import { CostFunction } from './SimplexEntry';
|
|
19
|
+
export declare class DownhillSimplex {
|
|
20
|
+
private constructor();
|
|
21
|
+
/**
|
|
22
|
+
* Compute the centroid from a list of [SimplexEntry] objects, using cost
|
|
23
|
+
* function [f].
|
|
24
|
+
*/
|
|
25
|
+
private static _centroid;
|
|
26
|
+
private static _shrink;
|
|
27
|
+
/**
|
|
28
|
+
* Generate a new simplex from initial guess [x0], and an optional
|
|
29
|
+
* simplex [step] value.
|
|
30
|
+
*/
|
|
31
|
+
static generateSimplex(x0: Float64Array, step?: number): Float64Array[];
|
|
32
|
+
/**
|
|
33
|
+
* Perform derivative-free Nelder-Mead simplex optimization to minimize the
|
|
34
|
+
* cost function [f] for the initial simplex [xs].
|
|
35
|
+
*
|
|
36
|
+
* Optional arguments:
|
|
37
|
+
* - `xTolerance`: centroid delta termination criteria
|
|
38
|
+
* - `fTolerance`: cost function delta termination criteria
|
|
39
|
+
* - `maxIter`: maximum number of optimization iterations
|
|
40
|
+
* - `adaptive`: use adaptive coefficients if possible
|
|
41
|
+
* - `printIter`: print a debug statement after each iteration
|
|
42
|
+
*/
|
|
43
|
+
static solveSimplex(f: CostFunction, xs: Float64Array[], { xTolerance, fTolerance, maxIter, adaptive, printIter, }: {
|
|
44
|
+
xTolerance?: number;
|
|
45
|
+
fTolerance?: number;
|
|
46
|
+
maxIter?: number;
|
|
47
|
+
adaptive?: boolean;
|
|
48
|
+
printIter?: boolean;
|
|
49
|
+
}): Float64Array;
|
|
50
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author @thkruz Theodore Kruczek
|
|
3
|
+
*
|
|
4
|
+
* @license AGPL-3.0-or-later
|
|
5
|
+
* @Copyright (c) 2020-2024 Theodore Kruczek
|
|
6
|
+
*
|
|
7
|
+
* Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
|
|
8
|
+
* terms of the GNU Affero General Public License as published by the Free Software
|
|
9
|
+
* Foundation, either version 3 of the License, or (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
12
|
+
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
* See the GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License along with
|
|
16
|
+
* Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
import { SimplexEntry } from './SimplexEntry';
|
|
19
|
+
// / Derivative-free Nelder-Mead simplex optimizer.
|
|
20
|
+
export class DownhillSimplex {
|
|
21
|
+
constructor() {
|
|
22
|
+
// disable constructor
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Compute the centroid from a list of [SimplexEntry] objects, using cost
|
|
26
|
+
* function [f].
|
|
27
|
+
*/
|
|
28
|
+
static _centroid(f, xss) {
|
|
29
|
+
const n = xss[0].points.length;
|
|
30
|
+
const m = xss.length - 1;
|
|
31
|
+
const output = new Float64Array(n);
|
|
32
|
+
for (let i = 0; i < m; i++) {
|
|
33
|
+
for (let j = 0; j < n; j++) {
|
|
34
|
+
output[j] += xss[i].points[j];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
for (let i = 0; i < n; i++) {
|
|
38
|
+
output[i] /= m;
|
|
39
|
+
}
|
|
40
|
+
return new SimplexEntry(f, output);
|
|
41
|
+
}
|
|
42
|
+
static _shrink(s, xss) {
|
|
43
|
+
const x1 = xss[0];
|
|
44
|
+
for (let i = 1; i < xss.length; i++) {
|
|
45
|
+
const xi = xss[i];
|
|
46
|
+
xss[i] = x1.modify(s, xi, x1);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Generate a new simplex from initial guess [x0], and an optional
|
|
51
|
+
* simplex [step] value.
|
|
52
|
+
*/
|
|
53
|
+
static generateSimplex(x0, step = 0.01) {
|
|
54
|
+
const output = [x0.slice(0)];
|
|
55
|
+
for (let i = 0; i < x0.length; i++) {
|
|
56
|
+
const tmp = x0.slice(0);
|
|
57
|
+
tmp[i] += tmp[i] * step;
|
|
58
|
+
output.push(tmp);
|
|
59
|
+
}
|
|
60
|
+
return output;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Perform derivative-free Nelder-Mead simplex optimization to minimize the
|
|
64
|
+
* cost function [f] for the initial simplex [xs].
|
|
65
|
+
*
|
|
66
|
+
* Optional arguments:
|
|
67
|
+
* - `xTolerance`: centroid delta termination criteria
|
|
68
|
+
* - `fTolerance`: cost function delta termination criteria
|
|
69
|
+
* - `maxIter`: maximum number of optimization iterations
|
|
70
|
+
* - `adaptive`: use adaptive coefficients if possible
|
|
71
|
+
* - `printIter`: print a debug statement after each iteration
|
|
72
|
+
*/
|
|
73
|
+
static solveSimplex(f, xs, { xTolerance = 1e-12, fTolerance = 1e-12, maxIter = 10000, adaptive = false, printIter = false, }) {
|
|
74
|
+
let a;
|
|
75
|
+
let g;
|
|
76
|
+
let p;
|
|
77
|
+
let s;
|
|
78
|
+
const n = xs.length - 1;
|
|
79
|
+
if (adaptive && n >= 2) {
|
|
80
|
+
a = 1.0;
|
|
81
|
+
g = 1.0 + 2.0 / n;
|
|
82
|
+
p = 0.75 - 1.0 / (2.0 * n);
|
|
83
|
+
s = 1.0 - 1.0 / n;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
a = 1.0;
|
|
87
|
+
g = 2.0;
|
|
88
|
+
p = 0.5;
|
|
89
|
+
s = 0.5;
|
|
90
|
+
}
|
|
91
|
+
let iter = 0;
|
|
92
|
+
let action = 'init';
|
|
93
|
+
const ordered = [];
|
|
94
|
+
for (const x of xs) {
|
|
95
|
+
ordered.push(new SimplexEntry(f, x));
|
|
96
|
+
}
|
|
97
|
+
// eslint-disable-next-line no-constant-condition
|
|
98
|
+
while (true) {
|
|
99
|
+
ordered.sort((x, y) => x.score - y.score);
|
|
100
|
+
const x0 = DownhillSimplex._centroid(f, ordered);
|
|
101
|
+
// update exit criterea
|
|
102
|
+
let xd = 0.0;
|
|
103
|
+
let fd = 0.0;
|
|
104
|
+
for (let i = 1; i < ordered.length; i++) {
|
|
105
|
+
xd = Math.max(xd, x0.distance(ordered[i]));
|
|
106
|
+
fd = Math.max(fd, Math.abs(x0.score - ordered[i].score));
|
|
107
|
+
}
|
|
108
|
+
if (printIter) {
|
|
109
|
+
// eslint-disable-next-line no-console
|
|
110
|
+
console.log(`${iter}: score=${x0.score} xd=${xd} fd=${fd} [${action}]`);
|
|
111
|
+
}
|
|
112
|
+
if (iter !== 0 && (xd < xTolerance || fd < fTolerance)) {
|
|
113
|
+
return ordered[0].points;
|
|
114
|
+
}
|
|
115
|
+
if (iter >= maxIter) {
|
|
116
|
+
return ordered[0].points;
|
|
117
|
+
}
|
|
118
|
+
iter++;
|
|
119
|
+
// reflection
|
|
120
|
+
const xr = x0.modify(a, x0, ordered[ordered.length - 1]);
|
|
121
|
+
if (ordered[0].score <= xr.score && xr.score < ordered[ordered.length - 2].score) {
|
|
122
|
+
ordered[ordered.length - 1] = xr;
|
|
123
|
+
action = 'reflect';
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
// expansion
|
|
127
|
+
if (xr.score < ordered[0].score) {
|
|
128
|
+
const xe = x0.modify(g, xr, x0);
|
|
129
|
+
if (xe.score < xr.score) {
|
|
130
|
+
ordered[ordered.length - 1] = xe;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
ordered[ordered.length - 1] = xr;
|
|
134
|
+
}
|
|
135
|
+
action = 'expand';
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
// contraction
|
|
139
|
+
if (xr.score < ordered[ordered.length - 1].score) {
|
|
140
|
+
const xc = x0.modify(p, xr, x0);
|
|
141
|
+
if (xc.score < xr.score) {
|
|
142
|
+
ordered[ordered.length - 1] = xc;
|
|
143
|
+
action = 'contract';
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
DownhillSimplex._shrink(s, ordered);
|
|
148
|
+
action = 'shrink';
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else if (xr.score >= ordered[ordered.length - 1].score) {
|
|
153
|
+
const xc = x0.modify(p, ordered[ordered.length - 1], x0);
|
|
154
|
+
if (xc.score < ordered[ordered.length - 1].score) {
|
|
155
|
+
ordered[ordered.length - 1] = xc;
|
|
156
|
+
action = 'contract';
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
DownhillSimplex._shrink(s, ordered);
|
|
161
|
+
action = 'shrink';
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=DownhillSimplex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DownhillSimplex.js","sourceRoot":"","sources":["../../src/optimize/DownhillSimplex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAgB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE5D,mDAAmD;AACnD,MAAM,OAAO,eAAe;IAC1B;QACE,sBAAsB;IACxB,CAAC;IAED;;;OAGG;IACK,MAAM,CAAC,SAAS,CAAC,CAAe,EAAE,GAAmB;QAC3D,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;QAC/B,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;QACzB,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;QAEnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;YAC1B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;gBAC1B,MAAM,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;a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AC,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,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author @thkruz Theodore Kruczek
|
|
3
|
+
*
|
|
4
|
+
* @license AGPL-3.0-or-later
|
|
5
|
+
* @Copyright (c) 2020-2024 Theodore Kruczek
|
|
6
|
+
*
|
|
7
|
+
* Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
|
|
8
|
+
* terms of the GNU Affero General Public License as published by the Free Software
|
|
9
|
+
* Foundation, either version 3 of the License, or (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
12
|
+
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
* See the GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License along with
|
|
16
|
+
* Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
import { DifferentiableFunction } from 'ootk-core';
|
|
19
|
+
export declare class GoldenSection {
|
|
20
|
+
private static readonly _grInv;
|
|
21
|
+
private static _check;
|
|
22
|
+
/**
|
|
23
|
+
* Search for an optimal input value for function [f] that minimizes the
|
|
24
|
+
* output value.
|
|
25
|
+
*
|
|
26
|
+
* Takes [lower] and [upper] input search bounds, and an optional
|
|
27
|
+
* search [tolerance].
|
|
28
|
+
*/
|
|
29
|
+
static search(f: DifferentiableFunction, lower: number, upper: number, { tolerance, solveMax, }: {
|
|
30
|
+
tolerance?: number;
|
|
31
|
+
solveMax?: boolean;
|
|
32
|
+
}): number;
|
|
33
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author @thkruz Theodore Kruczek
|
|
3
|
+
*
|
|
4
|
+
* @license AGPL-3.0-or-later
|
|
5
|
+
* @Copyright (c) 2020-2024 Theodore Kruczek
|
|
6
|
+
*
|
|
7
|
+
* Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
|
|
8
|
+
* terms of the GNU Affero General Public License as published by the Free Software
|
|
9
|
+
* Foundation, either version 3 of the License, or (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
12
|
+
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
* See the GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License along with
|
|
16
|
+
* Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
// / Golden Section bounded single value optimizer.
|
|
19
|
+
export class GoldenSection {
|
|
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
|
+
*/
|
|
30
|
+
static search(f, lower, upper, { tolerance = 1e-5, solveMax = false, }) {
|
|
31
|
+
let a = lower;
|
|
32
|
+
let b = upper;
|
|
33
|
+
let c = b - (b - a) * GoldenSection._grInv;
|
|
34
|
+
let d = a + (b - a) * GoldenSection._grInv;
|
|
35
|
+
while (Math.abs(b - a) > tolerance) {
|
|
36
|
+
if (GoldenSection._check(f(c), f(d), solveMax)) {
|
|
37
|
+
b = d;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
a = c;
|
|
41
|
+
}
|
|
42
|
+
c = b - (b - a) * GoldenSection._grInv;
|
|
43
|
+
d = a + (b - a) * GoldenSection._grInv;
|
|
44
|
+
}
|
|
45
|
+
return 0.5 * (b + a);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
GoldenSection._grInv = 1.0 / (0.5 * (Math.sqrt(5) + 1));
|
|
49
|
+
//# sourceMappingURL=GoldenSection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GoldenSection.js","sourceRoot":"","sources":["../../src/optimize/GoldenSection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,mDAAmD;AACnD,MAAM,OAAO,aAAa;IAGhB,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;;;;;;OAMG;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;;AAzCuB,oBAAM,GAAW,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author @thkruz Theodore Kruczek
|
|
3
|
+
*
|
|
4
|
+
* @license AGPL-3.0-or-later
|
|
5
|
+
* @Copyright (c) 2020-2024 Theodore Kruczek
|
|
6
|
+
*
|
|
7
|
+
* Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
|
|
8
|
+
* terms of the GNU Affero General Public License as published by the Free Software
|
|
9
|
+
* Foundation, either version 3 of the License, or (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
12
|
+
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
* See the GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License along with
|
|
16
|
+
* Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
import { PolynomicalRegressionResult } from './PolynomicalRegressionResult';
|
|
19
|
+
export declare class PolynomialRegression {
|
|
20
|
+
private constructor();
|
|
21
|
+
private static _bayesInformationCriterea;
|
|
22
|
+
/**
|
|
23
|
+
* Optimize polynomial coefficients to fit data series [xs] and [ys] for the
|
|
24
|
+
* provided polynomial [order].
|
|
25
|
+
*/
|
|
26
|
+
static solve(xs: Float64Array, ys: Float64Array, order: number, { printIter }?: {
|
|
27
|
+
printIter?: boolean;
|
|
28
|
+
}): PolynomicalRegressionResult;
|
|
29
|
+
/**
|
|
30
|
+
* Optimize polynomial coefficients to fit data series [xs] and [ys], and
|
|
31
|
+
* attempt to find an optimal order within the [minOrder] and
|
|
32
|
+
* [maxOrder] bounds.
|
|
33
|
+
*/
|
|
34
|
+
static solveOrder(xs: Float64Array, ys: Float64Array, minOrder: number, maxOrder: number, { printIter }?: {
|
|
35
|
+
printIter?: boolean;
|
|
36
|
+
}): PolynomicalRegressionResult;
|
|
37
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author @thkruz Theodore Kruczek
|
|
3
|
+
*
|
|
4
|
+
* @license AGPL-3.0-or-later
|
|
5
|
+
* @Copyright (c) 2020-2024 Theodore Kruczek
|
|
6
|
+
*
|
|
7
|
+
* Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
|
|
8
|
+
* terms of the GNU Affero General Public License as published by the Free Software
|
|
9
|
+
* Foundation, either version 3 of the License, or (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
12
|
+
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
* See the GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License along with
|
|
16
|
+
* Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
/* eslint-disable require-jsdoc */
|
|
19
|
+
/* eslint-disable func-style */
|
|
20
|
+
import { evalPoly } from 'ootk-core';
|
|
21
|
+
import { DownhillSimplex } from './DownhillSimplex';
|
|
22
|
+
import { PolynomicalRegressionResult } from './PolynomicalRegressionResult';
|
|
23
|
+
// / Polynomial regression optimizer.
|
|
24
|
+
export class PolynomialRegression {
|
|
25
|
+
constructor() {
|
|
26
|
+
// disable constructor
|
|
27
|
+
}
|
|
28
|
+
static _bayesInformationCriterea(n, k, sse) {
|
|
29
|
+
return n * Math.log(sse) + k * Math.log(n);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Optimize polynomial coefficients to fit data series [xs] and [ys] for the
|
|
33
|
+
* provided polynomial [order].
|
|
34
|
+
*/
|
|
35
|
+
static solve(xs, ys, order, { printIter = false } = {}) {
|
|
36
|
+
const simplex = DownhillSimplex.generateSimplex(Float64Array.from(Array(order + 1).fill(1.0)));
|
|
37
|
+
function f(coeffs) {
|
|
38
|
+
let sse = 0.0;
|
|
39
|
+
for (let i = 0; i < xs.length; i++) {
|
|
40
|
+
const diff = ys[i] - evalPoly(xs[i], coeffs);
|
|
41
|
+
sse += diff * diff;
|
|
42
|
+
}
|
|
43
|
+
return sse;
|
|
44
|
+
}
|
|
45
|
+
const result = DownhillSimplex.solveSimplex(f, simplex, {
|
|
46
|
+
adaptive: true,
|
|
47
|
+
printIter,
|
|
48
|
+
});
|
|
49
|
+
const sse = f(result);
|
|
50
|
+
return new PolynomicalRegressionResult(result, Math.sqrt(sse), PolynomialRegression._bayesInformationCriterea(xs.length, order, sse));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Optimize polynomial coefficients to fit data series [xs] and [ys], and
|
|
54
|
+
* attempt to find an optimal order within the [minOrder] and
|
|
55
|
+
* [maxOrder] bounds.
|
|
56
|
+
*/
|
|
57
|
+
static solveOrder(xs, ys, minOrder, maxOrder, { printIter = false } = {}) {
|
|
58
|
+
const cache = [];
|
|
59
|
+
for (let order = minOrder; order <= maxOrder; order++) {
|
|
60
|
+
cache.push(PolynomialRegression.solve(xs, ys, order, { printIter }));
|
|
61
|
+
}
|
|
62
|
+
cache.sort((a, b) => a.bic - b.bic);
|
|
63
|
+
return cache[0];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=PolynomialRegression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PolynomialRegression.js","sourceRoot":"","sources":["../../src/optimize/PolynomialRegression.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,kCAAkC;AAClC,+BAA+B;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,qCAAqC;AACrC,MAAM,OAAO,oBAAoB;IAC/B;QACE,sBAAsB;IACxB,CAAC;IAEO,MAAM,CAAC,yBAAyB,CAAC,CAAS,EAAE,CAAS,EAAE,GAAW;QACxE,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,KAAK,CACV,EAAgB,EAChB,EAAgB,EAChB,KAAa,EACb,EAAE,SAAS,GAAG,KAAK,KAA8B,EAAE;QAEnD,MAAM,OAAO,GAAG,eAAe,CAAC,eAAe,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAE/F,SAAS,CAAC,CAAC,MAAoB;YAC7B,IAAI,GAAG,GAAG,GAAG,CAAC;YAEd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CA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ruczek
|
|
3
|
+
*
|
|
4
|
+
* @license AGPL-3.0-or-later
|
|
5
|
+
* @Copyright (c) 2020-2024 Theodore Kruczek
|
|
6
|
+
*
|
|
7
|
+
* Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
|
|
8
|
+
* terms of the GNU Affero General Public License as published by the Free Software
|
|
9
|
+
* Foundation, either version 3 of the License, or (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
12
|
+
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
* See the GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License along with
|
|
16
|
+
* Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
export declare class PolynomicalRegressionResult {
|
|
19
|
+
coefficients: Float64Array;
|
|
20
|
+
rss: number;
|
|
21
|
+
bic: number;
|
|
22
|
+
/**
|
|
23
|
+
* Create a new [PolynomicalRegressionResult] object, containing the
|
|
24
|
+
* polynomial [coefficients], root-sum-squared error [rss], and Bayes
|
|
25
|
+
* information criterea [bic].
|
|
26
|
+
*/
|
|
27
|
+
constructor(coefficients: Float64Array, rss: number, bic: number);
|
|
28
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author @thkruz Theodore Kruczek
|
|
3
|
+
*
|
|
4
|
+
* @license AGPL-3.0-or-later
|
|
5
|
+
* @Copyright (c) 2020-2024 Theodore Kruczek
|
|
6
|
+
*
|
|
7
|
+
* Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
|
|
8
|
+
* terms of the GNU Affero General Public License as published by the Free Software
|
|
9
|
+
* Foundation, either version 3 of the License, or (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
12
|
+
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
* See the GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License along with
|
|
16
|
+
* Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
// / Polynomial regression optimization result.
|
|
19
|
+
export class PolynomicalRegressionResult {
|
|
20
|
+
/**
|
|
21
|
+
* Create a new [PolynomicalRegressionResult] object, containing the
|
|
22
|
+
* polynomial [coefficients], root-sum-squared error [rss], and Bayes
|
|
23
|
+
* information criterea [bic].
|
|
24
|
+
*/
|
|
25
|
+
constructor(coefficients, rss, bic) {
|
|
26
|
+
this.coefficients = coefficients;
|
|
27
|
+
this.rss = rss;
|
|
28
|
+
this.bic = bic;
|
|
29
|
+
// Nothing to do here.
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=PolynomicalRegressionResult.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PolynomicalRegressionResult.js","sourceRoot":"","sources":["../../src/optimize/PolynomicalRegressionResult.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,+CAA+C;AAC/C,MAAM,OAAO,2BAA2B;IACtC;;;;OAIG;IACH,YAAmB,YAA0B,EAAS,GAAW,EAAS,GAAW;QAAlE,iBAAY,GAAZ,YAAY,CAAc;QAAS,QAAG,GAAH,GAAG,CAAQ;QAAS,QAAG,GAAH,GAAG,CAAQ;QACnF,sBAAsB;IACxB,CAAC;CACF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author @thkruz Theodore Kruczek
|
|
3
|
+
*
|
|
4
|
+
* @license AGPL-3.0-or-later
|
|
5
|
+
* @Copyright (c) 2020-2024 Theodore Kruczek
|
|
6
|
+
*
|
|
7
|
+
* Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
|
|
8
|
+
* terms of the GNU Affero General Public License as published by the Free Software
|
|
9
|
+
* Foundation, either version 3 of the License, or (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
12
|
+
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
* See the GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License along with
|
|
16
|
+
* Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
export declare class SimpleLinearRegression {
|
|
19
|
+
xs: number[];
|
|
20
|
+
ys: number[];
|
|
21
|
+
/**
|
|
22
|
+
* Create a new [SimpleLinearRegression] object from lists of x and y
|
|
23
|
+
* values.
|
|
24
|
+
*/
|
|
25
|
+
constructor(xs: number[], ys: number[]);
|
|
26
|
+
private _slope;
|
|
27
|
+
private _intercept;
|
|
28
|
+
private _error;
|
|
29
|
+
get slope(): number;
|
|
30
|
+
get intercept(): number;
|
|
31
|
+
get error(): number;
|
|
32
|
+
get length(): number;
|
|
33
|
+
private _calcError;
|
|
34
|
+
update(): void;
|
|
35
|
+
evaluate(x: number): number;
|
|
36
|
+
/**
|
|
37
|
+
* Create a new [SimpleLinearRegression] object with outliers above the
|
|
38
|
+
* provided standard deviation [sigma] value removed.
|
|
39
|
+
*/
|
|
40
|
+
filterOutliers(sigma?: number): SimpleLinearRegression;
|
|
41
|
+
}
|