## Search found 83 matches

### Re: Loop

Hi, do you need the loop to define a parameter or is it an equation? No loops are used to define equations. anyway, you don't need a loop for this definition. as a equation: set i /1*13/ ; alias(i,j,k) eq(i).. log(gamma(i)) =e= - A*power(z(i),2) + 2*sum(j$(ord(j) ne ord(i)),m(j)*(B_0(i,j) + B_1(i,j)...

- 1 month ago
- Forum: Syntax
- Topic: logical equations & binary variables
- Replies:
**18** - Views:
**2159**

### Re: logical equations & binary variables

Hi, in the previous answer I wrote this code and I saved it as a draft. I hope this can help you. Bye! set i intervals /i1*i6/ n your nset /n1*n2/ l limits /l,u/ ; parameter p(n) /n1 1, n2 3/ intervals(n,i,l) anvalue(i) /i1 0 i2 0.2 i3 0.4 i4 0.6 i5 0.8 i6 1/ evalue /1e-6/ ; intervals(n,'i1','l')=0;...

- 1 month ago
- Forum: Syntax
- Topic: logical equations & binary variables
- Replies:
**18** - Views:
**2159**

### Re: logical equations & binary variables

Hi, if p (n) is a parameter, I think it is better to reformulate the intervals definition: if th >= p(n) then a(n) =0; else if th < p(n) and th >= p(n) * 10^-.5 then a(n) = .2; else if th < p(n)*10^-.5 and th >= p(n) * 10^-1 then a(n) = .4; else if th < p(n)*10^-1 and th >= p(n) * 10^-1.5 then a(n) ...

- 1 month ago
- Forum: Tools
- Topic: Generate an array of random numbers
- Replies:
**6** - Views:
**195**

### Re: Generate an array of random numbers

I did not know the shuffle option. Thanks for sharing dirkse!

- 1 month ago
- Forum: Tools
- Topic: Generate an array of random numbers
- Replies:
**6** - Views:
**195**

### Re: Generate an array of random numbers

Hi dirkse, i like your compact implementation.

I tested your code but sometimes I got less than seven items with a value of 1 and sometimes more.

i'm right?

I tested your code but sometimes I got less than seven items with a value of 1 and sometimes more.

i'm right?

- 1 month ago
- Forum: Tools
- Topic: Generate an array of random numbers
- Replies:
**6** - Views:
**195**

### Re: Generate an array of random numbers

Hi, this is a good challenged! I think this can work. *reset the seed for the random number generator. execseed = 1 + gmillisec(jnow); Set W /1*10/ select(W); alias(W,Wp); select(W)=NO; Parameter Coef(W) p A /70/ ; loop(W$(ord(w) le floor(A*card(W)/100)), p = uniformInt(1,card(W)); while( sum(Wp$(or...

- 1 month ago
- Forum: Syntax
- Topic: Index change for constraints
- Replies:
**4** - Views:
**195**

### Re: Index change for constraints

Ok, you must start with the second value of i

eq(i)$(ord(i) ge 2).. T(i) =g= T(i-1);

Bye!

eq(i)$(ord(i) ge 2).. T(i) =g= T(i-1);

Bye!

- 1 month ago
- Forum: Syntax
- Topic: Index change for constraints
- Replies:
**4** - Views:
**195**

### Re: Index change for constraints

Hi, Is T a binary or continuous variable?

Is "T(i)" greater (>) or greater than or equal (>=) than "T(i-1)" ?

Bye

Is "T(i)" greater (>) or greater than or equal (>=) than "T(i-1)" ?

Bye

- 2 months ago
- Forum: Syntax
- Topic: Question about replacing two sets
- Replies:
**6** - Views:
**333**

### Re: Question about replacing two sets

I do not know if I understood correctly. Your goal is to express Data_2 in a simpler or more compact way? I hope this can help you set i /i1 * i12/ j /j1 * j3/ DATA(j,i) /j1.i1,j2.i5,j3.i9/ ; parameter Data_1(i) / i1 5 i2 3 i3 0 i4 6 i5 7 i6 9 i7 0 i8 12 i9 0 i10 2 i11 8 i12 1 / Data_2(j) ; Data_2(j...

- 3 months ago
- Forum: Syntax
- Topic: Matrix multiplication in GAMS
- Replies:
**1** - Views:
**178**

### Re: Matrix multiplication in GAMS

hi, the matrix dimensions must be compatible to carry out the multiplication.

Here are some examples:

or
Bye!

Here are some examples:

Code: Select all

`eq(i,j).. C(i,j) =e= sum(k,A(i,k)*B(k,j));`

Code: Select all

`eq(i,j).. C(i,j) =e= sum((k,m)$(ord(m) eq ord(k)), A(i,k)*B(m,j) );`