Skip to content

feat!: Add a variable API and optimisation problems - #436

Open
jetuk wants to merge 1 commit into
mainfrom
variable-config
Open

jetuk wants to merge 1 commit into
mainfrom
variable-config

Conversation

@jetuk

@jetuk jetuk commented Aug 13, 2025 •

Copy link
Copy Markdown
Member

Allow parts of a model to be made variable, and outputs to be used as
objectives and constraints, for use with external optimisation
algorithms such as multi-objective evolutionary algorithms.

Core:

  • VariableParameter trait, implemented by the Constant, Offset,
    MonthlyProfile and RbfProfile parameters, with config validation,
    f64 and u64 values, and bounds.
  • The day of year bounds of RbfProfile points are capped at the
    midpoint to their neighbours, so the ranges do not overlap and any
    values within the bounds give each point a unique day of year.
  • NetworkVariableConfig and its builder define which parameters are
    variable, in order, and validate each config when it is added.
  • Variable values are applied during network setup, before constant
    parameters are computed (Model::setup_with_variables and
    Model::run_with_variables).
  • ModelProblem and ModelProblemBuilder combine a model, its
    variables, and objectives and constraints given by the aggregated
    values of recorders. ModelProblem::evaluate runs the model and
    returns the objective and constraint values; it is Send + Sync so
    evaluations can run in parallel.
  • Remove the unused per-parameter variable methods from Network.

Schema:

  • ProblemConfig defines the variables, objectives and constraints in
    a file separate from the model, and builds a ModelProblem.

Python:

  • ProblemConfig, ModelSchema.build_problem, ModelProblem (with
    evaluate and parallel evaluate_batch) and Evaluation, with
    ProblemBuildError and ProblemEvaluateError exceptions.

Docs:

  • Add an "Optimisation" page to the book with a random search example.

BREAKING CHANGE: The variable field is removed from the Constant,
Offset and RbfProfile parameters in the schema. Models that set it
will no longer load; define variables in a separate ProblemConfig
instead. RbfProfileVariableSettings is renamed to
RbfProfileVariableConfig, its is_active field is removed, and
value_upper_bounds is now required.

@jetuk
jetuk force-pushed the variable-config branch 2 times, most recently from 47e87b5 to d745186 Compare November 4, 2026 00:02
Allow parts of a model to be made variable, and outputs to be used as
objectives and constraints, for use with external optimisation
algorithms such as multi-objective evolutionary algorithms.

Core:
- `VariableParameter` trait, implemented by the Constant, Offset,
  MonthlyProfile and RbfProfile parameters, with config validation,
  f64 and u64 values, and bounds.
- The day of year bounds of RbfProfile points are capped at the
  midpoint to their neighbours, so the ranges do not overlap and any
  values within the bounds give each point a unique day of year.
- `NetworkVariableConfig` and its builder define which parameters are
  variable, in order, and validate each config when it is added.
- Variable values are applied during network setup, before constant
  parameters are computed (`Model::setup_with_variables` and
  `Model::run_with_variables`).
- `ModelProblem` and `ModelProblemBuilder` combine a model, its
  variables, and objectives and constraints given by the aggregated
  values of recorders. `ModelProblem::evaluate` runs the model and
  returns the objective and constraint values; it is `Send + Sync` so
  evaluations can run in parallel.
- Remove the unused per-parameter variable methods from `Network`.

Schema:
- `ProblemConfig` defines the variables, objectives and constraints in
  a file separate from the model, and builds a `ModelProblem`.

Python:
- `ProblemConfig`, `ModelSchema.build_problem`, `ModelProblem` (with
  `evaluate` and parallel `evaluate_batch`) and `Evaluation`, with
  `ProblemBuildError` and `ProblemEvaluateError` exceptions.

Docs:
- Add an "Optimisation" page to the book with a random search example.

BREAKING CHANGE: The `variable` field is removed from the `Constant`,
`Offset` and `RbfProfile` parameters in the schema. Models that set it
will no longer load; define variables in a separate `ProblemConfig`
instead. `RbfProfileVariableSettings` is renamed to
`RbfProfileVariableConfig`, its `is_active` field is removed, and
`value_upper_bounds` is now required.
@jetuk jetuk changed the title Variable config feat!: Add a variable API and optimisation problems Nov 4, 2026
@jetuk
jetuk marked this pull request as ready for review November 4, 2026 00:20
@jetuk
jetuk requested a review from Batch21 November 4, 2026 00:20
@jetuk
jetuk added this pull request to stack #942 November 4, 2026 00:35

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant