Model
Model(self, model_type='gurobi', model_name='model')
Mixed Integer Programming modeling object. Provides pass-through functionality to one of the three main commercial MIP Python APIs (CPLEX, Gurobi, and XPRESS).
add_var
Model.add_var(lb=0, ub=inf, type='continuous', name='')
Add a variable to the model. :param lb: The lower bound of the variable. :param ub: The upper bound of the variable. :param type: either 'binary' or 'continuous' :param name: The name of the variable. (Ignored if falsey). :return: The variable object associated with the model_type engine API
add_constraint
Model.add_constraint(constraint, name='')
Add a constraint to the model. :param constraint: A constraint created by via linear or quadratic combination of variables and numbers. Be sure to use Model.sum for summing over iterables. :param name: The name of the constraint. Ignored if falsey. :return: The constraint object associated with the model_type engine API
set_objective
Model.set_objective(expression, sense='minimize')
Set the objective for the model. :param expression: A linear or quadratic combination of variables and numbers. Be sure to use Model.sum for summing over iterables. :param sense: Either 'minimize' or 'maximize' :return: None
set_parameters
Model.set_parameters(**kwargs)
Set one or more parameters in the core model :param kwargs: A mapping of parameter keyword to parameter value. The keywords need to be on the list of known parameters, as follows. MIP_Gap : set the MIP optimization tolerance :return: None
optimize
Model.optimize(*args, **kwargs)
Optimize the model. :param args: Optional engine-specific arguments to pass to the model_type API :param kwargs: Optional engine-specific arguments to pass to the model_type API :return: Truthy if the model solves successfully, Falsey otherwise. For a cplex model, a sucessful optimization returns the cplex.Model.solve result
get_solution_value
Model.get_solution_value(var)
Get the value for a variable in the solution. Only call after a successful optimize() call. :param var: The variable returned from a pervious call to add_var() :return: The value of this variable in the optimal solution.