Search found 295 matches

by abhosekar
3 years ago
Forum: Syntax
Topic: Conditions on the decision variable
Replies: 1
Views: 1338

Re: Conditions on the decision variable

you want N(i) to be max(0, I(i) - b(i) + D(i));
You can do this by
N(i) =g= 0;
N(i) =g= I(i) - b(i) + D(i);

However, this depends on the fact that your objective naturally tries to minimize N(i). If that's not the case, you will have to use big-M constraints.

- Atharv
by abhosekar
3 years ago
Forum: Modeling
Topic: division by zero! touble...
Replies: 4
Views: 2889

Re: division by zero! touble...

Hi, you will need bunch of tricks using big-M constraints to correctly model this: 1. Declare a binary variable p that will be 0 if sum(W_w, x(W_w, T))) is 0 and 1 otherwise. You can do this as follows: sum(W_w, x(W_w, T))) =l= M*p; p =l= sum(W_w, x(W_w, T))) ; The second constraint will force p to ...
by abhosekar
3 years ago
Forum: Syntax
Topic: Pass set data
Replies: 4
Views: 3679

Re: Pass set data

You cannot use parameter to define a set. I am not sure if this is the best way, but you can define a subset of a big set and assign it using the parameter that you read form excel as follows: parameter set_size /5/; set univ /i1*i10000/ i(univ) ; i(univ)$(ord(univ) <= set_size) = yes; display i; - ...
by abhosekar
3 years ago
Forum: Modeling
Topic: How to formulate that once binary variable equals 1 then other one equals zero forever?
Replies: 2
Views: 2173

Re: How to formulate that once binary variable equals 1 then other one equals zero forever?

if var1 and var2 are binary, you can do this by using the constraint var1 + var2=e= 1; However, you would be introducing nonlinearities/nonconvexities in your problem by such a formulation that uses obj1*var1. If var1 depends 'only' on data, it would be advisable to calculate it beforehand and use i...
by abhosekar
3 years ago
Forum: Modeling
Topic: How to model dividing parameter by variable?
Replies: 1
Views: 2273

Re: How to model dividing parameter by variable?

The code that you showed does not 'divide' parameter by a variable. In the term "parameter1/parameter2 *var1", var1 is not in the denominator. You should change it to something like following:

Code: Select all

a(i) =e= b(i) + (parameter1 / (parameter2 * var1))
Hope this helps.

- Atharv
by abhosekar
3 years ago
Forum: Modeling
Topic: Paramter with defined values
Replies: 3
Views: 2457

Re: Paramter with defined values

Sure. You can find it here. https://www.gams.com/latest/docs/UG_Var ... 22_integer

There is not much about syntax instead of defining 'variable' or 'binary variable', you define 'integer variable'

- Atharv
by abhosekar
3 years ago
Forum: Modeling
Topic: Paramter with defined values
Replies: 3
Views: 2457

Re: Paramter with defined values

Hi, I don't completely understand your problem but I see that you would want one of your variables to be an integer multiple of 50 (or any other number for that matter). You can define a general integer variable integer y(k,t) that can take values from 0 to 3. Then you can write Q(k, t)=e= a(k)*y(k,...
by abhosekar
3 years ago
Forum: Syntax
Topic: Set Operations
Replies: 8
Views: 4300

Re: Set Operations

There are a couple of typos in my previous comment. Following code works. set s /s1*s5/ m /m1*m4/ i /i1*i8/ dummy_ts(i) /i2, i6, i7/ h(dummy_ts) /i2, i6, i7/ ; display dummy_ts h; alias(i, j); set f(s, m, i, i); f(s, m, 'i2', 'i6') = yes; sets fprojected1(i) fprojected2(i) fprojected(i); *fprojected...
by abhosekar
3 years ago
Forum: Syntax
Topic: Set Operations
Replies: 8
Views: 4300

Re: Set Operations

Let me reframe your question: You need t(s, i) only when i is in dummy_ts and i is in 'any' two of the last two columns of f. It is much clearer now that you need to create another set to tell you whether a given i exists in the last two columns of set f. Let's say that set is fprojected(i) that con...
by abhosekar
3 years ago
Forum: Solvers
Topic: EMP error
Replies: 5
Views: 5286

Re: EMP error

This is what I explained in my previous response and also the error message mentions the exact same thing that you have included a symbol that is 2 dimensional without any index. You should explicitly add C1_LL('h1','t1'), C1_LL('h2','t2') and so on. Simply writing C1_LL is not enough. You can do th...