Consider a set of $A_{vn}$ decision variables such that $A_{v1},A_{v2},\cdots,A_{vn}<A$. While this is the standard formulation finding the maximum value of $A_{vn}$, I would also like to find the second largest $A_{vn}$ of this set of decision variables.

  • 2
    $\begingroup$ Are the $n$ values known to be distinct? If not, what is the desired behavior if there is a tie for largest? $\endgroup$ – RobPratt Sep 9 '20 at 3:46
  • $\begingroup$ Yes and no unfortunately, of all of them, only either one or two of them are to be non-zero, i.e., the others are to be zero. Additionally, all of them are integers that are to be greater or equal to zero. Lastly, the two non-zero variables might also be equal, though they should be unequal most of the time. Sorry for the initial omission of such information. Thank you! $\endgroup$ – Mike Sep 9 '20 at 3:54
  • 3
    $\begingroup$ Then just take the sum of all of them and subtract the largest. $\endgroup$ – RobPratt Sep 9 '20 at 4:00
  • $\begingroup$ Dear Dr Rob, Thank you very much! $\endgroup$ – Mike Sep 9 '20 at 6:35

To get the second largest variable when all are nonnegative and at most two can be nonzero, just take the sum of all of them and subtract the largest.


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.