add_batch() is basically a shortcut for this:
for l, s, r, i, c, n, t in zip(lin_expr, sense, rhs, indvar, complemented, name, indtype):
cpx.indicator_constraints.add(l, s, r, i, c, n, t)So you specify a list of indicator constraints and they are added in one batch. There is no relation between the different constraints. If you have to add many, many constraints then it is faster to add them in batches than to add them individually.
------------------------------
Daniel Junglas
------------------------------
Original Message:
Sent: Mon May 25, 2020 05:52 AM
From: Andre Hoffmann
Subject: Python CPLEX API: defining binary decision variables
Is my understanding of the command indicator_constraints.add_batch() correct? You submit a collection of constraints and for each constraint you specify a variable that activates the individual constraint.
------------------------------
Andre Hoffmann
------------------------------
Original Message:
Sent: Thu May 21, 2020 02:50 PM
From: Ryan Kersh
Subject: Python CPLEX API: defining binary decision variables
It sounds like you are looking for indicator constraints.
Using the CPLEX Python API, you can create/modify/delete indicator constraints using the InidicatorConstraintInterface.
See also the following examples that are included when you install CPLEX:
- fixnet.py
- foodmanu.py
- diet.py
- etsp.py
------------------------------
Ryan Kersh
Original Message:
Sent: Thu May 21, 2020 02:24 PM
From: Andre Hoffmann
Subject: Python CPLEX API: defining binary decision variables
Pardon me, I found the ressource on http://www.yzuda.org/Useful_Links/optimization/if-then-else-01.html to solve my confusion.
------------------------------
Andre Hoffmann