eml.backend package¶
Submodules¶
eml.backend.cplex_backend module¶
-
class
eml.backend.cplex_backend.CplexBackend(ml_tol=0.0001)[source]¶ Bases:
eml.backend.base.BackendBackend for CPLEX solver
Parameters: ml_tol (float)) – Tollerance -
const_eps(mdl)[source]¶ Get tollerance
Parameters: mdl ( docplex.mp.model.Model) – Cplex modelReturns: Tollerance – Tollerance Return type: float
-
cst_eq(mdl, left, right, name=None)[source]¶ Add to the model equality constraint between two variables
Parameters: - mdl (
docplex.mp.model.Model) – Cplex model - left (:obj:docplex.mp.linear.Var) – Variable
- right (:obj:docplex.mp.linear.Var) – Variable
- name (string) – Name of the constraint
Returns: Equality constraint – Equality contraint between the two variables in input
Return type: docplex.mp.constr.LinearConstraint- mdl (
-
cst_indicator(mdl, trigger, val, cst, name=None)[source]¶ Add an indicator to the model
An indicator constraint links (one-way) the value of a binary variable to the satisfaction of a linear constraint
Parameters: - mdl (
docplex.mp.model.Model) – Cplex model - trigger (
docplex.mp.Var) – Binary Variable - val (int) – Active value, used to trigger the satisfaction of the constraint
- cst (
docplex.mp.constr.LinearConstraint) – Linear constraint - name (string) – Name of the constraint
Returns: Indicator constraint – Indicator constraint between the trigger and the linear constraint in input
Return type: docplex.mp.constr.IndicatorConstraint- mdl (
-
cst_leq(mdl, left, right, name=None)[source]¶ Add to the model a lowe or equal constraint between two variables
Parameters: - mdl (
docplex.mp.model.Model) – Cplex model - left (:obj:docplex.mp.linear.Var) – Variable
- right (:obj:docplex.mp.linear.Var) – Variable
- name (string) – Name of the constraint
Returns: Lower or equal constraint – Lowe or equal contraint between the two variables in input
Return type: docplex.mp.constr.LinearConstraint- mdl (
-
get_obj(mdl)[source]¶ Returns objextive expression
Parameters: mdl ( docplex.mp.model.Model) – Cplex modelReturns: Objective and expression – ‘min’ if the objective function is to be minimized, ‘max otherwise. The expression repesenting the objective function Return type: (string, )
-
new_model(mdl=None, name=None)[source]¶ Creates a new model
Parameters: - mdl (
docplex.mp.model.Model) – Cplex model (default None) - name (string) – Name of the model (default None)
Returns: Model – Cplex model
Return type: docplex.mp.model.Model- mdl (
-
set_obj(mdl, sense, xpr)[source]¶ Sets the objective function
Parameters: - mdl (
docplex.mp.model.Model) – Cplex model - sense (string) – Represents the objective, ‘min’ or ‘max’
- xpr – Expression representing the objective function
Returns: Return type: - mdl (
-
solve(mdl, timelimit)[source]¶ Solves the problem
Parameters: - mdl (
docplex.mp.model.Model) – Cplex model - timelimit (int) – time limit in seconds for the solver
Returns: Solution – A solution if the problem is feasible, the status of the of the solver otherwise
Return type: docplex.mp.solution.SolveSolution- mdl (
-
var_bin(mdl, name=None)[source]¶ Creates continuous variable in the model
Parameters: - mdl (
docplex.mp.model.Model) – Cplex model - name (string)) – Name of the variable (default None)
Returns: Binary Variable – Binary Variable
Return type: docplex.mp.linear.Var`- mdl (
-
var_cont(mdl, lb, ub, name=None)[source]¶ Creates continuous variable in the model
Parameters: Returns: Continuos Variable – Continuos variable with specified bounds and name
Return type: docplex.mp.linear.Var`
-
xpr_eq(mdl, left, right)[source]¶ Creates an equality constraint between two variables
Parameters: - mdl (
docplex.mp.model.Model) – Cplex model - left (:obj:docplex.mp.linear.Var) – Variable
- right (:obj:docplex.mp.linear.Var) – Variable
Returns: Equality constraint – Equality contraint between the two variables in input
Return type: docplex.mp.constr.LinearConstraint- mdl (
-