space-data-module-sdk 0.8.17 → 0.8.18

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.
@@ -0,0 +1,183 @@
1
+ /* ===========================================================================
2
+ * SCHEMA-DERIVED ABI CONTRACT.
3
+ *
4
+ * Source of truth : schemas/orbpro/Solver.fbs
5
+ * Contract : pull/supply maneuver-family solver ABI
6
+ *
7
+ * A solver has no propagator import. plugin_solver_next yields a candidate;
8
+ * the host evaluates it through the selected propagator/objective ports and
9
+ * returns the answer through plugin_solver_supply.
10
+ * ===========================================================================
11
+ */
12
+
13
+ #ifndef ORBPRO_SOLVER_ABI_H
14
+ #define ORBPRO_SOLVER_ABI_H
15
+
16
+ #include <stddef.h>
17
+ #include <stdint.h>
18
+
19
+ #if defined(__cplusplus)
20
+ #define ORBPRO_SOLVER_STATIC_ASSERT(cond, msg) static_assert(cond, msg)
21
+ #else
22
+ #define ORBPRO_SOLVER_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
23
+ #endif
24
+
25
+ #ifdef __cplusplus
26
+ extern "C" {
27
+ #endif
28
+
29
+ #define ORBPRO_SOLVER_MAX_DIMENSION 16u
30
+ #define ORBPRO_SOLVER_MAX_JACOBIAN_VALUES 256u
31
+
32
+ typedef enum {
33
+ ORBPRO_SOLVER_NEWTON_RAPHSON = 0,
34
+ ORBPRO_SOLVER_BROYDEN = 1,
35
+ ORBPRO_SOLVER_MODIFIED_BROYDEN = 2,
36
+ ORBPRO_SOLVER_SQP = 3,
37
+ } OrbProSolverAlgorithm;
38
+
39
+ typedef enum {
40
+ ORBPRO_SOLVER_DIFFERENCE_FORWARD = 0,
41
+ ORBPRO_SOLVER_DIFFERENCE_CENTRAL = 1,
42
+ ORBPRO_SOLVER_DIFFERENCE_ANALYTIC_STM = 2,
43
+ } OrbProSolverDifferenceMode;
44
+
45
+ typedef enum {
46
+ ORBPRO_SOLVER_STATUS_IDLE = 0,
47
+ ORBPRO_SOLVER_STATUS_NEEDS_EVALUATION = 1,
48
+ ORBPRO_SOLVER_STATUS_CONVERGED = 2,
49
+ ORBPRO_SOLVER_STATUS_INVALID_PROBLEM = 3,
50
+ ORBPRO_SOLVER_STATUS_EVALUATION_FAILED = 4,
51
+ ORBPRO_SOLVER_STATUS_SINGULAR_JACOBIAN = 5,
52
+ ORBPRO_SOLVER_STATUS_BUDGET_EXCEEDED = 6,
53
+ ORBPRO_SOLVER_STATUS_STALLED = 7,
54
+ ORBPRO_SOLVER_STATUS_INFEASIBLE = 8,
55
+ } OrbProSolverStatus;
56
+
57
+ typedef enum {
58
+ ORBPRO_SOLVER_EVALUATE_VALUES = 0,
59
+ ORBPRO_SOLVER_EVALUATE_VALUES_AND_JACOBIAN = 1,
60
+ } OrbProSolverEvaluationKind;
61
+
62
+ typedef struct {
63
+ uint8_t algorithm;
64
+ uint8_t difference_mode;
65
+ uint16_t _reserved0;
66
+ uint32_t maximum_iterations;
67
+ uint32_t maximum_evaluations;
68
+ uint32_t variable_count;
69
+ uint32_t goal_count;
70
+ uint32_t equality_constraint_count;
71
+ uint32_t inequality_constraint_count;
72
+ double residual_tolerance;
73
+ double step_tolerance;
74
+ double constraint_tolerance;
75
+ double kkt_tolerance;
76
+ } OrbProSolverSettings;
77
+
78
+ ORBPRO_SOLVER_STATIC_ASSERT(sizeof(OrbProSolverSettings) == 64,
79
+ "OrbProSolverSettings must be 64 bytes");
80
+ ORBPRO_SOLVER_STATIC_ASSERT(offsetof(OrbProSolverSettings, variable_count) == 12,
81
+ "OrbProSolverSettings.variable_count offset");
82
+ ORBPRO_SOLVER_STATIC_ASSERT(offsetof(OrbProSolverSettings, equality_constraint_count) == 20,
83
+ "OrbProSolverSettings.equality_constraint_count offset");
84
+ ORBPRO_SOLVER_STATIC_ASSERT(offsetof(OrbProSolverSettings, residual_tolerance) == 32,
85
+ "OrbProSolverSettings.residual_tolerance offset");
86
+
87
+ typedef struct {
88
+ uint64_t request_id;
89
+ uint8_t kind;
90
+ uint8_t _reserved0[3];
91
+ uint32_t variable_count;
92
+ double variables[ORBPRO_SOLVER_MAX_DIMENSION];
93
+ } OrbProSolverEvaluationRequest;
94
+
95
+ ORBPRO_SOLVER_STATIC_ASSERT(sizeof(OrbProSolverEvaluationRequest) == 144,
96
+ "OrbProSolverEvaluationRequest must be 144 bytes");
97
+
98
+ typedef struct {
99
+ uint64_t request_id;
100
+ uint8_t valid;
101
+ uint8_t _reserved0[3];
102
+ uint32_t goal_count;
103
+ uint32_t constraint_count;
104
+ uint32_t jacobian_rows;
105
+ uint32_t jacobian_columns;
106
+ double goals[ORBPRO_SOLVER_MAX_DIMENSION];
107
+ double objective;
108
+ double constraints[ORBPRO_SOLVER_MAX_DIMENSION];
109
+ double jacobian[ORBPRO_SOLVER_MAX_JACOBIAN_VALUES];
110
+ } OrbProSolverEvaluation;
111
+
112
+ ORBPRO_SOLVER_STATIC_ASSERT(sizeof(OrbProSolverEvaluation) == 2344,
113
+ "OrbProSolverEvaluation must be 2344 bytes");
114
+ ORBPRO_SOLVER_STATIC_ASSERT(offsetof(OrbProSolverEvaluation, goals) == 32,
115
+ "OrbProSolverEvaluation.goals offset");
116
+ ORBPRO_SOLVER_STATIC_ASSERT(offsetof(OrbProSolverEvaluation, objective) == 160,
117
+ "OrbProSolverEvaluation.objective offset");
118
+ ORBPRO_SOLVER_STATIC_ASSERT(offsetof(OrbProSolverEvaluation, constraints) == 168,
119
+ "OrbProSolverEvaluation.constraints offset");
120
+
121
+ typedef struct {
122
+ uint32_t iteration;
123
+ uint32_t evaluation_count;
124
+ uint32_t variable_count;
125
+ uint32_t goal_count;
126
+ double variables[ORBPRO_SOLVER_MAX_DIMENSION];
127
+ double values[ORBPRO_SOLVER_MAX_DIMENSION];
128
+ double residual_norm;
129
+ double step_norm;
130
+ double jacobian_condition;
131
+ double maximum_constraint_violation;
132
+ double kkt_residual;
133
+ uint8_t accepted;
134
+ uint8_t _reserved0[7];
135
+ } OrbProSolverIteration;
136
+
137
+ ORBPRO_SOLVER_STATIC_ASSERT(sizeof(OrbProSolverIteration) == 320,
138
+ "OrbProSolverIteration must be 320 bytes");
139
+
140
+ typedef struct {
141
+ uint8_t status;
142
+ uint8_t _reserved0[3];
143
+ uint32_t iteration_count;
144
+ uint32_t evaluation_count;
145
+ uint32_t variable_count;
146
+ uint32_t value_count;
147
+ double variables[ORBPRO_SOLVER_MAX_DIMENSION];
148
+ double values[ORBPRO_SOLVER_MAX_DIMENSION];
149
+ double objective;
150
+ double residual_norm;
151
+ double maximum_constraint_violation;
152
+ double kkt_residual;
153
+ } OrbProSolverResult;
154
+
155
+ ORBPRO_SOLVER_STATIC_ASSERT(sizeof(OrbProSolverResult) == 312,
156
+ "OrbProSolverResult must be 312 bytes");
157
+ ORBPRO_SOLVER_STATIC_ASSERT(offsetof(OrbProSolverResult, variables) == 24,
158
+ "OrbProSolverResult.variables offset");
159
+ ORBPRO_SOLVER_STATIC_ASSERT(offsetof(OrbProSolverResult, objective) == 280,
160
+ "OrbProSolverResult.objective offset");
161
+
162
+ static inline void orbpro_solver_zero(void* value, size_t size) {
163
+ size_t index;
164
+ for (index = 0; index < size; ++index) ((uint8_t*)value)[index] = 0;
165
+ }
166
+
167
+ int32_t plugin_solver_configure(const OrbProSolverSettings* settings,
168
+ const double* initial_variables,
169
+ const double* lower_bounds,
170
+ const double* upper_bounds,
171
+ const double* desired_values,
172
+ const double* perturbations);
173
+ int32_t plugin_solver_begin(void);
174
+ int32_t plugin_solver_next(OrbProSolverEvaluationRequest* request);
175
+ int32_t plugin_solver_supply(const OrbProSolverEvaluation* evaluation);
176
+ int32_t plugin_solver_result(OrbProSolverResult* result);
177
+ int32_t plugin_solver_iteration(uint32_t index, OrbProSolverIteration* result);
178
+
179
+ #ifdef __cplusplus
180
+ } /* extern "C" */
181
+ #endif
182
+
183
+ #endif /* ORBPRO_SOLVER_ABI_H */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "space-data-module-sdk",
3
- "version": "0.8.17",
3
+ "version": "0.8.18",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Module SDK for building, validating, signing, and deploying WebAssembly modules on the Space Data Network.",
6
6
  "type": "module",
@@ -125,7 +125,7 @@
125
125
  "flatsql": "^2.0.0",
126
126
  "hd-wallet-wasm": "2.0.28",
127
127
  "sdn-emception": "1.0.0",
128
- "spacedatastandards.org": "1.203.0"
128
+ "spacedatastandards.org": "1.206.0"
129
129
  },
130
130
  "devDependencies": {
131
131
  "esbuild": "^0.28.0",
@@ -0,0 +1,115 @@
1
+ include "Propagator.fbs";
2
+
3
+ namespace orbpro.solver;
4
+
5
+ // Pull/supply solver protocol. The solver never imports a propagator or an
6
+ // objective function: it asks the host for one evaluation at a candidate
7
+ // control vector, and the host routes that request to the selected ports.
8
+
9
+ enum SolverAlgorithm : ubyte (abi, abi_c_name: "OrbProSolverAlgorithm", abi_c_prefix: "ORBPRO_SOLVER_") {
10
+ NEWTON_RAPHSON = 0,
11
+ BROYDEN = 1,
12
+ MODIFIED_BROYDEN = 2,
13
+ SQP = 3
14
+ }
15
+
16
+ enum DifferenceMode : ubyte (abi, abi_c_name: "OrbProSolverDifferenceMode", abi_c_prefix: "ORBPRO_SOLVER_DIFFERENCE_") {
17
+ FORWARD = 0,
18
+ CENTRAL = 1,
19
+ ANALYTIC_STM = 2
20
+ }
21
+
22
+ enum SolverStatus : ubyte (abi, abi_c_name: "OrbProSolverStatus", abi_c_prefix: "ORBPRO_SOLVER_STATUS_") {
23
+ IDLE = 0,
24
+ NEEDS_EVALUATION = 1,
25
+ CONVERGED = 2,
26
+ INVALID_PROBLEM = 3,
27
+ EVALUATION_FAILED = 4,
28
+ SINGULAR_JACOBIAN = 5,
29
+ BUDGET_EXCEEDED = 6,
30
+ STALLED = 7,
31
+ INFEASIBLE = 8
32
+ }
33
+
34
+ enum EvaluationKind : ubyte (abi, abi_c_name: "OrbProSolverEvaluationKind", abi_c_prefix: "ORBPRO_SOLVER_EVALUATE_") {
35
+ VALUES = 0,
36
+ VALUES_AND_JACOBIAN = 1
37
+ }
38
+
39
+ /// Fixed ABI limit. A larger search problem travels as $SLP through the
40
+ /// command surface; the direct pull/supply surface intentionally stays small.
41
+ struct SolverSettings (abi, abi_c_name: "OrbProSolverSettings", abi_c_helper_prefix: "orbpro_solver_settings_") {
42
+ algorithm: SolverAlgorithm;
43
+ difference_mode: DifferenceMode;
44
+ _reserved0: ushort;
45
+ maximum_iterations: uint;
46
+ maximum_evaluations: uint;
47
+ variable_count: uint;
48
+ goal_count: uint;
49
+ equality_constraint_count: uint;
50
+ inequality_constraint_count: uint;
51
+ residual_tolerance: double;
52
+ step_tolerance: double;
53
+ constraint_tolerance: double;
54
+ kkt_tolerance: double;
55
+ }
56
+
57
+ /// Candidate that must be evaluated by the consumer-selected propagator and
58
+ /// objective ports.
59
+ struct SolverEvaluationRequest (abi, abi_c_name: "OrbProSolverEvaluationRequest", abi_c_helper_prefix: "orbpro_solver_request_") {
60
+ request_id: ulong;
61
+ kind: EvaluationKind;
62
+ _reserved0: [ubyte:3];
63
+ variable_count: uint;
64
+ variables: [double:16];
65
+ }
66
+
67
+ /// Values supplied after one request. Goals are the achieved values for a
68
+ /// target problem. For an optimization problem, objective and constraints are
69
+ /// also populated. The Jacobian is row-major with at most 16 by 16 entries.
70
+ struct SolverEvaluation (abi, abi_c_name: "OrbProSolverEvaluation", abi_c_helper_prefix: "orbpro_solver_evaluation_") {
71
+ request_id: ulong;
72
+ valid: ubyte;
73
+ _reserved0: [ubyte:3];
74
+ goal_count: uint;
75
+ constraint_count: uint;
76
+ jacobian_rows: uint;
77
+ jacobian_columns: uint;
78
+ goals: [double:16];
79
+ objective: double;
80
+ constraints: [double:16];
81
+ jacobian: [double:256];
82
+ }
83
+
84
+ struct SolverIteration (abi, abi_c_name: "OrbProSolverIteration", abi_c_helper_prefix: "orbpro_solver_iteration_") {
85
+ iteration: uint;
86
+ evaluation_count: uint;
87
+ variable_count: uint;
88
+ goal_count: uint;
89
+ variables: [double:16];
90
+ values: [double:16];
91
+ residual_norm: double;
92
+ step_norm: double;
93
+ jacobian_condition: double;
94
+ maximum_constraint_violation: double;
95
+ kkt_residual: double;
96
+ accepted: ubyte;
97
+ _reserved0: [ubyte:7];
98
+ }
99
+
100
+ struct SolverResult (abi, abi_c_name: "OrbProSolverResult", abi_c_helper_prefix: "orbpro_solver_result_") {
101
+ status: SolverStatus;
102
+ _reserved0: [ubyte:3];
103
+ iteration_count: uint;
104
+ evaluation_count: uint;
105
+ variable_count: uint;
106
+ value_count: uint;
107
+ variables: [double:16];
108
+ values: [double:16];
109
+ objective: double;
110
+ residual_norm: double;
111
+ maximum_constraint_violation: double;
112
+ kkt_residual: double;
113
+ }
114
+
115
+ root_type SolverResult;