Search found 50 matches
- 2 years ago
- Forum: Modeling
- Topic: use the loop index list to fix a variable
- Replies: 2
- Views: 3597
Re: use the loop index list to fix a variable
Hi Shaparak, Not sure what you want to achieve, but you might want to free the attack variable again after the solve, that way the variable only is fixed for the index i it is currently looping over. Regards, GFA loop(i, attack.fx(i)=0; solve T maximizing o using mip; attack.lo(i) = -inf; attack.up(...
- 2 years ago
- Forum: Syntax
- Topic: From multi-dimensional set table to simple set table
- Replies: 1
- Views: 2581
Re: From multi-dimensional set table to simple set table
Hi lpedauga, Didn't test it but looking at your code there seems to be an error in you mapping. In the SAM you refer to "ctry2.nace1" "ctry2.nace2" and "ctry2.nace3" however there is no mapping in "map", I guess the numbers in red (see below) have to be a 2? R...
- 2 years ago
- Forum: Syntax
- Topic: parameter with dynamic dependencies
- Replies: 3
- Views: 3520
Re: parameter with dynamic dependencies
Hi Pitters, Somethings which might be useful: - Inside your table you can write m1*m3 to refer to all set-elements, this way the parameter will have the same value for all materials for the specific country. - Which comes down to the same as: ' tariff("c1",materials) = 10; ' which will als...
- 2 years ago
- Forum: Syntax
- Topic: Problem with loop
- Replies: 2
- Views: 4334
Re: Problem with loop
Hi, B(z+1) is declared in the same loop as u2(zz), so in the last loop iteration B(z+1) will have a value (772) but u2+1 won't. One way to solve this is to declare u2(zz+1) in the same loop, but keep in mind that now you will miss the first value of u2(zz), but just like the first b-value you can al...
- 2 years ago
- Forum: Syntax
- Topic: index of elements in GAMS
- Replies: 4
- Views: 3550
Re: index of elements in GAMS
I assume you mean your algorithm in Matlab? I'm sure Matlab has some functionality to write .txt-files in which you could put the right set order after the algorithm is finished. Then you can include that file in your GAMS code to use this set order. So Matlab txt-file contains for example: 3,2,1 An...
- 2 years ago
- Forum: Syntax
- Topic: index of elements in GAMS
- Replies: 4
- Views: 3550
Re: index of elements in GAMS
Hi,
At the start of your GAMS-code you could define a set that orders set elements (eg "set setord /3,2,1/;), this way every time these set-elements will be presented they will be ordered this way.
Downside is that you have to update this setord-list if your set-elements change..
Cheers,
GFA
At the start of your GAMS-code you could define a set that orders set elements (eg "set setord /3,2,1/;), this way every time these set-elements will be presented they will be ordered this way.
Downside is that you have to update this setord-list if your set-elements change..
Cheers,
GFA
- 2 years ago
- Forum: Syntax
- Topic: problem with problem 149 - uncontrolled set entered as constant
- Replies: 2
- Views: 2009
Re: problem with problem 149 - uncontrolled set entered as constant
Hi, Have a look at: https://www.gams.com/33/docs/UG_Equations.html " Indexed Equations". You might need this addition: LOKAL (J) .. X(J)=E= X(J-1)+(N(J)- S(J)); By the way, in the display-statement referencing to indices is not needed. Also, when displaying variables you need to state the ...
- 3 years ago
- Forum: Syntax
- Topic: Multiple mixed conditions (string and value) using $Ifthen
- Replies: 5
- Views: 2952
Re: Multiple mixed conditions (string and value) using $Ifthen
This should work:
Or this:
GFA
Code: Select all
$ife %iclone%<>1 $set x yes
$if %random%==R $set x yes
$if %x% == yes display A
Code: Select all
$ife %iclone%<>1 $goto x
$if %random%==R $goto x
$goto skipx
$label x
display a
* + other statements if u wish
$label skipx
- 3 years ago
- Forum: Syntax
- Topic: Multiple mixed conditions (string and value) using $Ifthen
- Replies: 5
- Views: 2952
Re: Multiple mixed conditions (string and value) using $Ifthen
Hi zhj0735, Use $ifthen E for numerical expressions, also see: https://www.gams.com/mccarlGuide/ifthen_iftheni_ifthene_conditi.htm This seems to work but I'm not sure if it is the most elegant solution: $ifThene.cl %iclone%<>1 $ifThen.cl2 %random%==R display a; $endif.cl2 $endif.cl Regards, GFA
- 3 years ago
- Forum: Syntax
- Topic: Problem with data exchange and dynamic sets
- Replies: 2
- Views: 3023
Re: Problem with data exchange and dynamic sets
Hi Afccruz, Didn't test it but looking at your code I think you need to provide a sheetname for set "i" in ficheiroteste.txt (like you did for the Dst parameter, sheet DistanceDur): rng= <sheetname> !a1 You can also write a log-file of the GDXXRW call which may give you some hints: $call G...