Search found 57 matches

by GabrielYin
1 year ago
Forum: Modeling
Topic: Altering the standard transportation problem
Replies: 3
Views: 660

Re: Altering the standard transportation problem

Suggest you to post your code which others can run, either using BBcode or attachment :) Then we are more convenient and comprehensive to help you!

Best,
Gabriel
by GabrielYin
1 year ago
Forum: Syntax
Topic: binary variable fixed value for 1 place - solution searched
Replies: 1
Views: 485

Re: binary variable fixed value for 1 place - solution searched

solution is simple

Code: Select all

ow.fx('w1') = 1;
Suggest you to search relevant documentation first when encountering problem :)

Cheers.
Gabriel
by GabrielYin
1 year ago
Forum: Modeling
Topic: how to use a loop statement into dynamic recursive model?
Replies: 2
Views: 690

Re: how to use a loop statement into dynamic recursive model?

Hi Rodrigue, To store/use values in each loop, I recommend two alternatives. 1. Define a global parameter to store the value and update it in each iteration. An illustrative example is shown below. Set k /1*100/; Parameter store(n); store(n) = *something initial*; loop(k, param(n) = store(n); * para...
by GabrielYin
1 year ago
Forum: Modeling
Topic: To binary or not to binary...
Replies: 4
Views: 794

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: 916

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: 1615

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: 626

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: 764

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: 740

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: 740

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...