Skip to content

Variable: Flow

@kortexya/reasoninglayer


@kortexya/reasoninglayer / Flow

Variable: Flow

const Flow: object

Defined in: src/builders/flow.ts:223

Type Declaration

classifyEdges()

classifyEdges(input): FlowBuilderProblem<ClassifyEdgesVars>

Build a Dulmage-Mendelsohn edge-classification problem.

Each edge is classified as "always", "never", or "sometimes" used across the space of all max flows (or all min-cost max flows when optimal: true).

Parameters

input

ClassifyEdgesInput

Returns

FlowBuilderProblem<ClassifyEdgesVars>

classifyEdgesObjective()

classifyEdgesObjective(opts): TermInputArg

Low-level: build a single flow_classify_edges_constraint psi-term.

Parameters

opts
classifications

string

optimal?

boolean

sink

string

source

string

Returns

TermInputArg

edge()

edge(from, to, cap, options?): TermInputArg

Low-level: build a single flow_edge_constraint psi-term.

Parameters

from

string

to

string

cap

number

options?

FlowEdgeOptions = {}

Returns

TermInputArg

maxFlow()

maxFlow(input): FlowBuilderProblem<MaxFlowVars>

Build a max-flow problem.

Emits one flow_edge_constraint per edge, one flow_max_constraint with the requested output binding, and a flow_solve_constraint trigger. Returns the constraint terms plus the names of every output variable.

Parameters

input

MaxFlowInput

Returns

FlowBuilderProblem<MaxFlowVars>

maxObjective()

maxObjective(opts): TermInputArg

Low-level: build a single flow_max_constraint psi-term.

Parameters

opts
flowValue

string

sink

string

source

string

Returns

TermInputArg

Example

const constraints = [
Flow.edge('s', 'a', 10),
Flow.edge('a', 't', 10),
Flow.maxObjective({ source: 's', sink: 't', flowValue: '?V' }),
Flow.solve('s', 't'),
];

minCostMaxFlow()

minCostMaxFlow(input): FlowBuilderProblem<MinCostMaxFlowVars>

Build a min-cost-max-flow problem. Per-edge cost is required for the optimisation to be meaningful (defaults to 0 if absent).

Parameters

input

MinCostMaxFlowInput

Returns

FlowBuilderProblem<MinCostMaxFlowVars>

minCostMaxFlowObjective()

minCostMaxFlowObjective(opts): TermInputArg

Low-level: build a single flow_min_cost_max_flow_constraint psi-term.

Parameters

opts
flowValue

string

sink

string

source

string

totalCost

string

Returns

TermInputArg

minCut()

minCut(input): FlowBuilderProblem<MinCutVars>

Build a min-cut problem.

Emits flow_min_cut_constraint and binds cut_value, cut_edges, source_side, sink_side to the requested variable names (auto-generated when omitted).

Parameters

input

MinCutInput

Returns

FlowBuilderProblem<MinCutVars>

minCutObjective()

minCutObjective(opts): TermInputArg

Low-level: build a single flow_min_cut_constraint psi-term.

Parameters

opts
cutEdges

string

cutValue

string

sink

string

sinkSide

string

source

string

sourceSide

string

Returns

TermInputArg

node()

node(name): object

Low-level: get the node-variable reference used to identify a node name in goals built by this builder. Exposed so callers composing constraints by hand can refer to the same logical node the high-level helpers would produce — e.g., to add a feature test on the same node term inside the same goal.

Parameters

name

string

Returns

object

name

name: string

solve()

solve(source, sink): TermInputArg

Low-level: build a single flow_solve_constraint psi-term.

Parameters

source

string

sink

string

Returns

TermInputArg