Two-axis decision matrix engine for grid-based lookups.
Manages and executes decision matrix lookups from a database-backed two-axis grid. Given row and column axis values from a context, resolves the matching cell value. Supports EXACT match, RANGE match (low/high bounds), and DEFAULT fallback on each axis.
Used for pricing grids, risk categorisation, rate tables, and any decision that maps two input dimensions to an output value.
| Column | Type | Description |
|---|---|---|
| Guid | char(50) | Primary key |
| MatrixName | char(255) | Matrix code name |
| Package | char(50) | Package scope |
| Module | varchar(255) | Module name |
| Description | text | Human description |
| Version | int | Version number |
| RowAxis | varchar(255) | Row axis field name |
| ColAxis | varchar(255) | Column axis field name |
| DefaultValue | text | Fallback when no cell matches |
| SimDataTable | varchar(255) | Simulation input table |
| DataTable | text | Live input table |
| ConstantsTables | text | Comma-separated constant lookup tables |
| RaciSimulation | text | RACI for simulation |
| RaciProduction | text | RACI for production |
| RaciOutcome | text | RACI for outcomes |
| RaciDevelopment | text | RACI for development |
| Column | Type | Description |
|---|---|---|
| Guid | varchar(50) | Primary key |
| MatrixName | varchar(255) | Parent matrix |
| Package | varchar(50) | Package scope |
| Version | int | Version number |
| AxisName | varchar(255) | Axis identifier (matches RowAxis or ColAxis) |
| Position | int | Order within the axis |
| MatchType | varchar(20) | EXACT, RANGE, or DEFAULT |
| MatchValue | varchar(255) | Value for EXACT match |
| RangeLow | varchar(255) | Lower bound for RANGE |
| RangeHigh | varchar(255) | Upper bound for RANGE |
| Label | varchar(255) | Human-readable label |
| Column | Type | Description |
|---|---|---|
| Guid | varchar(50) | Primary key |
| MatrixName | varchar(255) | Parent matrix |
| Package | varchar(50) | Package scope |
| Version | int | Version number |
| RowPosition | int | Row axis position |
| ColPosition | int | Column axis position |
| CellValue | text | Output value |
| CellType | varchar(20) | VALUE (default) |
Version tracking table for audit trail.
read(matrix_name, version) — Load a matrix definition, axes, and cells from DB. Caches after first load.compute_matrix(context, run_context) — Resolve row/col values from context, match axes, return cell value. Sets _calc_{matrix_name} on context.get_matched_value(context, field, run_context) — Resolve a field value from context with constants cache, run_context, and prefix stripping.simulate(matrix_name, limit) — Batch-run the matrix against all rows in the configured DataTable. Writes results to bloom_sim_{matrix_name}.send_email(matrix_name, recipients, version) — Send a branded HTML email with the matrix grid, version history, RACI matrix, and signoff status. Falls back to RACI contacts if no recipients specified.load_csv(file_path, matrix_name, package, version) — Import a grid CSV (first row = column labels, first column = row labels, cells = values).save_csv(file_path) — Export the loaded matrix to a grid CSV.evaluate(value1, operator, value2) — Evaluate a condition via ObjOperator with constants resolution._match_axis(axis_entries, context_value) — Find the matching position along an axis (EXACT → RANGE → DEFAULT)._evaluate_between(value, between_expr) — Check if value falls within (low, high)._evaluate_range(value, range_expr) — Check if value falls within (anchor, anchor+offset).Inherits ObjRaci via ObjData. The def_decision_matrix table has RACI columns: RaciSimulation, RaciProduction, RaciOutcome, RaciDevelopment. These are used by:
get_raci() — load RACI contacts for a matrixbuild_raci_html() — render the RACI grid in emailsbuild_signoff_html() — render signoff status in emailsdef_package_rolesInherits ObjVersionMixin. Registered with:
main_table: def_decision_matrixnodes_table: def_decision_matrix_axeshistory_table: def_decision_matrix_historyname_column: MatrixNameRowAxis,ColLabel1,ColLabel2,ColLabel3
RowLabel1,18.0,18.5,19.0
RowLabel2,11.0,12.0,14.0
RowLabel3,7.5,8.5,9.5
First cell of the header row is the row axis name (or empty). Column headers become ColAxis entries. Row first-cells become RowAxis entries. Interior cells become matrix cell values.
python factory.core/ObjDecisionMatrix.py list
python factory.core/ObjDecisionMatrix.py import-csv MATRIX_NAME grid.csv
python factory.core/ObjDecisionMatrix.py run MATRIX_NAME --limit 1000
python factory.core/ObjDecisionMatrix.py export-csv MATRIX_NAME output.csv
python factory.core/ObjDecisionMatrix.py set-table MATRIX_NAME Data_input_table
python factory.core/ObjDecisionMatrix.py send-email MATRIX_NAME --recipients "a@b.com"
The ConstantsTables field holds comma-separated table names. Each table uses a two-column key/value convention (first column = key, second = value). Constants are resolved during axis matching and evaluation, enabling symbolic references in axis definitions.
| Type | Description |
|---|---|
| EXACT | Value must equal MatchValue |
| RANGE | Value must fall within [RangeLow, RangeHigh] |
| DEFAULT | Fallback position when no other axis entry matches |
ObjDecisionSwitch.py — Decision tree engine (node-based traversal)ObjDecisionRuleset.py — Rule-based decision engineObjDecisionSegmentation.py — Customer/data segmentationObjOperator.py — Unified operator evaluationObjVersionMixin.py — Version history tracking