1

I need your help to solve this "Little" problem I'm having programming with GAMS.

In my objective function I have this member that is z = [...]-TWC(j)*HS(j). Where HS(j)is a variable.

Now, TWC(j) should be a parameter that works like this:

TWC(j) = 0 when HS(j) < 1000

and

TWC(j) = 3.21 when HS(j) >=1000.

Any idea how to implement this in GAMS? my attempts all failed.

EDIT: this is what I tried I defined an equation called TWCup(j) that was:

TWCup(j)$(HS.l(j) >= 1000).. TWC(j) =e= 3.21;

Thanks ;)

Gigi Botte
  • 11
  • 3

1 Answers1

0

Probably not relevant for the OP anymore (since the question is more than 3 years old), but maybe useful for someone else that looks at this question.

If TWC(j) is a function of your variable HS(j), it is not a parameter. It is another variable. So you should define TWC(j) as a variable and not as a parameter. This is probably the reason you were getting errors.

There are some ways to fix your problem: One is to actually turn TWC(j) into a variable. But this would turn your problem into non-linear which could be (or not) an issue. Also, this could need the use of binary variables, which could also become a problem (again, or not).

But I think this issue could be resolved with a different specification of the LP. The cost function f(HS(j)) = TWC(j)*HS(j) is linear by parts and convex, which you can represent in a standard LP using auxiliary variables (assuming you are minimizing).

* declare auxiliary variable
Variable 
    w(j);

* declare equations for linear by part cost function
Equation
    costfun1(j)
    costfun2(j);
;

* define costfun1 and costfun2
costfun1(j).. w(j) =g= 0;
costfun2(j).. w(j) =g= -3210 + 3.21*HS(j);  


*redefine objective function (note that I changed to plus because I assumed this is a cost function that you are minimizing)
z = [...]+w(j)

This solution is very problem dependent. I assumed you were minimizing and I changed the sign in the objective function to '+'. If this was not the case, this would not work (would not be convex). Then we would need to check other approaches.

But the takeaway here is to stress that something that is a function of a variable is also a variable. But you may have options to reformulate your problem to address the problem.

kikoralston
  • 1,176
  • 5
  • 6