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 59f001f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
4 changes: 4 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,10 @@ 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".
scaling_suffix = self._pyomo_model.component('scaling_factor')
if scaling_suffix and scaling_suffix.ctype is pyo.Suffix:
need_scaling = True

self._constraints_scaling = BlockVector(len(nlps))
for i, nlp in enumerate(nlps):
Expand Down
25 changes: 22 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,12 @@ 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".
scaling_suffix = self._pyomo_model.component('scaling_factor')
if scaling_suffix and scaling_suffix.ctype is pyo.Suffix:
return 1.0 if val is None else val
else:
return val

# overloaded from NLP
def get_primals_scaling(self):
Expand All @@ -312,7 +317,12 @@ 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 320 in pyomo/contrib/pynumero/interfaces/pyomo_nlp.py

View workflow job for this annotation

GitHub Actions / lint/style-and-typos

"compatability" should be "compatibility".
scaling_suffix = self._pyomo_model.component('scaling_factor')
if scaling_suffix and scaling_suffix.ctype is pyo.Suffix:
return primals_scaling
else:
return ret

# overloaded from NLP
def get_constraints_scaling(self):
Expand All @@ -324,7 +334,12 @@ 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 337 in pyomo/contrib/pynumero/interfaces/pyomo_nlp.py

View workflow job for this annotation

GitHub Actions / lint/style-and-typos

"compatability" should be "compatibility".
scaling_suffix = self._pyomo_model.component('scaling_factor')
if scaling_suffix and scaling_suffix.ctype is pyo.Suffix:
return constraints_scaling
else:
return ret

def extract_subvector_grad_objective(self, pyomo_variables):
"""Compute the gradient of the objective and return the entries
Expand Down Expand Up @@ -612,6 +627,10 @@ 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 630 in pyomo/contrib/pynumero/interfaces/pyomo_nlp.py

View workflow job for this annotation

GitHub Actions / lint/style-and-typos

"compatability" should be "compatibility".
scaling_suffix = self._pyomo_model.component('scaling_factor')
if scaling_suffix and scaling_suffix.ctype is pyo.Suffix:
need_scaling = True

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

0 comments on commit 59f001f

Please sign in to comment.