Search found 135 matches

by abhosekar
13 hours ago
Forum: Modeling
Topic: Mutual exclusive variables in a LP model
Replies: 1
Views: 18

Re: Mutual exclusive variables in a LP model

Paulo, are charge(i) and discharge(i) binary variables? If yes then charge(i) + discharge(i) =l= 1 should be enough. If they are positive variables, then you need to define binary variables that are 1 if they are nonzero and 0 when they are 0. You have to use big-M condition to establish relation be...
by abhosekar
14 hours ago
Forum: Syntax
Topic: Exporting data from Excel to GAMS
Replies: 1
Views: 23

Re: Exporting data from Excel to GAMS

Two mistakes. 1. File extension .xlxs instead of .xlsx 2. You should not indent $call and $gdxin. Remove the space behind it After fixing, the following code works set r row labels /r1,r2/ c coloumn labels/c1,c2/; Parameter p(r,c); $call GDXXRW indata.xlsx trace=3 par=p rng=sheet1!a1 rdim=1 cdim=1 $...
by abhosekar
1 week ago
Forum: Modeling
Topic: variable as a condition for a equation
Replies: 1
Views: 67

Re: variable as a condition for a equation

Akram, This is an incorrect way to think when it comes to optimization models. Constraints in optimization are not sequentially executed as a normal code and therefore, such conditions that you are mentioning do not make sense. You say if x < z, but at the time when the model is generated or when th...
by abhosekar
2 weeks ago
Forum: Announcements
Topic: Defining equation with logical condition on index
Replies: 2
Views: 111

Re: Defining equation with logical condition on index

You can create multidimensional sets jp(j, p) and js(j, s). Find more information on multidimensional sets here: https://www.gams.com/latest/docs/UG_SetDefinition.html#UG_SetDefinition_Multi-dimensionalSets set jp /#j.#p/ js /#j.#s/ ; You can then write your constraint with if condition constraints8...
by abhosekar
3 weeks ago
Forum: Modeling
Topic: Initial Conditions for Inventory t=0
Replies: 2
Views: 119

Re: Initial Conditions for Inventory t=0

I assume the question is that you have something like (t-1) in your equations and you have issues when t = 1 because you have not assigned values for t = 0, yes? In your equations you can write $(ord(t) eq 1) and $(ord(t) ne 1) with the terms to achieve this. For example, I(t + 1) = I(t)$(ord(t) ne ...
by abhosekar
1 month ago
Forum: Syntax
Topic: Equation infeasible due to rhs value
Replies: 3
Views: 159

Re: Equation infeasible due to rhs value

I would suggest you to read about big-M constraints and look up some optimization formulations that have implemented a similar logic and adapt your model according to it. The question you are asking are related to general optimization and not specific to GAMS. Looking back at your problem, binary va...
by abhosekar
1 month ago
Forum: Syntax
Topic: Equation infeasible due to rhs value
Replies: 3
Views: 159

Re: Equation infeasible due to rhs value

Hi, is l(i, j) a parameter or a variable? If it is a parameter, then your problem is infeasible simply because 0.3 >= 1 should be infeasible. Regarding the error, GAMS is just rearranging the values 0 >= 0.7. This is equivalent to 0.3 >= 1 and both are infeasible. If l(i, j) is a variable (which I d...
by abhosekar
1 month ago
Forum: Syntax
Topic: division by zero
Replies: 1
Views: 819

Re: division by zero

Please use code blocks for writing your code, provide as much information about your code as you can, and do not delete parts of the question once it has been answered. The answers and question might be useful for other users in the future. There are several things that are wrong here. I don't under...
by abhosekar
1 month ago
Forum: Syntax
Topic: a suffix is missing error
Replies: 3
Views: 831

Re: a suffix is missing error

In your previous code, you defined w as a variable. In this code, you are defining it as a parameter (I think it should be a variable). This will be enough to get rid of your error. I see that you have -w(i) in the objective which makes me rethink my constraints. If you are maximizing your objective...
by abhosekar
1 month ago
Forum: Syntax
Topic: a suffix is missing error
Replies: 3
Views: 831

Re: a suffix is missing error

Please follow tutorials and examples from GAMS documentation. https://www.gams.com/latest/docs/UG_MAIN.html#UG_Tutorial_Examples You have to define constraint name and constraint as follows. equation con1; con1(i).. w(i)=e=sum(j,K(i,j)*x(j))*x(i); further, this constraint is not the best way to mode...