Skip to main content

I have a variable of a MIP problem, for example: total_power_plants = 2.7 but I only want to use the integer part of this value, that is 2, I have been reading this article but it does not work nor is it what we need (https://how-to.aimms.com/Articles/199/199-model-rounded-variable.html#example).

 

Could you bring me some solution, please?

Looking at the variable name, I am assuming you cannot have 0.7 powerplants (it is either 0, or 1, or 2, etc).

In your case, you can set the range of the variable total_power_plants to integer and this should result in the variable only taking integer values.


Thanks for your quick response. You are right, we only can have a integer number of power plants but I can’t set the range of this variable to integer because it is calculated from the production of the plant and this variable doesn’t have to be integer.


@QueraltA , do you always want to use the rounded down value ? 

Is the variable total_power_plants involved in other constraints ? Where is the value 2.7 coming from ? 

Something like total_power_plants = sumsindex_plants, power(index_plants)] .. 

 

I believe the approach in Model a Rounded Variable — AIMMS How-To should work in your case, can you elaborate how it does not fit your needs ? 

 

If you only need the rounded down value, you could even drop the auxilliary variable aux1 and just have var1 = value - aux2 as your constraint. Set the range of aux2 as o0,1] and the integer variable var1’s will be equal to rounddown(value). 


Thanks a lot for your answer. I have changed my model and now, due to these changes, I want to have the top value of total_power_plants.  I have solved it as follows:

total_power_plants_integer = total_power_plants + aux1

Where total_power_plants_integer is an integer variable and the range of aux1 is 0,1]. Generally, this solution works but when “total_power_plants” is an integer value I want to keep its value. For instance:

total_power_plants = 10

I want:

total_power_plants_integer=10

aux1=0

I tried to solve this problem changing the aux1 range: n0,1) but the solution with AIMMS was:

Warning: Postsolve indicates that solution to funciton_objetive is not reliable (see message window).

And the solution obtained does not make sense because some variables were outside their bounds.

 

 

 
 
 

 

 

 

 


@QueraltA 

 

if you need only the roundUp value, you could even just do the below. 

 

total_power_plants_integer >= total_power_plants

 

Include total_power_plants_integer to your objective function, with a minimize direction. If your problem is a minimization, then obj + total_power_plants_integer and if it is a maximization problem, then obj - total_power_plants_integer. 

 

Regarding the “postsolve indicates solution is unreliable” warning, can you review this thread on our (deprecated) google groups forum ? https://groups.google.com/g/aimms/c/67sYx0ZHFMo/m/sUWlkLe_0dIJ

Setting the integrality option to 1 should work in most cases. 

 

You can also review this post to improve the scaling of your model: Marcel Hunting on the AIMMS Scaling tool | AIMMS Community


Hi @QueraltA ,

 

Hope all is well.

Did @mohansx and @gdiepen 's answers help you to move forward?

Thanks for getting back to us!


Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator