Skip to content
Open
Show file tree
Hide file tree
Changes from 185 commits
Commits
Show all changes
191 commits
Select commit Hold shift + click to select a range
ed6707a
Add `_spec.md`
smondal13 Jan 14, 2026
eed6329
Add `optimize_experiment()`
smondal13 Jan 14, 2026
4861662
Add `experiment_list` in the `__init__` and a `DeprecationWarning`if …
smondal13 Jan 14, 2026
bf5eb91
Rename finite difference `scenario_blocks` to `fd_scenario_blocks` an…
smondal13 Jan 14, 2026
f70e461
Add new objective method for multiple experiment.
smondal13 Jan 14, 2026
7c7332b
Add complete `doe.py` for multi experiment without testing /example
smondal13 Jan 15, 2026
f5ba35e
Solve the `optimize_experiments()` for both 1 and 2 experiment case u…
smondal13 Jan 15, 2026
79d09cc
Solve `doe/examples/rooney_biegler_multiexperiment.py` and `reactor_m…
smondal13 Jan 15, 2026
fc0f8a5
Add plot and the grid best and optimal point points to the same point
smondal13 Jan 15, 2026
1a80a6c
Add minor changes
smondal13 Jan 17, 2026
948e77c
Merge branch 'change-a-optimality' into add-multiexperiment-and-param…
smondal13 Jan 29, 2026
b83ce4f
Add trace objective
smondal13 Jan 29, 2026
63488f0
Merge branch 'add-comp-efficient-tests' into add-multiexperiment-and-…
smondal13 Jan 29, 2026
6a53dc9
Resolve the test failing issue for `scenario_blocks` does not exist.
smondal13 Jan 29, 2026
4fa587c
Correct docstring
smondal13 Jan 29, 2026
422f0c2
Add `trace` and `pseudo_trace` in the plotting function for multiexpe…
smondal13 Jan 29, 2026
4bb38dc
A-optimality gives different results for rooney_biegler_multiexperime…
smondal13 Jan 29, 2026
974598b
Add new directory for multiexperiment protype examples
smondal13 Jan 29, 2026
c38875b
Solve the error FIM not positive definite when prior_FIM is passed
smondal13 Jan 30, 2026
62f28ed
Solve `rooney_biegler_multiexperiment.py`
smondal13 Jan 30, 2026
42b8744
Add FIM prior in multiexperiment
smondal13 Feb 2, 2026
26ea0a6
Add `multiexperiment_prototype.ipynb` that gives the same result from…
smondal13 Feb 2, 2026
cb19d00
When no prior was used, D-opt and trace FIM gave he same result, but …
smondal13 Feb 2, 2026
e56276a
Solve 2 experiment case with same result from both grid and optimization
smondal13 Feb 2, 2026
0f7cc9e
Merge branch 'Pyomo:main' into add-multiexperiment
smondal13 Feb 6, 2026
03bfb89
Add `local_name` of sym_break_cons
smondal13 Feb 6, 2026
e9d33b7
Add log10 codiition number
smondal13 Feb 13, 2026
0833295
Add `lhs` iniatialization method and test
smondal13 Feb 23, 2026
ca0a4dd
Add tests for optimize_experiments(). All tests passed
smondal13 Feb 23, 2026
02aa81a
Remove cherry-picked example artifacts from DOE test changes
smondal13 Feb 23, 2026
d1493a5
Add more tests for warnings, combinations
smondal13 Feb 23, 2026
802438b
Refactor result dict in `optimize_experiments()`
smondal13 Feb 23, 2026
5ae8280
Add test of opt values with hardcoded values
smondal13 Feb 23, 2026
476bc09
Going through`optimize_experiments`
smondal13 Feb 25, 2026
fe6ef62
Add parallel algorithm for initialization
smondal13 Feb 25, 2026
3879b1c
Enhance LHS initialization with diagnostics and parallel processing i…
smondal13 Feb 25, 2026
73d9387
Enhance diagnostics and error handling in LHS initialization; add tes…
smondal13 Feb 25, 2026
2f1f5a1
Enhance error handling and diagnostics in optimize_experiments; add c…
smondal13 Feb 26, 2026
7913222
Improve optimize_experiments robustness and docs
smondal13 Feb 26, 2026
65cc0cc
Refine optimize_experiments validation and review tracking
smondal13 Feb 26, 2026
72dd1eb
Enhance DesignOfExperiments with parallel processing for LHS scoring …
smondal13 Feb 26, 2026
ce032b5
Refactor DesignOfExperiments for improved LHS sampling and error hand…
smondal13 Feb 27, 2026
845de61
Refactor DesignOfExperiments to improve Cholesky rule handling and en…
smondal13 Feb 27, 2026
05097d5
Enhance DesignOfExperiments with timeout handling for LHS FIM evaluat…
smondal13 Feb 27, 2026
c386945
Clean up the branch by removing the `.md` scripts
smondal13 Mar 2, 2026
859e214
Add `_spec.md`
smondal13 Jan 14, 2026
6f401ad
Add `optimize_experiment()`
smondal13 Jan 14, 2026
ce305a6
Add `experiment_list` in the `__init__` and a `DeprecationWarning`if …
smondal13 Jan 14, 2026
72df8e1
Rename finite difference `scenario_blocks` to `fd_scenario_blocks` an…
smondal13 Jan 14, 2026
dd86620
Add new objective method for multiple experiment.
smondal13 Jan 14, 2026
bcc833a
Add complete `doe.py` for multi experiment without testing /example
smondal13 Jan 15, 2026
82a8aad
Solve the `optimize_experiments()` for both 1 and 2 experiment case u…
smondal13 Jan 15, 2026
336ea3a
Solve `doe/examples/rooney_biegler_multiexperiment.py` and `reactor_m…
smondal13 Jan 15, 2026
2fda230
Add plot and the grid best and optimal point points to the same point
smondal13 Jan 15, 2026
da15eef
Add minor changes
smondal13 Jan 17, 2026
d5a2411
Add trace objective
smondal13 Jan 29, 2026
bb65dcf
Resolve the test failing issue for `scenario_blocks` does not exist.
smondal13 Jan 29, 2026
40381f7
Correct docstring
smondal13 Jan 29, 2026
786d8dd
Add `trace` and `pseudo_trace` in the plotting function for multiexpe…
smondal13 Jan 29, 2026
5947553
A-optimality gives different results for rooney_biegler_multiexperime…
smondal13 Jan 29, 2026
2919813
Add new directory for multiexperiment protype examples
smondal13 Jan 29, 2026
f37bc1d
Solve the error FIM not positive definite when prior_FIM is passed
smondal13 Jan 30, 2026
3338e8b
Solve `rooney_biegler_multiexperiment.py`
smondal13 Jan 30, 2026
0b2e546
Add FIM prior in multiexperiment
smondal13 Feb 2, 2026
490f8fe
Add `multiexperiment_prototype.ipynb` that gives the same result from…
smondal13 Feb 2, 2026
a9287e2
When no prior was used, D-opt and trace FIM gave he same result, but …
smondal13 Feb 2, 2026
afa7090
Solve 2 experiment case with same result from both grid and optimization
smondal13 Feb 2, 2026
e1db056
Add `local_name` of sym_break_cons
smondal13 Feb 6, 2026
6a429d2
Add log10 codiition number
smondal13 Feb 13, 2026
995f137
Add `lhs` iniatialization method and test
smondal13 Feb 23, 2026
dbfc6ba
Add tests for optimize_experiments(). All tests passed
smondal13 Feb 23, 2026
a62a67b
Remove cherry-picked example artifacts from DOE test changes
smondal13 Feb 23, 2026
e17a896
Add more tests for warnings, combinations
smondal13 Feb 23, 2026
489be46
Refactor result dict in `optimize_experiments()`
smondal13 Feb 23, 2026
33b5e66
Add test of opt values with hardcoded values
smondal13 Feb 23, 2026
25752c0
Going through`optimize_experiments`
smondal13 Feb 25, 2026
5657dab
Add parallel algorithm for initialization
smondal13 Feb 25, 2026
60c4a96
Enhance LHS initialization with diagnostics and parallel processing i…
smondal13 Feb 25, 2026
e09d340
Enhance diagnostics and error handling in LHS initialization; add tes…
smondal13 Feb 25, 2026
b7111a3
Enhance error handling and diagnostics in optimize_experiments; add c…
smondal13 Feb 26, 2026
3df6c9a
Improve optimize_experiments robustness and docs
smondal13 Feb 26, 2026
0bfc396
Refine optimize_experiments validation and review tracking
smondal13 Feb 26, 2026
4e3b72d
Enhance DesignOfExperiments with parallel processing for LHS scoring …
smondal13 Feb 26, 2026
290747e
Refactor DesignOfExperiments for improved LHS sampling and error hand…
smondal13 Feb 27, 2026
c76632f
Refactor DesignOfExperiments to improve Cholesky rule handling and en…
smondal13 Feb 27, 2026
4041693
Enhance DesignOfExperiments with timeout handling for LHS FIM evaluat…
smondal13 Feb 27, 2026
6be8b2f
Clean up the branch by removing the `.md` scripts
smondal13 Mar 2, 2026
d6ee86b
Merge remote-tracking branch 'refs/remotes/origin/add-multiexperiment…
smondal13 Mar 2, 2026
77f6ff7
Refactor imports and clean up unused code in DoE modules and tests
smondal13 Mar 2, 2026
f542882
Refactor and enhance tests for optimize_experiments()
smondal13 Mar 2, 2026
74eb4bc
Refactor LHS initialization parameters in DesignOfExperiments and rel…
smondal13 Mar 2, 2026
eabc592
Add test for optimize_experiments with multi-experiment trace option
smondal13 Mar 2, 2026
fe72c91
Cleaned up prototype scripts
smondal13 Mar 2, 2026
edaae02
Add tests for JSON encoder and optimize_experiments error handling in…
smondal13 Mar 2, 2026
0d236c4
Refine DOE optimize_experiments test coverage
smondal13 Mar 2, 2026
adf7de2
Add more tests. Remove symmetry breaking constraint suffix for multi-…
smondal13 Mar 3, 2026
b4a50e3
Refactor DOE tests and remove deprecated multi-experiment test file
smondal13 Mar 3, 2026
faa689c
Run black
smondal13 Mar 3, 2026
eef390a
Update documentation and imports in DoE module for clarity and consis…
smondal13 Mar 3, 2026
280b01a
Run black
smondal13 Mar 3, 2026
c6be263
Refactor DesignOfExperiments to standardize initialization method nam…
smondal13 Mar 3, 2026
592d54c
Merge branch 'main' into add-multiexperiment
smondal13 Mar 6, 2026
1f8f016
Fix multi-experiment compute_FIM aggregation
smondal13 Mar 8, 2026
ff5e465
Merge branch 'add-multiexperiment' of github.com:smondal13/pyomo into…
smondal13 Mar 8, 2026
967e790
Run black
smondal13 Mar 9, 2026
8ee7b2b
Refactor `_enum_label` method placement and add review documentation …
smondal13 Mar 10, 2026
3c034b7
fix(doe): clarify lhs parallel fallback logs
smondal13 Mar 13, 2026
c4103d9
Remove the review file
smondal13 Mar 17, 2026
1518abe
Add comments to explain the test
smondal13 Mar 17, 2026
e4fbf66
Refactor DesignOfExperiments to accept a single experiment or a list
smondal13 Mar 17, 2026
ee6e63f
- update init_method type hint in DesignOfExperiments constructor
smondal13 Mar 17, 2026
ebc7aa3
fix(doc): clarify design variables and FIM in multi-experiment docume…
smondal13 Mar 17, 2026
8f4732d
Rename documentation
smondal13 Mar 17, 2026
735762c
Merge branch 'main' into add-multiexperiment
smondal13 Mar 17, 2026
584091c
Rename
smondal13 Mar 17, 2026
3a52f2d
Merge branch 'add-multiexperiment' of github.com:smondal13/pyomo into…
smondal13 Mar 17, 2026
3678ecb
fix(doc): Test failure
smondal13 Mar 18, 2026
990b812
feat(doe): add multiexp greybox support
smondal13 Mar 27, 2026
0266ca3
feat(tests): add tests for multi-experiment grey box optimization
smondal13 Mar 27, 2026
c1ca9c6
Merge branch 'Pyomo:main' into add-multiexperiment
smondal13 Mar 27, 2026
1e1c048
Merge branch 'Pyomo:main' into multiexp-greybox
smondal13 Mar 27, 2026
bc08c2a
feat(doe): enhance multi-experiment support and add synchronization f…
smondal13 Mar 27, 2026
35ee2f9
enforce consistency in unknown parameter values and order for multi-e…
smondal13 Mar 27, 2026
3e66a71
update error message for objective_option and improve test assertions
smondal13 Mar 27, 2026
293f9c6
Refactor greybox tests and optimize_experiments functionality
smondal13 Mar 30, 2026
b145e3c
refactor(tests): consolidate validation tests for optimize_experiment…
smondal13 Mar 30, 2026
f03a862
refactor(tests): streamline DoE test cases by removing redundant tests
smondal13 Mar 30, 2026
ecdde5a
test: add validation for non-greybox objectives in optimize_experiments
smondal13 Mar 30, 2026
4bb0a5a
refactor: update results structure to use param_scenarios and streaml…
smondal13 Mar 30, 2026
967d0fa
Run black
smondal13 Mar 30, 2026
a2d42dc
Merge pull request #2 from smondal13/multiexp-greybox
smondal13 Mar 30, 2026
f6ea71f
Rename rb_multi.py script and greybox tests documentation
smondal13 Mar 30, 2026
d927ed9
docs: update documentation to include GreyBox-based objectives and re…
smondal13 Mar 30, 2026
2b28bcb
fix: correct typos in error messages for rb_multi function
smondal13 Mar 30, 2026
0f653a8
Refactor the result dict
smondal13 Apr 2, 2026
c85e4fb
Merge branch 'main' into add-multiexperiment
smondal13 Apr 2, 2026
5c856e2
Merge branch 'main' into add-multiexperiment
smondal13 Apr 14, 2026
8a95a60
Merge branch 'main' into add-multiexperiment
smondal13 Apr 14, 2026
c83ea69
Merge branch 'main' into add-multiexperiment
smondal13 Apr 17, 2026
0089ff1
Merge branch 'main' into add-multiexperiment
smondal13 Apr 22, 2026
211f16c
Merge branch 'main' into add-multiexperiment
smondal13 Apr 24, 2026
7d9d2c5
Merge branch 'Pyomo:main' into add-multiexperiment
smondal13 May 4, 2026
eceee44
Merge branch 'main' into add-multiexperiment
smondal13 May 4, 2026
652ee57
Merge branch 'main' into add-multiexperiment
smondal13 May 5, 2026
8dfee15
Merge branch 'main' into add-multiexperiment
smondal13 May 6, 2026
04f7b3e
Merge branch 'main' into add-multiexperiment
smondal13 May 6, 2026
6ed6c90
Defer imports for numpy and scipy and move Greybox imports inside the…
smondal13 May 6, 2026
aeb3916
Remove parallel initialization of LHS
smondal13 May 6, 2026
250aa64
Run black and typos
smondal13 May 6, 2026
5516fbf
Refactor timing mechanism in DesignOfExperiments to use TicTocTimer
smondal13 May 6, 2026
ba82571
Refactor experiment class to handle sym_break_cons and remove the rem…
smondal13 May 6, 2026
d3ce44d
Run black
smondal13 May 6, 2026
7a3db4b
Fix patch references for combinations in test cases
smondal13 May 7, 2026
6db76ff
Merge branch 'main' into add-multiexperiment
smondal13 May 7, 2026
bebda40
Merge branch 'main' into add-multiexperiment
smondal13 May 11, 2026
199d7db
Merge branch 'main' into add-multiexperiment
smondal13 May 12, 2026
5de90ce
Add _TrackingSolver class to monitor solver calls and options in tests
smondal13 May 12, 2026
fab71e1
Refactor experiment optimization tests for clarity and consistency in…
smondal13 May 12, 2026
762c128
Refactor experiment optimization tests for improved clarity and consi…
smondal13 May 12, 2026
21f79dd
Remove unused patch import
smondal13 May 12, 2026
68e9cce
Merge branch 'main' into add-multiexperiment
mrmundt May 15, 2026
b4fb2a1
Merge branch 'main' into add-multiexperiment
smondal13 May 19, 2026
e0d17f1
Implementing reviews: Remove mock tests and add numpy available check
smondal13 May 19, 2026
3960614
Review implementation: remove k_aug runtime available. Remove mock
smondal13 May 19, 2026
f604ceb
Review implementation: streamline FIM computation and remove unnecess…
smondal13 May 19, 2026
683e797
Review implementation: replace inline solver configuration with utili…
smondal13 May 20, 2026
73b7744
Refactor test for multiexperiment optimization to use parameterized i…
smondal13 May 20, 2026
c76c461
Add paremterized tests i
smondal13 May 20, 2026
82bf682
Refactor logger level assignment in FIMExternalGreyBox for clarity
smondal13 May 20, 2026
0d17088
Break down the large `optimize_experiments()` method to smaller helpe…
smondal13 May 20, 2026
cbdbb07
Fix error messages in DesignOfExperiments class to use single quotes …
smondal13 May 20, 2026
7167a5c
Merge branch 'main' into add-multiexperiment
smondal13 May 20, 2026
3512967
Rename 'lhs' to 'latin_hypercube_sampling' in DesignOfExperiments and…
smondal13 May 20, 2026
1f763f2
Merge branch 'add-multiexperiment' of github.com:smondal13/pyomo into…
smondal13 May 20, 2026
d192e9a
Update tests to replace 'lhs' with 'latin_hypercube_sampling' for cla…
smondal13 May 20, 2026
b4505ef
Remove redundant 'cyipopt' availability check from multiple test case…
smondal13 May 20, 2026
651621a
Remove assertion from TestMultiexperimentBuild
smondal13 May 20, 2026
e6d7a27
Add empty list check at the beginning instead of adding a separate ch…
smondal13 May 21, 2026
20b2991
Fix parameterized import and update test decorator to skip if unavail…
smondal13 May 21, 2026
867a84b
Update pyomo/contrib/doe/tests/test_doe_errors.py
smondal13 May 21, 2026
c444b69
Merge branch 'main' into add-multiexperiment
smondal13 May 21, 2026
ceae3d7
Refactor tests to use parameterized inputs for validation cases in Do…
smondal13 May 21, 2026
6b3e5bf
Merge branch 'main' into add-multiexperiment
smondal13 May 21, 2026
bd6d099
Delete pyomo/contrib/doe/documentation.md
smondal13 May 27, 2026
8edc6fa
Delete pyomo/contrib/doe/rb_multi.py
smondal13 May 27, 2026
dc1bfc4
Merge branch 'main' into add-multiexperiment
smondal13 May 28, 2026
0980905
Address Alex's review comments and resolve conflict
smondal13 May 28, 2026
a20061b
Merge branch 'main' into add-multiexperiment
blnicho May 28, 2026
8346a48
Merge branch 'main' into add-multiexperiment
smondal13 May 31, 2026
e0a9d5f
Merge branch 'main' into add-multiexperiment
blnicho Jun 1, 2026
fd51a4c
Implement Reviewer comments. Refactor RooneyBieglerMultiExperiment do…
smondal13 Jun 3, 2026
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
2,306 changes: 2,072 additions & 234 deletions pyomo/contrib/doe/doe.py

Large diffs are not rendered by default.

49 changes: 40 additions & 9 deletions pyomo/contrib/doe/grey_box_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@
class FIMExternalGreyBox(
ExternalGreyBoxModel if (scipy_available and numpy_available) else object
):
def __init__(self, doe_object, objective_option="determinant", logger_level=None):
def __init__(
self,
doe_object=None,
objective_option="determinant",
logger_level=None,
parameter_names=None,
fim_initial=None,
):
"""
Grey box model for metrics on the FIM. This methodology reduces
numerical complexity for the computation of FIM metrics related
Expand All @@ -68,17 +75,35 @@ def __init__(self, doe_object, objective_option="determinant", logger_level=None
default: None, or equivalently, use the logging level of doe_object.

NOTE: Use logging.DEBUG for all messages.
parameter_names:
Optional ordered iterable of parameter labels. When provided, this
lets the grey box object operate on any FIM source with the same
ordering instead of assuming the data must come from
``doe_object.model.parameter_names``. This is needed for the
multi-experiment grey box path because the linked FIM lives on a
scenario block (``scenario.total_fim``), while ``doe_object.model``
is the top-level container and does not own ``parameter_names``
directly.
fim_initial:
Optional dense, symmetric FIM used to seed the grey box inputs. This
is required when ``doe_object`` is not provided.
"""

if doe_object is None:
if doe_object is None and (parameter_names is None or fim_initial is None):
raise ValueError(
"DoE Object must be provided to build external grey box of the FIM."
"Either ``doe_object`` or both ``parameter_names`` and "
"``fim_initial`` must be provided to build the FIM grey box."
)

self.doe_object = doe_object

# Grab parameter list from the doe_object model
self._param_names = [i for i in self.doe_object.model.parameter_names]
# Grab parameter ordering from the explicit arguments when available.
# Multi-experiment optimization passes the aggregated scenario FIM
# directly, so we should not assume the linked FIM always shares the
# same location as self.doe_object.model.
if parameter_names is None:
parameter_names = self.doe_object.model.parameter_names
self._param_names = [i for i in parameter_names]
self._n_params = len(self._param_names)

# Check if the doe_object has model components that are required
Expand All @@ -93,15 +118,21 @@ def __init__(self, doe_object, objective_option="determinant", logger_level=None

# If logger level is None, use doe_object's logger level
if logger_level is None:
logger_level = doe_object.logger.level

if doe_object is not None:
logger_level = doe_object.logger.level
else:
logger_level = logging.WARNING
self.logger.setLevel(level=logger_level)

# Set initial values for inputs
# Need a mask structure
self._masking_matrix = np.triu(np.ones_like(self.doe_object.fim_initial))
if fim_initial is None:
fim_initial = self.doe_object.fim_initial
fim_initial = np.asarray(fim_initial, dtype=np.float64)

self._masking_matrix = np.triu(np.ones_like(fim_initial))
self._input_values = np.asarray(
self.doe_object.fim_initial[self._masking_matrix > 0], dtype=np.float64
fim_initial[self._masking_matrix > 0], dtype=np.float64
)
self._n_inputs = len(self._input_values)

Expand Down
77 changes: 77 additions & 0 deletions pyomo/contrib/doe/tests/experiment_class_example_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,80 @@ def get_labeled_model(self):
m.bad_con_2 = pyo.Constraint(expr=m.hour <= 0.0)

return m


class RooneyBieglerMultiExperiment(RooneyBieglerExperiment):
"""
Experiment class based on the multi-experiment Rooney-Biegler prototype.

This mirrors the implementation in
``examples/multiexperiment-prototype/rooney_biegler_multiexperiment.py``
Comment thread
smondal13 marked this conversation as resolved.
Outdated
while allowing test-time control over initial hour and bounds.
"""

def __init__(
self, hour=2.0, y=10.0, theta=None, measure_error=0.1, hour_bounds=(1.0, 10.0)
):
data = {'hour': hour, 'y': y}
super().__init__(data=data, measure_error=measure_error, theta=theta)
self.hour_bounds = hour_bounds

def get_labeled_model(self):
m = super().get_labeled_model()
hour_lb, hour_ub = self.hour_bounds
m.hour.setlb(hour_lb)
m.hour.setub(hour_ub)

if hasattr(m, "sym_break_cons"):
m.sym_break_cons.clear()
else:
m.sym_break_cons = pyo.Suffix(direction=pyo.Suffix.LOCAL)
m.sym_break_cons[m.hour] = None
Comment on lines +97 to +101
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? Are you adding a new required sym_break_cons Suffix as part of this PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes — in multi-experiment design, sym_break_cons is an optional suffix that lets the user specify which experiment input should be used for symmetry breaking. If the user does not provide it, we automatically use the first variable in the experiment_inputs suffix.

We do this to reduce permutation symmetry and save solver time. In multi-experiment design, the order of experiments does not matter. For example, if we are designing two experiments with design variable T, then the designs (exp 1: T = 300 K, exp 2: T = 350 K) and (exp 1: T = 350 K, exp 2: T = 300 K) are equivalent. The symmetry-breaking constraint helps restrict these equivalent permutations so the solver only considers one ordering.

return m


class RooneyBieglerMultiInputExperimentFlag(RooneyBieglerExperiment):
"""
Two-input Rooney-Biegler style experiment for symmetry-breaking tests.

Parameters
----------
sym_break_flag : int
0 -> do not add ``sym_break_cons`` suffix
1 -> add single marker (hour)
2 -> add multiple markers (hour and temp)
"""

def __init__(self, hour=2.0, temp=300.0, y=10.0, sym_break_flag=1):
data = {'hour': hour, 'y': y}
super().__init__(
data=data, measure_error=0.1, theta={'asymptote': 15, 'rate_constant': 0.5}
)
self.hour = hour
self.temp = temp
self.sym_break_flag = sym_break_flag

def get_labeled_model(self):
m = super().get_labeled_model()

m.hour.setlb(1.0)
m.hour.setub(10.0)
m.temp = pyo.Var(initialize=self.temp, bounds=(280.0, 340.0))
m.temp.fix()

# Replace base Rooney-Biegler response with two-input synthetic variant
# used only for symmetry-breaking tests.
m.del_component(m.response_function)
m.response_function = pyo.Constraint(
expr=m.y
== m.asymptote * (1 - pyo.exp(-m.rate_constant * m.hour)) + 0.01 * m.temp
)
m.experiment_inputs[m.temp] = self.temp
Comment on lines +131 to +141
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is only used for symmetry-breaking tests, should this code be moved inside the if-statement below that is checking if the sym_break_flag is set?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We keep that code outside the sym_break_flag conditional because this helper is intended to be a two-input experiment in all cases. The flag only controls whether we add an explicit sym_break_cons suffix.

We still need the temp input and modified response when sym_break_flag=0, because that case is used to test the automatic fallback behavior when no explicit symmetry-breaking marker is provided. In that path, the code should infer the symmetry-breaking variable from experiment_inputs. Moving the two-input setup inside the conditional would remove that coverage.


if self.sym_break_flag in (1, 2):
m.sym_break_cons = pyo.Suffix(direction=pyo.Suffix.LOCAL)
m.sym_break_cons[m.hour] = None
if self.sym_break_flag == 2:
m.sym_break_cons[m.temp] = None

return m
Loading
Loading