How to add up negative and positive numbers?

Problems with syntax of GAMS
Post Reply
Gaucho
User
User
Posts: 4
Joined: 2 weeks ago

How to add up negative and positive numbers?

Post by Gaucho » 1 week ago

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 143 times
I hope i made clear, what's my problem and hope somebody can help.

Best regards

User avatar
Renger
Posts: 398
Joined: 3 years ago

Re: How to add up negative and positive numbers?

Post by Renger » 1 week ago

Hi
Search in this forum for "absolute value" and you will find 8 pages with hits (not all relevant).
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist

User avatar
dirkse
Moderator
Moderator
Posts: 84
Joined: 3 years ago
Location: Fairfax, VA

Re: How to add up negative and positive numbers?

Post by dirkse » 1 week ago

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

Gaucho
User
User
Posts: 4
Joined: 2 weeks ago

Re: How to add up negative and positive numbers?

Post by Gaucho » 1 week ago

Thank you.

I figured it out!

Best regards

Post Reply