Question

24 views
Skip to first unread message

Sahebeh Azar

unread,
Feb 11, 2023, 6:07:47 AM2/11/23
to am...@googlegroups.com
I would be grateful if someone could answer my question:

I have two param, how I can have a new param including their sum. For example:

Options randseed 0;
Param L:= 100;
Param x1 {1..10} := L*Uniform01();
Param y1 {1..10} := L*Uniform01();
Param x2 {0} := L/2;
Param y2 {0} := L/2;

How I can have this????👇🏻
Param x = summation  param x1 and x2
Param y = summation param y1 and y2



AMPL Google Group

unread,
Feb 12, 2023, 10:53:24 PM2/12/23
to AMPL Modeling Language
You can write "param x =" (or "param x :=") followed by the expression that you want to use to define x. For example, if you want x to be equal to x2[0] + x1[1] + . . . + x1[10], you can write

param x = x2[0] + sum {j in 1..10} x1[j];

The same approach can be used for param y. (Note that the statement begins with "param", not "Param". Also if you want x2 to be indexed over only the set that contains 0, you must write "param x2 {0..0}".)


--
Robert Fourer
AMPL Forum
{#HS:2153013795-113980#}
Reply all
Reply to author
Forward
0 new messages