Gobryas
Gobryas

Reputation: 395

Sets and Indexing in GAMS

I am trying to solve a mathematical optimization model. I want to define a set in my model, say, i and I want it to be from 0 to 15. Is it possible? Or I have to define from 1 to 16? I am using the demo version of GAMS (General Algebraic Modeling System) available on the website.

Thanks

PS: Someone with enough reputation please create a GAMS tag!

Upvotes: 0

Views: 516

Answers (1)

Sophia Yao
Sophia Yao

Reputation: 11

You can define the set from 0 to 15 if you wish. For example,

set i 'plants' /i0*i9/
parameter a(i);
a(i)=uniformint(1,9);
display a;

Here are the results,

PARAMETER a  
i0 2.000,    i1 8.000,    i2 5.000,    i3 3.000,    i4 3.000,    i5 3.000
i6 4.000,    i7 8.000,    i8 1.000,    i9 5.000

Hope that helps. Sophia

Upvotes: 1

Related Questions