What is the difference between printf and display of a value in glpsol?

  Kiến thức lập trình

I have a binary assignment problem that I want to find the maximum value of using glpsol.
The solution is easily (i.e. quickly) found and I can print using:

printf{i in I} "%d ", x[i];

(if it does matter: x[i] is an array of variables defined like this var x{i in I}, >= 0;)
Since I expect each variable to be binary the above statement returns a list of 0s and 1s, which is fine.

A strange thing happens when I output the very same solution using:

display {i in I} x[i];

This way I get values that are not binary (0.5 to be precise).

Why is this happening?
Can I output (just) a solution obtained using printf to a file ? (--output returns the values same as display)

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT