added 247 characters in body
Source Link
Richard
  • 2.8k
  • 4
  • 16

I would add an auxiliary variable $z\in\{0,1\}$:

$$ z \geq a_i \ \ \forall a_i \in A $$

Then you can write:

$$ b_j \leq 1-z \ \ \forall b_j \in B $$

If $z=0$, then the constraint is redundant. However, if $z=1$, then all elements of $B$ have to be 0.


Update: @RobPratt correctly pointed out that the above formulation allows for $a_i = b_j = 0$, which violates the requirement the initial requirements. To fix this, I suggest to add:

$$ z \leq \sum_i a_i \\ \sum_j b_j = 1 -z $$

I would add an auxiliary variable $z\in\{0,1\}$:

$$ z \geq a_i \ \ \forall a_i \in A $$

Then you can write:

$$ b_j \leq 1-z \ \ \forall b_j \in B $$

If $z=0$, then the constraint is redundant. However, if $z=1$, then all elements of $B$ have to be 0.

I would add an auxiliary variable $z\in\{0,1\}$:

$$ z \geq a_i \ \ \forall a_i \in A $$

Then you can write:

$$ b_j \leq 1-z \ \ \forall b_j \in B $$

If $z=0$, then the constraint is redundant. However, if $z=1$, then all elements of $B$ have to be 0.


Update: @RobPratt correctly pointed out that the above formulation allows for $a_i = b_j = 0$, which violates the requirement the initial requirements. To fix this, I suggest to add:

$$ z \leq \sum_i a_i \\ \sum_j b_j = 1 -z $$

Source Link
Richard
  • 2.8k
  • 4
  • 16

I would add an auxiliary variable $z\in\{0,1\}$:

$$ z \geq a_i \ \ \forall a_i \in A $$

Then you can write:

$$ b_j \leq 1-z \ \ \forall b_j \in B $$

If $z=0$, then the constraint is redundant. However, if $z=1$, then all elements of $B$ have to be 0.