@@ -300,7 +300,12 @@ def get_inequality_constraint_indices(self, constraints):
300
300
def get_obj_scaling (self ):
301
301
obj = self .get_pyomo_objective ()
302
302
val = SuffixFinder ('scaling_factor' ).find (obj )
303
- return val
303
+ # maintain backwards compatibility
304
+ scaling_suffix = self ._pyomo_model .component ('scaling_factor' )
305
+ if scaling_suffix and scaling_suffix .ctype is pyo .Suffix :
306
+ return 1.0 if val is None else val
307
+ else :
308
+ return val
304
309
305
310
# overloaded from NLP
306
311
def get_primals_scaling (self ):
@@ -312,7 +317,12 @@ def get_primals_scaling(self):
312
317
if val is not None :
313
318
primals_scaling [i ] = val
314
319
ret = primals_scaling
315
- return ret
320
+ # maintain backwards compatibility
321
+ scaling_suffix = self ._pyomo_model .component ('scaling_factor' )
322
+ if scaling_suffix and scaling_suffix .ctype is pyo .Suffix :
323
+ return primals_scaling
324
+ else :
325
+ return ret
316
326
317
327
# overloaded from NLP
318
328
def get_constraints_scaling (self ):
@@ -324,7 +334,12 @@ def get_constraints_scaling(self):
324
334
if val is not None :
325
335
constraints_scaling [i ] = val
326
336
ret = constraints_scaling
327
- return ret
337
+ # maintain backwards compatibility
338
+ scaling_suffix = self ._pyomo_model .component ('scaling_factor' )
339
+ if scaling_suffix and scaling_suffix .ctype is pyo .Suffix :
340
+ return constraints_scaling
341
+ else :
342
+ return ret
328
343
329
344
def extract_subvector_grad_objective (self , pyomo_variables ):
330
345
"""Compute the gradient of the objective and return the entries
@@ -612,6 +627,10 @@ def __init__(self, pyomo_model):
612
627
if v_scaling is not None :
613
628
need_scaling = True
614
629
self ._primals_scaling [i ] = v_scaling
630
+ # maintain backwards compatibility
631
+ scaling_suffix = self ._pyomo_model .component ('scaling_factor' )
632
+ if scaling_suffix and scaling_suffix .ctype is pyo .Suffix :
633
+ need_scaling = True
615
634
616
635
self ._constraints_scaling = []
617
636
pyomo_nlp_scaling = self ._pyomo_nlp .get_constraints_scaling ()
0 commit comments