Search found 54 matches

by GabrielYin
1 year ago
Forum: Modeling
Topic: To binary or not to binary...
Replies: 4
Views: 646

Re: To binary or not to binary...

More precisely, if your variable can ONLY take integer values from 50 to 150, as you stated in the post, then define the variable used by Manassaldi as integer variable like the following. Integer Variable T; T.lo=50; T.up=150; For more definition reference, you can visit the documentation site. htt...
by GabrielYin
1 year ago
Forum: Syntax
Topic: Product between matrices and vector
Replies: 2
Views: 733

Re: Product between matrices and vector

Hi, Try to use loops. I wrote a simple code for you. set col /1*4/ set row /1*5/ Table matrix(row, col) 1 2 3 4 1 2 3 4 5 2 4 6 2 1 3 9 7 1 0 4 6 7 1 8 5 7 2 3 1 ; Parameter vector(col)/ 1 1 2 1 3 0 4 0 /; Parameter result(row); loop(row, result(row) = sum(col, matrix(row, col) * vector(col)); ); di...
by GabrielYin
1 year ago
Forum: Syntax
Topic: How to update parameters iteratively within a Loop?
Replies: 5
Views: 1280

Re: How to update parameters iteratively within a Loop?

Dear, I have a similar problem, but instead of updating parameter I would like to write it in in a matrix/array at each iteration. My code is the following: *parameters xNpjf(P,Jn); set ITR /ITR0 * ITR5/; parameter mat_xNpjf(P,Jn,ITR); loop(ITR, solve $include "C:\Users\is\Documents\gamsdir\projdir...
by GabrielYin
1 year ago
Forum: Syntax
Topic: Data Transfer with Same Index Length
Replies: 0
Views: 545

Data Transfer with Same Index Length

Hi all, I got stuck in how to transfer the table/parameter data with different index but the same length. Take the following as an example: Set l All Trans. Lines/l1*l81/ cl(l) Candidate Trans. Lines /l7*l81/ cl1(cl) Candidate Trans. Lines /l7*l21/ cl2(cl) /l22*l36/ ; Table CLDATA1(cl1, *) Trans. Li...
by GabrielYin
1 year ago
Forum: Syntax
Topic: Add dynamically constraints to a model
Replies: 2
Views: 617

Re: Add dynamically constraints to a model

Hi, I do not know whether you want to add one more constraint per iteration or not. But here is my example. This is a Benders Decomposition example, and it works for adding one more Benders cut constraint to the master problem in each iteration. I use semi-pseudocode to enhance readability. Set k it...
by GabrielYin
1 year ago
Forum: Syntax
Topic: Can GAMS define my own function?
Replies: 2
Views: 583

Re: Can GAMS define my own function?

Gabriel, GAMS does not support functions of the sort you describe. Instead, you can use the include facility to include a file containing the GAMS source at both spots. A little reminder though: you cannot declare things inside an if statement. It is fine to make assignments and solve models inside...
by GabrielYin
1 year ago
Forum: Syntax
Topic: Can GAMS define my own function?
Replies: 2
Views: 583

Can GAMS define my own function?

Hi All, I am considering if GAMS can store codes to one callable function like Matlab and C then use the function in another gms. file. Like the sample use of: Loop(iter, if(ord(iter)<=1, s(i) = m.l(i); call:function.gms; ... ); if(ord(iter)>1, call:function.gms; ... ); ); the "function.gms" contain...
by GabrielYin
1 year ago
Forum: Syntax
Topic: Inner Assignment of Parameter
Replies: 1
Views: 455

Inner Assignment of Parameter

Hi All, I wonder if there is an efficient way to assign values for part of the parameter. For instance, I have a parameter with 64 values controlled by m. Then I have another parameter with 12 values controlled by n. Now I want to put the latter parameter within the former one. Specifically, I want ...
by GabrielYin
1 year ago
Forum: Modeling
Topic: Aggregate Parameter Indices
Replies: 3
Views: 690

Re: Aggregate Parameter Indices

By the way, I think GUSS needs exactly a single scenario index 's' to run right? But likely if I have a scenario set which is controlled by multiple indices like I posted previously, is it possible to use GUSS? The relevant site and my another post about GUSS are listed below. https://www.gams.com/l...
by GabrielYin
1 year ago
Forum: Modeling
Topic: Aggregate Parameter Indices
Replies: 3
Views: 690

Re: Aggregate Parameter Indices

Hi, GAMS has an obscure syntax to do exactly this. For details see https://www.gams.com/latest/docs/UG_SystemAttributes.html#UG_SystemAttributes_PowerSet . $set digits 3 set s / s1*s%digits% /, b / 1,2,3 /; $eval nMax power(card(b),card(s)) set n / n1*n%nMax% / x(n,s,b) / system.powerSetRight /; pa...