1
$\begingroup$

I want to use linear programming to assign weights to a number of groups of variables.

Let's assume we have group $A$ with $x,y,$ and $z$ and group $B$ with $m,n,$ and $p$.

Is it possible to define constraints so that at least one of the variables from each group gets a weight larger than zero?

A feasible solution wout be $x=2,y=0,z=0$ and $m=3, n=0, p=0$.

$\endgroup$
4
$\begingroup$

I am assuming the weights are integers.

Let $x_i^A$ denote the weight assigned to item $i$ from group $A$ and $x_i^B$ denote the weight assigned to item $i$ from group $B$.

You need the following constraints : $$ \sum_{i} x_i^A \ge 1 \\ \sum_{i} x_i^B \ge 1 \\ x_i^A, x_i^B \in \mathbb{N} $$

$\endgroup$
1
  • $\begingroup$ Thank you! I feel stupid how simple the answer was! $\endgroup$ – Mehdi Zare Oct 20 '20 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.