Round variable up to the next whole number (integer)

Problems with modeling
Post Reply
keatzaii
User
User
Posts: 11
Joined: 4 years ago

Round variable up to the next whole number (integer)

Post by keatzaii »

Hi,

My variable is the number of plant (i.e. 3.2 plants) and I would like to round it up to the next integer (i.e. 4 plants). This is to calculate the capital cost (number of plant x capital cost per plant) as we cannot build 3.2 plants.

At the same time, this variable need to keep as decimal point for the next equation that calculate the operating cost (number of plant x capacity per plant x operating cost per capacity) as some plant can run without in full capacity.

Hope someone can help.

Many thanks,
Jun Keat
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: Round variable up to the next whole number (integer)

Post by abhosekar »

If the number of plants is in the objective function and the problem structure naturally favors minimizing it, you can define an integer variable p and add a constraint p =g= number_of_plants;
This way, if the number of plants is 3.2, p will be 4; if the number of plants is 3, p will be 3.
keatzaii
User
User
Posts: 11
Joined: 4 years ago

Re: Round variable up to the next whole number (integer)

Post by keatzaii »

Thanks for your solution. I'm really appreciate it.
Post Reply