# Re: \[AMPL 24419\] AMPLPY using list as a parameter value

**URL:** <https://discuss.ampl.com/t/re-ampl-24419-amplpy-using-list-as-a-parameter-value/275>\
**Category:** Google Group Mirror\
**Created:** [December 16, 2022, 11:16pm UTC](https://discuss.ampl.com/t/re-ampl-24419-amplpy-using-list-as-a-parameter-value/275 "2022-12-16T23:16:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AMPL\_Google\_Group](https://avatars.discourse-cdn.com/v4/letter/a/9dc877/32.png) [@AMPL\_Google\_Group](https://discuss.ampl.com/u/AMPL_Google_Group)\
**Post date:** [December 16, 2022, 11:16pm UTC](https://discuss.ampl.com/t/re-ampl-24419-amplpy-using-list-as-a-parameter-value/275/1 "2022-12-16T23:16:15Z")

</div>

For the specific situation you are describing, the following definitions would be sufficient:

```auto
set D circular = {'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'} ;
param demand {D};

var x {D} >= 0;

subject to day_constraint {d in D}:
   sum {dd in D diff {next(d),next(d,2)}} x[dd] >= demand[d];

```

Then you would just need to provide AMPL with data for param demand. However, if you need something more general then you can use an indexed collection of AMPL sets:

```auto
set D circular = {'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'} ;
set O {D};
param demand {D};

var x {D} >= 0;

subject to day_constraint {d in D}:
   sum {dd in D diff O[d]} x[dd] >= demand[d];

```

Then you also need to provide AMPL with the members of the sets O[d] for each d in D. Write back if you need help with that.

---

<div class="post-metadata">

**Author:** ![Atma\_Iyer](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/atma_iyer/32/107_2.png) [@Atma\_Iyer](https://discuss.ampl.com/u/Atma_Iyer)\
**Post date:** [December 16, 2022, 11:25pm UTC](https://discuss.ampl.com/t/re-ampl-24419-amplpy-using-list-as-a-parameter-value/275/2 "2022-12-16T23:25:52Z")

</div>

Thanks so much Robert for your prompt response and amazingly elegant solution!! Greatly appreciate it. AMPL is just fantastic!

Thanks  
Atma
