Hi,
I have been trying to understand the code for bid evaluation in :https://www.gams.com/latest/gamslib_ml/libhtml/gamslib_bidpwl.html
As per my understanding goes the x(v) is a variable that represents the quantity each vendor bids for whereas in equation defy(v) the corresponding cost has been calculated, but I don’t get why defx(v) should be used to calculate x(v) which seems to be calculated through a piecewise linear function since x(v) looks like an exogenous variable and not an endogenous one.

One more thing is the use of BidPwl, BidPwl_Seg, BidPwl_x, BidPwl_y is very confusing, why does it have the suffix and sometimes it doesn’t?

I suggest that you look at the listing file. It expands what pwpfunc.inc does and that gives you the full picture if you want to understand what is going on. For example, BidPwl_x(v) is not a variable it is a macro for an expression:

I leave the other questions unanswered. I guess you will study the listing file and then things will hopefully be more clearer. pwlfunc.inc is a convenience wrapper. If you want to understand pwl linearizations and get the last out of your reformulation, do the reformulation yourself without the convenience wrapper.

Hi,
Thanks a lot for your reply. I think that I have understood it to some extent. But I do have one additional question. If I want to consider the demand varying with the time so does the quantity and cost will be dependent on time. So, the ‘req’ will turn into ‘req(t)’ and so do the ‘x(v) and y(v)’ to ‘x(v,t) and y(v,t)’. I am assuming that I don’t need to change the BidPwl definition since it’s just evaluating the corresponding cost for the time dependent quantity. Am I thinking correct or I also need to adopt the ‘t’ in the BidPwl evaluation.