These statements define param minrow as the number of the first row in which the minimum value occurs:
set S = 1..3;
param matrix {S,S};
param minval = min {i in S, j in S} matrix[i,j];
param minrow = min {i in S: exists {j in S} matrix[i,j] = minval} i;
This is not especially efficient, but you will not notice the inefficiency unless you have a very large matrix -- say, more than 1000 rows. For a matrix of 10000 rows, the following is faster:
param minval = min {i in S, j in S} matrix[i,j];
param minrowval {i in S} = min {j in S} matrix[i,j];
param minrow = min {i in S: minrowval[i] = minval} i;
But here you are likely to spend more time just setting up the matrix, since it has 100 million elements.
Bob Fourer
am...@googlegroups.com
-----Original Message-----
From:
am...@googlegroups.com [mailto:
am...@googlegroups.com] On Behalf Of
sahebe...@gmail.com
Sent: Tuesday, October 18, 2016 5:25 PM
To: AMPL Modeling Language
Subject: [AMPL 12766] Min function
I have a matrix[i,j]. How can i find the number of rows of the minimum value???!
For example: I want to get number 2 because 5 is in it.