How to use the docplex.mp.constants.ComparisonType.EQ function in docplex

To help you get started, we’ve selected a few docplex examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Qiskit / qiskit-aqua / qiskit / optimization / ising / docplex.py View on Github external
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.')

docplex

The IBM Decision Optimization CPLEX Modeling for Python

Apache-2.0
Latest version published 3 months ago

Package Health Score

68 / 100
Full package analysis

Similar packages