You can model your covariance matrix as a sparse matrix in AMPL. As a small example, in the model you could write
param m integer > 0;
set C within {1..m,1..m};
param cov {C};
Then in an AMPL data file, the covariance matrix could be given by
param m := 4;
param: C: cov: 1 2 3 4 :=
1 36 . . -2
2 . 7 3 .
3 . . -8 16
4 12 3 . 77 ;
The second param statement defines both C and cov, as you can see by displaying them after reading above statements:
ampl: option display_1col 0;
ampl: display C, cov;
set C := (1,1) (1,4) (2,2) (2,3) (3,3) (3,4) (4,1) (4,2) (4,4);
cov [*,*]
: 1 2 3 4 :=
1 36 . . -2
2 . 7 3 .
3 . . -8 16
4 12 3 . 77 ;
Then in your model, instead of indexing over {i in 1..m, j in 1..m} you would index over {(i,j) in C} so that you refer only to the nonzero elements of cov.
Alternatively you can define the covariances as, say,
param cov {1..m,1..m} default 0.0;
so that cov[i,j] gets a value of zero (or some other number you choose) wherever there is a . in the data. Then you can write indexing expressions like {i in 1..m, j in 1..m: cov[i,j] <> 0} to index over only the significant values. For large problems this can become inefficient, however.
Bob Fourer
am...@googlegroups.com
=======