Skip to content

Function: constrained()

@kortexya/reasoninglayer


@kortexya/reasoninglayer / constrained

Function: constrained()

constrained(name, constraint): ConstrainedPlainVar

Defined in: src/builders/psi.ts:135

Create a constrained variable for use in psi() features.

Parameters

name

string

Variable name (must start with ?, e.g., "?Score").

constraint

Constraint term, typically from guard() or psi().

TermInputDto | PsiTermInput

Returns

ConstrainedPlainVar

A ConstrainedPlainVar that can be used as a feature value in psi().

Remarks

Constrained variables are only meaningful in inference contexts. When the containing psi() term is passed to an inference method, the constrained variable is converted to { name: "?S", constraint: {...} } in the untagged FeatureInputValueDto format.

Example

import { psi, constrained, guard } from '@kortexya/reasoninglayer';
const eligible = psi("eligible", {
applicant: "?A",
score: constrained("?S", guard("gt", 700)),
});