The following loop also stores the number of the column in which the minimum occurs:
param s {VCH};
param scol {VCH};
for {j in VCH}{
let s[j] := min {i in z} D[i,j] ;
let scol[j] := min {i in z: D[i,j] = s[j]} i;
};
Bob Fourer
am...@googlegroups.com
=======
Cc:
4...@ampl.com
Subject: Re: [AMPL 14248] ERROR
I have a matrix and I want to find the minimum value of each rows!
As example:
D [*,*] (tr)
: 5 10 15 17 :=
1 8.73976 34.309 62.2722 39.8081
2 31.825 23.1055 40.6804 8.17676
3 80.3651 56.2559 38.3523 44.5855
4 59.3589 31.1478 4.11042 39.9419
min value of row1:= 8.73976 it is belong to point 5
min value of row2:= 8.17676 it is belong to point 17
param s {j in VCH};
for {j in VCH}{
let s[j] := min {i in z} D[i,j] ;}
With this code I can find the minimum value of each rows, but how I can get the number of column?