Skip to main content
function parseSolverResponse(response): SolverResult;
Extracts shift assignments from solver response. Parses role-specific variable names matching the pattern assign_role:${memberId}:${patternId}:${roleId}:${day} and aggregate assignment variable names matching assign:${memberId}:${patternId}:${day}.

Parameters

response
{ error?: string; hardConstraintConflicts?: object[]; softConstraintViolations: object[]; solutionInfo?: string; stageResults?: object[]; statistics?: { branches?: number; conflicts?: number; solveTimeMs?: number; }; status: "OPTIMAL" | "FEASIBLE"; values?: Record\<string, number\>; } | { error?: string; hardConstraintConflicts?: object[]; softConstraintViolations?: object[]; solutionInfo?: string; stageResults?: object[]; statistics?: { branches?: number; conflicts?: number; solveTimeMs?: number; }; status: "INFEASIBLE" | "TIMEOUT" | "ERROR"; values?: Record\<string, number\>; }
required
The solver response containing variable values

Returns

SolverResult Parsed schedule result with assignments The model uses aggregate assignment variables as the canonical shift presence literals for intervals, objectives, shift-level rules, and skill-only coverage. Role-specific variables are emitted when the solver also chooses a concrete role for that shift. When both variable shapes exist for the same member, pattern, and day, the role-specific assignment is returned so callers can see the selected role without receiving a duplicate aggregate assignment. IDs are validated by ModelBuilder to not contain colons, ensuring unambiguous parsing.

Example

const response = await client.solve(request);
const result = parseSolverResponse(response);

if (result.status === "OPTIMAL" || result.status === "FEASIBLE") {
  for (const assignment of result.assignments) {
    console.log(`${assignment.memberId} works ${assignment.shiftPatternId} on ${assignment.day}`);
  }
}