# AMPLPY using list as a parameter value

**URL:** <https://discuss.ampl.com/t/amplpy-using-list-as-a-parameter-value/274>\
**Category:** New to AMPL\
**Created:** [December 16, 2022, 10:06pm UTC](https://discuss.ampl.com/t/amplpy-using-list-as-a-parameter-value/274 "2022-12-16T22:06:18Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![fdabrandao](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/fdabrandao/32/63_2.png) [@fdabrandao](https://discuss.ampl.com/u/fdabrandao)\
**Post date:** [January 3, 2023, 11:36am UTC](https://discuss.ampl.com/t/amplpy-using-list-as-a-parameter-value/274/2 "2023-01-03T11:36:44Z")

</div>

Note: This question was answered on [Google Groups](https://discuss.ampl.com/t/re-ampl-24419-amplpy-using-list-as-a-parameter-value/275), and I am just copying the answer here:

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.

---

_[View the full topic](https://discuss.ampl.com/t/amplpy-using-list-as-a-parameter-value/274)._
