Dear Community,

i have following problem:

I work at a topic similiar to the newsvendor model.

I need to find the optimal quantity q that maximizes the profit. In my equation for the profit is a term f, the quantity f is the number of units that could theoretically be sold, but coulnd’t in the end, because the demand is higher than the supply.

f = d(s) - q, where d is the demand and q the selected quantity. For the case that q is larger than d, f should simply be zero.

f = max(0, d(s)-q)

The parameter s is for a szenario. I have to generate a given number of random demands d(s).

I have to do this for university, but i have to solve the problem as lp, so i can’t use the max funktion.

I declared f as positive variable and i am using the equation f = d(s) - q. But that results in q being the lowest random generatet d(s).

Is there a equation for f, that does the following thing (other than the max function):

If d(s) > q, then f should be d(s) - q,

else f should be zero and should have no influence on q.

f =e= d(s) - q just works as a restriction and not like i want it to.

I hope you can understand my problem. Thanks for any help