38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
// Protocol 0.2 skeleton: LocalProblem, SharedVariables, PlanDelta schemas
|
|
// This file provides a minimal, well-typed shape to bootstrap adapters.
|
|
|
|
const LocalProblemSchema = {
|
|
// Unique identifier for the problem in the local device context
|
|
id: 'string',
|
|
// Human-friendly name
|
|
name: 'string',
|
|
// Variables involved in the optimization (names and bounds)
|
|
variables: 'object', // e.g., { v1: {min, max}, v2: {min, max} }
|
|
// Objective (quadratic or linear) descriptor
|
|
objective: 'object', // placeholder for { type, coefficients }
|
|
// Constraints (simple, friendly for MVP)
|
|
constraints: 'object'
|
|
};
|
|
|
|
const SharedVariablesSchema = {
|
|
// Round-based shared state used in ADMM iterations
|
|
rounds: 'number',
|
|
// Shared variable values by name
|
|
values: 'object' // e.g., { x1: 1.2, x2: 3.4 }
|
|
};
|
|
|
|
const PlanDeltaSchema = {
|
|
// Delta from the latest local plan, used for delta-syncs
|
|
delta: 'object', // e.g., { updatedVars: [...], deltaValues: {...} }
|
|
// Versioning for deterministic reconciliation
|
|
version: 'number',
|
|
// Audit timestamp
|
|
timestamp: 'number'
|
|
};
|
|
|
|
module.exports = {
|
|
LocalProblemSchema,
|
|
SharedVariablesSchema,
|
|
PlanDeltaSchema
|
|
};
|