2026-01-14 20:00:35 -05:00
|
|
|
/**
|
|
|
|
|
* Canvas Schema - Type definitions for optimization workflow nodes
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
export type NodeType =
|
|
|
|
|
| 'model'
|
|
|
|
|
| 'solver'
|
|
|
|
|
| 'designVar'
|
|
|
|
|
| 'extractor'
|
|
|
|
|
| 'objective'
|
|
|
|
|
| 'constraint'
|
|
|
|
|
| 'algorithm'
|
|
|
|
|
| 'surrogate';
|
|
|
|
|
|
|
|
|
|
export interface BaseNodeData {
|
|
|
|
|
label: string;
|
|
|
|
|
configured: boolean;
|
|
|
|
|
errors?: string[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ModelNodeData extends BaseNodeData {
|
|
|
|
|
type: 'model';
|
|
|
|
|
filePath?: string;
|
|
|
|
|
fileType?: 'prt' | 'fem' | 'sim';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface SolverNodeData extends BaseNodeData {
|
|
|
|
|
type: 'solver';
|
|
|
|
|
solverType?: 'SOL101' | 'SOL103' | 'SOL105' | 'SOL106' | 'SOL111' | 'SOL112';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface DesignVarNodeData extends BaseNodeData {
|
|
|
|
|
type: 'designVar';
|
|
|
|
|
expressionName?: string;
|
|
|
|
|
minValue?: number;
|
|
|
|
|
maxValue?: number;
|
|
|
|
|
unit?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ExtractorNodeData extends BaseNodeData {
|
|
|
|
|
type: 'extractor';
|
|
|
|
|
extractorId?: string;
|
|
|
|
|
extractorName?: string;
|
|
|
|
|
config?: Record<string, unknown>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ObjectiveNodeData extends BaseNodeData {
|
|
|
|
|
type: 'objective';
|
|
|
|
|
name?: string;
|
|
|
|
|
direction?: 'minimize' | 'maximize';
|
|
|
|
|
weight?: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ConstraintNodeData extends BaseNodeData {
|
|
|
|
|
type: 'constraint';
|
|
|
|
|
name?: string;
|
|
|
|
|
operator?: '<' | '<=' | '>' | '>=' | '==';
|
|
|
|
|
value?: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface AlgorithmNodeData extends BaseNodeData {
|
|
|
|
|
type: 'algorithm';
|
|
|
|
|
method?: 'TPE' | 'CMA-ES' | 'NSGA-II' | 'GP-BO' | 'RandomSearch';
|
|
|
|
|
maxTrials?: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface SurrogateNodeData extends BaseNodeData {
|
|
|
|
|
type: 'surrogate';
|
|
|
|
|
enabled?: boolean;
|
|
|
|
|
modelType?: 'MLP' | 'GNN' | 'Ensemble';
|
|
|
|
|
minTrials?: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type CanvasNodeData =
|
|
|
|
|
| ModelNodeData
|
|
|
|
|
| SolverNodeData
|
|
|
|
|
| DesignVarNodeData
|
|
|
|
|
| ExtractorNodeData
|
|
|
|
|
| ObjectiveNodeData
|
|
|
|
|
| ConstraintNodeData
|
|
|
|
|
| AlgorithmNodeData
|
|
|
|
|
| SurrogateNodeData;
|
|
|
|
|
|
|
|
|
|
export interface CanvasEdge {
|
|
|
|
|
id: string;
|
|
|
|
|
source: string;
|
|
|
|
|
target: string;
|
|
|
|
|
sourceHandle?: string;
|
|
|
|
|
targetHandle?: string;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-16 14:47:10 -05:00
|
|
|
// Valid connections - defines what a node can connect TO (as source)
|
|
|
|
|
// Flow: DesignVar -> Model -> Solver -> Extractor -> Objective/Constraint -> Algorithm -> Surrogate
|
2026-01-14 20:00:35 -05:00
|
|
|
export const VALID_CONNECTIONS: Record<NodeType, NodeType[]> = {
|
2026-01-16 14:47:10 -05:00
|
|
|
model: ['solver'], // Model outputs to Solver
|
|
|
|
|
solver: ['extractor'], // Solver outputs to Extractor
|
|
|
|
|
designVar: ['model'], // DesignVar outputs to Model (expressions feed into model)
|
|
|
|
|
extractor: ['objective', 'constraint'], // Extractor outputs to Objective/Constraint
|
|
|
|
|
objective: ['algorithm'], // Objective outputs to Algorithm
|
|
|
|
|
constraint: ['algorithm'], // Constraint outputs to Algorithm
|
|
|
|
|
algorithm: ['surrogate'], // Algorithm outputs to Surrogate
|
|
|
|
|
surrogate: [], // Surrogate is terminal
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Node handle configuration for proper flow direction
|
|
|
|
|
export interface HandleConfig {
|
|
|
|
|
id: string;
|
|
|
|
|
label?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface NodeHandleConfig {
|
|
|
|
|
inputs: HandleConfig[];
|
|
|
|
|
outputs: HandleConfig[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Define handles for each node type
|
|
|
|
|
// Flow: DesignVar(s) -> Model -> Solver -> Extractor(s) -> Objective(s) -> Algorithm
|
|
|
|
|
export const NODE_HANDLES: Record<NodeType, NodeHandleConfig> = {
|
|
|
|
|
model: {
|
|
|
|
|
inputs: [{ id: 'params', label: 'Parameters' }], // Receives from DesignVars
|
|
|
|
|
outputs: [{ id: 'sim', label: 'Simulation' }], // Sends to Solver
|
|
|
|
|
},
|
|
|
|
|
solver: {
|
|
|
|
|
inputs: [{ id: 'model', label: 'Model' }], // Receives from Model
|
|
|
|
|
outputs: [{ id: 'results', label: 'Results' }], // Sends to Extractors
|
|
|
|
|
},
|
|
|
|
|
designVar: {
|
|
|
|
|
inputs: [], // No inputs - this is a source
|
|
|
|
|
outputs: [{ id: 'value', label: 'Value' }], // Sends to Model
|
|
|
|
|
},
|
|
|
|
|
extractor: {
|
|
|
|
|
inputs: [{ id: 'results', label: 'Results' }], // Receives from Solver
|
|
|
|
|
outputs: [{ id: 'value', label: 'Value' }], // Sends to Objective/Constraint
|
|
|
|
|
},
|
|
|
|
|
objective: {
|
|
|
|
|
inputs: [{ id: 'value', label: 'Value' }], // Receives from Extractor
|
|
|
|
|
outputs: [{ id: 'objective', label: 'Objective' }], // Sends to Algorithm
|
|
|
|
|
},
|
|
|
|
|
constraint: {
|
|
|
|
|
inputs: [{ id: 'value', label: 'Value' }], // Receives from Extractor
|
|
|
|
|
outputs: [{ id: 'constraint', label: 'Constraint' }], // Sends to Algorithm
|
|
|
|
|
},
|
|
|
|
|
algorithm: {
|
|
|
|
|
inputs: [{ id: 'objectives', label: 'Objectives' }], // Receives from Objectives/Constraints
|
|
|
|
|
outputs: [{ id: 'algo', label: 'Algorithm' }], // Sends to Surrogate
|
|
|
|
|
},
|
|
|
|
|
surrogate: {
|
|
|
|
|
inputs: [{ id: 'algo', label: 'Algorithm' }], // Receives from Algorithm
|
|
|
|
|
outputs: [], // No outputs - this is a sink
|
|
|
|
|
},
|
2026-01-14 20:00:35 -05:00
|
|
|
};
|