Variable: LP
Variable: LP
Section titled “Variable: LP”
constLP:object
Defined in: src/builders/lp.ts:71
Builder namespace for defining Linear Program optimization problems.
Type Declaration
Section titled “Type Declaration”bounds()
Section titled “bounds()”
readonlybounds(min?,max?):VariableBounds
Create bounds for a variable.
Parameters
Section titled “Parameters”number
Lower bound (omit for unbounded below).
number
Upper bound (omit for unbounded above).
Returns
Section titled “Returns”Variable bounds specification.
Remarks
Section titled “Remarks”Serialization format: SDK-internal (compiled to constraint sorts).
Example
Section titled “Example”LP.bounds(0, 100)// { min: 0, max: 100 }constraint()
Section titled “constraint()”
readonlyconstraint(coefficients,op,rhs,label?):LinearConstraint
Create a linear constraint.
Parameters
Section titled “Parameters”coefficients
Section titled “coefficients”Map of variable names to their constraint coefficients.
Comparison operator: ‘<=’, ‘>=’, or ‘=’.
number
Right-hand side constant.
label?
Section titled “label?”string
Optional human-readable label.
Returns
Section titled “Returns”A linear constraint.
Remarks
Section titled “Remarks”Serialization format: SDK-internal (compiled to constraint sorts).
Example
Section titled “Example”LP.constraint({ chairs: 1, tables: 3 }, '<=', 12, 'wood')// { coefficients: { chairs: 1, tables: 3 }, op: '<=', rhs: 12, label: 'wood' }maximize()
Section titled “maximize()”
readonlymaximize(coefficients):ObjectiveFunction
Create a maximization objective.
Parameters
Section titled “Parameters”coefficients
Section titled “coefficients”Map of variable names to their objective coefficients.
Returns
Section titled “Returns”An objective function to maximize.
Remarks
Section titled “Remarks”Serialization format: SDK-internal (compiled to constraint sorts).
Example
Section titled “Example”LP.maximize({ chairs: 3, tables: 5 })// { direction: 'maximize', coefficients: { chairs: 3, tables: 5 } }minimize()
Section titled “minimize()”
readonlyminimize(coefficients):ObjectiveFunction
Create a minimization objective.
Parameters
Section titled “Parameters”coefficients
Section titled “coefficients”Map of variable names to their objective coefficients.
Returns
Section titled “Returns”An objective function to minimize.
Remarks
Section titled “Remarks”Serialization format: SDK-internal (compiled to constraint sorts).
Example
Section titled “Example”LP.minimize({ cost_a: 2, cost_b: 5 })// { direction: 'minimize', coefficients: { cost_a: 2, cost_b: 5 } }nonNegative()
Section titled “nonNegative()”
readonlynonNegative(…variables):Record<string,VariableBounds>
Create non-negativity bounds (>= 0) for the given variables.
Parameters
Section titled “Parameters”variables
Section titled “variables”…string[]
Variable names to constrain to be non-negative.
Returns
Section titled “Returns”Record<string, VariableBounds>
A bounds map with { min: 0 } for each variable.
Remarks
Section titled “Remarks”Serialization format: SDK-internal (compiled to constraint sorts).
Example
Section titled “Example”LP.nonNegative('chairs', 'tables')// { chairs: { min: 0 }, tables: { min: 0 } }Remarks
Section titled “Remarks”Provides sugar functions for constructing LinearProgramDefinition objects
that can be passed to client.optimize.solve(). All functions return plain objects —
the builder is optional convenience, not required.
Serialization format: The LP builder produces types consumed by the SDK’s
optimize client, which internally compiles them into untagged TermInputDto
structures using CLP(Q) constraint sorts.
Example
Section titled “Example”import { LP } from '@kortexya/reasoninglayer';
const result = await client.optimize.solve({ objective: LP.maximize({ chairs: 3, tables: 5 }), constraints: [ LP.constraint({ chairs: 1, tables: 3 }, '<=', 12), LP.constraint({ chairs: 2, tables: 1 }, '<=', 8), ], bounds: LP.nonNegative('chairs', 'tables'),});