Fractions
AnsweredIf the coefficient of a variable in an LP file is a fraction (like 1/3) or an irrational number (e.g., sqt(2)), how do you correctly write that? I.e., what syntax is correct?
Is the only option to use decimals? Is there no better way?
-
For fractions you can of course just multiply the whole constraint by the smallest common multiplier of your denominators. So, instead of writing 1/3x + 2y <= 7 you would write x + 6y <= 21. For roots or other irrational numbers, there is no better way than using floating points.
In any case, you should always use double precision in your calculations to get the floating point values, and you should not truncate digits. So, please don't write 1.414214x + y <= 5, but instead write 1.414213562373095x + y <= 5.
Regards,
Tobias
1
Please sign in to leave a comment.
Comments
1 comment