Page 1 of 1

How to add up negative and positive numbers?

Posted: Mon Oct 07, 2019 2:13 pm
by Gaucho
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
u5hd.png (890 Bytes) Viewed 2742 times
I hope i made clear, what's my problem and hope somebody can help.

Best regards

Re: How to add up negative and positive numbers?

Posted: Mon Oct 07, 2019 6:19 pm
by Renger
Hi
Search in this forum for "absolute value" and you will find 8 pages with hits (not all relevant).
Cheers
Renger

Re: How to add up negative and positive numbers?

Posted: Tue Oct 08, 2019 5:24 pm
by dirkse
Hi,

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

viewtopic.php?f=9&t=11074&p=26062&hilit ... ion#p26062

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

-Steve

Re: How to add up negative and positive numbers?

Posted: Wed Oct 09, 2019 10:58 am
by Gaucho
Thank you.

I figured it out!

Best regards