[AMPL 24678] How to Make a variable hold x decimal places?

Hello,

I would like to have a variable called myVar hold x decimal places (let’s say 5 decimal places). How can I enforce this?

Thank you for your guidance.

The requirement for myVar to “hold 5 decimal places” is not entirely clear. It could mean, for example,

  • In the solver algorithm, you want to restrict myVar to be an exact multiple of 0.00001. (That is, the only values that the solver can assign to myVar are 0.00000, 0.00001, 0.00002, etc.)
  • After the solver is finished, you want to round or truncate the solution to 5 decimal places.
  • After the solver is finished, you want to display the solution so that only 5 decimal places are shown.

Can you explain in more detail what you are looking for? Then it will be possible to say how to do it in AMPL.