How to use the mip.exceptions.MipBaseException function in mip

To help you get started, we’ve selected a few mip 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 coin-or / python-mip / mip / exceptions.py View on Github external
Inherits from the Python builtin ``Exception``."""


class ProgrammingError(MipBaseException):
    """Exception that is raised when the calling program performs an invalid
     or nonsensical operation.
     Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class InterfacingError(MipBaseException):
    """Exception that is raised when an unknown error occurs while interfacing
    with a solver.
    Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class InvalidLinExpr(MipBaseException):
    """Exception that is raised when an invalid
    linear expression is created.
    Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class InvalidParameter(MipBaseException):
    """Exception that is raised when an invalid/non-existent
    parameter is used or set.
    Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class ParameterNotAvailable(MipBaseException):
    """Exception that is raised when some parameter is not
    available or can not be set.
    Inherits from :attr:`~mip.exceptions.MipBaseException`."""
github coin-or / python-mip / mip / cbc.py View on Github external
def read(self, file_path: str) -> None:
        if not isfile(file_path):
            raise FileNotFoundError("File {} does not exists".format(file_path))

        if file_path.lower().endswith(".gz") and cbclib.Cbc_supportsGzip() == CHAR_ZERO:
            raise MipBaseException("CBC not compiled with gzip support")
        if (
            file_path.lower().endswith(".bz2")
            and cbclib.Cbc_supportsBzip2() == CHAR_ZERO
        ):
            raise MipBaseException("CBC not compiled with bzip2 support")

        fpstr = file_path.encode("utf-8")
        if ".mps" in file_path.lower():
            cbclib.Cbc_readMps(self._model, fpstr)
        elif ".lp" in file_path.lower():
            cbclib.Cbc_readLp(self._model, fpstr)
        else:
            raise ValueError(
                "Enter a valid extension (.lp or .mps) \
                to indicate the file format"
github coin-or / python-mip / mip / exceptions.py View on Github external
Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class ParameterNotAvailable(MipBaseException):
    """Exception that is raised when some parameter is not
    available or can not be set.
    Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class InfeasibleSolution(MipBaseException):
    """Exception that is raised the produced solution
    is unfeasible.
    Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class SolutionNotAvailable(MipBaseException):
    """Exception that is raised when a method that requires
    a solution is queried but the solution is not available.
github coin-or / python-mip / mip / exceptions.py View on Github external
Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class InvalidLinExpr(MipBaseException):
    """Exception that is raised when an invalid
    linear expression is created.
    Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class InvalidParameter(MipBaseException):
    """Exception that is raised when an invalid/non-existent
    parameter is used or set.
    Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class ParameterNotAvailable(MipBaseException):
    """Exception that is raised when some parameter is not
    available or can not be set.
    Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class InfeasibleSolution(MipBaseException):
    """Exception that is raised the produced solution
    is unfeasible.
    Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class SolutionNotAvailable(MipBaseException):
    """Exception that is raised when a method that requires
    a solution is queried but the solution is not available.
github coin-or / python-mip / mip / cbc.py View on Github external
def read(self, file_path: str) -> None:
        if not isfile(file_path):
            raise FileNotFoundError("File {} does not exists".format(file_path))

        if file_path.lower().endswith(".gz") and cbclib.Cbc_supportsGzip() == CHAR_ZERO:
            raise MipBaseException("CBC not compiled with gzip support")
        if (
            file_path.lower().endswith(".bz2")
            and cbclib.Cbc_supportsBzip2() == CHAR_ZERO
        ):
            raise MipBaseException("CBC not compiled with bzip2 support")

        fpstr = file_path.encode("utf-8")
        if ".mps" in file_path.lower():
            cbclib.Cbc_readMps(self._model, fpstr)
        elif ".lp" in file_path.lower():
            cbclib.Cbc_readLp(self._model, fpstr)
        else:
            raise ValueError(
                "Enter a valid extension (.lp or .mps) \
                to indicate the file format"
github coin-or / python-mip / mip / exceptions.py View on Github external
Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class InterfacingError(MipBaseException):
    """Exception that is raised when an unknown error occurs while interfacing
    with a solver.
    Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class InvalidLinExpr(MipBaseException):
    """Exception that is raised when an invalid
    linear expression is created.
    Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class InvalidParameter(MipBaseException):
    """Exception that is raised when an invalid/non-existent
    parameter is used or set.
    Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class ParameterNotAvailable(MipBaseException):
    """Exception that is raised when some parameter is not
    available or can not be set.
    Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class InfeasibleSolution(MipBaseException):
    """Exception that is raised the produced solution
    is unfeasible.
    Inherits from :attr:`~mip.exceptions.MipBaseException`."""
github coin-or / python-mip / mip / exceptions.py View on Github external
"""Python-MIP Exceptions"""


class MipBaseException(Exception):
    """Base class for all exceptions specific to Python MIP. Only sub-classes
    of this exception are raised.
    Inherits from the Python builtin ``Exception``."""


class ProgrammingError(MipBaseException):
    """Exception that is raised when the calling program performs an invalid
     or nonsensical operation.
     Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class InterfacingError(MipBaseException):
    """Exception that is raised when an unknown error occurs while interfacing
    with a solver.
    Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class InvalidLinExpr(MipBaseException):
    """Exception that is raised when an invalid
    linear expression is created.
    Inherits from :attr:`~mip.exceptions.MipBaseException`."""
github coin-or / python-mip / mip / exceptions.py View on Github external
Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class InvalidParameter(MipBaseException):
    """Exception that is raised when an invalid/non-existent
    parameter is used or set.
    Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class ParameterNotAvailable(MipBaseException):
    """Exception that is raised when some parameter is not
    available or can not be set.
    Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class InfeasibleSolution(MipBaseException):
    """Exception that is raised the produced solution
    is unfeasible.
    Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class SolutionNotAvailable(MipBaseException):
    """Exception that is raised when a method that requires
    a solution is queried but the solution is not available.
github coin-or / python-mip / mip / exceptions.py View on Github external
"""Python-MIP Exceptions"""


class MipBaseException(Exception):
    """Base class for all exceptions specific to Python MIP. Only sub-classes
    of this exception are raised.
    Inherits from the Python builtin ``Exception``."""


class ProgrammingError(MipBaseException):
    """Exception that is raised when the calling program performs an invalid
     or nonsensical operation.
     Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class InterfacingError(MipBaseException):
    """Exception that is raised when an unknown error occurs while interfacing
    with a solver.
    Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class InvalidLinExpr(MipBaseException):
    """Exception that is raised when an invalid
    linear expression is created.
    Inherits from :attr:`~mip.exceptions.MipBaseException`."""


class InvalidParameter(MipBaseException):
    """Exception that is raised when an invalid/non-existent
    parameter is used or set.
    Inherits from :attr:`~mip.exceptions.MipBaseException`."""