daitum-configuration
Builder library for the Daitum platform’s model-configuration JSON.
A ConfigurationBuilder composes an algorithm, a model configuration
(decision variables, objectives, constraints), data sources, schedule, and
report/model properties; ConfigurationBuilder.write_to_file() emits
model-configuration.json.
- class ConfigurationBuilder[source]
Builder for a complete model configuration.
Use
set_*methods to attach the algorithm, model configuration, schedule, and model property; useadd_*methods to register data sources and report properties; callwrite_to_file()to emitmodel-configuration.json.- set_algorithm(algorithm)[source]
Set the top-level algorithm. Mutually exclusive with a schedule.
- Return type:
- set_model_configuration(model_configuration)[source]
Set the
ModelConfiguration(decision variables, objectives, constraints).- Return type:
- set_schedule_configuration(schedule_configuration)[source]
Set a multi-step schedule. Mutually exclusive with a single algorithm.
- Return type:
- set_solution_view_allowed(solution_view_allowed)[source]
Set whether the solution-view feature is permitted for this model.
- Return type:
- set_solution_view_enabled(solution_view_enabled)[source]
Set whether the solution view is enabled by default when allowed.
- Return type:
- add_report_property(key, report_property)[source]
Register a
ReportPropertyunder the given key.- Return type:
- set_model_property(calculate_on_load=True, calculation_enabled=True, ignore_formula=False, import_options=None, overlay_config=None)[source]
Construct and attach a
ModelPropertyfrom the given flags and configurations.- Return type:
- add_excel_transform(name, config)[source]
Register an Excel-transform data source and return its
DataSourcewrapper for further customisation (e.g.set_post_optimise).- Return type:
- add_model_transform(name, config)[source]
Register a model-transform data source. See
add_excel_transform()for the return value.- Return type:
- add_data_store(name, config)[source]
Register a data-store data source. See
add_excel_transform()for the return value.- Return type:
- add_batched_data_source(name, config)[source]
Register a batched data source bundling other data sources. See
add_excel_transform()for the return value.- Return type:
- add_report_data_source(name, report_name)[source]
Register a data source that feeds rows from a previously-run report. See
add_excel_transform()for the return value.- Return type:
- add_external_model_data_source(name)[source]
Register a data source that runs the model’s configured external evaluator. Input, parameter, and output mappings are declared on
ExternalModelConfiguration. Seeadd_excel_transform()for the return value.- Return type:
- add_distance_matrix(name, config)[source]
Register a distance-matrix data source. See
add_excel_transform()for the return value.- Return type:
- add_set_features(name, config)[source]
Register a feature-flag data source. See
add_excel_transform()for the return value.- Return type:
- add_geo_location(name, config)[source]
Register a geocoding data source. See
add_excel_transform()for the return value.- Return type:
- class GeneticAlgorithm(log_info=False, evaluations=100000, max_evaluations_without_improvement=10000, max_time_without_improvement=300, min_improvement=1e-06, max_restart_count=0, prng_seed=None, time_limit=60, mutation_rate=(1 / NUM_VARIABLES), recombinator_rate=0.8, population_size=NUM_VARIABLES, elitism=1, mutation=<factory>, recombinator=RecombinatorType.UNIFORM_CROSSOVER, n_point_cuts=None, selection=<factory>, comparator=None, tiebreaker=False, distance_metric=DistanceMetricType.EUCLIDEAN_DISTANCE, sample_count=0, sampling_method=SamplingMethodType.UNIFORM_RANDOM)[source]
Population-based evolutionary algorithm.
- mutation_rate: float | NumericExpression | Parameter | Calculation = (1 / NUM_VARIABLES)
Probability of mutating an offspring (0–1).
- recombinator_rate: float | NumericExpression | Parameter | Calculation = 0.8
Probability of applying crossover (0–1).
- population_size: int | NumericExpression | Parameter | Calculation = NUM_VARIABLES
Number of individuals in the population.
- elitism: int | NumericExpression | Parameter | Calculation = 1
Number of top individuals copied unchanged into the next generation.
- mutation: Mutation
Mutation operator.
- recombinator: RecombinatorType = 'Uniform crossover'
Crossover strategy.
- n_point_cuts: int | NumericExpression | Parameter | Calculation | None = None
Number of crossover points; auto-set for N-point crossover.
- selection: Selection
Selection operator.
- comparator: ComparatorType | None = None
Optional solution comparator for multi-objective runs.
- tiebreaker: bool = False
Apply a diversity-aware tiebreaker on equal objective values.
- distance_metric: DistanceMetricType = 'Euclidean distance'
Distance metric for diversity-aware operators.
- sample_count: int | NumericExpression | Parameter | Calculation = 0
Initial-sample count for sampling-based seeding.
- sampling_method: SamplingMethodType = 'Uniform random'
Initial-population sampling method.
- property key: str
The algorithm key emitted as
algorithmKeyin the serialised output.
- class RecombinatorType(*values)[source]
Crossover strategies for combining parent solutions.
- UNIFORM_CROSSOVER = 'Uniform crossover'
- N_POINT_CROSSOVER = 'N-point crossover'
- class ComparatorType(*values)[source]
Solution-comparison strategy for multi-objective optimisation.
- LEXICOGRAPHIC_COMPARATOR = 'Lexicographic comparator'
- WEIGHTED_OBJECTIVE_COMPARATOR = 'Weighted objective lexicographic comparator'
- SAMPLE_WEIGHTED_OBJECTIVE_COMPARATOR = 'Weighted objective online lexicographic comparator'
- USER_WEIGHTED_OBJECTIVE_COMPARATOR = 'User weighted objective comparator'
- LEXICOGRAPHIC_ONLINE_WEIGHTED_OBJECTIVE_COMPARATOR = 'Lexicographic online weighted objective comparator'
- class MutationType(*values)[source]
Mutation strategy used to perturb individual solutions.
- GAUSSIAN_MUTATION = 'Gaussian mutation'
- UNIFORM_MUTATION = 'Uniform mutation'
- class SelectionType(*values)[source]
Strategy for selecting individuals from the population.
- TOURNAMENT_SELECTION = 'Tournament selection'
- FAST_TOURNAMENT_SELECTION = 'Fast tournament selection'
- RANDOM_SELECTION = 'Random selection'
- class DistanceMetricType(*values)[source]
Distance metric used for diversity-aware operators.
- EUCLIDEAN_DISTANCE = 'Euclidean distance'
- HAMMING_DISTANCE = 'Manhattan distance'
- class SamplingMethodType(*values)[source]
Method used to generate the initial population.
- UNIFORM_RANDOM = 'Uniform random'
- LATIN_HYPERCUBE = 'Latin Hypercube'
- class Mutation(name, parameters)[source]
A mutation operator: a
MutationTypeplus its operator-specific parameters.- name: MutationType
- classmethod mutation(name=None, variation_range=None)[source]
Construct a
Mutationwith default operator parameters.- Parameters:
name (
MutationType|None) – Mutation strategy. Defaults toUNIFORM_MUTATION.variation_range (
float|NumericExpression|None) – Variation magnitude for uniform mutation. Must be non-negative.
- Return type:
- class Selection(name, parameters)[source]
A selection operator: a
SelectionTypeplus its operator-specific parameters.- name: SelectionType
- classmethod selection(name=None, pool_size=None)[source]
Construct a
Selectionwith default operator parameters.- Parameters:
name (
SelectionType|None) – Selection strategy. Defaults toFAST_TOURNAMENT_SELECTION.pool_size (
int|NumericExpression|None) – Tournament pool size. Must be at least 2.
- Return type:
- class CMAESAlgorithm(log_info=False, evaluations=100000, max_evaluations_without_improvement=10000, max_time_without_improvement=300, min_improvement=1e-06, max_restart_count=0, prng_seed=None, time_limit=60, population_size=NUM_VARIABLES, consistency_check=False, cc=4 / NUM_VARIABLES, cs=2 / NUM_VARIABLES, damps=1 + 2 / NUM_VARIABLES, ccov=1 / NUM_VARIABLES, ccovsep=1 / NUM_VARIABLES * NUM_VARIABLES, sigma=0.5, diagonal_iterations=NUM_VARIABLES)[source]
Covariance Matrix Adaptation Evolution Strategy.
- population_size: int | NumericExpression | Parameter | Calculation = NUM_VARIABLES
Number of candidate solutions per generation.
- consistency_check: bool = False
Enable internal consistency assertions.
- cc: float | NumericExpression | Parameter | Calculation = (4 / NUM_VARIABLES)
Covariance-matrix cumulation constant.
- cs: float | NumericExpression | Parameter | Calculation = (2 / NUM_VARIABLES)
Step-size cumulation constant.
- damps: float | NumericExpression | Parameter | Calculation = (1 + (2 / NUM_VARIABLES))
Damping factor for step-size control.
- ccov: float | NumericExpression | Parameter | Calculation = (1 / NUM_VARIABLES)
Learning rate for the covariance-matrix update.
- ccovsep: float | NumericExpression | Parameter | Calculation = (1 / (NUM_VARIABLES * NUM_VARIABLES))
Learning rate for the separable update.
- sigma: float | NumericExpression | Parameter | Calculation = 0.5
Initial step size.
- diagonal_iterations: int | NumericExpression | Parameter | Calculation = NUM_VARIABLES
Iterations using the diagonal-only update before the full update.
- property key: str
The algorithm key emitted as
algorithmKeyin the serialised output.
- class SteepestDynamicLocalSearch(log_info=False, evaluations=100000, max_evaluations_without_improvement=10000, max_time_without_improvement=300, min_improvement=1e-06, max_restart_count=0, prng_seed=None, time_limit=60, allow_neutral_walks=False, integer_step_size=10, decimal_step_size=0.1, integer_step_change=1, integer_lowest_step=1, decimal_step_change=0.001, decimal_lowest_step=0.001)[source]
Steepest Descent local search with a dynamic step-size schedule.
Each iteration perturbs every decision variable by ±``step_size`` and accepts the best neighbour.
integer_step_sizeapplies to integer-typed variables;decimal_step_sizeapplies to real-typed variables. When an iteration finds no improvement the step shrinks toward..._lowest_stepby..._step_change; once at the lowest step with no further improvement the search terminates (subject to the base stopping criteria inherited fromAlgorithm).allow_neutral_walkspermits accepting equal-objective neighbours, letting the search drift across plateaus.- allow_neutral_walks: bool = False
Accept neighbours with equal objective value (plateau drift).
- integer_step_size: int | NumericExpression | Parameter | Calculation = 10
Initial perturbation magnitude for integer-typed variables.
- decimal_step_size: float | NumericExpression | Parameter | Calculation = 0.1
Initial perturbation magnitude for real-typed variables.
- integer_step_change: int | NumericExpression | Parameter | Calculation = 1
Amount by which the integer step is reduced after a non-improving iteration.
- integer_lowest_step: int | NumericExpression | Parameter | Calculation = 1
Floor below which the integer step will not shrink.
- decimal_step_change: float | NumericExpression | Parameter | Calculation = 0.001
Amount by which the decimal step is reduced after a non-improving iteration.
- decimal_lowest_step: float | NumericExpression | Parameter | Calculation = 0.001
Floor below which the decimal step will not shrink.
- property key: str
The algorithm key emitted as
algorithmKeyin the serialised output.
- class NumericExpression(value)[source]
Symbolic numeric value supporting
+,-,*,/operators.Wraps a numeric literal or an expression in the special variable
NUM_VARIABLES. Operators return a newNumericExpression, so expressions compose naturally:evals = 100_000 * NumericExpression("NUM_VARIABLES") rate = 1 / NumericExpression("NUM_VARIABLES")
- NUM_VARIABLES: str = 'NUM_VARIABLES'
- is_expression()[source]
Return True if the expression contains a variable rather than a numeric literal.
- Return type:
- classmethod from_str(expr)[source]
Construct from a numeric or
NUM_VARIABLESstring.- Return type:
- classmethod from_number(num)[source]
Construct from an int or float literal.
- Return type:
- classmethod variable(name)[source]
Construct from a variable name. Currently only
NUM_VARIABLESis supported.- Return type:
- class ConstraintType(*values)[source]
Constraint operator.
- Values:
EQUALITY: The expression must equal the bound. INEQUALITY: The expression must lie within the lower/upper bounds.
- EQUALITY = 'equality'
- INEQUALITY = 'inequality'
- class DVType(*values)[source]
Domain of a decision variable.
- Values:
RANGE: Discrete integer in a contiguous range. LIST: Discrete integer drawn from an allowed list. REAL: Continuous floating-point value.
- RANGE = 'range'
- LIST = 'list'
- REAL = 'real'
- class Priority(*values)[source]
Lexicographic priority for an objective or constraint.
- LOW = 'LOW'
- MEDIUM = 'MEDIUM'
- HIGH = 'HIGH'
- class MetricCombinationRule(*values)[source]
Rule for combining a metric across multiple stochastic trials.
- MIN = 'MIN'
- MAX = 'MAX'
- MEAN = 'MEAN'
- PVALUE_MAX = 'PVALUE_MAX'
- PVALUE_MIN = 'PVALUE_MIN'
- class StochasticConfiguration(runs, p, disable_evaluator_caching)[source]
Configures the solver to run multiple evaluations per candidate solution.
- Parameters:
- metric_rules: dict[str, MetricCombinationRule]
- add_metric_rule(key, metric_rule)[source]
Register a per-metric
MetricCombinationRule.- Return type:
- class ModelConfiguration[source]
Decision variables, objectives, constraints, and solver-level flags for one model.
- set_disable_seed_solution(disable_seed_solution)[source]
Disable the seed solution loaded from input data.
- Return type:
- set_calculated_seed(calculated_seed)[source]
Enable computing the seed solution from formulas instead of input data.
- Return type:
- set_validation_enabled(validation_enabled)[source]
Enable or disable validators on the input data.
- Return type:
- set_profiling(profiling)[source]
Enable solver-side performance profiling.
- Return type:
- set_hide_objective_when_infeasible(hide_objective_when_infeasible)[source]
Hide objective values from the UI when the solution is infeasible.
- Return type:
- set_stochastic_configuration(stochastic_configuration)[source]
Attach a
StochasticConfigurationfor multi-trial evaluation.- Return type:
- set_external_configuration(custom_evaluator_version, custom_evaluator_key, external_configuration)[source]
Route evaluation through an external evaluator with the given version, key, and
ExternalModelConfigurationmappings.- Return type:
- add_decision_variable(dv, dv_table=None, dv_type=DVType.RANGE)[source]
Register a decision variable.
- Parameters:
- Return type:
- Returns:
The new
DecisionVariable; chain.set_min(...)and.set_max(...)to bound it.
- add_objective(objective, maximise=False, priority=Priority.HIGH, weight=1.0, name=None)[source]
Register an
Objective.- Parameters:
- Return type:
- add_constraint(constraint)[source]
Register a
Constraintover a numeric calculation.Returns the new
Constraint; chain.set_type(...)and.set_lower_bound(...)/.set_upper_bound(...)to configure it.- Return type:
- add_scenario_output(name, scenario_output_value, scenario_output_table=None)[source]
Register a
ScenarioOutputexposed in scenario comparison.- Raises:
ValueError – If
nameor the resolved cell reference duplicates an existing scenario output.- Return type:
- class ModelImportOptions[source]
Default import behaviour applied to every data source on the model.
Construct with default flags, then customise via the chained
set_*methods.- set_match_column_count(match_column_count)[source]
Reject imports whose column count differs from the target.
- Return type:
- set_expected_column_count(expected_column_count)[source]
Set the column count enforced when
match_column_countis True.- Return type:
- set_match_column_headers(match_column_headers)[source]
Reject imports whose column headers differ from the target.
- Return type:
- set_preserve_ordering(preserve_ordering)[source]
Preserve source row order in the target.
- Return type:
- set_match_existing_rows(match_existing_rows)[source]
Match incoming rows against existing rows by
key_column.- Return type:
- set_clear_sheet(clear_sheet)[source]
Clear the sheet before writing imported rows.
- Return type:
- set_reset_decisions(reset_decisions)[source]
Reset decision-variable values on matched rows.
- Return type:
- set_close_on_success(close_on_success)[source]
Auto-close the import dialog on successful import.
- Return type:
- set_skip_pre_processors(skip_pre_processors)[source]
Skip configured pre-processors during import.
- Return type:
- set_key_column(key_column)[source]
Set the column used to match incoming rows against existing ones.
- Return type:
- set_locale_key(locale_key)[source]
Set the locale used to parse incoming numbers, dates, and currency.
- Return type:
- set_sync_key(sync_key)[source]
Set the per-user synchronisation key used by
generate_sync_key().- Return type:
- get_sync_key()[source]
Return the sync key, or an empty string if unset or whitespace.
- Return type:
- class OverlayConfig(show_decision_overlay=False, show_lock_overlay=False, show_objective_overlay=False, show_constraint_overlay=False)[source]
Toggles for spreadsheet overlays that surface solver state in the UI.
- Parameters:
show_decision_overlay (
bool) – Highlight cells driven by decision variables.show_lock_overlay (
bool) – Highlight cells locked at their seed value.show_objective_overlay (
bool) – Highlight cells contributing to objectives.show_constraint_overlay (
bool) – Highlight cells contributing to constraints.
- class ReportExportFormat(*values)[source]
File format produced when a report is exported.
- XLSX = 'XLSX'
- CSV = 'CSV'
- JSON = 'JSON'
- MSDOS = 'MSDOS'
- class ReportData(required_sheets=None, requires_monte_carlo=False, requires_scenario_comparison=False)[source]
Sheet and feature prerequisites for one report.
- Parameters:
- class StepType(*values)[source]
Kind of node in a
ScheduleConfigurationexecution tree.A
StepConfiguration’s type determines whether it executes an algorithm (leaf) or composes child steps (container).- Values:
- SINGLE: Leaf node — runs the algorithm registered under
algorithm_config_keyagainst the current best solution. Carries no children.- SEQUENCE: Container — runs child steps one after another, each
seeded with the previous step’s best solution.
- PARALLEL: Container — runs child steps concurrently from the same
seed and merges their results.
- PARALLEL = 'PARALLEL'
- SEQUENCE = 'SEQUENCE'
- SINGLE = 'SINGLE'
- class StepConfiguration(step_type, algorithm_config_key=None)[source]
One node in a
ScheduleConfigurationexecution tree.A step is either a leaf —
StepType.SINGLEreferencing an algorithm by key — or a container —StepType.PARALLELorStepType.SEQUENCE— holding child steps. Containers may nest arbitrarily.Subproblem and execution behaviour are configured via chained
add_*/set_*methods after construction. Each maps to one subproblem feature:add_included_tag()— restrict the step to a subset of decision variables by tag (seeDecisionVariable.set_tag_source).add_override_parameter()— set model parameter values for the duration of this step.set_split_values_key()— split the step into independent parallel subproblems based on a comma-separated model value.set_recalculate_ranges()— narrow decision-variable bounds based on current model state before executing this step.set_disabled_key()— skip the step when a model value equals"true".set_deferred()— delay step construction until just before execution; required when the configuration above depends on results of earlier steps.
All six fields and
add_stepreturnselffor fluent chaining.- Parameters:
- Raises:
ValueError – If
algorithm_config_keydoes not matchstep_type.
Example:
from daitum_configuration import StepConfiguration, StepType # A SEQUENCE: per-day separable optimisation, then a full # optimisation with narrowed ranges, then an optional refinement. root = StepConfiguration(StepType.SEQUENCE) root.add_step( StepConfiguration(StepType.SINGLE, algorithm_config_key="ga") .set_split_values_key("DayOfWeek") .add_included_tag("PerDay") .add_override_parameter("dailyOptimisation", "true") ) root.add_step( StepConfiguration(StepType.SINGLE, algorithm_config_key="ga") .set_deferred(True) .set_recalculate_ranges(True) ) root.add_step( StepConfiguration(StepType.SINGLE, algorithm_config_key="ls") .set_disabled_key("skipRefinement") )
- add_step(step_configuration)[source]
Append a child step to this container.
- Raises:
ValueError – If this node is
StepType.SINGLE.- Return type:
- add_included_tag(tag)[source]
Append a tag to the variable filter for this step.
Only decision variables whose tags are all in
included_tagsare optimised; variables with no tags are always included. Excluded variables are held at their seed values. Adding the sametagtwice is a no-op.Variable tags are sourced via
DecisionVariable.set_tag_source.- Return type:
- add_override_parameter(key, value)[source]
Add a model parameter override applied during this step.
keyis a parameter name andvalueis a serialised model value. Overrides are applied before each evaluation in this step; the model is fully re-evaluated, so override targets need not lie on decision-dependent paths. Adding the samekeytwice replaces the previous value. Step-scoped overrides take precedence overScheduleConfiguration.add_global_parameter.- Return type:
- set_split_values_key(split_values_key)[source]
Split this step into independent subproblems by model value.
split_values_keyis a model reference returning a comma-separated string (for example"North,South,East,West"). One subproblem is run per value, with the value appended toincluded_tagsso each subproblem optimises a disjoint slice of decision variables. Subproblem variable sets must not overlap.- Return type:
- set_recalculate_ranges(recalculate_ranges)[source]
Narrow decision-variable bounds from current model state.
When
True, the platform reads each variable’s range fields against the current best solution and any applied parameter overrides, then builds the subproblem with the resulting bounds. The new bounds must be a subset of the original. Variables with empty new ranges are excluded; single-value ranges are fixed.Commonly combined with
set_deferred()so the recalculation happens after earlier steps have shaped the current best solution.- Return type:
- set_disabled_key(disabled_key)[source]
Conditionally skip this step based on a model value.
disabled_keyis a model reference; when its serialised value equals"true"the step is replaced with an empty pass-through and the current best solution flows through unchanged.- Return type:
- set_deferred(deferred)[source]
Delay step construction until just before execution.
Required when any of
add_included_tag(),add_override_parameter(),set_split_values_key(),set_recalculate_ranges(), orset_disabled_key()depends on results produced by earlier steps. When deferred, the current best solution is passed in as the seed for evaluating those model references.- Return type:
- class ScheduleConfiguration(schedule_root)[source]
Multi-step optimisation schedule.
Pairs a named map of
Algorithminstances with aStepConfigurationtree that references them by key. The tree is the execution plan; the map supplies the algorithms eachStepType.SINGLEleaf invokes.Algorithms are registered via
add_algorithm(). Thekeyargument is the same string that a SINGLEStepConfigurationpasses as itsalgorithm_config_key. Schedule-wide parameter overrides are registered viaadd_global_parameter(); step-scoped overrides on individual steps take precedence (seeStepConfiguration.add_override_parameter()).Attach a built schedule to a
ConfigurationBuilderwithset_schedule_configuration()— mutually exclusive withset_algorithm().Example:
from daitum_configuration import ( GeneticAlgorithm, ScheduleConfiguration, StepConfiguration, StepType, ) root = StepConfiguration(StepType.SINGLE, algorithm_config_key="ga") schedule = ( ScheduleConfiguration(root) .add_algorithm("ga", GeneticAlgorithm()) .add_global_parameter("seed", "42") )
- Parameters:
schedule_root (
StepConfiguration) – Root step of the execution tree. Required.
- add_algorithm(key, algorithm)[source]
Register an
Algorithmunderkey.keyis the same string a SINGLEStepConfigurationpasses as itsalgorithm_config_keyto invoke this algorithm. Everyalgorithm_config_keyreferenced anywhere in the schedule tree must resolve to a key registered here. Adding the samekeytwice replaces the previous algorithm.- Return type:
- add_global_parameter(key, value)[source]
Add a parameter override applied across every step in the schedule.
keyis a parameter name andvalueis a serialised model value. Adding the samekeytwice replaces the previous value. Step-scoped overrides set viaStepConfiguration.add_override_parameter()take precedence over these globals for the steps on which they’re set.- Return type:
- class ExcelTransformConfig(file_key, file_name, sheet_mapping)[source]
Data source that imports rows from an Excel workbook.
- Parameters:
- set_debug_file(debug_file)[source]
Emit a debug copy of the imported workbook.
- Return type:
- set_manual_sheet_names(manual_sheet_names)[source]
Resolve sheet names manually rather than via the configured mapping.
- Return type:
- set_import_object_references_as_keys(import_object_references_as_keys)[source]
Treat object-reference cells as raw keys instead of resolved objects.
- Return type:
- set_per_sheet_overrides(per_sheet_overrides)[source]
Override import options per source sheet name.
- Return type:
- property type: DataSourceType
The
DataSourceTypediscriminator for this configuration.
- class ImportOptionOverrides(match_column_count=False, match_column_headers=False, match_existing_rows=False, preserve_ordering=False)[source]
Per-sheet overrides for column matching, ordering, and row reconciliation.
- Parameters:
- set_clear_sheet(clear_sheet)[source]
Clear the sheet before writing imported rows.
- Return type:
- set_reset_decisions(reset_decisions)[source]
Reset decision-variable values for any matched rows on import.
- Return type:
- set_expected_column_count(expected_column_count)[source]
Set the column count enforced when
match_column_countis True.- Return type:
- set_key_column(key_column)[source]
Set the column used to match incoming rows against existing ones.
- Return type:
- class ModelTransform(model_builder)[source]
Sub-model that produces output tables consumed by a
ModelTransformConfig.- Parameters:
model_builder (
ModelBuilder) – The sub-model whose tables are mapped onto target-model tables viaadd_output_table().
- add_output_table(sub_model_table, model_table, field_mapping=None)[source]
Route rows from
sub_model_tableintomodel_table.- Parameters:
- Return type:
- class ModelTransformConfig(file_key, file_name, debug_file=False)[source]
Data source that runs a secondary model and feeds its outputs back into the parent.
Inputs to the secondary model are registered via the
add_*_inputmethods.- Parameters:
- add_dynamic_values(timezone_key)[source]
Inject current-time/date variants as inputs.
- Parameters:
timezone_key (
Parameter|Calculation|None) – Optional model named value of typeSTRINGsupplying an IANA timezone for non-UTC time variants.- Return type:
- add_datastore_input(data_store_key, tables, model_filter=None, direct_data_pull=False)[source]
Register a data-store input feeding the secondary model.
- Return type:
- add_datastore_interface_input(data_store_key, tables, model_filter=None, direct_data_pull=False)[source]
Register a data-store-interface input feeding the secondary model.
- Return type:
- add_direct_upload_input(tables, missing_header_severity=ValidationSeverity.ERROR, unexpected_header_severity=ValidationSeverity.ERROR)[source]
Register a direct-upload (CSV) input feeding the secondary model.
missing_header_severityandunexpected_header_severitycontrol how header mismatches at upload time are surfaced; both default toValidationSeverity.ERROR.- Return type:
- property type: DataSourceType
The
DataSourceTypediscriminator for this configuration.
- class ValidationSeverity(*values)[source]
How a header-validation issue should be surfaced when running a model transform input.
Used on every
ModelTransformInputfor both the missing header and unexpected header checks.- ERROR = 'ERROR'
Treat as a hard error — block the file upload and surface in the validation dialog.
- WARNING = 'WARNING'
Surface in the validation dialog but allow the import to proceed.
- IGNORE = 'IGNORE'
Suppress entirely — neither block nor display.
- class DataStoreConfig(data_store_key, tables)[source]
Data source that reads rows from a stored dataset.
Apply a
DataFilterviaset_model_filter()to restrict which rows are imported.- Parameters:
- set_model_filter(model_filter)[source]
Apply a row-level
DataFilterto narrow the rows pulled in.- Return type:
- set_debug_file(debug_file)[source]
Emit a debug copy of the imported data.
- Return type:
- set_using_interface(using_interface)[source]
Read through the data store’s interface layer rather than directly.
- Return type:
- set_direct_data_pull(direct_data_pull)[source]
Bypass any caching layer and pull rows directly each import.
- Return type:
- property type: DataSourceType
The
DataSourceTypediscriminator for this configuration.
- class EqualityDataFilter(path, source_key, value=None)[source]
Match rows whose value at
pathequals the value resolved fromsource_key.- Parameters:
- property type: DataFilterType
The
DataFilterTypediscriminator for this filter.
- class InequalityDataFilter(path, lower_key, upper_key, lower=None, upper=None)[source]
Match rows whose numeric value at
pathfalls within a range.- Parameters:
lower_key (
float|Parameter|Calculation) – Lower bound source — a literal or model named value.upper_key (
float|Parameter|Calculation) – Upper bound source — a literal or model named value.lower (
float|None) – Optional literal lower-bound value emitted alongside the key.upper (
float|None) – Optional literal upper-bound value emitted alongside the key.
- property type: DataFilterType
The
DataFilterTypediscriminator for this filter.
- class RegexDataFilter(path, source_key, value=None)[source]
Match rows whose value at
pathmatches the regex resolved fromsource_key.- Parameters:
- property type: DataFilterType
The
DataFilterTypediscriminator for this filter.
- class SetDataFilter(path, source_keys, values=None)[source]
Match rows whose value at
pathis in a set of values resolved fromsource_keys.- Parameters:
- property type: DataFilterType
The
DataFilterTypediscriminator for this filter.
- class WildcardDataFilter(path, source_key, value=None, case_sensitive=False)[source]
Match rows whose value at
pathmatches the glob pattern resolved fromsource_key.- Parameters:
- property type: DataFilterType
The
DataFilterTypediscriminator for this filter.
- class BatchedDataSourceConfig(run_after_import_sheet=None)[source]
A data source that runs other data sources in a configured order.
- Parameters:
run_after_import_sheet (
str|None) – Optional sheet name whose import triggers this batch.
- add_data_source(data_source, order, batch_data_source_type=BatchDataSourceType.NONE_PARALLEL)[source]
Add
data_sourceto this batch with the given executionorderandBatchDataSourceType.- Return type:
- property type: DataSourceType
The
DataSourceTypediscriminator for this configuration.
- class DataSourceInfo(data_source, order, batch_data_source_type=BatchDataSourceType.NONE_PARALLEL)[source]
One
DataSourcereference inside aBatchedDataSourceConfig.- Parameters:
data_source (
DataSource) – The data source to include in the batch.order (
int) – Execution order within the batch (lower runs first).batch_data_source_type (
BatchDataSourceType) – Position within any surrounding parallel block.
- class BatchDataSourceType(*values)[source]
Position of a batched-data-source step in a parallel block.
- START_PARALLEL = 'START_PARALLEL'
First step of a parallel block.
- NEXT_PARALLEL = 'NEXT_PARALLEL'
Subsequent step inside a parallel block.
- END_PARALLEL = 'END_PARALLEL'
Final step of a parallel block.
- NONE_PARALLEL = 'NONE_PARALLEL'
Sequential step (no parallel block).
- class DistanceMatrixConfig(from_sheet_name, from_longitude_column, from_latitude_column, outputs)[source]
Computes a matrix of distances/durations between origin and destination points.
Configure destinations via
set_to_sheet(). By default the destination sheet is the same as the origin sheet (square matrix). Each entry inoutputsdefines where one metric is written.- Parameters:
from_sheet_name (
str) – Source sheet for origin rows.from_longitude_column (
str) – Origin-row longitude column name.from_latitude_column (
str) – Origin-row latitude column name.outputs (
list[OutputMatrix]) – OneOutputMatrixper metric to produce.
- set_to_sheet(to_sheet_name, to_longitude_column, to_latitude_column)[source]
Set the destination sheet name and longitude/latitude columns.
- Return type:
- set_from_table_name(from_table_name)[source]
Set the structured-table name for origin rows (alternative to a sheet name).
- Return type:
- set_to_table_name(to_table_name)[source]
Set the structured-table name for destination rows.
- Return type:
- property type: DataSourceType
The
DataSourceTypediscriminator for this configuration.
- class OutputMatrix(sheet_name, named_range, metric)[source]
Where one metric of a
DistanceMatrixConfigis written.
- class Metric(*values)[source]
Distance-matrix output metric.
- DRIVING_DISTANCE = 'DRIVING_DISTANCE'
Driving distance along the route.
- DRIVING_TIME = 'DRIVING_TIME'
Driving time along the route.
- class GeoLocationConfig(sheet_name, address_column, longitude_column, latitude_column)[source]
Geocodes address rows and writes longitude/latitude back into the same sheet.
- Parameters:
- set_table_name(table_name)[source]
Use a structured table rather than a sheet for the source rows.
- Return type:
- set_preserve_existing_data(preserve)[source]
Skip geocoding rows that already have coordinates.
- Return type:
- set_latitude_bounds(lower, upper)[source]
Reject geocoded latitudes outside the given bounds.
- Return type:
- set_longitude_bounds(lower, upper)[source]
Reject geocoded longitudes outside the given bounds.
- Return type:
- set_region(region)[source]
Bias the geocoder towards a region (e.g.,
"AU").- Return type:
- set_live_update(live_update)[source]
Re-geocode immediately when the address column changes in the UI.
- Return type:
- set_run_on_data_import(run)[source]
Run geocoding automatically as part of data import.
- Return type:
- property type: DataSourceType
The
DataSourceTypediscriminator for this configuration.
- class SetFeaturesConfig(feature_settings=None)[source]
Toggles named feature flags when the data source runs.
- property type: DataSourceType
The
DataSourceTypediscriminator for this configuration.
- class VariableNeighbourhoodSearch(log_info=False, evaluations=100000, max_evaluations_without_improvement=10000, max_time_without_improvement=300, min_improvement=1e-06, max_restart_count=0, prng_seed=None, time_limit=60, initial_mutation_rate=(1 / NUM_VARIABLES), minimum_mutation_rate=(1 / NUM_VARIABLES), maximum_mutation_rate=1.0, mutation_rate_tau=0.5, offspring_size=64, population_size=NUM_VARIABLES, mutation=<factory>, selection=<factory>)[source]
Variable Neighbourhood Search — a (μ+λ) evolutionary algorithm with a self-adapting mutation rate.
Each individual carries its own mutation rate as part of its genome. When producing offspring, the rate is perturbed by a lognormal step:
\[\text{childRate} = \text{parentRate} \times \exp(\tau \cdot \mathcal{N}(0, 1))\]where \(\tau\) is
mutation_rate_tau. The result is clamped to[minimum_mutation_rate, maximum_mutation_rate], and the offspring inherits the new rate alongside the mutated genome. Larger \(\tau\) widens the per-generation step in log-space.The population is (μ+λ):
population_sizeis λ (total offspring per generation) and the number of parents μ ispopulation_size / offspring_size.selectionpicks the μ parents each generation.- initial_mutation_rate: float | NumericExpression | Parameter | Calculation = (1 / NUM_VARIABLES)
Mutation rate used to seed each individual at the start of the run (0–1).
- minimum_mutation_rate: float | NumericExpression | Parameter | Calculation = (1 / NUM_VARIABLES)
Lower clamp on per-individual mutation rate (0–1).
- maximum_mutation_rate: float | NumericExpression | Parameter | Calculation = 1.0
Upper clamp on per-individual mutation rate (0–1).
- mutation_rate_tau: float | NumericExpression | Parameter | Calculation = 0.5
Log-normal learning rate τ controlling the magnitude of per-offspring mutation-rate steps:
childRate = parentRate × exp(τ × N(0, 1)). Must be non-negative; larger values widen the step distribution.
- offspring_size: int | NumericExpression | Parameter | Calculation = 64
Offspring produced per parent each generation. Combined with
population_sizethis fixes μ =population_size / offspring_size.
- population_size: int | NumericExpression | Parameter | Calculation = NUM_VARIABLES
Total offspring per generation — λ in (μ+λ) notation.
- mutation: Mutation
Mutation operator applied to offspring genomes.
- selection: Selection
Parent-selection operator.
- property key: str
The algorithm key emitted as
algorithmKeyin the serialised output.
- class AdaptiveLargeNeighbourhoodSearch(log_info=False, evaluations=100000, max_evaluations_without_improvement=10000, max_time_without_improvement=300, min_improvement=1e-06, max_restart_count=0, prng_seed=None, time_limit=60, candidates_per_iteration=1, segment_length=100, decay_factor=0.8, new_best_reward=33.0, improving_reward=9.0, accepted_reward=3.0, stagnation_limit=0, acceptance_criterion=<factory>)[source]
Adaptive Large Neighbourhood Search (Ropke & Pisinger, 2006).
ALNS maintains a single incumbent solution and, each iteration, generates one or more candidate solutions by applying a
destroyoperator followed by arepairoperator. Operators are drawn from user-supplied pools by weighted random selection; their weights are updated online based on the outcome of each iteration so that operators that recently produced good moves are picked more often.Each iteration:
Select
kdestroy operators by weighted random sampling.Select
krepair operators by weighted random sampling.Generate
kcandidate solutions by applying each destroy/repair pair to a copy of the incumbent.Evaluate the
kcandidates (in parallel whenk > 1).Decide whether to accept the best candidate via the configured
AcceptanceCriterion.Reward the operator pairs that produced this iteration’s candidates.
Every
segment_lengthiterations, decay all operator weights bydecay_factor.
The operator-reward schedule has three tiers:
new_best_reward(\(\sigma_1\)) — the candidate became a new global best.improving_reward(\(\sigma_2\)) — the candidate improved on the current incumbent but is not a new global best.accepted_reward(\(\sigma_3\)) — the candidate did not improve but was accepted by the acceptance criterion (e.g. by SA).
Operator weights are then decayed each segment via:
\[w_{t+1} = \rho \cdot w_t\]where \(\rho\) is
decay_factor.The destroy and repair operator pools, plus the solution representation, are defined inside the user’s external model implementation (see the platform
ALNSExternalModelinterface); only the algorithm-level controls are configured here.- candidates_per_iteration: int | NumericExpression | Parameter | Calculation = 1
Number of candidate solutions generated per iteration.
k=1runs sequentially;k>1evaluates candidates in parallel.
- segment_length: int | NumericExpression | Parameter | Calculation = 100
Iterations between operator weight decay steps.
- decay_factor: float | NumericExpression | Parameter | Calculation = 0.8
weight multiplier applied per segment. Must be in
(0, 1).- Type:
\(\rho\)
- new_best_reward: float | NumericExpression | Parameter | Calculation = 33.0
reward applied to operators that produced a new global best.
- Type:
\(\sigma_1\)
- improving_reward: float | NumericExpression | Parameter | Calculation = 9.0
reward applied to operators that produced a candidate improving on the current incumbent (but not a new global best).
- Type:
\(\sigma_2\)
- accepted_reward: float | NumericExpression | Parameter | Calculation = 3.0
reward applied to operators that produced an accepted but non-improving candidate.
- Type:
\(\sigma_3\)
- stagnation_limit: int | NumericExpression | Parameter | Calculation = 0
Number of consecutive iterations without a new global best before triggering a soft restart. Set to
0to disable. Requiresperturb()to be implemented in the external model.
- acceptance_criterion: AcceptanceCriterion
Acceptance criterion governing whether candidates replace the incumbent.
- property key: str
The algorithm key emitted as
algorithmKeyin the serialised output.
- class AcceptanceCriterion(name, parameters)[source]
An ALNS acceptance criterion: a
AcceptanceCriterionTypeplus its parameters.Simulated Annealing accepts improving moves and probabilistically accepts worsening moves based on a temperature schedule. Greedy only accepts improving (or equal) moves.
- name: AcceptanceCriterionType
- classmethod simulated_annealing(initial_temperature=None, cooling_rate=None)[source]
Construct a Simulated Annealing acceptance criterion.
- Parameters:
initial_temperature (
float|NumericExpression|None) – Starting temperature for the SA schedule. Must be positive. Defaults to100.0.cooling_rate (
float|NumericExpression|None) – Geometric cooling factor applied each iteration. Must be in(0, 1). Defaults to0.9998.
- Return type:
- classmethod greedy()[source]
Construct a Greedy acceptance criterion (only improving moves are accepted).
- Return type:
- class AcceptanceCriterionType(*values)[source]
Strategy used to decide whether a candidate solution replaces the current one.
- SIMULATED_ANNEALING = 'Simulated Annealing'
- GREEDY = 'Greedy'
- class ExternalModelConfiguration(requires_reload=True)[source]
All input, parameter, and output mappings used by an external evaluator.
- Parameters:
requires_reload (
bool) – Whether the evaluator should be reloaded between runs.
- add_input_data_mapping(mapping)[source]
Register an
InputDataMapping.- Return type:
- add_parameter_mapping(mapping)[source]
Register a
ParameterMapping.- Return type:
- add_output_data_mapping(mapping)[source]
Register an
OutputDataMapping.- Return type:
- class InputDataMapping(entity_name, table, column_mappings=None)[source]
Map a model
Tableto an external-evaluator input entity.Add per-column property mappings via
add_column_mapping().- add_column_mapping(property_name, column)[source]
Append a
ColumnMappinglinkingproperty_nametocolumn.- Return type:
- class OutputDataMapping(entity_name, table, column_mappings=None, key_column=None, preserve_order=False, clear_existing=True)[source]
Extension of
InputDataMappingthat controls how outputs are written back.- Parameters:
- class ParameterMapping(parameter_name, named_value)[source]
Map a model
ParameterorCalculationto an external evaluator parameter name.
Getting Started