On Jun 26, 7:46 pm, Yasin053 <
yasin...@...> wrote:
> Hi,
> I need to define a parameter that should be defined over values of the first
> components of the elements of a set:
>
> set CG within {STATE,ACTION};
> param state_c {s in CG[1]} ???
>
> Essentially, the parameter state_c should be defined for all possible values
> of the first component of the elements of the set CG. When CG= {(1,1),
> (2,1), (3,2)}, I should have state_c[1], state_c[2], and state_c[3]. (I am
> updating the set CG during the implementation of the algorithm, so the
> elements of CG are dynamic)
>
> Does anyone know how to do this?
>
Getting the index set you want is fairly straightforward.
set CG within {STATE,ACTION};
set SC within STATE; # indexes state_c
param state_c {SC};
# ...
let SC := setof {(s,a) in CG} s;
# ...
/Paul
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to
ampl@...
To unsubscribe from this group, send email to
ampl+unsubscribe@...
For more options, visit this group at
http://groups.google.com/group/ampl?hl=en-~----------~----~----~----~------~----~------~--~---