Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
46924fe
Alter logging levels for timing breakdown and solver options
shermanjasonaf Sep 7, 2025
371d36e
Merge branch 'main' into pyros-alter-logging-levels
shermanjasonaf Sep 7, 2025
cf1375d
Simplify setup of PyROS solver config
shermanjasonaf Sep 7, 2025
f879423
Add comment in user options logging method
shermanjasonaf Sep 7, 2025
95ed27f
Remove redundant code comment
shermanjasonaf Sep 7, 2025
c7c2c88
Address logging case of no user-specified options
shermanjasonaf Sep 7, 2025
2ed1463
Tweak argument setup for full solver config logging
shermanjasonaf Sep 7, 2025
683193d
Modify logging of backup solver invocation
shermanjasonaf Sep 8, 2025
c6a797b
Modify symbols used for logging backup solver use
shermanjasonaf Sep 9, 2025
7056a20
Track master feasibility solve success in iteration logs
shermanjasonaf Sep 9, 2025
28a5626
Modify PyROS logging disclaimer message
shermanjasonaf Sep 14, 2025
ce1e5de
Apply black
shermanjasonaf Sep 14, 2025
0f1f6ea
Check logger level before checking separation problem initial point
shermanjasonaf Sep 14, 2025
fdf8568
Log master feasibility and DR polishing failure msgs at DEBUG level
shermanjasonaf Sep 22, 2025
e8c4331
Update logging of PyROS input model statistics
shermanjasonaf Sep 23, 2025
6e2f19a
Update documentation of the PyROS logging system
shermanjasonaf Sep 23, 2025
0955998
Fix updated solver log example
shermanjasonaf Sep 23, 2025
a5d2624
Modify PyROS logging disclaimer in docs example
shermanjasonaf Sep 23, 2025
52ed442
Merge branch 'main' into pyros-alter-logging-levels
shermanjasonaf Sep 23, 2025
968f254
Fix typo in pyros docs
shermanjasonaf Sep 23, 2025
799564f
Add summary of successful separation results to DEBUG-level log
shermanjasonaf Sep 24, 2025
79a64d5
Tweak discrete separation progress logging
shermanjasonaf Sep 24, 2025
6754c35
Add worst-case realization to separation results summary log
shermanjasonaf Sep 24, 2025
9cf06e4
Fix typo logging violated constraints
shermanjasonaf Sep 24, 2025
cca2ef7
Merge branch 'main' into pyros-alter-logging-levels
shermanjasonaf Oct 3, 2025
dc2085f
Remove repeated 'four' in test comments
shermanjasonaf Oct 9, 2025
49782fd
Rewrite PyROS test method docstring
shermanjasonaf Oct 9, 2025
0359897
Add reference to issue #3721 in `user_values` logging comment
shermanjasonaf Oct 9, 2025
9e8bc0d
Remove repeated elements of DR polishing solver logging
shermanjasonaf Oct 9, 2025
cfb4965
Merge branch 'main' into pyros-alter-logging-levels
mrmundt Oct 14, 2025
20c2e0b
Simplify retrieval of config `user_values` post #3722
shermanjasonaf Oct 15, 2025
4e37ea1
Merge branch 'main' into pyros-alter-logging-levels
blnicho Oct 17, 2025
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
Prev Previous commit
Next Next commit
Address logging case of no user-specified options
  • Loading branch information
shermanjasonaf committed Sep 7, 2025
commit c7c2c8883b22bf536e7fdc0448e994d3741162d9
36 changes: 29 additions & 7 deletions pyomo/contrib/pyros/pyros.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,19 +227,41 @@ def _log_config_user_values(
):
"""
Log explicitly set PyROS solver options.

If there are no such options, or all such options
are to be excluded from consideration, then nothing is logged.

Parameters
----------
logger : logging.Logger
Logger for the solver options.
config : ConfigDict
PyROS solver options.
exclude_options : None or iterable of str, optional
Options (keys of the ConfigDict) to exclude from
logging. If `None` passed, then the names of the
required arguments to ``self.solve()`` are skipped.
**log_kwargs : dict, optional
Keyword arguments to each statement of ``logger.log()``.
"""
if exclude_options is None:
exclude_options = self._DEFAULT_CONFIG_USER_OPTIONS
exclude_options = set(self._DEFAULT_CONFIG_USER_OPTIONS)
else:
exclude_options = set(exclude_options)

logger.log(msg="User-provided solver options:", **log_kwargs)
for val in config.user_values():
val_name, val_value = val.name(), val.value()
# note: first clause of if statement
user_values = list(filter(
# note: first clause of logical expression
# accounts for bug(?) causing an iterate
# of user_values to be the config dict itself
if val_name and val_name not in exclude_options:
lambda val: bool(val.name()) and val.name() not in exclude_options,
config.user_values(),
))
if user_values:
logger.log(msg="User-provided solver options:", **log_kwargs)
for val in user_values:
val_name, val_value = val.name(), val.value()
logger.log(msg=f" {val_name}={val_value!r}", **log_kwargs)
logger.log(msg="-" * self._LOG_LINE_LENGTH, **log_kwargs)
logger.log(msg="-" * self._LOG_LINE_LENGTH, **log_kwargs)

def _log_config(self, logger, config, exclude_options=None, **log_kwargs):
"""
Expand Down
25 changes: 25 additions & 0 deletions pyomo/contrib/pyros/tests/test_grcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3370,6 +3370,31 @@ class TestPyROSSolverLogIntros(unittest.TestCase):
Test logging of introductory information by PyROS solver.
"""

def test_log_config_user_values_all_default(self):
"""
Test method for logging config user values logs
nothing if all values are set to default.
"""
pyros_solver = SolverFactory("pyros")
config = pyros_solver.CONFIG(dict(
# mandatory arguments to PyROS solver.
# by default, these should be excluded from the printout
first_stage_variables=[],
second_stage_variables=[],
uncertain_params=[],
uncertainty_set=BoxSet([[1, 2]]),
local_solver=SimpleTestSolver(),
global_solver=SimpleTestSolver(),
# no optional arguments
))
with LoggingIntercept(logger=logger, level=logging.INFO) as LOG:
pyros_solver._log_config_user_values(
logger=logger,
config=config,
level=logging.INFO,
)
self.assertEqual(LOG.getvalue(), "")

def test_log_config_user_values(self):
"""
Test method for logging config user values.
Expand Down