Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions doc/OnlineDocs/explanation/analysis/doe/guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,73 @@ After applying ``run_doe`` on the ``DesignOfExperiments`` object,
the optimal design is an initial concentration of 5.0 mol/L and
an initial temperature of 494 K with all other temperatures being 300 K.
The corresponding :math:`\log_{10}` determinant of the FIM is 19.32.

Finite-difference evaluation and results
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

``compute_FIM(method="sequential")`` first solves the fixed-design model at
its nominal parameter values. Central differences use this solution as a warm
start; forward and backward differences also use its outputs as the nominal
response in the difference formula. Outputs are evaluated before resetting each
perturbed parameter, including Expression outputs that reference parameters
directly.

If a relative finite-difference perturbation crosses a declared parameter bound,
Pyomo.DoE widens the bound to include the perturbation and logs a warning for
that parameter. Perturbations are not clipped, so the finite-difference step is
unchanged. Parameters are fixed during these solves. Sequential evaluation
restores the original bounds, including when a solve fails; simultaneous scenario
blocks retain the widened bounds to accommodate their fixed perturbed values.
The experiment model must remain valid at the perturbed parameter values.

``run_doe(results_file=...)`` accepts a string or a ``pathlib.Path`` and writes
JSON results. The ``"Measurement Error"`` field and
``get_measurement_error_values()`` report the standard deviations stored as
values in the ``measurement_error`` suffix, in suffix order, rather than the
corresponding measured output values.

Expression measurements with k_aug
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

``compute_FIM(method="kaug")`` supports measurements labeled with either Vars
or Expressions. Expression sensitivities use the chain rule at the solved
model state, combining output derivatives with the variable sensitivities
returned by k_aug. Direct dependence on unknown parameters is included even
when those parameters are fixed in the experiment model. Ordinary fixed
variables and constant Expressions contribute zero sensitivity. An unfixed
dependency missing from the k_aug sensitivity columns raises an error instead
of silently contributing a zero row. Expressions must support Pyomo's numeric
differentiation.

If the model contains active inequality constraints, Pyomo.DoE logs a warning
before the nominal solve. k_aug may reject such formulations, even if the
inequalities are satisfied at the nominal solution. This includes inequalities
inside active nested blocks; deactivated constraints and variable bounds do not
trigger the warning. Here, "active" refers to Pyomo component activation, not
whether an inequality is binding at the solution. Consider sequential finite
differences or an equivalent formulation with explicit slack variables. The
warning does not alter the model or suppress subsequent solver errors. It uses
the ``pyomo.contrib.doe.doe`` logger at ``logging.WARNING`` level, consistent
with other Pyomo.DoE diagnostics, rather than Python's ``warnings.warn``.

The k_aug path requires working ``ipopt``, ``k_aug``, and ``dot_sens`` executables.
The solver-backed Expression regression can be run on an equipped machine with::

python -m pytest pyomo/contrib/doe/tests/test_kaug_outputs.py -v

Starting values from solved scenarios
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

``create_doe_model()`` initializes its default sensitivity matrix from the
already solved finite-difference scenarios. It then initializes the default
FIM using those sensitivities, measurement-error weights, and the prior FIM.
This avoids unnecessary Jacobian/FIM assembly residuals without additional
scenario solves. The fixed-design initialization solve in ``run_doe()`` remains
in place.

Explicit constructor values for ``jac_initial`` and ``fim_initial`` are
preserved independently. If only ``jac_initial`` is supplied, the default FIM
is computed from that supplied Jacobian; if only ``fim_initial`` is supplied,
the Jacobian is still derived from solved scenarios. Objective auxiliaries use
the resulting FIM and the existing Cholesky regularization policy. Lower-only
FIM storage retains fixed zeros in the unused upper triangle.
18 changes: 17 additions & 1 deletion doc/OnlineDocs/explanation/analysis/doe/objective.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,20 @@ Objective Options

.. note::

Detailed descriptions and example code for the objective options in Pyomo.DoE will be added in a future update.
Detailed descriptions and example code for the objective options in Pyomo.DoE will be added in a future update.

Grey-box Hessian interface
--------------------------

When using ``use_grey_box_objective=True``, the FIM metric is represented by
``FIMExternalGreyBox``. Its ``evaluate_hessian_outputs()`` method returns the
lower-triangular sparse Hessian multiplied by the output-constraint multiplier,
as required by the ``ExternalGreyBoxModel`` interface. The solver supplies this
multiplier through ``set_output_constraint_multipliers()`` when assembling the
Hessian of the Lagrangian.

For direct evaluation outside a solver, the multiplier defaults to one, giving
the unweighted metric Hessian. Call ``set_output_constraint_multipliers([1.0])``
to restore that behavior after a different multiplier has been set. Multipliers
do not change the metric value or its Jacobian; the pseudo-A-optimal metric is
linear in the FIM and has a zero Hessian for every multiplier.
Loading
Loading