Search found 118 matches

by Manassaldi
2 years ago
Forum: Modeling
Topic: Help in writing linear equations based on conditionality in GAMS (9 variables)
Replies: 6
Views: 4209

Re: Help in writing linear equations based on conditionality in GAMS (9 variables)

hi, i think i'd better index the variables. x=0, if a+b+c+d+e+f+g+h≤1 => x=0, if sum(i,z(i)) ≤ 1 x=1, if a+b+c+d+e+f+g+h>1 => x=1, if sum(i,z(i)) > 1 so maybe a "bigM" decomposition can work. M is a large enough parameter eq1.. sum(i,z(i)) =l= 1 + M*x; eq2.. sum(i,z(i)) =g= 2 - M*(1-x); best
by Manassaldi
2 years ago
Forum: Modeling
Topic: Model a equation for following condition
Replies: 3
Views: 2384

Re: Model a equation for following condition

If you put them together, they are a single set of equations. I don't think you will achieve your goal with a single equation. best binary variable X,A,B,C ; equation eq1,eq2,eq3,eq4,eq5,eq6,eq7,eq8, eq9,eq10,eq11,eq12,eq13,eq14,eq15,eq16 eq17,eq18,eq19,eq20 ; variable z ; eq1.. X + 1 - A + 1 - B =g...
by Manassaldi
2 years ago
Forum: Modeling
Topic: Model a equation for following condition
Replies: 3
Views: 2384

Re: Model a equation for following condition

Hi, i think this could work. Please check it. if atleast 2 of A,B,C are ones then X = 1 X + 1 - A + 1 - B =g= 1; X + 1 - A + 1 - C =g= 1; X + 1 - B + 1 - C =g= 1; if X = 1 then 2 of A,B,C are ones 1 - X + A + B =g= 1 1 - X + A + C =g= 1 1 - X + A + B + C =g= 1 1 - X + B + C =g= 1 if only one of A,B,...
by Manassaldi
2 years ago
Forum: Modeling
Topic: Small Modelling Question
Replies: 2
Views: 2475

Re: Small Modelling Question

hi, try with this sets definition

sets i /i1*i10/
;
alias(i,j)


eq1(i).. x(i) =E= sum(j$(ord(j) le ord(i)),y(j));

best
by Manassaldi
3 years ago
Forum: Syntax
Topic: Cumulative sum
Replies: 5
Views: 3319

Re: Cumulative sum

I think this can work...

Code: Select all

eq.. z =e= sum((i,j)$(ord(j) le ord(i)),x(j) - y(j));  
bye!
by Manassaldi
3 years ago
Forum: Syntax
Topic: Cumulative sum
Replies: 5
Views: 3319

Re: Cumulative sum

hi, you should define an alias. Try this code
bye!

Code: Select all

Set i /1*6/;
alias(i,j)
Variables
x(i)
y(i)
;
equation
eq
;

eq(i).. sum(j$(ord(j) le ord(i)),x(j)) =l= sum(j$(ord(j) le ord(i)),y(j));
by Manassaldi
3 years ago
Forum: Syntax
Topic: Condtional statement and large positive value
Replies: 2
Views: 2007

Re: Condtional statement and large positive value

hy, try this options. eq(h, j, i, k)$(ord(h) gt 1 and ord(j) gt 1 and ord(i) gt 1 and ord(k) gt 1 and not sameas(h,j)).. C(j) – AM(1-X(i,j,k)) =g= S(h,j) + Sum(o, X(i,j,o)*P(i,j)) + C(h) + V(j); or eq(h, j, i, k)$(ord(h) gt 1 and ord(j) gt 1 and ord(i) gt 1 and ord(k) gt 1 and ord(h) ne ord(j)).. C(...
by Manassaldi
3 years ago
Forum: Syntax
Topic: Is it possible to calculate an integral in GAMS?
Replies: 2
Views: 2246

Re: Is it possible to calculate an integral in GAMS?

hi, i think you should use an analytic integration (if possible) otherwise make a numerical integration (like simpson rule).