How to add a constraint that involves multiplication?

404 views
Skip to first unread message

Muhammad Bilal

unread,
Jul 14, 2016, 8:49:24 AM7/14/16
to Gurobi Optimization
Hi All,

Can someone instructs me about specifying a constraint in Gurobi Java API that involves multiplication, like the one given below (for Matlab version):

a.*const >= 0; where a is the array of decision variable values while const is the constant.

I can't see any method in GRBLinExpr to specify this kind of constraint. Is this a quadric constraint?

Your guidance will be highly appreciated.

Thanks in advance

Kind Regards
Bilal

Renan Garcia

unread,
Jul 14, 2016, 10:08:22 AM7/14/16
to gur...@googlegroups.com
  a.*const >= 0

is equivalent to

  a(1) * const >= 0
  a(2) * const >= 0
  ...

If const > 0, then that is equivalent to

  a(1) >= 0
  a(2) >= 0
  ...

and you can enforce this without a constraint by setting the LB attribute (http://www.gurobi.com/documentation/6.5/refman/lb.html#attr:LB) for each variable in a to 0. Fortunately, this is the default for Gurobi unless otherwise specified.

If const < 0, then that is equivalent to

  a(1) <= 0
  a(2) <= 0
  ...

and you'll need to set the LB attribute to -GRB.INFINITY (if necessary) and UB attribute to 0 (GRB.INFINITY by default).

--

---
You received this message because you are subscribed to the Google Groups "Gurobi Optimization" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gurobi+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Muhammad Bilal

unread,
Jul 14, 2016, 12:08:11 PM7/14/16
to Gurobi Optimization
Hi Renan Garcia,

Many thanks for the clarification and very nice explanation. I got it right now.

Kind Regards,
Bilal

Muhammad Bilal

unread,
Jul 14, 2016, 12:34:43 PM7/14/16
to Gurobi Optimization
In my case, always const > 0 holds, which means the first case you mentioned. Since Gurobi API by default take care by this, which mean this constraint can be skipped, without compromising the results of the model.

Am I right?

On Thursday, July 14, 2016 at 3:08:22 PM UTC+1, Renan Garcia wrote:

Renan Garcia

unread,
Jul 14, 2016, 12:43:24 PM7/14/16
to gur...@googlegroups.com
Yes

Muhammad Bilal

unread,
Jul 14, 2016, 1:54:15 PM7/14/16
to Gurobi Optimization
I appreciate your help.

Thanks a lot.
Reply all
Reply to author
Forward
0 new messages