@@ -331,6 +331,9 @@ def _add_var(self, var, cplex_var_data=None):
331
331
else :
332
332
ub = self ._cplex .infinity
333
333
334
+ if var .is_fixed ():
335
+ lb = value (var )
336
+ ub = value (var )
334
337
335
338
ctx = (
336
339
_VariableData (self ._solver_model )
@@ -346,10 +349,6 @@ def _add_var(self, var, cplex_var_data=None):
346
349
self ._ndx_count += 1
347
350
self ._referenced_variables [var ] = 0
348
351
349
- if var .is_fixed ():
350
- self ._solver_model .variables .set_lower_bounds (varname , var .value )
351
- self ._solver_model .variables .set_upper_bounds (varname , var .value )
352
-
353
352
def _set_instance (self , model , kwds = {}):
354
353
self ._pyomo_var_to_ndx_map = ComponentMap ()
355
354
self ._ndx_count = 0
@@ -441,14 +440,15 @@ def _add_constraint(self, con, cplex_lin_con_data=None):
441
440
con .body , self ._max_constraint_degree
442
441
)
443
442
444
- if con .has_lb ():
445
- if not is_fixed (con .lower ):
446
- raise ValueError ("Lower bound of constraint {0} "
447
- "is not constant." .format (con ))
448
- if con .has_ub ():
449
- if not is_fixed (con .upper ):
450
- raise ValueError ("Upper bound of constraint {0} "
451
- "is not constant." .format (con ))
443
+ if con .has_lb () and not is_fixed (con .lower ):
444
+ raise ValueError (
445
+ "Lower bound of constraint {0} is not constant." .format (con )
446
+ )
447
+
448
+ if con .has_ub () and not is_fixed (con .upper ):
449
+ raise ValueError (
450
+ "Upper bound of constraint {0} is not constant." .format (con )
451
+ )
452
452
453
453
range_ = 0.0
454
454
if con .equality :
0 commit comments