<![CDATA[GAMS World Forum]]> https://forum.gamsworld.org Sat, 27 Apr 2024 06:24:36 +0000 Smartfeed extension for phpBB https://forum.gamsworld.org/styles/we_universal/theme/images/site_logo.svg <![CDATA[GAMS World Forum]]> https://forum.gamsworld.org en-GB Sat, 27 Apr 2024 06:24:36 +0000 60 <![CDATA[Syntax :: $ifThen set X or Y :: Author zamry]]> https://forum.gamsworld.org/viewtopic.php?f=2&t=12985&p=31286#p31286
Is there a way to execute the following condition when solving a model?

Code: Select all

$ifThen set X or Y
Solve MODEL using nlp minimizing OBJ;
$else
Solve MODEL using lp minimizing OBJ;
$endIf
X and Y are compilation variables, and either one exists at a time.

Thanks,
Zamry]]>
no_email@example.com (zamry) https://forum.gamsworld.org/viewtopic.php?f=2&t=12985&p=31286#p31286 Mon, 01 Apr 2024 17:38:40 +0000 https://forum.gamsworld.org/viewtopic.php?f=2&t=12985&p=31286#p31286
<![CDATA[Syntax :: Re: $ifThen set X or Y :: Reply by bussieck]]> https://forum.gamsworld.org/viewtopic.php?f=2&t=12985&p=31288#p31288

Code: Select all

$set xset 0
$if set x $set xset 1
$set yset 0
$if set y $set yset 1
$log %xset%%yset%
$ifThenE (%xset%)or(%yset%)
Solve MODEL using nlp minimizing OBJ;
$else
Solve MODEL using lp minimizing OBJ;
$endIf
-Michael]]>
no_email@example.com (bussieck) https://forum.gamsworld.org/viewtopic.php?f=2&t=12985&p=31288#p31288 Tue, 02 Apr 2024 05:57:28 +0000 https://forum.gamsworld.org/viewtopic.php?f=2&t=12985&p=31288#p31288
<![CDATA[Syntax :: Re: $ifThen set X or Y :: Reply by zamry]]> https://forum.gamsworld.org/viewtopic.php?f=2&t=12985&p=31291#p31291 no_email@example.com (zamry) https://forum.gamsworld.org/viewtopic.php?f=2&t=12985&p=31291#p31291 Tue, 02 Apr 2024 14:00:36 +0000 https://forum.gamsworld.org/viewtopic.php?f=2&t=12985&p=31291#p31291 <![CDATA[Syntax :: Error 2, Error 149, Error 243 :: Author Essouaied Aziz]]> https://forum.gamsworld.org/viewtopic.php?f=2&t=12979&p=31276#p31276 Here is the code (it is also attached to this post):

Sets
i /100
101
102
103
104
105
106
107
108
109
110
113
114
115
116
117
118
119
122
123
124
125
128
129
130
131
132
133
134
135
136
138
139
141
142
143
145
146
149
151
152
153
154
155
157
162
164
167
168
169
170
173
174
175
176
178
179
182
183
189
192
194
206
209
219
300
306
321
501
502
503
504
506
507
508
509
510
512
517
518/
j /1*4/
t /1*4/;

Alias (i,ii);

Parameters
D(i,j) Distribution de la Demande sur par Ligne i et Période j
FV(i,j) Variable binaire indiquant si la route i est desservie pendant la saison j
P(i) Variable binaire indiquant si la route i est active
Cap(t) Capacité des bus par type
Min(j) Minimum de bus requis par saison;

Scalar bigM;
bigM = 1000;

Table D(i,j) Distribution de la Demande pour la Ligne i et la Période j
1 2 3 4
100 13921 13496 33134 22629
101 13017 12620 30983 21160
102 16842 16328 40087 27378
103 3209 3111 7639 5217
104 9931 9628 23637 16143
105 12302 11927 29281 19998
106 395 382 939 641
107 11676 11320 27791 18980
108 14341 13903 34133 23311
109 90 87 213 145
110 2845 2758 6772 4625
113 16537 16032 39361 26882
114 12717 12329 30269 20673
115 12237 11863 29126 19892
116 370 359 881 602
117 122 118 291 199
118 8153 7905 19406 13254
119 255 247 607 414
122 13278 12873 31605 21585
123 14297 13861 34030 23241
124 1620 1571 3856 2633
125 37 36 88 60
128 62 60 148 101
129 67 65 158 108
130 1 1 1 1
131 8890 8619 21161 14452
132 3352 3250 7979 5449
133 478 463 1137 777
134 37 36 89 61
135 10196 9885 24269 16574
136 42 40 99 68
138 4515 4377 10745 7339
139 14792 14341 35207 24045
141 12123 11753 28854 19706
142 1993 1932 4744 3240
143 13278 12873 31603 21584
145 6258 6068 14896 10174
146 1004 973 2389 1632
149 15059 14599 35842 24479
151 1529 1482 3639 2485
152 8573 8311 20405 13936
153 34 33 80 55
154 10 9 23 16
155 6 5 13 9
157 10 9 23 16
162 12927 12533 30769 21014
164 11696 11339 27837 19012
167 66 64 157 107
168 59 57 139 95
169 1083 1050 2577 1760
170 1302 1263 3100 2117
173 4047 3923 9632 6578
174 1332 1291 3170 2165
175 71 69 170 116
176 253 246 603 412
178 80 78 191 130
179 16679 16170 39699 27113
182 85 82 202 138
183 13012 12615 30971 21152
189 13329 12923 31726 21668
192 2134 2069 5080 3469
194 12774 12384 30404 20765
206 9876 9575 23507 16054
209 13941 13516 33182 22662
219 67 65 159 109
300 9223 8942 21952 14992
306 1 1 2 1
321 20 20 49 33
501 12934 12539 30785 21025
502 13643 13227 32474 22178
503 11162 10821 26566 18144
504 10998 10663 26178 17879
506 12878 12485 30652 20934
507 5699 5525 13565 9264
508 11939 11575 28417 19408
509 11285 10940 26859 18344
510 670 650 1595 1090
512 16055 15565 38213 26098
517 13875 13451 33024 22554
518 12618 12233 30032 20511;

Table FV(i,j) Facteur du voyage de la Ligne i et la Période j
1 2 3 4
100 303.429 313.714 627.429 473.143
101 217.846 225.231 450.462 339.692
102 166.588 172.235 344.471 259.765
103 212.400 219.600 439.200 331.200
104 166.588 172.235 344.471 259.765
105 354.000 366.000 732.000 552.000
106 298.105 308.211 616.421 464.842
107 274.065 283.355 566.710 427.355
108 314.667 325.333 650.667 490.667
109 472.000 488.000 976.000 736.000
110 354.000 366.000 732.000 552.000
113 314.667 325.333 650.667 490.667
114 314.667 325.333 650.667 490.667
115 386.182 399.273 798.545 602.182
116 283.200 292.800 585.600 441.600
117 177.000 183.000 366.000 276.000
118 404.571 418.286 836.571 630.857
119 472.000 488.000 976.000 736.000
122 369.391 381.913 763.826 576.000
123 346.776 358.531 717.061 540.735
124 404.571 418.286 836.571 630.857
125 435.692 450.462 900.923 679.385
128 514.909 532.364 1064.727 802.909
129 472.000 488.000 976.000 736.000
130 472.000 488.000 976.000 736.000
131 514.909 532.364 1064.727 802.909
132 531.000 549.000 1098.000 828.000
133 404.571 418.286 836.571 630.857
134 257.455 266.182 532.364 401.455
135 283.200 292.800 585.600 441.600
136 283.200 292.800 585.600 441.600
138 472.000 488.000 976.000 736.000
139 472.000 488.000 976.000 736.000
141 314.667 325.333 650.667 490.667
142 177.000 183.000 366.000 276.000
143 202.286 209.143 418.286 315.429
145 377.600 390.400 780.800 588.800
146 173.388 179.265 358.531 270.367
149 195.310 201.931 403.862 304.552
151 404.571 418.286 836.571 630.857
152 435.692 450.462 900.923 679.385
153 435.692 450.462 900.923 679.385
154 354.000 366.000 732.000 552.000
155 566.400 585.600 1171.200 883.200
157 377.600 390.400 780.800 588.800
162 188.800 195.200 390.400 294.400
164 339.840 351.360 702.720 529.920
167 283.200 292.800 585.600 441.600
168 283.200 292.800 585.600 441.600
169 354.000 366.000 732.000 552.000
170 472.000 488.000 976.000 736.000
173 472.000 488.000 976.000 736.000
174 369.391 381.913 763.826 576.000
175 404.571 418.286 836.571 630.857
176 354.000 366.000 732.000 552.000
178 150.372 155.469 310.938 234.478
179 128.727 133.091 266.182 200.727
182 314.667 325.333 650.667 490.667
183 202.286 209.143 418.286 315.429
189 161.829 167.314 334.629 252.343
192 314.667 325.333 650.667 490.667
194 149.053 154.105 308.211 232.421
206 435.692 450.462 900.923 679.385
209 182.710 188.903 377.806 284.903
219 236.000 244.000 488.000 368.000
300 5142909 532.364 1064.727 802.909
306 514.909 532.364 1064.727 802.909
321 514.909 532.364 1064.727 802.909
501 190.921 197.393 394.787 297.708
502 141.600 146.400 292.800 220.800
503 149.053 154.105 308.211 232.421
504 160.302 165.736 331.472 249.962
506 166.588 172.235 344.471 259.765
507 171.636 177.455 354.909 267.636
508 236.000 244.000 488.000 368.000
509 209.778 216.889 433.778 327.111
510 188.800 195.200 390.400 294.400
512 178.863 184.926 369.853 278.905
517 128.727 133.091 266.182 200.727
518 160.302 165.736 331.472 249.962;

Parameters Min(j) Minimum de Voyages requis pour la Période j
/1 59
2 61
3 122
4 92/

Parameter Cap(t)
/1 55
2 53
3 51
4 49/

Parameter P(i) Proportion de Voyage pour la Ligne i (de toutes les Lignes)
/100 0.0258605
101 0.0241818
102 0.0312868
103 0.0059617
104 0.0184483
105 0.0228528
106 0.0007329
107 0.0216898
108 0.0266398
109 0.0001663
110 0.0052855
113 0.0307200
114 0.0236242
115 0.0227318
116 0.0006876
117 0.0002270
118 0.0151461
119 0.0004734
122 0.0246665
123 0.0265595
124 0.0030095
125 0.0000687
128 0.0001151
129 0.0001236
130 0.0000012
131 0.0165154
132 0.0062276
133 0.0008877
134 0.0000695
135 0.0189410
136 0.0000774
138 0.0083864
139 0.0274785
141 0.0225200
142 0.0037029
143 0.0246654
145 0.0116261
146 0.0018649
149 0.0279738
151 0.0028403
152 0.0159257
153 0.0000625
154 0.0000178
155 0.0000105
157 0.0000178
162 0.0240140
164 0.0217263
167 0.0001227
168 0.0001087
169 0.0020110
170 0.0024192
173 0.0075177
174 0.0024738
175 0.0001324
176 0.0004707
178 0.0001490
179 0.0309838
182 0.0001578
183 0.0241724
189 0.0247612
192 0.0039647
194 0.0237297
206 0.0183466
209 0.0258976
219 0.0001242
300 0.0171331
306 0.0000015
321 0.0000380
501 0.0240266
502 0.0253448
503 0.0207343
504 0.0204313
506 0.0239232
507 0.0105870
508 0.0221790
509 0.0209631
510 0.0012451
512 0.0298240
517 0.0257746
518 0.0234393/

Variables
W(i,j) Nombre de bus de type W assignés à la route i pendant la saison j
X(i,j) Nombre de bus de type X assignés à la route i pendant la saison j
Y(i,j) Nombre de bus de type Y assignés à la route i pendant la saison j
Z(i,j) Nombre de bus de type Z assignés à la route i pendant la saison j;

Positive Variable W, X, Y, Z;

Equations
DemandConstraint(i,j)
CapacityConstraint(t,i,j)
FleetUtilizationConstraint
FleetAvailabilityConstraint(t,i,j)
RouteActivationConstraint(i);

DemandConstraint(i,j).. sum(t, Cap(t)*(ord(t)-51)*(ord(t)-53)*(ord(t)-55)*(ord(t)-49)) =g= D(i,j);

CapacityConstraint(t,i,j).. sum(ii, W(i,j))$((ord(t)-51)*FV(i,j)) =l= Cap(t)*sum(ii, FV(i,j));

FleetUtilizationConstraint.. sum((i,j), W(i,j) + X(i,j) + Y(i,j) + Z(i,j)) =g= 80*sum(j, Min(j));

FleetAvailabilityConstraint(t,i,j).. W(i,j) =l= Cap(t)*sum(ii, FV(i,j));

RouteActivationConstraint(i).. sum(t, FV(i,j)) =g= 1;

Model transport /all/;
Option solver = CPLEX;
Solve transport using LP minimizing sum((i, j), W(i,j) + X(i,j) + Y(i,j) + Z(i,j));

Display W, X, Y, Z;

When running the code, I get Eroor messages number 149, 243 and 2.
I've tried to correct my code, but I've got kind of lost.

Any help please? With thanks!

Attachments

The GAMS code. When running it, I get errors
Untitled_6.gms (13.91 KiB)
]]>
no_email@example.com (Essouaied Aziz) https://forum.gamsworld.org/viewtopic.php?f=2&t=12979&p=31276#p31276 Thu, 28 Mar 2024 11:17:13 +0000 https://forum.gamsworld.org/viewtopic.php?f=2&t=12979&p=31276#p31276
<![CDATA[Syntax :: Re: Error 2, Error 149, Error 243 :: Reply by Rodrigue]]> https://forum.gamsworld.org/viewtopic.php?f=2&t=12979&p=31284#p31284
You might be a French speaker.
J'ai crois que tes équations ont un sérieux problèmes. Je ne sais pas comment tu les as obtenues. J'ai néanmoins fourni quelques pistes qui aident à corriger ton problème.

Cordialement,
Rodrigue

Attachments

new.gms (14.24 KiB)
]]>
no_email@example.com (Rodrigue) https://forum.gamsworld.org/viewtopic.php?f=2&t=12979&p=31284#p31284 Mon, 01 Apr 2024 10:17:12 +0000 https://forum.gamsworld.org/viewtopic.php?f=2&t=12979&p=31284#p31284
<![CDATA[Syntax :: Re: Error 2, Error 149, Error 243 :: Reply by Essouaied Aziz]]> https://forum.gamsworld.org/viewtopic.php?f=2&t=12979&p=31285#p31285
Merci bien pour votre réponse, ça m'a aidé à comprendre les défauts de mon code.
Mais là, ça me donne des résultats un peu étrange, finalement, j'ai besoin de minimiser le nombre de bus par lignes et par saison, tout en servant la méme demande par ces bus.
Les résultats sont du genre "668.000" pour un nombre de bus, ce qui n'est pas assez logique déjà. Je pense qu'il faut multiplier le résultat do code que vous avez suggérer par le facteur FV0(i,j), qui est le minimum de voyages qu'un bus peut faire par ligne i et par période j.
Aussi, je ne comprends pas pourquoi on a définit W.up, X. up, Y.up et Z.up par 34454 alors que la taille de la flotte des bus est de 76.

Votre clarification me sera utile.
Merci]]>
no_email@example.com (Essouaied Aziz) https://forum.gamsworld.org/viewtopic.php?f=2&t=12979&p=31285#p31285 Mon, 01 Apr 2024 15:58:54 +0000 https://forum.gamsworld.org/viewtopic.php?f=2&t=12979&p=31285#p31285
<![CDATA[Syntax :: Re: Error 2, Error 149, Error 243 :: Reply by Rodrigue]]> https://forum.gamsworld.org/viewtopic.php?f=2&t=12979&p=31292#p31292
Je n'ai pas solutionné ton problème. J'ai juste fait en sorte que ton code fonctionne. Les valeurs maximales que j'ai affectées à ces variables (en utilisant l'extension.Up) permettent juste que certaines valeurs croissent infiniment et empêchent GAMS de trouver une solution à ton problème. C'est à toi de les modifier pour attribuer des valeurs raisonnables.

Je dis encore ton modèle ne me semble pas bien monté. Il faut repenser les équations et s'assurer qu'elles sont correctes. Tu ne peux pas en l'état actuel interpréter ce que je t'ai envoyé. Ça ne signifie rien de bon.

Cordialement]]>
no_email@example.com (Rodrigue) https://forum.gamsworld.org/viewtopic.php?f=2&t=12979&p=31292#p31292 Wed, 03 Apr 2024 06:18:11 +0000 https://forum.gamsworld.org/viewtopic.php?f=2&t=12979&p=31292#p31292
<![CDATA[Syntax :: Re: Error 2, Error 149, Error 243 :: Reply by Essouaied Aziz]]> https://forum.gamsworld.org/viewtopic.php?f=2&t=12979&p=31293#p31293
Cher Rodriguez, merci beaucoup pour la réponse. Je comprends, je vais essayé de travailler encore sur le code et le solutionner (même si je suis encore un débutant à ce niveau).
Je partagerais le résultat une fois qu'il est trouvé.

Cdt;]]>
no_email@example.com (Essouaied Aziz) https://forum.gamsworld.org/viewtopic.php?f=2&t=12979&p=31293#p31293 Wed, 03 Apr 2024 08:51:39 +0000 https://forum.gamsworld.org/viewtopic.php?f=2&t=12979&p=31293#p31293
<![CDATA[Syntax :: A problem with parentheses :: Author Essouaied Aziz]]> https://forum.gamsworld.org/viewtopic.php?f=2&t=12993&p=31298#p31298
I'am running a GAMS code with this command:

W.lo(i, j)$[(D(i, j)/55) ≤ (FV0(i, j) ∗ P(i) ∗ 55)] = FV0(i, j)/55;

Yet, I always get "Error 8: ')' expected", I've tried my best to count the parentheses and correct the command, but i didn't succeed.

Any help with this please?

Thnaks!]]>
no_email@example.com (Essouaied Aziz) https://forum.gamsworld.org/viewtopic.php?f=2&t=12993&p=31298#p31298 Wed, 03 Apr 2024 16:15:55 +0000 https://forum.gamsworld.org/viewtopic.php?f=2&t=12993&p=31298#p31298
<![CDATA[Syntax :: Re: A problem with parentheses :: Reply by vistro]]> https://forum.gamsworld.org/viewtopic.php?f=2&t=12993&p=31299#p31299 no_email@example.com (vistro) https://forum.gamsworld.org/viewtopic.php?f=2&t=12993&p=31299#p31299 Thu, 04 Apr 2024 05:31:34 +0000 https://forum.gamsworld.org/viewtopic.php?f=2&t=12993&p=31299#p31299 <![CDATA[Syntax :: Re: A problem with parentheses :: Reply by bussieck]]> https://forum.gamsworld.org/viewtopic.php?f=2&t=12993&p=31300#p31300
-Michael]]>
no_email@example.com (bussieck) https://forum.gamsworld.org/viewtopic.php?f=2&t=12993&p=31300#p31300 Thu, 04 Apr 2024 07:06:13 +0000 https://forum.gamsworld.org/viewtopic.php?f=2&t=12993&p=31300#p31300
<![CDATA[Syntax :: Re: A problem with parentheses :: Reply by Essouaied Aziz]]> https://forum.gamsworld.org/viewtopic.php?f=2&t=12993&p=31302#p31302 Thnak you both of you for the help!]]> no_email@example.com (Essouaied Aziz) https://forum.gamsworld.org/viewtopic.php?f=2&t=12993&p=31302#p31302 Thu, 04 Apr 2024 07:47:01 +0000 https://forum.gamsworld.org/viewtopic.php?f=2&t=12993&p=31302#p31302 <![CDATA[Syntax :: Connecting ordered sets :: Author Exlaw]]> https://forum.gamsworld.org/viewtopic.php?f=2&t=13011&p=31322#p31322 I am currently learning GAMS and I came up on this issue:
I am using these sets:

Sets
y "Set of years in the planning horizon" /y2023*y2045/
d "Set of all days in a year" /d1*d366/
t "Set of all hours in a day" /h1*h24/;

Then I am importing data for some parameters from excel. e.g. E(y,d,t)
Therefore I would prefer not to change the way my sets are defined, because I will need to change everything in my excel as well.

And further down the code, in certain equations I need to use variables like this one: "E_b_res(y,d,t-1)"
So is should work like this:

if ( ord(t)=1 AND ord(d)=1 AND E(y-1,'d366','h24') <> 0 )
x=E_b_res(y-1,'d366','h24')
else if ( ord(t=1) AND ord(d)=1 )
x=E_b_res(y-1,'d365','h24')
else if( ord(t=1) )
x=E_b_res(y,d-1,'h24')
else
x=E_b_res(y,d,t-1)


Where x is the value I need E_b_res(y,d,t-1) to have.

*note: in the E(y-1,'d366','h24') <> 0 part, I am checking whether or not its a leap year. My excel doesn't input values for d366 of non leap years so this is an easy way of checking

This felt very complex to do using the $ operator. I am also considering using Multi-Dimensional Sets, but I couldn't really figure out how they work just using the documentation. For example: why can't I define a variable over a multi-dimensional set?
I am pretty sure there are some easy solutions for this that I am missing.]]>
no_email@example.com (Exlaw) https://forum.gamsworld.org/viewtopic.php?f=2&t=13011&p=31322#p31322 Wed, 10 Apr 2024 16:09:28 +0000 https://forum.gamsworld.org/viewtopic.php?f=2&t=13011&p=31322#p31322
<![CDATA[Syntax :: Re: Connecting ordered sets :: Reply by bussieck]]> https://forum.gamsworld.org/viewtopic.php?f=2&t=13011&p=31338#p31338
-Michael

Code: Select all

Sets
  y "Set of years in the planning horizon" /y2023*y2045/
  d "Set of all days in a year" /d1*d366/
  t "Set of all hours in a day" /h1*h24/;
  
$eval P card(y)*card(d)*card(t)
Set p period / p1*p%P% /;

Parameter E(y,d,t), cnt /0/;
loop((y,d,t), cnt=cnt+1; E(y,d,t) = cnt);

* Remove data for non leap years
set leap(y) / y2024, y2028, y2032, y2036, y2040, y2044 /;
E(y,'d366',t)$(not leap(y)) = 0;

* Now match non-zero E to p:
set ydt(y,d,t), pydtmap(p,y,d,t);
option ydt<E, pydtmap(p:ydt);

* Have parameters in p space
alias (y,yy), (d,dd), (t,tt);
Parameter Ep(p); Ep(p) = sum(pydtmap(p,y,d,t), E(y,d,t));

Variable Ep_b_res(p), oo(d);
Equation balance(p), daystart(p);
balance(p).. Ep_b_res(p) =e= sum(pydtmap(p,y,d,t), oo(d))*(Ep_b_res(p-1) + Ep(p));
daystart(p)$sum(pydtmap(p,y,d,'h1'),1).. Ep_b_res(p) =l= 2*Ep_b_res(p-1);
]]>
no_email@example.com (bussieck) https://forum.gamsworld.org/viewtopic.php?f=2&t=13011&p=31338#p31338 Thu, 18 Apr 2024 11:56:01 +0000 https://forum.gamsworld.org/viewtopic.php?f=2&t=13011&p=31338#p31338
<![CDATA[Syntax :: Re: Connecting ordered sets :: Reply by Exlaw]]> https://forum.gamsworld.org/viewtopic.php?f=2&t=13011&p=31340#p31340 no_email@example.com (Exlaw) https://forum.gamsworld.org/viewtopic.php?f=2&t=13011&p=31340#p31340 Fri, 19 Apr 2024 18:20:38 +0000 https://forum.gamsworld.org/viewtopic.php?f=2&t=13011&p=31340#p31340 <![CDATA[Syntax :: BESS modeling Error 148 and 258 in obj function. :: Author GeGo]]> https://forum.gamsworld.org/viewtopic.php?f=2&t=13021&p=31341#p31341 I get in the last line the following errors. I cant understand why,
*** Error 148 in C:\Users\eirini\Documents\GAMS\Studio\workspace\gams 240\PPA_PV_BESS.gms[ERR:"C:\Users\eirini\Documents\GAMS\Studio\workspace\gams 240\PPA_PV_BESS.gms",115,40][LST:102]
Dimension different - The symbol is referenced with more/less
indices as declared
*** Error 257 in C:\Users\eirini\Documents\GAMS\Studio\workspace\gams 240\PPA_PV_BESS.gms[ERR:"C:\Users\eirini\Documents\GAMS\Studio\workspace\gams 240\PPA_PV_BESS.gms",115,42][LST:102]
Solve statement not checked because of previous errors
--- PPA_PV_BESS.gms(115) 3 Mb 2 Errors[FIL:"C:\Users\eirini\Documents\GAMS\Studio\workspace\gams 240\PPA_PV_BESS.gms",115,0]
*** Status: Compilation error(s)[LST:151]
--- Job PPA_PV_BESS.gms Stop 04/20/24 15:52:36 elapsed 0:00:10.719

I want to maximize income so i am trying to fine the best combination of z and h for all t.

This is my code:
Set t "Time" /t1*t240/;
Set h "hour of bess" /h1*h4/;
Set z 'safety level of contracted energy' /z1*z2/;


Parameters
P_real(t)
P_ppa(t,z)
P_excess(t,z)
pvf(t) pv is in producing
mp(t) more profitable market price
iseop(t,z) there is excess of power P_real-P_ppa>0
SoCz1(t,h) 'state of charge time, hours of batery, z1'
SoCz2(t,h) 'state of charge time, hours of batery, z2'
SoC(t,h,z) 'state of charge time, hours of batery, safety level'
P_b2g(t,z) 'Power battery to grid';


$CALL GDXXRW P_r.xlsx trace=3 par=P_real rng=New_Sheet! rdim=1
$CALL GDXXRW P_p.xlsx trace=3 par=P_ppa rng=New_Sheet! rdim=1 cdim=1
$CALL GDXXRW P_e.xlsx trace=3 par=P_excess rng=Sheet1! rdim=1 cdim=1
$CALL GDXXRW pvf.xlsx trace=3 par=pvf rng=New_Sheet! rdim=1
$CALL GDXXRW iseop.xlsx trace=3 par=iseop rng=Sheet1! rdim=1 cdim=1
$CALL GDXXRW mp.xlsx trace=3 par=mp rng=New_Sheet! rdim=1
$CALL GDXXRW P_b2g.xlsx trace=3 par=P_b2g rng=Sheet1! rdim=1 cdim=1
$CALL GDXXRW SoC_z1.xlsx trace=3 par=SoCz1 rng=New_Sheet! rdim=1 cdim=1
$CALL GDXXRW SoC_z2.xlsx trace=3 par=SoCz2 rng=New_Sheet! rdim=1 cdim=1


$GDXIN P_r.gdx
$LOAD P_real
$GDXIN
*Display P_real;


$GDXIN P_p.gdx
$LOAD P_ppa
$GDXIN

$GDXIN P_e.gdx
$LOAD P_excess
$GDXIN

$GDXIN pvf.gdx
$LOAD pvf
$GDXIN

$GDXIN mp.gdx
$LOAD mp
$GDXIN

$GDXIN P_b2g.gdx
$LOAD P_b2g
$GDXIN

$GDXIN iseop.gdx
$LOAD iseop
$GDXIN

$GDXIN SoC_z1.gdx
$LOAD SoCz1
$GDXIN

$GDXIN SoC_z2.gdx
$LOAD SoCz2
$GDXIN

SoC(t,h,z)$(ord(z)=1) = SoCz1(t,h);
SoC(t,h,z)$(ord(z)=2) = SoCz2(t,h);

Scalar P_pv_max max PV power out put same as battery /8/;
Scalar SP_ppa strike price of the PPA /85/;


Parameter hb(h) hours of battery
/h1 1
h2 2
h3 4
h4 6/;




Variables
obj(h,z) objective function
C(h) 'variable for CAPEX'
ppa_i(z) 'income through ppa';



*SP_ppa.up = 195;
*SP_ppa.lo = 175;


Equations
Income ObjetiveFunction
CAPEX 'capital cost of pv+storage'
ppa_income 'income through ppa'
con_ppa_income_lb 'income through ppa lower bound';


*sto 2o athrisma tis antikimenikis sinartisis prepei na mpi mia diadiki metavliti
*b=1 otan SoC(T)>0, b=0 otan SoC(T)<=0 mporei na gini xoris senaria?
Income(h,z) .. obj(h,z) =e= sum(t,(P_ppa(t,z)/1000)*SP_ppa) + sum(t,(mp(t)*(1-pvf(t))*(P_b2g(t,z))))
+sum(t,(182*(P_excess(t,z)/1000)*(1-iseop(t,z))*pvf(t)))-C(h);

CAPEX(h) .. C(h) =e= (200000*P_pv_max+220000*hb(h)*P_pv_max)*240/(12*8760);
ppa_income(z).. ppa_i(z) =e= sum(t,(P_ppa(t,z)/1000)*SP_ppa);
con_ppa_income_lb(h,z).. ppa_i(z) =g= 0.5*C(h);



Model PP_PV_BESS /all/ ;
Option mip=cplex;
Solve PP_PV_BESS using lp maximizing obj ;]]>
no_email@example.com (GeGo) https://forum.gamsworld.org/viewtopic.php?f=2&t=13021&p=31341#p31341 Sat, 20 Apr 2024 13:06:10 +0000 https://forum.gamsworld.org/viewtopic.php?f=2&t=13021&p=31341#p31341
<![CDATA[Syntax :: Re: BESS modeling Error 148 and 258 in obj function. :: Reply by bussieck]]> https://forum.gamsworld.org/viewtopic.php?f=2&t=13021&p=31345#p31345
First the is a very nice formatting control to copy and paste code. Please use that. On the particular question. You have an objective variable obj(h,z), so for every h and z there is a variable and you ask the solver to optimize it. A solver can only optimize a single variable not h times z many. So GAMS assumes your obj is a scalar variable and hence complains that you use z as a 2-dim variable in the declaration and equations and as a scalar variable in the solve statement. Perhaps, you want to add all income, then you should redefine your income equation:

Code: Select all

Variables
obj objective function
Income .. obj =e= sum((h,z),sum(t,(P_ppa(t,z)/1000)*SP_ppa) + sum(t,(mp(t)*(1-pvf(t))*(P_b2g(t,z)))));

Hope this helps,
-Michael]]>
no_email@example.com (bussieck) https://forum.gamsworld.org/viewtopic.php?f=2&t=13021&p=31345#p31345 Sun, 21 Apr 2024 07:20:44 +0000 https://forum.gamsworld.org/viewtopic.php?f=2&t=13021&p=31345#p31345
<![CDATA[Modeling :: Re: Optimizing bus assignement to routes :: Reply by Essouaied Aziz]]> https://forum.gamsworld.org/viewtopic.php?f=9&t=12973&p=31277#p31277 I've spent some time correcting and perfecting the model, yet I still get some errors. Basically I get Errors 149, 2, 243.
I've tried to deal with those but I've got lost.

Here is the current code I'm working on (I attach it to this post aswell):
Sets
i /100
101
102
103
104
105
106
107
108
109
110
113
114
115
116
117
118
119
122
123
124
125
128
129
130
131
132
133
134
135
136
138
139
141
142
143
145
146
149
151
152
153
154
155
157
162
164
167
168
169
170
173
174
175
176
178
179
182
183
189
192
194
206
209
219
300
306
321
501
502
503
504
506
507
508
509
510
512
517
518/
j /1*4/
t /1*4/;

Alias (i,ii);

Parameters
D(i,j) Distribution de la Demande sur par Ligne i et Période j
FV(i,j) Variable binaire indiquant si la route i est desservie pendant la saison j
P(i) Variable binaire indiquant si la route i est active
Cap(t) Capacité des bus par type
Min(j) Minimum de bus requis par saison;

Scalar bigM;
bigM = 1000;

Table D(i,j) Distribution de la Demande pour la Ligne i et la Période j
1 2 3 4
100 13921 13496 33134 22629
101 13017 12620 30983 21160
102 16842 16328 40087 27378
103 3209 3111 7639 5217
104 9931 9628 23637 16143
105 12302 11927 29281 19998
106 395 382 939 641
107 11676 11320 27791 18980
108 14341 13903 34133 23311
109 90 87 213 145
110 2845 2758 6772 4625
113 16537 16032 39361 26882
114 12717 12329 30269 20673
115 12237 11863 29126 19892
116 370 359 881 602
117 122 118 291 199
118 8153 7905 19406 13254
119 255 247 607 414
122 13278 12873 31605 21585
123 14297 13861 34030 23241
124 1620 1571 3856 2633
125 37 36 88 60
128 62 60 148 101
129 67 65 158 108
130 1 1 1 1
131 8890 8619 21161 14452
132 3352 3250 7979 5449
133 478 463 1137 777
134 37 36 89 61
135 10196 9885 24269 16574
136 42 40 99 68
138 4515 4377 10745 7339
139 14792 14341 35207 24045
141 12123 11753 28854 19706
142 1993 1932 4744 3240
143 13278 12873 31603 21584
145 6258 6068 14896 10174
146 1004 973 2389 1632
149 15059 14599 35842 24479
151 1529 1482 3639 2485
152 8573 8311 20405 13936
153 34 33 80 55
154 10 9 23 16
155 6 5 13 9
157 10 9 23 16
162 12927 12533 30769 21014
164 11696 11339 27837 19012
167 66 64 157 107
168 59 57 139 95
169 1083 1050 2577 1760
170 1302 1263 3100 2117
173 4047 3923 9632 6578
174 1332 1291 3170 2165
175 71 69 170 116
176 253 246 603 412
178 80 78 191 130
179 16679 16170 39699 27113
182 85 82 202 138
183 13012 12615 30971 21152
189 13329 12923 31726 21668
192 2134 2069 5080 3469
194 12774 12384 30404 20765
206 9876 9575 23507 16054
209 13941 13516 33182 22662
219 67 65 159 109
300 9223 8942 21952 14992
306 1 1 2 1
321 20 20 49 33
501 12934 12539 30785 21025
502 13643 13227 32474 22178
503 11162 10821 26566 18144
504 10998 10663 26178 17879
506 12878 12485 30652 20934
507 5699 5525 13565 9264
508 11939 11575 28417 19408
509 11285 10940 26859 18344
510 670 650 1595 1090
512 16055 15565 38213 26098
517 13875 13451 33024 22554
518 12618 12233 30032 20511;

Table FV(i,j) Facteur du voyage de la Ligne i et la Période j
1 2 3 4
100 303.429 313.714 627.429 473.143
101 217.846 225.231 450.462 339.692
102 166.588 172.235 344.471 259.765
103 212.400 219.600 439.200 331.200
104 166.588 172.235 344.471 259.765
105 354.000 366.000 732.000 552.000
106 298.105 308.211 616.421 464.842
107 274.065 283.355 566.710 427.355
108 314.667 325.333 650.667 490.667
109 472.000 488.000 976.000 736.000
110 354.000 366.000 732.000 552.000
113 314.667 325.333 650.667 490.667
114 314.667 325.333 650.667 490.667
115 386.182 399.273 798.545 602.182
116 283.200 292.800 585.600 441.600
117 177.000 183.000 366.000 276.000
118 404.571 418.286 836.571 630.857
119 472.000 488.000 976.000 736.000
122 369.391 381.913 763.826 576.000
123 346.776 358.531 717.061 540.735
124 404.571 418.286 836.571 630.857
125 435.692 450.462 900.923 679.385
128 514.909 532.364 1064.727 802.909
129 472.000 488.000 976.000 736.000
130 472.000 488.000 976.000 736.000
131 514.909 532.364 1064.727 802.909
132 531.000 549.000 1098.000 828.000
133 404.571 418.286 836.571 630.857
134 257.455 266.182 532.364 401.455
135 283.200 292.800 585.600 441.600
136 283.200 292.800 585.600 441.600
138 472.000 488.000 976.000 736.000
139 472.000 488.000 976.000 736.000
141 314.667 325.333 650.667 490.667
142 177.000 183.000 366.000 276.000
143 202.286 209.143 418.286 315.429
145 377.600 390.400 780.800 588.800
146 173.388 179.265 358.531 270.367
149 195.310 201.931 403.862 304.552
151 404.571 418.286 836.571 630.857
152 435.692 450.462 900.923 679.385
153 435.692 450.462 900.923 679.385
154 354.000 366.000 732.000 552.000
155 566.400 585.600 1171.200 883.200
157 377.600 390.400 780.800 588.800
162 188.800 195.200 390.400 294.400
164 339.840 351.360 702.720 529.920
167 283.200 292.800 585.600 441.600
168 283.200 292.800 585.600 441.600
169 354.000 366.000 732.000 552.000
170 472.000 488.000 976.000 736.000
173 472.000 488.000 976.000 736.000
174 369.391 381.913 763.826 576.000
175 404.571 418.286 836.571 630.857
176 354.000 366.000 732.000 552.000
178 150.372 155.469 310.938 234.478
179 128.727 133.091 266.182 200.727
182 314.667 325.333 650.667 490.667
183 202.286 209.143 418.286 315.429
189 161.829 167.314 334.629 252.343
192 314.667 325.333 650.667 490.667
194 149.053 154.105 308.211 232.421
206 435.692 450.462 900.923 679.385
209 182.710 188.903 377.806 284.903
219 236.000 244.000 488.000 368.000
300 5142909 532.364 1064.727 802.909
306 514.909 532.364 1064.727 802.909
321 514.909 532.364 1064.727 802.909
501 190.921 197.393 394.787 297.708
502 141.600 146.400 292.800 220.800
503 149.053 154.105 308.211 232.421
504 160.302 165.736 331.472 249.962
506 166.588 172.235 344.471 259.765
507 171.636 177.455 354.909 267.636
508 236.000 244.000 488.000 368.000
509 209.778 216.889 433.778 327.111
510 188.800 195.200 390.400 294.400
512 178.863 184.926 369.853 278.905
517 128.727 133.091 266.182 200.727
518 160.302 165.736 331.472 249.962;

Parameters Min(j) Minimum de Voyages requis pour la Période j
/1 59
2 61
3 122
4 92/

Parameter Cap(t)
/1 55
2 53
3 51
4 49/

Parameter P(i) Proportion de Voyage pour la Ligne i (de toutes les Lignes)
/100 0.0258605
101 0.0241818
102 0.0312868
103 0.0059617
104 0.0184483
105 0.0228528
106 0.0007329
107 0.0216898
108 0.0266398
109 0.0001663
110 0.0052855
113 0.0307200
114 0.0236242
115 0.0227318
116 0.0006876
117 0.0002270
118 0.0151461
119 0.0004734
122 0.0246665
123 0.0265595
124 0.0030095
125 0.0000687
128 0.0001151
129 0.0001236
130 0.0000012
131 0.0165154
132 0.0062276
133 0.0008877
134 0.0000695
135 0.0189410
136 0.0000774
138 0.0083864
139 0.0274785
141 0.0225200
142 0.0037029
143 0.0246654
145 0.0116261
146 0.0018649
149 0.0279738
151 0.0028403
152 0.0159257
153 0.0000625
154 0.0000178
155 0.0000105
157 0.0000178
162 0.0240140
164 0.0217263
167 0.0001227
168 0.0001087
169 0.0020110
170 0.0024192
173 0.0075177
174 0.0024738
175 0.0001324
176 0.0004707
178 0.0001490
179 0.0309838
182 0.0001578
183 0.0241724
189 0.0247612
192 0.0039647
194 0.0237297
206 0.0183466
209 0.0258976
219 0.0001242
300 0.0171331
306 0.0000015
321 0.0000380
501 0.0240266
502 0.0253448
503 0.0207343
504 0.0204313
506 0.0239232
507 0.0105870
508 0.0221790
509 0.0209631
510 0.0012451
512 0.0298240
517 0.0257746
518 0.0234393/

Variables
W(i,j) Nombre de bus de type W assignés à la route i pendant la saison j
X(i,j) Nombre de bus de type X assignés à la route i pendant la saison j
Y(i,j) Nombre de bus de type Y assignés à la route i pendant la saison j
Z(i,j) Nombre de bus de type Z assignés à la route i pendant la saison j;

Positive Variable W, X, Y, Z;

Equations
DemandConstraint(i,j)
CapacityConstraint(t,i,j)
FleetUtilizationConstraint
FleetAvailabilityConstraint(t,i,j)
RouteActivationConstraint(i);

DemandConstraint(i,j).. sum(t, Cap(t)*(ord(t)-51)*(ord(t)-53)*(ord(t)-55)*(ord(t)-49)) =g= D(i,j);

CapacityConstraint(t,i,j).. sum(ii, W(i,j))$((ord(t)-51)*FV(i,j)) =l= Cap(t)*sum(ii, FV(i,j));

FleetUtilizationConstraint.. sum((i,j), W(i,j) + X(i,j) + Y(i,j) + Z(i,j)) =g= 80*sum(j, Min(j));

FleetAvailabilityConstraint(t,i,j).. W(i,j) =l= Cap(t)*sum(ii, FV(i,j));

RouteActivationConstraint(i).. sum(t, FV(i,j)) =g= 1;

Model transport /all/;
Option solver = CPLEX;
Solve transport using LP minimizing sum((i, j), W(i,j) + X(i,j) + Y(i,j) + Z(i,j));

Display W, X, Y, Z;

I would love to correct my code in a way it gives my a table which shows how many buses to assign to each route by the route number and the season.

Any help please? With thanks!

Attachments

The GAMS code
Untitled_6.gms (13.91 KiB)
]]>
no_email@example.com (Essouaied Aziz) https://forum.gamsworld.org/viewtopic.php?f=9&t=12973&p=31277#p31277 Thu, 28 Mar 2024 11:22:08 +0000 https://forum.gamsworld.org/viewtopic.php?f=9&t=12973&p=31277#p31277
<![CDATA[Modeling :: Erorr 149 :: Author osmane]]> https://forum.gamsworld.org/viewtopic.php?f=9&t=13003&p=31312#p31312
why am i getting error 149 here

s(i) service level of state i
d(j) Demand of state j
z(i,j) number of humanitarian kits sent from state i to state j]]>
no_email@example.com (osmane) https://forum.gamsworld.org/viewtopic.php?f=9&t=13003&p=31312#p31312 Sat, 06 Apr 2024 23:19:46 +0000 https://forum.gamsworld.org/viewtopic.php?f=9&t=13003&p=31312#p31312
<![CDATA[Modeling :: Re: Erorr 149 :: Reply by bussieck]]> https://forum.gamsworld.org/viewtopic.php?f=9&t=13003&p=31316#p31316
-Michael]]>
no_email@example.com (bussieck) https://forum.gamsworld.org/viewtopic.php?f=9&t=13003&p=31316#p31316 Mon, 08 Apr 2024 06:25:34 +0000 https://forum.gamsworld.org/viewtopic.php?f=9&t=13003&p=31316#p31316
<![CDATA[Modeling :: Nonlinear Programming/ Steiner Weber Modell with barriers :: Author Student75]]> https://forum.gamsworld.org/viewtopic.php?f=9&t=13007&p=31317#p31317 I would like to solve a mathematical model with GAMS and unfortunately I can't find the solution. I would like to solve the following problem with the GAMS programme:

I would like to carry out location planning taking a barrier into account. I will take the federal state of Brandenburg as an example. My demand/requirement locations are all cities in Brandenburg. I get the coordinates of the cities from Excel using geocoordinates and can thus determine the respective distances between the cities. To do this, I form a distance matrix between the cities and insert the values in a table in GAMS. I have one demand point per 200 inhabitants. For example, if I have 1000 inhabitants in a small town, then I have 5 demand points for this town. My barrier should be Berlin. The barrier area is represented by a circle or, even more simply, by the corner points of the rectangle as an area. The corner points of the rectangle represent the area for the barrier zone. The new locations should be shown with X and Y coordinates. If a new location falls on the barrier area, the location is moved to the edge of the barrier. There should also be a capacity limit for the new location. For example, a location can only cover 20 demand points.

My objective function is to minimise the distance between demand points and new locations.There should also be the possibility to limit the number of new locations.

How can I create a formula, that moves locations out of the barrier zone to the edge of the barrier zones?

Many thanks in advance :)]]>
no_email@example.com (Student75) https://forum.gamsworld.org/viewtopic.php?f=9&t=13007&p=31317#p31317 Mon, 08 Apr 2024 20:32:21 +0000 https://forum.gamsworld.org/viewtopic.php?f=9&t=13007&p=31317#p31317
<![CDATA[Modeling :: Re: Nonlinear Programming/ Steiner Weber Modell with barriers :: Reply by bussieck]]> https://forum.gamsworld.org/viewtopic.php?f=9&t=13007&p=31320#p31320
-Michael]]>
no_email@example.com (bussieck) https://forum.gamsworld.org/viewtopic.php?f=9&t=13007&p=31320#p31320 Tue, 09 Apr 2024 05:24:42 +0000 https://forum.gamsworld.org/viewtopic.php?f=9&t=13007&p=31320#p31320
<![CDATA[Modeling :: Zero Division Error :: Author Merey]]> https://forum.gamsworld.org/viewtopic.php?f=9&t=13020&p=31335#p31335 I was trying to create a model for Mozambique. But the program gets zero division error every time. I see gaps in my data set, but I don't know how I can fill them. Any ideas?

Attachments

MOZSAM.xlsx (179.57 KiB)
MOZSAM_test.gms (5.86 KiB)
]]>
no_email@example.com (Merey) https://forum.gamsworld.org/viewtopic.php?f=9&t=13020&p=31335#p31335 Wed, 17 Apr 2024 14:11:13 +0000 https://forum.gamsworld.org/viewtopic.php?f=9&t=13020&p=31335#p31335
<![CDATA[Modeling :: Re: Zero Division Error :: Reply by Fred]]> https://forum.gamsworld.org/viewtopic.php?f=9&t=13020&p=31339#p31339
Running your code, I get

Code: Select all

--- MOZSAM_test.gms(165) 4 Mb[FIL:"C:\Users\ffian\Documents\support\MOZSAM_test.gms",165,0]
*** Error at line 165: division by zero (0)[LST:522]
--- MOZSAM_test.gms(171) 4 Mb 1 Error[FIL:"C:\Users\ffian\Documents\support\MOZSAM_test.gms",171,0]
*** Error at line 171: division by zero (0)[LST:523]
--- MOZSAM_test.gms(899) 6 Mb 2 Errors
The corresponding lines in the echo print are

Code: Select all

165  tq(c)=SAM("stax",c)/QQ0(c);
[...]
171  tim(c) = SAM("mtax",c)/SAM("ROW",c);
If QQ0(c) is zero for certain c, you get a division by zero error. The question is, what should tq(c) be for those elements in c? You could for example just skip those c by adding a simple dollar condition

Code: Select all

tq(c)$QQ0(c)=SAM("stax",c)/QQ0(c);
You could use the same "trick" in line 171 as well. The question is, whether this gives you the desired results? You are the only person that can answer this question.

I hope this helps!

Fred]]>
no_email@example.com (Fred) https://forum.gamsworld.org/viewtopic.php?f=9&t=13020&p=31339#p31339 Thu, 18 Apr 2024 12:21:29 +0000 https://forum.gamsworld.org/viewtopic.php?f=9&t=13020&p=31339#p31339
<![CDATA[Modeling :: How can I random the consecutive number? :: Author celebpanama]]> https://forum.gamsworld.org/viewtopic.php?f=9&t=13022&p=31342#p31342 My target is like, for example,

Code: Select all

i/j  1    2    3    4    5   6
1    0    1    0    0    0   1
2    0    1    0    0    0   1
3    0    1    1    0    0   1
4    1    1    1    0    0   1
5    1    0    1    0    1   0
6    1    0    1    0    1   0
7    1    0    0    0    1   0
8    0    0    0    0    1   0
9    0    0    0    0    0   0
10   0    0    0    0    0   0
Thank you for the recommendation.

Right now, I cannot fix 4 times each column

set i /r1*r10/, j /c1*c6/, iter /1*3/;

parameter
randval(i,j) Random values,
randvalloop(iter, i,j) Store the random values;

$set seed 123456
loop(iter,
randval(i, j) = uniformInt(0,1);
randvalloop(iter, i,j) = randval(i,j);
);

* Check the results
display randvalloop;]]>
no_email@example.com (celebpanama) https://forum.gamsworld.org/viewtopic.php?f=9&t=13022&p=31342#p31342 Sat, 20 Apr 2024 21:22:50 +0000 https://forum.gamsworld.org/viewtopic.php?f=9&t=13022&p=31342#p31342
<![CDATA[Modeling :: Re: How can I random the consecutive number? :: Reply by bussieck]]> https://forum.gamsworld.org/viewtopic.php?f=9&t=13022&p=31344#p31344

Code: Select all

set i /r1*r10/, j /c1*c6/, iter /1*3/;

parameter
rowstart, cnt,
randval(i,j) Random values,
randvalloop(iter, i,j) Store the random values;

$set seed 123456
loop(iter,
  loop(j,
    rowstart = uniformInt(1,card(i)-3);
    loop(i$(ord(i)=rowstart),
      for (cnt=0 to 3,
        randvalloop(iter, i+cnt,j) = 1;
      )
    )
  )
);

* Check the results
option randvalloop:0:1:1;
display randvalloop;
-Michael]]>
no_email@example.com (bussieck) https://forum.gamsworld.org/viewtopic.php?f=9&t=13022&p=31344#p31344 Sun, 21 Apr 2024 07:12:16 +0000 https://forum.gamsworld.org/viewtopic.php?f=9&t=13022&p=31344#p31344
<![CDATA[Modeling :: Re: How can I random the consecutive number? :: Reply by celebpanama]]> https://forum.gamsworld.org/viewtopic.php?f=9&t=13022&p=31347#p31347 I have some question. How GAMS can start 1 from r1 at some column and 1 end up with the last row (r10) in every iteration? As shown in the table below, 1 can start in row 1 (r1) both c2 and c6, and 1 end at row 10 (r10) in c5.

Code: Select all

      c1   c2   c3   c4   c5  c6
r1    0    1    0    0    0   1
r2    0    1    0    0    0   1
r3    0    1    1    0    0   1
r4    1    1    1    0    0   1
r5    1    0    1    0    0   0
r6    1    0    1    0    0   0
r7    1    0    0    0    1   0
r8    0    0    0    0    1   0
r9    0    0    0    0    1   0
r10   0    0    0    0    1   0
]]>
no_email@example.com (celebpanama) https://forum.gamsworld.org/viewtopic.php?f=9&t=13022&p=31347#p31347 Sun, 21 Apr 2024 18:56:55 +0000 https://forum.gamsworld.org/viewtopic.php?f=9&t=13022&p=31347#p31347
<![CDATA[Modeling :: Re: How can I random the consecutive number? :: Reply by bussieck]]> https://forum.gamsworld.org/viewtopic.php?f=9&t=13022&p=31349#p31349

Code: Select all

set i /r1*r10/, j /c1*c6/, iter /1*3/;

parameter
rowstart, cnt,
randval(i,j) Random values,
randvalloop(iter, i,j) Store the random values;

$set seed 123456
loop(iter,
  loop(j,
    rowstart = uniformInt(1,card(i)-3);
    loop(i$(ord(i)=rowstart),
      for (cnt=0 to 3,
        randvalloop(iter, i+cnt,j) = 1;
      )
    )
  )
* No start in any column  
  if (sum(j, randvalloop(iter,'r1',j))=0, randvalloop(iter,i,'c1') = ord(i)<5);
* No end in any column  
  if (sum(j, randvalloop(iter,'r10',j))=0, randvalloop(iter,i,'c6') = ord(i)>card(i)-4);
);

* Check the results
option randvalloop:0:1:1;
display randvalloop;
]]>
no_email@example.com (bussieck) https://forum.gamsworld.org/viewtopic.php?f=9&t=13022&p=31349#p31349 Mon, 22 Apr 2024 13:53:04 +0000 https://forum.gamsworld.org/viewtopic.php?f=9&t=13022&p=31349#p31349
<![CDATA[Modeling :: Re: How can I random the consecutive number? :: Reply by celebpanama]]> https://forum.gamsworld.org/viewtopic.php?f=9&t=13022&p=31350#p31350 no_email@example.com (celebpanama) https://forum.gamsworld.org/viewtopic.php?f=9&t=13022&p=31350#p31350 Mon, 22 Apr 2024 23:17:04 +0000 https://forum.gamsworld.org/viewtopic.php?f=9&t=13022&p=31350#p31350 <![CDATA[Modeling :: Re: How can I random the consecutive number? :: Reply by celebpanama]]> https://forum.gamsworld.org/viewtopic.php?f=9&t=13022&p=31354#p31354

Code: Select all

set t /1*10/, i /1*6/, [b]iter /1*1/[/b];

parameter
rowstart, cnt, q,
randval(t,i) Random values,
randvalloop(iter, t,i) Store the random values

$set seed 123456

loop(iter,
  q = 6  
  loop(i,
    rowstart = uniformInt(1,card(t)-(q-1));
    loop(t$(ord(t)=rowstart),
      for (cnt=0 to (q-1),
        randvalloop(iter, t+cnt,i) = 1;
      )
    )
  )
* No start in any column  
  if (sum(i, randvalloop(iter,'1',i))=0, randvalloop(iter,t,'1') = ord(t)<(q+1));
* No end in any column  
  if (sum(i, randvalloop(iter,'10',i))=0, randvalloop(iter,t,'6') = ord(t)>card(t)-q);
  
);

* Check the results
option randvalloop:0:1:1;
display randvalloop;
]]>
no_email@example.com (celebpanama) https://forum.gamsworld.org/viewtopic.php?f=9&t=13022&p=31354#p31354 Wed, 24 Apr 2024 00:02:44 +0000 https://forum.gamsworld.org/viewtopic.php?f=9&t=13022&p=31354#p31354
<![CDATA[Modeling :: Error on finding max value in MIP :: Author Agustino]]> https://forum.gamsworld.org/viewtopic.php?f=9&t=13031&p=31359#p31359

Code: Select all

 Error 59 Endogenous prod smin smax require model type "dnlp"
 Error 256 equation eq2.. VAR prod smin smax
Suppose I have EM(f,t,i) as the positive variable, which is the result from previous constraints like this

Code: Select all

      i1 i2 i3 i4 i5
f1.t1  7  5  6  0  6
f1.t2  8  4  6  1  6
f1.t3  6  7  3  2  4
f2.t1  8  7  5  3  1
f2.t2  0  5  5  7  0
f2.t3  0  8  0  5  9

Code: Select all

eq2(f,i)..         last(i) =e= smax((t),EM(f,t,i));
So, I would like to fix the above coding and find the max value each column, and then collect in last(i) variable.
My target should be

last(1) = 8
last(2) = 8
last(3) = 6
last(4) = 7
last(5) = 9

Please help me to achieve this MIP model. Thank you.]]>
no_email@example.com (Agustino) https://forum.gamsworld.org/viewtopic.php?f=9&t=13031&p=31359#p31359 Fri, 26 Apr 2024 08:32:43 +0000 https://forum.gamsworld.org/viewtopic.php?f=9&t=13031&p=31359#p31359
<![CDATA[Tools :: GDX MPS2GMS :: Author Rester]]> https://forum.gamsworld.org/viewtopic.php?f=3&t=13024&p=31346#p31346 no_email@example.com (Rester) https://forum.gamsworld.org/viewtopic.php?f=3&t=13024&p=31346#p31346 Sun, 21 Apr 2024 11:11:04 +0000 https://forum.gamsworld.org/viewtopic.php?f=3&t=13024&p=31346#p31346 <![CDATA[Tools :: Re: GDX MPS2GMS :: Reply by bussieck]]> https://forum.gamsworld.org/viewtopic.php?f=3&t=13024&p=31348#p31348

Good luck,
-Michael]]>
no_email@example.com (bussieck) https://forum.gamsworld.org/viewtopic.php?f=3&t=13024&p=31348#p31348 Mon, 22 Apr 2024 06:43:25 +0000 https://forum.gamsworld.org/viewtopic.php?f=3&t=13024&p=31348#p31348
<![CDATA[Tools :: Re: GDX MPS2GMS :: Reply by ClssicSupreme11]]> https://forum.gamsworld.org/viewtopic.php?f=3&t=13024&p=31352#p31352
GAMS (General Algebraic Modeling System) is often used with .gdx files, as it is a modeling language and environment that supports optimization modeling. If you have a .gdx file generated from MPS2GMS, you can use GAMS to read the data from the .gdx file and formulate and solve your optimization model.

After formulating your optimization model in GAMS, you can solve it using a solver compatible with GAMS, such as CPLEX, Gurobi, or others.

If you have specific requirements or constraints for your optimization problem, please provide more details, and I can assist you further.]]>
no_email@example.com (ClssicSupreme11) https://forum.gamsworld.org/viewtopic.php?f=3&t=13024&p=31352#p31352 Tue, 23 Apr 2024 07:24:57 +0000 https://forum.gamsworld.org/viewtopic.php?f=3&t=13024&p=31352#p31352
<![CDATA[API :: Python API picking up wrong GAMS version :: Author akingCCC]]> https://forum.gamsworld.org/viewtopic.php?f=10&t=13019&p=31332#p31332
I started by creating a new environment in Anaconda, and in a command line entered:

Code: Select all

(gams_py46) C:\Users\myusername>pip install gamsapi[all]==46.4.0
which seemed to install successfully. Then (following the instructions in https://www.gams.com/latest/docs/API_PY ... ARTED.html), I entered

Code: Select all

python -c "import gams; print(f'API OK -- Version {gams.__version__}')"
which gave me

Code: Select all

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\GAMS\38\apifiles\Python\gams\gams\__init__.py", line 32, in <module>
    from .workspace import *
  File "C:\GAMS\38\apifiles\Python\gams\gams\workspace.py", line 32, in <module>
    from .database import *
  File "C:\GAMS\38\apifiles\Python\gams\gams\database.py", line 26, in <module>
    from gdxcc import *
ModuleNotFoundError: No module named 'gdxcc'
so clearly it is trying to get something from GAMS 38 instead of GAMS 46. So I tried

Code: Select all

(gams_py46) C:\Users\myusername>python -m site
and got

Code: Select all

sys.path = [
    'C:\\Users\\myusername',
    'C:\\GAMS\\38\\apifiles\\Python\\gams',
    'C:\\Users\\myusername\\%PYTHONPATH%',
    'C:\\Anaconda3\\envs\\gams_py46\\python311.zip',
    'C:\\Anaconda3\\envs\\gams_py46\\DLLs',
    'C:\\Anaconda3\\envs\\gams_py46\\Lib',
    'C:\\Anaconda3\\envs\\gams_py46',
    'C:\\Anaconda3\\envs\\gams_py46\\Lib\\site-packages',
]
USER_BASE: 'C:\\Users\\myusername\\AppData\\Roaming\\Python' (exists)
USER_SITE: 'C:\\Users\\myusername\\AppData\\Roaming\\Python\\Python311\\site-packages' (doesn't exist)
ENABLE_USER_SITE: True
The instructions tell me to correct the GAMS path in the file sitecustomize.py, but there is no such file in the USER_BASE folder (and the USER_SITE folder doesn't exist), and any other files I can find with this name don't have a C:\GAMS\38 path in them (or any other explicit GAMS path for that matter).

I don't really want to uninstall GAMS 38 as I need to retain that for the working version of the code I want to upgrade. How do I fix this path issue? Thanks!]]>
no_email@example.com (akingCCC) https://forum.gamsworld.org/viewtopic.php?f=10&t=13019&p=31332#p31332 Mon, 15 Apr 2024 04:22:43 +0000 https://forum.gamsworld.org/viewtopic.php?f=10&t=13019&p=31332#p31332
<![CDATA[API :: Re: Python API picking up wrong GAMS version :: Reply by Clemens]]> https://forum.gamsworld.org/viewtopic.php?f=10&t=13019&p=31334#p31334
Something seems to put in the GAMS 38 path into your configuration. Have you checked if the PYTHONPATH environment variable is set? Run from the Anaconda command prompt:

Code: Select all

echo %PYTHONPATH%
Best,
Clemens]]>
no_email@example.com (Clemens) https://forum.gamsworld.org/viewtopic.php?f=10&t=13019&p=31334#p31334 Wed, 17 Apr 2024 10:41:44 +0000 https://forum.gamsworld.org/viewtopic.php?f=10&t=13019&p=31334#p31334
<![CDATA[API :: Re: Python API picking up wrong GAMS version :: Reply by dirkse]]> https://forum.gamsworld.org/viewtopic.php?f=10&t=13019&p=31336#p31336
It sounds to me like the GAMS 38 in the sitecustomize.py file is confusing your fresh conda install.

Many years ago I used the Python site package, but once I started to use miniconda I dropped it completely. I found that the two don't work well together. And at some level they are fundamental incompatible. With conda I want to create a self-contained environment that is independent of other Python stuff (conda or otherwise). But with the site package, I am sharing settings between Python versions.

-Steve]]>
no_email@example.com (dirkse) https://forum.gamsworld.org/viewtopic.php?f=10&t=13019&p=31336#p31336 Wed, 17 Apr 2024 15:15:46 +0000 https://forum.gamsworld.org/viewtopic.php?f=10&t=13019&p=31336#p31336
<![CDATA[API :: Re: Python API picking up wrong GAMS version :: Reply by akingCCC]]> https://forum.gamsworld.org/viewtopic.php?f=10&t=13019&p=31337#p31337
Clemens wrote: 1 week ago Hi,

Something seems to put in the GAMS 38 path into your configuration. Have you checked if the PYTHONPATH environment variable is set? Run from the Anaconda command prompt:

Code: Select all

echo %PYTHONPATH%
Best,
Clemens
Hi Clemens,

Yes, thanks, I think that's it! When I put that into the command prompt, I get

Code: Select all

C:\GAMS\38\apifiles\Python\gams;%PYTHONPATH%
and I remember changing something along those lines a year or two ago when we were setting up the original connection between GAMS and Python.

To remove it, in my Windows search I looked up "edit environment variables for your account", which opened the Environment Variables box (similar to but distinct from the System Environment Variables). In the top box User variables, I had a couple of variables that had values that included the path to GAMS 38. I deleted those and closed that box, closed and restarted Anaconda, then checked the echo %PYTHONPATH% command again, and the reference to GAMS 38 was gone. I then reinstalled the API using the commands above and checked the install, and this time it told me it was using the right version of GAMS:

Code: Select all

C:\Users\myusername>python -c "import gams; print(f'API OK -- Version {gams.__version__}')"
API OK -- Version 46.4.0
Now I just need to try using it...]]>
no_email@example.com (akingCCC) https://forum.gamsworld.org/viewtopic.php?f=10&t=13019&p=31337#p31337 Thu, 18 Apr 2024 03:38:45 +0000 https://forum.gamsworld.org/viewtopic.php?f=10&t=13019&p=31337#p31337
<![CDATA[Solvers :: Re: CNS Solver: Pivot Too Small :: Reply by Rodrigue]]> https://forum.gamsworld.org/viewtopic.php?f=11&t=12928&p=31282#p31282 Note that many equations do not solve either because they are not correctly written or the initialisation of variables is wrong.
Rodrigue,

Cheers]]>
no_email@example.com (Rodrigue) https://forum.gamsworld.org/viewtopic.php?f=11&t=12928&p=31282#p31282 Mon, 01 Apr 2024 09:09:01 +0000 https://forum.gamsworld.org/viewtopic.php?f=11&t=12928&p=31282#p31282
<![CDATA[Archive Google Group :: Re: GAMS Installation Error :: Reply by Clemens]]> https://forum.gamsworld.org/viewtopic.php?f=13&t=12959&p=31333#p31333
This is a Windows problem that can most likely be prevented by running the installer from a command prompt with /SILENT or /VERYSILENT. There is a note on this in the documentation: https://www.gams.com/latest/docs/UG_WIN_INSTALL.html
image.png
1. Open command prompt
2. Switch to directory containing the GAMS installer
3. Run "windows_x64_64.exe /SILENT" or "windows_x64_64.exe /VERYSILENT"

Best,
Clemens

Attachments


image.png (23.6 KiB)


(Click on the image to see it full size.)
]]>
no_email@example.com (Clemens) https://forum.gamsworld.org/viewtopic.php?f=13&t=12959&p=31333#p31333 Wed, 17 Apr 2024 07:22:21 +0000 https://forum.gamsworld.org/viewtopic.php?f=13&t=12959&p=31333#p31333
<![CDATA[Bugs :: Re: Search in Studio :: Reply by Rob Davies]]> https://forum.gamsworld.org/viewtopic.php?f=6&t=12942&p=31326#p31326 I am using search and replace. The search still finds the wrong thing, but now in all of the files, not just the lst file.
I also notice that it tells me at the start there are, say, 5 matches found, but when I replace the first one, it still indicates 5 remaining, and after replacing all, it indicates there is 1 match remaining.
Trivial, but clearly a bug. I am scared to use replace all, since it may replace the wrong thing.
Best
Rob]]>
no_email@example.com (Rob Davies) https://forum.gamsworld.org/viewtopic.php?f=6&t=12942&p=31326#p31326 Fri, 12 Apr 2024 10:36:28 +0000 https://forum.gamsworld.org/viewtopic.php?f=6&t=12942&p=31326#p31326
<![CDATA[Bugs :: Re: Search in Studio :: Reply by Lutz]]> https://forum.gamsworld.org/viewtopic.php?f=6&t=12942&p=31328#p31328
Thanks again for the report! Would it be possible, that you send an example of this to support@gams.com?
Just two days ago, I discovered, that the replace action works correctly, but the find afterwards still reports the old results (though, they were replaced correctly), if I use use "This project" as serach scope. That problem does not happenn, if I do a replace in a single file. I am not sure, if that is actually the same, you ran into.

Best regards,
Lutz]]>
no_email@example.com (Lutz) https://forum.gamsworld.org/viewtopic.php?f=6&t=12942&p=31328#p31328 Fri, 12 Apr 2024 19:05:17 +0000 https://forum.gamsworld.org/viewtopic.php?f=6&t=12942&p=31328#p31328