Hey there,
how would you fill the cols with numbers 1..n in this instance? I've been stuck on this for a while, because in the .dat file you cant use this syntax and in the .mod you cant index it as far as i found.
Thanks in advance,
Bence
On Sat, Nov 27, 2021 at 2:03 AM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
This structure is often represented in AMPL by indexed collection of sets. Here is an example:
param N integer > 0;
set allCOLS = setof {i in 65 .. 90} char(i);
set ROWS = 1..N;
set COLS {ROWS} within allCOLS; # COLS[i] = set of columns in row i
var t {i in ROWS, COLS[i]};
Here's how your data would be written, in AMPL's text data format:
param N := 3;
set COLS[1] := A B C ;
set COLS[2] := D E F G H I ;
set COLS[3] := L M ;
An indexing expression like {i in ROWS, j in COLS[i]} would run over all columns in all rows.
The same data could also be modeled as a set of pairs (i,j) where i is a row and j is a column in that row. The possibilities are described in Chapter 6: Compound Sets and Indexing in the AMPL book; sets of pairs and indexed collections of sets are introduced in section 6.1 and section 6.5, respectively.
--
Robert Fourer
am...@googlegroups.com