Search found 118 matches
- 5 years ago
- Forum: Tools
- Topic: Generate an array of random numbers
- Replies: 6
- Views: 7071
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...
- 5 years ago
- Forum: Syntax
- Topic: Index change for constraints
- Replies: 4
- Views: 5018
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!
- 5 years ago
- Forum: Syntax
- Topic: Index change for constraints
- Replies: 4
- Views: 5018
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
- 5 years ago
- Forum: Syntax
- Topic: Question about replacing two sets
- Replies: 6
- Views: 6495
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...
- 5 years ago
- Forum: Syntax
- Topic: Matrix multiplication in GAMS
- Replies: 1
- Views: 4035
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) );
- 5 years ago
- Forum: Syntax
- Topic: linearization of power function
- Replies: 1
- Views: 2533
Re: linearization of power function
I think you should linearize the 4 possibilities and then using a binary variable to select one.
four possibilities: y^1 (linear) y^2 (non linear and convex) y^3 (non linear and convex) and y^4 (non linear and convex)
bye
four possibilities: y^1 (linear) y^2 (non linear and convex) y^3 (non linear and convex) and y^4 (non linear and convex)
bye
- 5 years ago
- Forum: Syntax
- Topic: Syntax for sets
- Replies: 2
- Views: 2829
Re: Syntax for sets
Is this code ok? This select the stream 4 for the mixer 2 and stream 7 for mixer 3. I hope it is useful to you Bye Set mxr number of mixers / 1*3 / Str process streams / 1*10 / imxr(mxr,str) mixer-stream (inlet) matches / 1.(1,2) , 2.(4,5), 3.(8,7) / smxr(mxr) mixer selected for linearization / 2,3 ...
- 5 years ago
- Forum: Syntax
- Topic: searching string in set
- Replies: 11
- Views: 10718
Re: searching string in set
In your code tac is a subset not a set... i think this is the problem
- 5 years ago
- Forum: Syntax
- Topic: searching string in set
- Replies: 11
- Views: 10718
Re: searching string in set
Or, if you need to use the set tid:
Code: Select all
set tid /2000*2014/;
alias(tid,tidp)
parameter
p
;
loop(tidp,
loop(tid$(ord(tid) eq card(tid) - (ord(tidp)-1)),
p=ord(tid);
display p;
););
- 5 years ago
- Forum: Syntax
- Topic: searching string in set
- Replies: 11
- Views: 10718
Re: searching string in set
I quickly think that it can be something like this:
set tid /2000*2014/;
parameter
p
;
loop(tid,
p=2014-(ord(tid) -1)
display p;
);
set tid /2000*2014/;
parameter
p
;
loop(tid,
p=2014-(ord(tid) -1)
display p;
);