Skip to content

Commit

Permalink
maintain backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
bknueven committed Jun 27, 2024
1 parent 44da068 commit cd729bf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
3 changes: 3 additions & 0 deletions pyomo/contrib/pynumero/interfaces/pyomo_grey_box_nlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ def __init__(self, pyomo_model):
if v_scaling is not None:
need_scaling = True
self._primals_scaling[i] = v_scaling
# maintain backwards compatability

Check warning on line 237 in pyomo/contrib/pynumero/interfaces/pyomo_grey_box_nlp.py

View workflow job for this annotation

GitHub Actions / lint/style-and-typos

"compatability" should be "compatibility".
if self._pyomo_model.component('scaling_factor') is not None:
need_scaling = True

self._constraints_scaling = BlockVector(len(nlps))
for i, nlp in enumerate(nlps):
Expand Down
21 changes: 18 additions & 3 deletions pyomo/contrib/pynumero/interfaces/pyomo_nlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,11 @@ def get_inequality_constraint_indices(self, constraints):
def get_obj_scaling(self):
obj = self.get_pyomo_objective()
val = SuffixFinder('scaling_factor').find(obj)
return val
# maintain backwards compatability

Check warning on line 303 in pyomo/contrib/pynumero/interfaces/pyomo_nlp.py

View workflow job for this annotation

GitHub Actions / lint/style-and-typos

"compatability" should be "compatibility".
if self._pyomo_model.component('scaling_factor') is None:
return val
else:
return 1.0 if val is None else val

# overloaded from NLP
def get_primals_scaling(self):
Expand All @@ -312,7 +316,11 @@ def get_primals_scaling(self):
if val is not None:
primals_scaling[i] = val
ret = primals_scaling
return ret
# maintain backwards compatability

Check warning on line 319 in pyomo/contrib/pynumero/interfaces/pyomo_nlp.py

View workflow job for this annotation

GitHub Actions / lint/style-and-typos

"compatability" should be "compatibility".
if self._pyomo_model.component('scaling_factor') is None:
return ret
else:
return primals_scaling

# overloaded from NLP
def get_constraints_scaling(self):
Expand All @@ -324,7 +332,11 @@ def get_constraints_scaling(self):
if val is not None:
constraints_scaling[i] = val
ret = constraints_scaling
return ret
# maintain backwards compatability

Check warning on line 335 in pyomo/contrib/pynumero/interfaces/pyomo_nlp.py

View workflow job for this annotation

GitHub Actions / lint/style-and-typos

"compatability" should be "compatibility".
if self._pyomo_model.component('scaling_factor') is None:
return ret
else:
return constraints_scaling

def extract_subvector_grad_objective(self, pyomo_variables):
"""Compute the gradient of the objective and return the entries
Expand Down Expand Up @@ -612,6 +624,9 @@ def __init__(self, pyomo_model):
if v_scaling is not None:
need_scaling = True
self._primals_scaling[i] = v_scaling
# maintain backwards compatability

Check warning on line 627 in pyomo/contrib/pynumero/interfaces/pyomo_nlp.py

View workflow job for this annotation

GitHub Actions / lint/style-and-typos

"compatability" should be "compatibility".
if self._pyomo_model.component('scaling_factor') is not None:
need_scaling = True

self._constraints_scaling = []
pyomo_nlp_scaling = self._pyomo_nlp.get_constraints_scaling()
Expand Down

0 comments on commit cd729bf

Please sign in to comment.