[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] Proper syntax for the Uniform function in the data segme
From: |
Andrew Makhorin |
Subject: |
Re: [Help-glpk] Proper syntax for the Uniform function in the data segment |
Date: |
Thu, 10 Oct 2013 01:43:44 +0400 |
On Wed, 2013-10-09 at 15:32 -0400, Marc Goetschalckx wrote:
>
> On 09-Oct-13 7:55 AM, Andrew Makhorin wrote:
> >> I am trying to use the Uniform function to set the value of a
> >> two-dimensional array in the data segment of a model.
> >> Parameter array is defined as follows (and works correctly when used
> >> with explicit value initialization) in the model section
> >>
> >> param c{i in I, j in J},>= 0;
> >>
> >> The following statement gives a syntax error
> >>
> >> param c : Uniform (1, 500);
> >>
> >> I could not find an example of using the Uniform function with a
> >> parameter matrix in the GMPL manual.
> >> What is the proper syntax
> >>
> >>
> > param c{i in I, j in J},>= 0, := Uniform (1, 500);
> >
> >
>
> The following statement in the data section
>
> param c{i in I, j in J} := uniform (1, 500);
>
> generates the following syntax error
>
> data_file.dat, line 131 (offset 1391):
> expected ; ( [ : or symbol
> context: param c >>> { <<< i in I, j in J} := uniform (1, 500);
>
> The initialization of the parameter c with values is part of the data
> section and instance dependent. The model section remains unchanged for
> all instances.
>
I meant model section. In data section you cannot do that. If you need
to initialize c by randoms only if no data for c are provided in the
data section, you could use 'default' attribute rather than ':=', e.g.
param c{i in I, j in J}, default uniform (1, 500);