Skip to content
Limited preview Core mixed-integer linear modeling and execution are available. Formulation planning and algorithmic discovery are not included yet.

DECIDE queries

In DeQL, a DECIDE statement tells Decisionhouse what to choose from a candidate set.

DECIDE INTO knapsack
FROM items
DECISION COLUMNS (
is_selected INTEGER BETWEEN 0 AND 1
)
SUBJECT TO
CONSTRAINT budget: SUM(weight * is_selected) <= 25
MAXIMIZE SUM(value * is_selected);
ClausePurpose
DECIDE INTO knapsackNames the result
FROM itemsSelects a candidate set
DECISION COLUMNS (...)Declares the unknown values
SUBJECT TOLists constraints, separated by commas
MAXIMIZE or MINIMIZEDefines one objective

FROM must name a candidate set. It cannot name a raw source table.

Each decision column becomes a new column in the result. Its value is selected by the solver for each candidate row.

DECISION COLUMNS (
is_selected INTEGER BETWEEN 0 AND 1
)

A decision column cannot reuse the name of a column already present in the candidate set.

Aggregate across candidates with SUM(...).

CONSTRAINT budget: SUM(weight * is_selected) <= 25

A constraint without SUM(...) applies to every row individually.

CONSTRAINT per_item_limit: allocation <= available

Supported constraint senses are <=, >=, and =. The right-hand side may be a literal or a candidate column.

Use BY (...) to repeat an aggregate constraint for each group.

SUBJECT TO
CONSTRAINT capacity:
SUM(gpus) <= capacity BY (pool_id),
CONSTRAINT demand:
SUM(gpus) = demand BY (workload_id)

The first constraint limits each pool independently. The second satisfies each workload independently.

A query has one linear objective.

MAXIMIZE SUM(value * is_selected)

Sums can be added and subtracted, and the expression may include a constant term.

MAXIMIZE
SUM(value * pick)
- SUM(DISTINCT fixed_cost * open)

For a decision column grouped with BY, SUM(DISTINCT ...) counts its single group value once instead of repeating it for every candidate row in that group.