28 lines
852 B
JavaScript
28 lines
852 B
JavaScript
// Toy inverter bridge adapter for EnergiBridge canonical path
|
|
class InverterBridgeAdapter {
|
|
constructor(id) {
|
|
this.id = id;
|
|
}
|
|
|
|
// Lightweight solve() method compatible with EnergyMesh.admmAdapter usage
|
|
// Computes a simple plan targeting the current localProblem value
|
|
solve(localProblem, /* sharedVariables */) {
|
|
const target = (localProblem && localProblem.vars && typeof localProblem.vars.value === 'number')
|
|
? localProblem.vars.value
|
|
: 0;
|
|
// Simple heuristic: approach target as generation; no load signal here
|
|
const generationW = Math.max(0, target * 0.95);
|
|
const result = {
|
|
generationW,
|
|
// Keep consumption at 0 in this toy adapter; focus is demonstrating path
|
|
consumptionW: 0,
|
|
netFlowW: generationW
|
|
};
|
|
return result;
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
InverterBridgeAdapter
|
|
};
|