Skip to main content

Linear Constraint

Enforce weighted sums of variables — for mixtures, budgets, and physical limits.

Linear Constraint

Enforce a mathematical relationship between numerical variables.

A linear constraint defines a weighted sum of variables that must satisfy a condition — like "components must add up to 100%".


How It Works

  • Select two or more numerical variables.

  • Assign a weight to each variable (the multiplier in the sum).

  • Choose an operator and a target value.

The constraint enforces: w1 x Var1 + w2 x Var2 + ... (operator) value

Operators

Operator

Meaning

You set

Equal

Sum must equal exactly this value

A single target value

Less than or equal

Sum must not exceed this value

An upper limit

Greater than or equal

Sum must be at least this value

A lower limit

Between

Sum must fall within a range

A lower and upper bound


Examples

Mixture — Components must sum to 100%

  • Variables: Component A, Component B, Component C (each 0–100%)

  • Weights: all 1

  • Operator: Equal

  • Value: 100

This ensures: A + B + C = 100%. The optimizer will only suggest compositions that are valid mixtures.

Budget — Weighted cost limit

  • Variables: Reagent A (mL), Reagent B (mL)

  • Weights: 2 (cost per mL of A), 3 (cost per mL of B)

  • Operator: Less than or equal

  • Value: 500

This ensures: 2 x A + 3 x B ≤ 500. Total cost stays under budget.

Range — Bounded sum

  • Variables: Additive 1 (g), Additive 2 (g)

  • Weights: both 1

  • Operator: Between

  • Lower bound: 10, Upper bound: 50

This ensures: 10 ≤ Additive 1 + Additive 2 ≤ 50. Total additive loading stays in range.


When to Use It

  • Mixtures where components must sum to a total (e.g. 100%).

  • Budgets where a weighted total must not exceed a limit.

  • Physical limits like total volume, total weight, or total flow rate.

Good to Know

  • Linear constraints only work with numerical variables.

  • Weights can be any number (including decimals and negatives).

  • A weight of 1 means "add the variable value as-is." A weight of 2 means "double it."

  • Make sure the constraint is achievable given the variable bounds — an impossible constraint will prevent the optimizer from finding solutions.

Did this answer your question?