- if equalities is None:
- equalities = []
- else:
- for i, equality in enumerate(equalities):
- if not isinstance(equality, LinExpr):
- raise TypeError('equalities must be linear expressions')
- equalities[i] = equality.scaleint()
- if inequalities is None:
- inequalities = []
- else:
- for i, inequality in enumerate(inequalities):
- if not isinstance(inequality, LinExpr):
- raise TypeError('inequalities must be linear expressions')
- inequalities[i] = inequality.scaleint()
- symbols = cls._xsymbols(equalities + inequalities)
- islbset = cls._toislbasicset(equalities, inequalities, symbols)
+ sc_equalities = []
+ if equalities is not None:
+ for equality in equalities:
+ if isinstance(equality, LinExpr):
+ sc_equalities.append(equality.scaleint())
+ elif isinstance(equality, numbers.Rational):
+ sc_equalities.append(Rational(equality).scaleint())
+ else:
+ raise TypeError('equalities must be linear expressions '
+ 'or rational numbers')
+ sc_inequalities = []
+ if inequalities is not None:
+ for inequality in inequalities:
+ if isinstance(inequality, LinExpr):
+ sc_inequalities.append(inequality.scaleint())
+ elif isinstance(inequality, numbers.Rational):
+ sc_inequalities.append(Rational(inequality).scaleint())
+ else:
+ raise TypeError('inequalities must be linear expressions '
+ 'or rational numbers')
+ symbols = cls._xsymbols(sc_equalities + sc_inequalities)
+ islbset = cls._toislbasicset(sc_equalities, sc_inequalities, symbols)