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

Pyomo.DoE: Handle edge case where the nominal value for a parameter is zero #3530

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
8 changes: 7 additions & 1 deletion pyomo/contrib/doe/doe.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ def __init__(
# (i.e., no model rebuilding for large models with sequential)
self._built_scenarios = False

# Minimum step size for finite difference perturbations
# This is important if a parameter has a value of 0
self.min_step_size = 1e-6

# Perform doe
def run_doe(self, model=None, results_file=None):
"""
Expand Down Expand Up @@ -575,7 +579,7 @@ def _sequential_FIM(self, model=None):
# Loop over parameter values and grab correct columns for finite difference calculation

for k, v in model.unknown_parameters.items():
curr_step = v * self.step
curr_step = max(v * self.step, self.min_step_size)

if self.fd_formula == FiniteDifferenceStep.central:
col_1 = 2 * i
Expand Down Expand Up @@ -864,6 +868,8 @@ def jacobian_rule(m, n, p):
param = m.parameter_scenarios[max(s1, s2)]
param_loc = pyo.ComponentUID(param).find_component_on(m.scenario_blocks[0])
param_val = m.scenario_blocks[0].unknown_parameters[param_loc]

# How does this change if we enforce the minimum step size?
param_diff = param_val * fd_step_mult * self.step

if self.scale_nominal_param_value:
Expand Down
Loading