Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding ability to reduce the amount of text printed when displaying optimization results #395

Merged
merged 11 commits into from
May 8, 2024
15 changes: 10 additions & 5 deletions pyoptsparse/pyOpt_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -1577,7 +1577,7 @@
con_opt = self._mapContoOpt(con)
return self.processContoDict(con_opt, scaled=False, natural=True)

def __str__(self):
def summary_str(self, minimal_print=False):

Check warning on line 1580 in pyoptsparse/pyOpt_optimization.py

View check run for this annotation

Codecov / codecov/patch

pyoptsparse/pyOpt_optimization.py#L1580

Added line #L1580 was not covered by tests
"""
Print Structured Optimization Problem
"""
crecine marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -1642,7 +1642,8 @@
else:
raise ValueError(f"Unrecognized type for variable {var.name}: {var.type}")

text += fmt.format(idx, var.name, var.type, lower, value, upper, status, width=num_c)
if not (minimal_print and not status):
ewu63 marked this conversation as resolved.
Show resolved Hide resolved
text += fmt.format(idx, var.name, var.type, lower, value, upper, status, width=num_c)
idx += 1

if len(self.constraints) > 0:
Expand Down Expand Up @@ -1698,13 +1699,17 @@
# Active upper bound
status += "u"

text += fmt.format(
idx, c.name, typ, lower, value, upper, status, lambdaStar[con_name][j], width=num_c
)
if not (minimal_print and not status):
text += fmt.format(
idx, c.name, typ, lower, value, upper, status, lambdaStar[con_name][j], width=num_c
)
idx += 1

return text

def __str__(self, minimal_print=False):

Check warning on line 1710 in pyoptsparse/pyOpt_optimization.py

View check run for this annotation

Codecov / codecov/patch

pyoptsparse/pyOpt_optimization.py#L1710

Added line #L1710 was not covered by tests
crecine marked this conversation as resolved.
Show resolved Hide resolved
return self.summary_str(minimal_print)

def __getstate__(self) -> dict:
"""
This is used for serializing class instances.
Expand Down
Loading