Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
valid = True
# validate an object type of the input.
if not isinstance(mdl, Model):
raise AquaError('An input model must be docplex.mp.model.Model.')
# raise an error if the type of the variable is not a binary type.
for var in mdl.iter_variables():
if not var.is_binary():
logger.warning('The type of Variable %s is %s. It must be a binary variable. ',
var, var.vartype.short_name)
valid = False
# raise an error if the constraint type is not an equality constraint.
for constraint in mdl.iter_constraints():
if not constraint.sense == ComparisonType.EQ:
logger.warning('Constraint %s is not an equality constraint.', constraint)
valid = False
if not valid:
raise AquaError('The input model has unsupported elements.')