Skip to content

Commit

Permalink
Revert "always return a scaling factor"
Browse files Browse the repository at this point in the history
This reverts commit a7791e1.
  • Loading branch information
bknueven committed Jun 27, 2024
1 parent 50df842 commit 44da068
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions pyomo/contrib/pynumero/interfaces/pyomo_nlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,24 +299,32 @@ def get_inequality_constraint_indices(self, constraints):
# overloaded from NLP
def get_obj_scaling(self):
obj = self.get_pyomo_objective()
val = SuffixFinder('scaling_factor', 1.0).find(obj)
val = SuffixFinder('scaling_factor').find(obj)
return val

# overloaded from NLP
def get_primals_scaling(self):
scaling_suffix_finder = SuffixFinder('scaling_factor', 1.0)
scaling_suffix_finder = SuffixFinder('scaling_factor')
primals_scaling = np.ones(self.n_primals())
ret = None
for i, v in enumerate(self.get_pyomo_variables()):
primals_scaling[i] = scaling_suffix_finder.find(v)
return primals_scaling
val = scaling_suffix_finder.find(v)
if val is not None:
primals_scaling[i] = val
ret = primals_scaling
return ret

# overloaded from NLP
def get_constraints_scaling(self):
scaling_suffix_finder = SuffixFinder('scaling_factor', 1.0)
scaling_suffix_finder = SuffixFinder('scaling_factor')
constraints_scaling = np.ones(self.n_constraints())
ret = None
for i, c in enumerate(self.get_pyomo_constraints()):
constraints_scaling[i] = scaling_suffix_finder.find(c)
return constraints_scaling
val = scaling_suffix_finder.find(c)
if val is not None:
constraints_scaling[i] = val
ret = constraints_scaling
return ret

def extract_subvector_grad_objective(self, pyomo_variables):
"""Compute the gradient of the objective and return the entries
Expand Down

0 comments on commit 44da068

Please sign in to comment.