Hi! I have got a stock problem and solving it on GAMS but I didnt linearize th function above; if a<=b then c=0 and a=a if a>b then c= a-b and a=b
This question is marked "community wiki".
asked
gcndn |

I'm not sure what you are aiming for with the "If a>b then ... a=b". That looks more like a programming structure than a constraint. Can we add a variable s for "sales" so the constraints are If a<=b then c=0 and s = a, and if a>b then c= a-b and s=b ? Then something like s<=a s<=b c>= a-b c>= 0 works if the objective/constraints are such that s naturally maximizes and c naturally minimizes.
answered
Mike Trick ♦♦ |

Building on your comment, I'd suggest to rewrite (or, more precisely, shorten) your if-then-expression like:
which can be equivalently expressed as:
[If you need to capture the amount of sales explicitly, The max-expression, in turn, can be rewritten ["mip'ed"] as:
If If not -- i. e., Linearizing these directly (as initially suggested -- if you've read this post before) turns out to be a bit cumbersome. Fortunately, though, there's another modeling trick we can use here:
From propositional logic we know:
I. e.,
Let
Now, the "only" thing left to do is: linearize
Et voilà!
- http://orinanobworld.blogspot.de/2011/01/max-and-min-functions-in-mip.html
- http://orinanobworld.blogspot.de/2010/10/binary-variables-and-quadratic-terms.html
...and AIMMS' modeling guide (chapter on integer programming tricks): Any mistakes are mine, though.
answered
fbahr ♦ |

a is my variable about customer demand if there are not enough stock in warehouse customers all demand doesnot satisfied so there will be lost sales if there are enough stock all "a" (customer demand) will satisfied I meant this and I didnt write it on GAMS

b is my stock and c is my loss sales amount