From 0b9ccea0fa5d4674129bcda6548e1f3edea91fd8 Mon Sep 17 00:00:00 2001 From: Braulio Brunaud Date: Tue, 7 Feb 2017 17:40:12 -0500 Subject: [PATCH 1/5] added addindconstr! interface for indicator constraints --- src/SolverInterface/LinearQuadratic.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SolverInterface/LinearQuadratic.jl b/src/SolverInterface/LinearQuadratic.jl index 02376d9..4a1b56e 100644 --- a/src/SolverInterface/LinearQuadratic.jl +++ b/src/SolverInterface/LinearQuadratic.jl @@ -21,6 +21,7 @@ export AbstractLinearQuadraticModel delconstrs! addsos1! addsos2! + addindconstr! writeproblem getvarLB getvarUB From 90ebe93a8222cf6b362be5487929819fe15c1172 Mon Sep 17 00:00:00 2001 From: bbrunaud Date: Wed, 8 Feb 2017 17:04:17 -0500 Subject: [PATCH 2/5] add docs for addindconstr! --- doc/lpqcqp.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/lpqcqp.rst b/doc/lpqcqp.rst index 868d61e..1c82f1c 100644 --- a/doc/lpqcqp.rst +++ b/doc/lpqcqp.rst @@ -108,6 +108,16 @@ to indicate equality constraints. are specified in a sparse format: the ``coef`` vector contains the nonzero coefficients, and the ``varidx`` vector contains the indices of the corresponding variables. + +.. function:: addindconstr!(m::AbstractLinearQuadraticModel, ind, comp, varidx, coef, lb, ub) + + Adds a new indicator constraint to the model, of the form +.. math:: + y = 1 \Rightarrow ax \leq b + + ``ind`` is the indicator variable (binary), and ``comp`` is the complement relationship. If bin = 1, comp = true = 0. + The rest of the arguments are the same as addconstr! + .. function:: delconstrs!(m::AbstractLinearQuadraticModel, idxs) From ac49049c2f77aac28a3e02be1be39a40783b1613 Mon Sep 17 00:00:00 2001 From: bbrunaud Date: Wed, 8 Feb 2017 22:46:52 -0500 Subject: [PATCH 3/5] clarifications to addindconstr! replacing ``ind`` by ``binvar``, and ``comp`` to ``binval``, where ``binval`` is the actual value of the indicator variable. Simpler to understand and aligned with the definition of indicator constraints in Gurobi --- doc/lpqcqp.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/lpqcqp.rst b/doc/lpqcqp.rst index 1c82f1c..0fea202 100644 --- a/doc/lpqcqp.rst +++ b/doc/lpqcqp.rst @@ -109,13 +109,13 @@ to indicate equality constraints. coefficients, and the ``varidx`` vector contains the indices of the corresponding variables. -.. function:: addindconstr!(m::AbstractLinearQuadraticModel, ind, comp, varidx, coef, lb, ub) +.. function:: addindconstr!(m::AbstractLinearQuadraticModel, binvar, binval, varidx, coef, lb, ub) Adds a new indicator constraint to the model, of the form .. math:: y = 1 \Rightarrow ax \leq b - ``ind`` is the indicator variable (binary), and ``comp`` is the complement relationship. If bin = 1, comp = true = 0. + ``binvar`` is the indicator variable (binary), and ``binval`` is the value of the binary variable. The rest of the arguments are the same as addconstr! From e114f67fffdc9ea0eb139f2bd6a55330c2035538 Mon Sep 17 00:00:00 2001 From: Braulio Brunaud Date: Tue, 14 Feb 2017 15:16:06 -0500 Subject: [PATCH 4/5] converted addindicator! docs to (expr,sense,rhs) --- doc/lpqcqp.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/lpqcqp.rst b/doc/lpqcqp.rst index 0fea202..5a47ede 100644 --- a/doc/lpqcqp.rst +++ b/doc/lpqcqp.rst @@ -109,14 +109,13 @@ to indicate equality constraints. coefficients, and the ``varidx`` vector contains the indices of the corresponding variables. -.. function:: addindconstr!(m::AbstractLinearQuadraticModel, binvar, binval, varidx, coef, lb, ub) +.. function:: addindconstr!(m::AbstractLinearQuadraticModel, binvar, binval, varidx, coef, sense, rhs) Adds a new indicator constraint to the model, of the form .. math:: y = 1 \Rightarrow ax \leq b - ``binvar`` is the indicator variable (binary), and ``binval`` is the value of the binary variable. - The rest of the arguments are the same as addconstr! + ``binvar`` is the indicator variable (binary), and ``binval`` is the value of the binary variable. Coefficients for the linear constraint are specified in a sparse format: the ``coef`` vector contains the nonzero coefficients, and the ``varidx`` vector contains the indices of the corresponding variables. ``sense`` is the sense of the linear constraint ``('<','=','>')``, and ``rhs`` is the right hand side. .. function:: delconstrs!(m::AbstractLinearQuadraticModel, idxs) From ad10e5ceeee38e32f82ac59581b2634d1af8cb32 Mon Sep 17 00:00:00 2001 From: Braulio Brunaud Date: Fri, 3 Mar 2017 13:56:42 -0500 Subject: [PATCH 5/5] more detailed explanation of !addindconstr --- doc/lpqcqp.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/lpqcqp.rst b/doc/lpqcqp.rst index 5a47ede..af86518 100644 --- a/doc/lpqcqp.rst +++ b/doc/lpqcqp.rst @@ -115,7 +115,9 @@ to indicate equality constraints. .. math:: y = 1 \Rightarrow ax \leq b - ``binvar`` is the indicator variable (binary), and ``binval`` is the value of the binary variable. Coefficients for the linear constraint are specified in a sparse format: the ``coef`` vector contains the nonzero coefficients, and the ``varidx`` vector contains the indices of the corresponding variables. ``sense`` is the sense of the linear constraint ``('<','=','>')``, and ``rhs`` is the right hand side. + ``binvar`` is the index of the indicator variable (binary), and ``binval`` is the value of the binary variable, either ``0`` or ``1``. Coefficients for the linear constraint are specified in a sparse format: the ``coef`` vector contains the nonzero coefficients, and the ``varidx`` vector contains the indices of the corresponding variables. ``sense`` is the sense of the linear constraint ``('<','=','>')``, and ``rhs`` is the right hand side. + + This builds the constraint ``binvar = binval => ax <= b``, where ``ax <= b`` is specified with ``(varidx,coef,sense,rhs``) .. function:: delconstrs!(m::AbstractLinearQuadraticModel, idxs)