Skip to content

Commit

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

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

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

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

0 comments on commit a7791e1

Please sign in to comment.