How to add up negative and positive numbers?

Hello,

I didn’t really know how to explain in the title, but here is my problem:

I want to solve a Bike-Station-repositioning-problem, and as a penalty function for bikes, that can not be repositioned I want to add everything that can’t be repositioned properly.
I defined my penalty function as follows:

objective function(penalty part)… sum (i, g(i) );

pf(i)… g(i) =E= s(i) - d(i);

d(i) = the desired number of bikes at each station /demand
s(i) = the number of bikes at each station after the repositioning took place

When there are less bikes afterwards I get a negative value. I want that value to be counted as positive, so it can add up with the other values, as the penalty function should grow with every demand, that can not be satisfied, something like this:
u5hd.png
I hope i made clear, what’s my problem and hope somebody can help.

Best regards

Hi
Search in this forum for “absolute value” and you will find 8 pages with hits (not all relevant).
Cheers
Renger

Hi,

Five days ago Renger answered a similar question with a very nice reply:

https://newforum.gams.com/t/how-to-add-this-formula-in-my-minimization-objective-function/2811/2

If that doesn’t work, just search for posts from Renger about minimization and you’ll see it.

-Steve

Thank you.

I figured it out!

Best regards