To resample all random parameters, you can also use reset data
followed by whatever data statements are necessary to re-read the
non-random parameter data.
> As discussed below, with AMPL versions prior to 19951020, you must use
> default rather than := in declaring param avail:
>
param avail {s in STAGE} default
Normal (avail_mean[s], avail_var[s]);
305a337,421
> There are some subtleties:
> 1. AMPL does not evaluate default and := expressions until they are
> needed, so the sequence of commands you issue can affect the random
> values it computes.
> 2. If p is an indexed parameter that lacks a := expression,
> "display p;" only shows the components of p that have been read,
> assigned by "let", or computed when necessary from a default expression.
> Thus if p has a default expression, "display p;" may show nothing until
> some other command forces some components of p to be computed. On the
> other hand, any reference to an indexed parameter with a := expression
> causes all of its components to be computed. For example:
>
> ampl: set A;
> ampl: param p{A};
> ampl: param q{A} default Uniform01();
> ampl: param r{i in A} := q[i] + 1;
> ampl: data; set A := a b c d;
> ampl data: param p := a 1.3 d 2.7;
> ampl data: display p,q; # no values for q yet
> : p q :=
> a 1.3 .
> d 2.7 .
> ;
>
> ampl: display r; # Force q to be computed.
> r [*] :=
> a 1.60921
> b 1.18987
> c 1.92189
> d 1.95716
> ;
>
> ampl: display p,q,r;
> : p q r :=
> a 1.3 0.609209 1.60921
> b . 0.189873 1.18987
> c . 0.921892 1.92189
> d 2.7 0.957156 1.95716
> ;
>
> 3. Parameters declared with a := expression, even one that involves
> a random function, are only recomputed after a set or parameter on which
> they depend has changed. AMPL versions earlier than 19951020 would
> complain at
>
> param p := Uniform01();
> reset data p;
>
> complaining that "p has a := value in the model", and would not
> resample p after a "reset data;" command. Starting with version
> 19951020, "reset data p;" and "reset data;" cause p to be resampled.
> With the earlier versions, it is safest to use default expressions rather
> than := expressions for random-valued parameters. For example (with
> an earlier version):
>
> ampl: param p := Uniform01();
> ampl: param q default Uniform01();
> ampl: set I default 1..3;
> ampl: param r{I} := Uniform01();
> ampl: param s{1..3} := Uniform01();
> ampl: display p,q,r,s;
> p = 0.609209
> q = 0.263135
>
> : r s :=
> 1 0.189873 0.105726
> 2 0.921892 0.714106
> 3 0.957156 0.551532
> ;
>
> ampl: reset data;
> ampl: display p,q,r,s;
> p = 0.609209
> q = 0.575807
>
> : r s :=
> 1 0.349604 0.105726
> 2 0.407247 0.714106
> 3 0.665212 0.551532
> ;
>
> Notice that p and s were not affected by "reset data;".
> Parameter r was recomputed because "reset data;" forced
> its index set to be recomputed.
>