Union of parameters

12 views
Skip to first unread message

Giovanni Pavese

unread,
Dec 2, 2016, 1:54:58 PM12/2/16
to AMPL Modeling Language
Hi!
I would like to know if it is possible to merge parameters defined for two different sets.

Suppose that I have a set A, a set B and a set C as C := A union B.
If I define param a{A} and param b{B}, is it possible to define something like  c{C} := a{A} union b{B} ?

Thank in advance for your patience.

Giovanni

Robert Fourer

unread,
Dec 4, 2016, 3:40:29 PM12/4/16
to am...@googlegroups.com
You could define

param c {k in C} = if k in A then a[k] else b[k];

Note that if there is any member k of A that is also a member of B, then this places a[k] into c, but you could modify the expression to make a different choice.

Bob Fourer
am...@googlegroups.com

=======

Giovanni Pavese

unread,
Dec 5, 2016, 11:07:54 AM12/5/16
to AMPL Modeling Language, 4...@ampl.com
Ok perfect! Thank you!
Giovanni
Reply all
Reply to author
Forward
0 new messages