Page 1 of 1

Round variable up to the next whole number (integer)

Posted: Wed Oct 14, 2020 9:54 am
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

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

Posted: Fri Oct 16, 2020 3:40 pm
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.

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

Posted: Fri Oct 16, 2020 5:23 pm
by keatzaii
Thanks for your solution. I'm really appreciate it.